mirror of
https://github.com/owenlejeune/TVTime.git
synced 2025-11-22 11:40:54 -05:00
move some remember to rememberSaveable
This commit is contained in:
@@ -5,6 +5,7 @@ import androidx.activity.ComponentActivity
|
|||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalFocusManager
|
import androidx.compose.ui.platform.LocalFocusManager
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
@@ -29,7 +30,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
AppKeyboardFocusManager()
|
AppKeyboardFocusManager()
|
||||||
val displayUnderStatusBar = remember { mutableStateOf(false) }
|
val displayUnderStatusBar = rememberSaveable { mutableStateOf(false) }
|
||||||
// WindowCompat.setDecorFitsSystemWindows(window, false)
|
// WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
// WindowCompat.setDecorFitsSystemWindows(window, !displayUnderStatusBar.value)
|
// WindowCompat.setDecorFitsSystemWindows(window, !displayUnderStatusBar.value)
|
||||||
// val statusBarColor = if (displayUnderStatusBar.value) {
|
// val statusBarColor = if (displayUnderStatusBar.value) {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ fun MainAppView(appNavController: NavHostController, preferences: AppPreferences
|
|||||||
}
|
}
|
||||||
|
|
||||||
val focusRequester = remember { FocusRequester() }
|
val focusRequester = remember { FocusRequester() }
|
||||||
val focusSearchBar = remember { mutableStateOf(false) }
|
val focusSearchBar = rememberSaveable { mutableStateOf(false) }
|
||||||
val searchableScreens = listOf(BottomNavItem.Movies.route, BottomNavItem.TV.route, BottomNavItem.People.route)
|
val searchableScreens = listOf(BottomNavItem.Movies.route, BottomNavItem.TV.route, BottomNavItem.People.route)
|
||||||
|
|
||||||
val appBarActions = remember { mutableStateOf<@Composable RowScope.() -> Unit>( {} ) }
|
val appBarActions = remember { mutableStateOf<@Composable RowScope.() -> Unit>( {} ) }
|
||||||
@@ -123,7 +123,7 @@ private fun SearchTopBar(
|
|||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
val hasSearchFocus = remember { mutableStateOf(requestSearchFocus.value) }
|
val hasSearchFocus = rememberSaveable { mutableStateOf(requestSearchFocus.value) }
|
||||||
if (!requestSearchFocus.value && !hasSearchFocus.value && !(preferences.persistentSearch && preferences.hideTitle)) {
|
if (!requestSearchFocus.value && !hasSearchFocus.value && !(preferences.persistentSearch && preferences.hideTitle)) {
|
||||||
Text(text = title.value)
|
Text(text = title.value)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,17 +54,25 @@ fun AccountTab(
|
|||||||
appBarTitle: MutableState<String>,
|
appBarTitle: MutableState<String>,
|
||||||
appBarActions: MutableState<@Composable (RowScope.() -> Unit)> = mutableStateOf({})
|
appBarActions: MutableState<@Composable (RowScope.() -> Unit)> = mutableStateOf({})
|
||||||
) {
|
) {
|
||||||
when (SessionManager.currentSession?.isAuthorized) {
|
if (appBarTitle.value.equals(stringResource(id = R.string.nav_account_title))) {
|
||||||
false -> {
|
when (SessionManager.currentSession?.isAuthorized) {
|
||||||
appBarTitle.value =
|
false -> {
|
||||||
stringResource(id = R.string.account_header_title_formatted, stringResource(id = R.string.account_name_guest))
|
appBarTitle.value =
|
||||||
}
|
stringResource(
|
||||||
true -> {
|
id = R.string.account_header_title_formatted,
|
||||||
appBarTitle.value =
|
stringResource(id = R.string.account_name_guest)
|
||||||
stringResource(id = R.string.account_header_title_formatted, getAccountName(SessionManager.currentSession?.accountDetails))
|
)
|
||||||
}
|
}
|
||||||
else -> {
|
true -> {
|
||||||
appBarTitle.value = stringResource(id = R.string.account_not_logged_in)
|
appBarTitle.value =
|
||||||
|
stringResource(
|
||||||
|
id = R.string.account_header_title_formatted,
|
||||||
|
getAccountName(SessionManager.currentSession?.accountDetails)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
appBarTitle.value = stringResource(id = R.string.account_not_logged_in)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ fun PeopleTab(
|
|||||||
appBarTitle: MutableState<String>,
|
appBarTitle: MutableState<String>,
|
||||||
appNavController: NavHostController
|
appNavController: NavHostController
|
||||||
) {
|
) {
|
||||||
// appBarTitle.value = stringResource(id = R.string.nav_popular_people_title)
|
// appBarTitle.value = stringResource(id = R.string.nav_people_title)
|
||||||
|
|
||||||
val service = PeopleService()
|
val service = PeopleService()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user