package com.paint.sweet.drawing.sweetfragment;

import android.content.pm.PackageInfo;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;

import com.paint.sweet.drawing.R;
import com.paint.sweet.drawing.databinding.FragmentSettingCenterBinding;
import com.paint.sweet.drawing.sweetmanager.AppUtils;

public class SettingCenterFragment extends Fragment {
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";


    private String mParam1;
    private String mParam2;
    private FragmentSettingCenterBinding fragmentSettingBinding;

    public SettingCenterFragment() {

    }
    public static SettingCenterFragment newInstance() {
        SettingCenterFragment fragment = new SettingCenterFragment();
        Bundle args = new Bundle();

        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        fragmentSettingBinding = FragmentSettingCenterBinding.inflate(getLayoutInflater());
        onInit();
        return fragmentSettingBinding.getRoot();
    }

    private void onInit(){
        String version = "1.0";
        PackageInfo info = AppUtils.getInfo(requireContext());
        if(info!=null){
            version = info.versionName;
        }
        String format = String.format(getString(R.string.version_code), version);
        fragmentSettingBinding.textAppVersion.setText(format);
    }
}