// SPDX-FileCopyrightText: Adam Evyčędo
//
// SPDX-License-Identifier: GPL-3.0-or-later

package xyz.apiote.bimba.czwek.dashboard.ui.voyage

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import xyz.apiote.bimba.czwek.databinding.FragmentVoyageBinding

class VoyageFragment : Fragment() {

	private var _binding: FragmentVoyageBinding? = null

	// This property is only valid between onCreateView and
	// onDestroyView.
	private val binding get() = _binding!!

	override fun onCreateView(
		inflater: LayoutInflater,
		container: ViewGroup?,
		savedInstanceState: Bundle?
	): View {
		val voyageViewModel =
			ViewModelProvider(this)[VoyageViewModel::class.java]

		_binding = FragmentVoyageBinding.inflate(inflater, container, false)
		val root: View = binding.root

		val textView: TextView = binding.textDashboard
		voyageViewModel.text.observe(viewLifecycleOwner) {
			textView.text = it
		}
		return root
	}

	override fun onDestroyView() {
		super.onDestroyView()
		_binding = null
	}
}