diff --git a/app/src/main/java/com/croumy/hltb_wearos/presentation/models/api/Categories.kt b/app/src/main/java/com/croumy/hltb_wearos/presentation/models/api/Categories.kt index a3106fe..f2c1929 100644 --- a/app/src/main/java/com/croumy/hltb_wearos/presentation/models/api/Categories.kt +++ b/app/src/main/java/com/croumy/hltb_wearos/presentation/models/api/Categories.kt @@ -21,20 +21,32 @@ abstract class Category { object Custom: Category() { override val value: String = "custom" - override var label: String? = "Paused" + override var label: String? = "" override val color: Color = Color(0xFF175A53) + + fun updateLabel(newLabel: String?) { + label = newLabel + } } object Custom2: Category() { override val value: String = "custom2" - override var label: String? = "Stopped" + override var label: String? = "" override val color: Color = Color(0xFF175A53) + + fun updateLabel(newLabel: String?) { + label = newLabel + } } object Custom3: Category() { override val value: String = "custom3" - override var label: String? = "Let's Play" + override var label: String? = "" override val color: Color = Color(0xFF175A53) + + fun updateLabel(newLabel: String?) { + label = newLabel + } } object Completed: Category() { @@ -48,8 +60,6 @@ abstract class Category { override var label: String = "Retired" override val color: Color = Color(0xFF9F2A2B) } - - companion object { - val all = listOf(Playing, Backlog, Custom, Custom2, Custom3, Completed, Retired).filter { it.label != null && it.label?.isNotEmpty() == true } - } -} \ No newline at end of file +} +val categories = listOf(Category.Playing, Category.Backlog, Category.Custom, Category.Custom2, Category.Custom3, Category.Completed, Category.Retired) + .filter { it.label != null && it.label?.isNotEmpty() == true } \ No newline at end of file diff --git a/app/src/main/java/com/croumy/hltb_wearos/presentation/models/api/GameRequest.kt b/app/src/main/java/com/croumy/hltb_wearos/presentation/models/api/GameRequest.kt index 029088d..be19699 100644 --- a/app/src/main/java/com/croumy/hltb_wearos/presentation/models/api/GameRequest.kt +++ b/app/src/main/java/com/croumy/hltb_wearos/presentation/models/api/GameRequest.kt @@ -2,7 +2,7 @@ package com.croumy.hltb_wearos.presentation.models.api data class GameRequest( - val lists: List = Category.all.map { it.value }, + val lists: List = categories.map { it.value }, val set_playstyle: String = "comp_all", val limit: Int = 1000, val name: String = "" diff --git a/app/src/main/java/com/croumy/hltb_wearos/presentation/ui/home/Home.kt b/app/src/main/java/com/croumy/hltb_wearos/presentation/ui/home/Home.kt index f6c61dc..c45caa7 100644 --- a/app/src/main/java/com/croumy/hltb_wearos/presentation/ui/home/Home.kt +++ b/app/src/main/java/com/croumy/hltb_wearos/presentation/ui/home/Home.kt @@ -43,6 +43,7 @@ import com.croumy.hltb_wearos.presentation.LocalNavController import com.croumy.hltb_wearos.presentation.components.GameItem import com.croumy.hltb_wearos.presentation.models.Constants import com.croumy.hltb_wearos.presentation.models.api.Category +import com.croumy.hltb_wearos.presentation.models.api.categories import com.croumy.hltb_wearos.presentation.theme.Dimensions import com.croumy.hltb_wearos.presentation.theme.HLTBwearosTheme import com.croumy.hltb_wearos.presentation.theme.shimmerColor @@ -64,7 +65,7 @@ fun HomeScreen( val previousGameId = navController.currentBackStackEntry?.savedStateHandle?.getLiveData("previousGameId") // CROWN SCROLL CONFIG + LISTS STATES - val focusRequester = listOf(FocusRequester()).plus((Category.all).map { FocusRequester() }) + val focusRequester = listOf(FocusRequester()).plus((categories).map { FocusRequester() }) val horizontalScrollState = rememberLazyListState(initialFirstVisibleItemIndex = 1) val horizontalFirstVisibleIndex = remember { derivedStateOf { horizontalScrollState.firstVisibleItemIndex } } @@ -112,7 +113,7 @@ fun HomeScreen( ) } - itemsIndexed(Category.all) { index, category -> + itemsIndexed(categories) { index, category -> val games = viewModel.gamesByCategories[category] ?: emptyList() Column( diff --git a/app/src/main/java/com/croumy/hltb_wearos/presentation/ui/home/HomeViewModel.kt b/app/src/main/java/com/croumy/hltb_wearos/presentation/ui/home/HomeViewModel.kt index 2c44667..9089e74 100644 --- a/app/src/main/java/com/croumy/hltb_wearos/presentation/ui/home/HomeViewModel.kt +++ b/app/src/main/java/com/croumy/hltb_wearos/presentation/ui/home/HomeViewModel.kt @@ -9,6 +9,7 @@ import com.croumy.hltb_wearos.presentation.data.AppService import com.croumy.hltb_wearos.presentation.data.HLTBService import com.croumy.hltb_wearos.presentation.models.api.Category import com.croumy.hltb_wearos.presentation.models.api.Game +import com.croumy.hltb_wearos.presentation.models.api.categories import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch import javax.inject.Inject @@ -20,12 +21,12 @@ class HomeViewModel @Inject constructor( ): ViewModel() { private val games: MutableState> = mutableStateOf(emptyList()) // IN VIEWMODEL TO KEEP LIST SCROLLSTATE ON NAVIGATION - val listStates = listOf(ScalingLazyListState(initialCenterItemIndex = 0)).plus((Category.all).map { ScalingLazyListState(initialCenterItemIndex = 0) }) + val listStates = listOf(ScalingLazyListState(initialCenterItemIndex = 0)).plus((categories).map { ScalingLazyListState(initialCenterItemIndex = 0) }) val currentListState = mutableStateOf(listStates[1]) val gamesByCategories get(): Map> { val map = mutableMapOf>() - Category.all.forEach { category -> + categories.forEach { category -> map[category] = games.value.filter { it.categories.contains(category) } } return map diff --git a/app/src/main/java/com/croumy/hltb_wearos/presentation/ui/startapp/StartApp.kt b/app/src/main/java/com/croumy/hltb_wearos/presentation/ui/startapp/StartApp.kt index 5085de7..fecf863 100644 --- a/app/src/main/java/com/croumy/hltb_wearos/presentation/ui/startapp/StartApp.kt +++ b/app/src/main/java/com/croumy/hltb_wearos/presentation/ui/startapp/StartApp.kt @@ -76,8 +76,8 @@ fun StartApp( if (isLoggedIn.value) { if (isLoggedIn.value && isLoggingIn.value) { delay(400) // TIME TO SHOW THE CHECK ICON - viewModel.initCategories() } + viewModel.initCategories() navigateToHome() } }