| | |
| | | import com.example.firstapp.utils.PreferencesManager |
| | | import com.google.android.material.bottomsheet.BottomSheetDialog |
| | | import kotlinx.coroutines.launch |
| | | import com.example.firstapp.view.UnderlineTextView |
| | | |
| | | class HomeFragment : Fragment() { |
| | | |
| | | private var _binding: FragmentHomeBinding? = null |
| | | |
| | | // This property is only valid between onCreateView and |
| | | // onDestroyView. |
| | | private val binding get() = _binding!! |
| | | |
| | | private lateinit var homeViewModel: HomeViewModel |
| | |
| | | } |
| | | } |
| | | |
| | | private fun updateTabStyles(selectedTab: TextView) { |
| | | private fun updateTabStyles(selectedTab: UnderlineTextView) { |
| | | binding.apply { |
| | | val tabs = listOf(tabExpress, tabFinance, tabIncome, tabFlight, tabTrain) |
| | | tabs.forEach { tab -> |
| | | // 设置文字颜色为黑色或灰色 |
| | | tab.setTextColor(ContextCompat.getColor(requireContext(), |
| | | if (tab == selectedTab) R.color.tab_selected else R.color.gray)) |
| | | if (tab == selectedTab) android.R.color.black else R.color.gray)) |
| | | // 设置文字大小 |
| | | tab.textSize = if (tab == selectedTab) 16f else 14f |
| | | // 设置下划线 |
| | | tab.setUnderlineVisible(tab == selectedTab) |
| | | } |
| | | } |
| | | } |