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.OnboardThreeFragmentBinding;

public class OnBoardThree extends Fragment {

    // view binding
    protected OnboardThreeFragmentBinding binding;

    public OnBoardThree(){
        // required empty constructor
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = OnboardThreeFragmentBinding.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_2));
            binding.subTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.sub_title_small));
        }


        return binding.getRoot();
    }
}
