package com.tanya.careerguidanceproject.fragments

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import com.tanya.careerguidanceproject.R
import com.tanya.careerguidanceproject.activities.CollegeList
import com.tanya.careerguidanceproject.activities.CourseList
import com.tanya.careerguidanceproject.activities.ExamsList

class DashboardFragment : Fragment() {

    private lateinit var btnViewCourses : Button
    private lateinit var btnViewColleges : Button
    private lateinit var btnViewExams : Button
    private lateinit var btnConsultExpert : Button

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
                              savedInstanceState: Bundle?): View? {
        // Inflate the layout for this fragment

        val view = inflater.inflate(R.layout.fragment_dashboard, container, false)

        btnViewCourses = view.findViewById(R.id.btnViewCourses)
        btnViewColleges = view.findViewById(R.id.btnColleges)
        btnViewExams = view.findViewById(R.id.btnCompetitiveExams)
        btnConsultExpert = view.findViewById(R.id.btnDFConsultExpert)

        btnViewCourses.setOnClickListener {
         /*   val fragment = CourseDescriptionFragment()
            val fragmentManager = activity!!.supportFragmentManager
            val fragmentTransaction = fragmentManager.beginTransaction()
            fragmentTransaction.replace(R.id.cbFrameLayout, fragment)
            fragmentTransaction.addToBackStack(null)
            fragmentTransaction.commit()
*/
            val intent = Intent(activity, CourseList::class.java)
            startActivity(intent)

        }

        btnViewColleges.setOnClickListener {
            val intent = Intent(activity, CollegeList::class.java)
            startActivity(intent)
        }

        btnViewExams.setOnClickListener {
            val intent = Intent(activity, ExamsList::class.java)
            startActivity(intent)
        }

       btnConsultExpert.setOnClickListener {
           val openURL = Intent(Intent.ACTION_VIEW)
           openURL.data = Uri.parse("https://www.expertrons.com/career-transformation-masterclass/")
           startActivity(openURL)
        }

        return view
    }

    /*override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        activity!!.title = "Fragment 1"
    }*/

}

