Merge branch 'simple_sub_system' into 'master'
Add a simple toggle for debugging purposes See merge request ti/2023-2024/s4/mobile-security/students/joren-schipman/pokesearch!4
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user