mirror of
https://github.com/owenlejeune/TVTime.git
synced 2025-11-08 04:32:43 -05:00
flatten settigns navigation + move next mcu card behind preference
This commit is contained in:
@@ -34,6 +34,7 @@ class AppPreferences(context: Context) {
|
||||
private val ACCOUNT_TAB_POSITION = "account_tab_position"
|
||||
private val SHOW_BTAB_LABELS = "show_btab_labels"
|
||||
private val SHOW_POSTER_TITLE = "show_poster_titles"
|
||||
private val SHOW_NEXT_MCU = "show_next_mcu"
|
||||
}
|
||||
|
||||
private val preferences: SharedPreferences = context.getSharedPreferences(PREF_FILE, Context.MODE_PRIVATE)
|
||||
@@ -128,6 +129,12 @@ class AppPreferences(context: Context) {
|
||||
get() = preferences.getBoolean(SHOW_BACKDROP_GALLERY, showBackdropGalleryDefault)
|
||||
set(value) { preferences.put(SHOW_BACKDROP_GALLERY, value) }
|
||||
|
||||
/******** Special Features Preferences ********/
|
||||
val showNextMcuProductionDefault: Boolean = false
|
||||
var showNextMcuProduction: Boolean
|
||||
get() = preferences.getBoolean(SHOW_NEXT_MCU, showNextMcuProductionDefault)
|
||||
set(value) { preferences.put(SHOW_NEXT_MCU, value) }
|
||||
|
||||
/********* Helpers ********/
|
||||
private fun SharedPreferences.put(key: String, value: Any?) {
|
||||
edit().apply {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.owenlejeune.tvtime.ui.navigation
|
||||
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.compose.animation.AnimatedContentTransitionScope
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.fadeIn
|
||||
@@ -93,18 +91,6 @@ fun AppNavigationHost(
|
||||
}
|
||||
}
|
||||
}
|
||||
composable(
|
||||
AppNavItem.SettingsView.route.plus("/{${NavConstants.SETTINGS_KEY}}"),
|
||||
arguments = listOf(
|
||||
navArgument(NavConstants.SETTINGS_KEY) { type = NavType.StringType }
|
||||
)
|
||||
) {
|
||||
val route = it.arguments?.getString(NavConstants.SETTINGS_KEY)
|
||||
SettingsScreen(
|
||||
appNavController = appNavController,
|
||||
route = route
|
||||
)
|
||||
}
|
||||
composable(AppNavItem.SettingsView.route) {
|
||||
SettingsScreen(appNavController = appNavController)
|
||||
}
|
||||
@@ -237,9 +223,7 @@ sealed class AppNavItem(val route: String) {
|
||||
object DetailView: AppNavItem("detail_route") {
|
||||
fun withArgs(type: MediaViewType, id: Int) = route.plus("/${type}/${id}")
|
||||
}
|
||||
object SettingsView: AppNavItem("settings_route") {
|
||||
fun withArgs(page: String) = route.plus("/$page")
|
||||
}
|
||||
object SettingsView: AppNavItem("settings_route")
|
||||
object SearchView: AppNavItem("search_route") {
|
||||
fun withArgs(searchType: MediaViewType, pageTitle: String) = route.plus("?searchType=$searchType&pageTitle=$pageTitle")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.owenlejeune.tvtime.ui.navigation
|
||||
|
||||
import androidx.compose.animation.AnimatedContentTransitionScope
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import com.owenlejeune.tvtime.R
|
||||
import com.owenlejeune.tvtime.ui.screens.DarkModePreferences
|
||||
import com.owenlejeune.tvtime.ui.screens.DesignPreferences
|
||||
import com.owenlejeune.tvtime.ui.screens.DevPreferences
|
||||
import com.owenlejeune.tvtime.ui.screens.HomeScreenPreferences
|
||||
import com.owenlejeune.tvtime.ui.screens.SearchPreferences
|
||||
import com.owenlejeune.tvtime.ui.screens.SettingsHome
|
||||
import com.owenlejeune.tvtime.ui.screens.SpecialFeaturePreferences
|
||||
|
||||
@Composable
|
||||
fun SettingsNavigationHost(
|
||||
appNavController: NavController,
|
||||
appBarTitle: MutableState<String>,
|
||||
popBackAction: MutableState<() -> Unit>
|
||||
) {
|
||||
val settingsNavController = rememberNavController()
|
||||
NavHost(
|
||||
navController = settingsNavController,
|
||||
startDestination = SettingsNavItem.Home.route,
|
||||
enterTransition = { slideIntoContainer(AnimatedContentTransitionScope.SlideDirection.Start, tween(500)) },
|
||||
popEnterTransition = { fadeIn(tween(500)) },
|
||||
exitTransition = { fadeOut(tween(500)) },
|
||||
popExitTransition = { slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.End, tween(500)) }
|
||||
) {
|
||||
composable(SettingsNavItem.Home.route) {
|
||||
appBarTitle.value = stringResource(id = R.string.nav_settings_title)
|
||||
popBackAction.value = { appNavController.popBackStack() }
|
||||
SettingsHome(settingsNavController = settingsNavController)
|
||||
}
|
||||
composable(SettingsNavItem.Search.route) {
|
||||
appBarTitle.value = stringResource(id = R.string.preference_heading_search)
|
||||
popBackAction.value = { settingsNavController.popBackStack() }
|
||||
SearchPreferences()
|
||||
}
|
||||
composable(SettingsNavItem.Design.route) {
|
||||
appBarTitle.value = stringResource(id = R.string.preference_heading_design)
|
||||
popBackAction.value = { settingsNavController.popBackStack() }
|
||||
DesignPreferences(settingsNavController = settingsNavController)
|
||||
}
|
||||
composable(SettingsNavItem.DarkMode.route) {
|
||||
appBarTitle.value = stringResource(id = R.string.preference_heading_dark_mode)
|
||||
popBackAction.value = { settingsNavController.popBackStack() }
|
||||
DarkModePreferences()
|
||||
}
|
||||
composable(SettingsNavItem.HomeScreen.route) {
|
||||
appBarTitle.value = stringResource(id = R.string.preference_heading_home_screen)
|
||||
popBackAction.value = { settingsNavController.popBackStack() }
|
||||
HomeScreenPreferences()
|
||||
}
|
||||
composable(SettingsNavItem.SpecialFeatures.route) {
|
||||
appBarTitle.value = stringResource(id = R.string.preference_heading_special_features)
|
||||
popBackAction.value = { settingsNavController.popBackStack() }
|
||||
SpecialFeaturePreferences()
|
||||
}
|
||||
composable(SettingsNavItem.Developer.route) {
|
||||
appBarTitle.value = stringResource(id = R.string.preferences_debug_title)
|
||||
popBackAction.value = { settingsNavController.popBackStack() }
|
||||
DevPreferences()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sealed class SettingsNavItem(val route: String) {
|
||||
object Home: SettingsNavItem("settings_home")
|
||||
object Search: SettingsNavItem("settings_search")
|
||||
object Design: SettingsNavItem("settings_design")
|
||||
object DarkMode: SettingsNavItem("settings_dark_mode")
|
||||
object HomeScreen: SettingsNavItem("settings_home_screen")
|
||||
object SpecialFeatures: SettingsNavItem("settings_special_feature")
|
||||
object Developer: SettingsNavItem("settings_developer")
|
||||
}
|
||||
@@ -46,6 +46,7 @@ import com.owenlejeune.tvtime.extensions.format
|
||||
import com.owenlejeune.tvtime.extensions.getCalendarYear
|
||||
import com.owenlejeune.tvtime.extensions.lazyPagingItems
|
||||
import com.owenlejeune.tvtime.extensions.listItems
|
||||
import com.owenlejeune.tvtime.preferences.AppPreferences
|
||||
import com.owenlejeune.tvtime.ui.components.*
|
||||
import com.owenlejeune.tvtime.ui.navigation.AppNavItem
|
||||
import com.owenlejeune.tvtime.ui.viewmodel.MainViewModel
|
||||
@@ -54,6 +55,7 @@ import com.owenlejeune.tvtime.utils.SessionManager
|
||||
import com.owenlejeune.tvtime.utils.TmdbUtils
|
||||
import com.owenlejeune.tvtime.utils.types.MediaViewType
|
||||
import kotlinx.coroutines.*
|
||||
import org.koin.java.KoinJavaComponent.get
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalPagerApi::class)
|
||||
@Composable
|
||||
@@ -152,7 +154,8 @@ private fun MediaViewContent(
|
||||
type: MediaViewType,
|
||||
windowSize: WindowSizeClass,
|
||||
showImageGallery: MutableState<Boolean>,
|
||||
pagerState: PagerState
|
||||
pagerState: PagerState,
|
||||
preferences: AppPreferences = get(AppPreferences::class.java)
|
||||
) {
|
||||
LaunchedEffect(Unit) {
|
||||
mainViewModel.getExternalIds(itemId, type)
|
||||
@@ -249,7 +252,10 @@ private fun MediaViewContent(
|
||||
|
||||
WatchProvidersCard(itemId = itemId, type = type, mainViewModel = mainViewModel)
|
||||
|
||||
if (mediaItem?.productionCompanies?.firstOrNull { it.name == "Marvel Studios" } != null) {
|
||||
if (
|
||||
mediaItem?.productionCompanies?.firstOrNull { it.name == "Marvel Studios" } != null
|
||||
&& preferences.showNextMcuProduction
|
||||
) {
|
||||
NextMcuProjectCard(appNavController = appNavController)
|
||||
}
|
||||
|
||||
@@ -1078,7 +1084,7 @@ private fun NextMcuProjectCard(
|
||||
Text(
|
||||
text = nextMcuProject.value?.title ?: "",
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
fontWeight = FontWeight.W700
|
||||
fontWeight = FontWeight.W600
|
||||
)
|
||||
|
||||
val releaseDate =
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,7 @@ class SettingsViewModel: ViewModel() {
|
||||
private val _showPosterTitles = MutableStateFlow(preferences.showPosterTitles)
|
||||
private val _firstLaunchTesting = MutableStateFlow(preferences.firstLaunchTesting)
|
||||
private val _showBackdropGallery = MutableStateFlow(preferences.showBackdropGallery)
|
||||
private val _showNextMcuProduction = MutableStateFlow(preferences.showNextMcuProduction)
|
||||
}
|
||||
|
||||
val showSearchBar = _showSearchBar.asStateFlow()
|
||||
@@ -36,6 +37,7 @@ class SettingsViewModel: ViewModel() {
|
||||
val showPosterTitles = _showPosterTitles.asStateFlow()
|
||||
val firstLaunchTesting = _firstLaunchTesting.asStateFlow()
|
||||
val showBackdropGallery = _showBackdropGallery.asStateFlow()
|
||||
val showNextMcuProduction = _showNextMcuProduction.asStateFlow()
|
||||
|
||||
fun toggleShowSearchBar() {
|
||||
_showSearchBar.value = _showSearchBar.value.not()
|
||||
@@ -132,4 +134,14 @@ class SettingsViewModel: ViewModel() {
|
||||
preferences.showBackdropGallery = value
|
||||
}
|
||||
|
||||
fun toggleShowNextMcuProduction() {
|
||||
_showNextMcuProduction.value = _showNextMcuProduction.value.not()
|
||||
preferences.showNextMcuProduction = _showNextMcuProduction.value
|
||||
}
|
||||
|
||||
fun setShowNextMcuProduction(value: Boolean) {
|
||||
_showNextMcuProduction.value = value
|
||||
preferences.showNextMcuProduction = value
|
||||
}
|
||||
|
||||
}
|
||||
@@ -84,6 +84,10 @@
|
||||
<string name="preference_show_text_labels_title">Show tab text labels</string>
|
||||
<string name="preference_show_text_labels_subtitle">Show text labels for tab items in the bottom tab bar or navigation rail</string>
|
||||
<string name="preference_home_tab_order_heading">Home Tab Order</string>
|
||||
<string name="preference_heading_special_features">Special Features</string>
|
||||
<string name="preference_subtitle_special_features">Extra features and hidden goodies</string>
|
||||
<string name="preferences_show_next_mcu_title">Show Next MCU Production</string>
|
||||
<string name="preferences_show_next_mcu_subtitle">Show a card with information on the next scheduled MCU production when viewing details for an MCU release</string>
|
||||
|
||||
<!-- video type -->
|
||||
<string name="video_type_clip">Clips</string>
|
||||
|
||||
Reference in New Issue
Block a user