package com.app.simplitend.welcome.welcomepatient.fragments.onboardfragments;

import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.app.simplitend.R;
import com.app.simplitend.databinding.OnboardOneFragmentBinding;

public class OnBoardOne extends Fragment {

    // view binding
    protected OnboardOneFragmentBinding binding;

    public OnBoardOne(){
        // required empty constructor
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = OnboardOneFragmentBinding.inflate(inflater, container, false);

        // Calculate screen dimensions in pixels
        DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        int screenWidth = displayMetrics.widthPixels;
        int screenHeight = displayMetrics.heightPixels;

        // Calculate aspect ratio
        float aspectRatio = (float) screenHeight / (float) screenWidth;

//        Toast.makeText(requireContext(), "" + aspectRatio, Toast.LENGTH_SHORT).show();

        if (aspectRatio > 2.1){
            // screen is taller
            binding.title.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.title_tall));
            binding.subTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.sub_title_tall));
        }else if (aspectRatio > 2){
            // screen is normal size
            binding.title.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.title_tall_medium));
            binding.subTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.sub_title_tall_medium));
        }else {
            // screen is smaller
            binding.title.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.title_small));
            binding.subTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.sub_title_small));
        }

        return binding.getRoot();
    }
}
