Add a simple toggle for debugging purposes
This commit is contained in:
parent
8690ed006e
commit
09f9b2c5cf
@ -1,5 +1,6 @@
|
||||
package com.ti.mobpo.ui.screens
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
@ -28,6 +29,11 @@ fun FavoritesScreen(viewModel: FavouritesViewModel) {
|
||||
|
||||
@Composable
|
||||
fun Favorites(favoritesViewModel: FavouritesViewModel) {
|
||||
// Function to toggle debug mode
|
||||
val toggleDebugMode: () -> Unit = {
|
||||
favoritesViewModel.toggleDebugMode()
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
favoritesViewModel.loadFavourites()
|
||||
}
|
||||
@ -43,11 +49,9 @@ fun Favorites(favoritesViewModel: FavouritesViewModel) {
|
||||
) {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
// Show AlertDialog if access check failed
|
||||
if (favoritesViewModel.accessCheckFailed.value) {
|
||||
AlertDialog(
|
||||
onDismissRequest = {
|
||||
// Dismiss the dialog
|
||||
favoritesViewModel.accessCheckFailed.value = false
|
||||
},
|
||||
title = {
|
||||
@ -68,6 +72,11 @@ fun Favorites(favoritesViewModel: FavouritesViewModel) {
|
||||
)
|
||||
}
|
||||
|
||||
Text(
|
||||
text = "Toggle Debug Mode",
|
||||
modifier = Modifier.clickable { toggleDebugMode() }
|
||||
)
|
||||
|
||||
favorites?.let { favoritesList ->
|
||||
if (favoritesList.isNotEmpty()) {
|
||||
LazyVerticalGrid(
|
||||
|
@ -28,6 +28,9 @@ class FavouritesViewModel(private val favouritesRepository: FavouritesRepository
|
||||
val pokemonDetails: StateFlow<List<PokemonDetails>?> = _pokemonDetails.asStateFlow()
|
||||
val accessCheckFailed: MutableState<Boolean> = mutableStateOf(false)
|
||||
|
||||
fun toggleDebugMode() {
|
||||
featureManager.setPaidFeatureEnabled(!featureManager.hasAccessToPaidFeature())
|
||||
}
|
||||
fun loadFavourites() {
|
||||
// featureManager.setPaidFeatureEnabled(false) enable and disable acccess
|
||||
// Ugly workaround to make sure all the favourites are loaded before displaying them
|
||||
|
Loading…
x
Reference in New Issue
Block a user