package net.micode.notes;

import android.os.Bundle;

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

public class MainActivity extends AppCompatActivity {

    // 定义 main 视图的 ID，以便于在其他地方引用
    private static final int MAIN_VIEW_ID = R.id.main;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // 启用 EdgeToEdge，使内容延伸到屏幕的边缘
        EdgeToEdge.enable(this);

        // 设置布局
        setContentView(R.layout.activity_main);

        // 设置视图的 padding 以适应系统栏
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(MAIN_VIEW_ID), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
    }
}