package com.example.tampopo_client.views;

import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.bumptech.glide.Glide;
import com.example.tampopo_client.R;
import com.example.tampopo_client.Tampopo;

public class TestFriendIconActivity extends AppCompatActivity {

    Tampopo tampopo;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        tampopo = (Tampopo) getApplication();
        super.onCreate(savedInstanceState);
//        EdgeToEdge.enable(this);
//        setContentView(R.layout.activity_test_friend_icon);
//        String uid = tampopo.getUserId();

        // ルートレイアウトを FrameLayout に（自由配置できる）
        FrameLayout rootLayout = new FrameLayout(this);
        // 画面密度取得（dp → px 換算用）
        float density = getResources().getDisplayMetrics().density;

        //FriendIconView　1個目
        String uid = "haru";
        FriendIconView view1 = new FriendIconView(this);
        //view1.setAccount(uid);
        FrameLayout.LayoutParams params1 = new FrameLayout.LayoutParams(
                (int) (250*density), // width in px
                (int) (250*density) // height in px
        );
        view1.setLayoutParams(params1);
        view1.setX(130); // px単位
        view1.setY(150);
        rootLayout.addView(view1);

        //FriendIconView　２個目
        FriendIconView view2 = new FriendIconView(this);
        FrameLayout.LayoutParams params2 = new FrameLayout.LayoutParams(
                (int) (250*density),
                (int) (250*density)
        );
        view2.setLayoutParams(params2);
        view2.setX(200);
        view2.setY(600);
        rootLayout.addView(view2);

        setContentView(rootLayout);
//
//        FriendIconView friendIconView = new FriendIconView(this);
//        uid = "test0";

//        FriendIconView friendIconView = findViewById(R.id.friendIconView);
//        friendIconView.setAccount(uid);
//
//        //xmlで複製後uidを設定するとそのアカウントのニックネーム，コメント，アイコンが表示される
//        uid = "test1";
//        FriendIconView friendIconView2 = findViewById(R.id.friendIconView2);
//        friendIconView2.setAccount(uid);

//        friendIconView.setNickname("nitta");
//        friendIconView.setComment(("kjrig"));
//        Glide.with(TestFriendIconActivity.this)
//                .load("http://nitta-lab-www.is.konan-u.ac.jp/tampopo-data/icon" + uid + ".jpg")
//                .into(friendIconView.getImageView());
        //friendIconView.setImageResource(Integer.parseInt("http://nitta-lab-www.is.konan-u.ac.jp/tampopo-data/icontest.jpg"));
//        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
//            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
//            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
//            return insets;
//        });

    }
}