package com.ttiglobal.inttilectgpchat.fragments;


import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.ttiglobal.inttilectgpchat.R;

public class IndroFragment extends Fragment {

    View mainView;
    int POSITION = 0;
    ImageView indroImage;
    TextView indroTitle, indroDesc;

    public IndroFragment() {

    }

    public void setPosition(int pos) {
        this.POSITION = pos;
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_indro, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mainView = view;
        indroImage = mainView.findViewById(R.id.indroImage);
        indroTitle = mainView.findViewById(R.id.indroTitle);
        indroDesc = mainView.findViewById(R.id.indroDesc);

        if (POSITION == 0) {
            Glide.with(this).load(R.mipmap.m_icon_1)
                    .transition(DrawableTransitionOptions.withCrossFade()).into(indroImage);
            String header = "<b>EXPLORE</b>";
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
                indroTitle.setText(Html.fromHtml(header, Html.FROM_HTML_MODE_LEGACY));
            } else {
                indroTitle.setText(Html.fromHtml(header));
            }
            indroDesc.setText("\"Coming together is a beginning;\n keeping together is progress;\n working together is success.\" \n ― Henry Ford");
        } else if (POSITION == 1) {
            Glide.with(this).load(R.mipmap.m_icon_3)
                    .transition(DrawableTransitionOptions.withCrossFade()).into(indroImage);
            String header = "Be informed take short <b>QUIZ</b>";
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
                indroTitle.setText(Html.fromHtml(header, Html.FROM_HTML_MODE_LEGACY));
            } else {
                indroTitle.setText(Html.fromHtml(header));
            }
            indroDesc.setText("\"Education is not the learning of facts\n It’s rather the training of the mind to think\" \n ― Albert Einstein");
        } else if (POSITION == 2) {
            Glide.with(this).load(R.mipmap.m_icon_2)
                    .transition(DrawableTransitionOptions.withCrossFade()).into(indroImage);
            String header = "Stay on top be a <b>LEADER</b>";
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
                indroTitle.setText(Html.fromHtml(header, Html.FROM_HTML_MODE_LEGACY));
            } else {
                indroTitle.setText(Html.fromHtml(header));
            }
            indroDesc.setText("\"Don't be afraid to give up  \n the good to go for the great.\" \n -John D. Rockefeller");
        }
    }

}
