From 987efa2d66bfcb78fac702866648d709c55efdad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Santos?= Date: Wed, 13 Nov 2024 14:11:41 +0000 Subject: [PATCH] Remove zoom transitions by always providing content on screens --- .../org/ooni/probe/ui/descriptor/DescriptorScreen.kt | 10 +++++----- .../ui/settings/category/SettingsCategoryScreen.kt | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/descriptor/DescriptorScreen.kt b/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/descriptor/DescriptorScreen.kt index d1a883b6..3c6e5c08 100644 --- a/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/descriptor/DescriptorScreen.kt +++ b/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/descriptor/DescriptorScreen.kt @@ -69,8 +69,6 @@ fun DescriptorScreen( state: DescriptorViewModel.State, onEvent: (DescriptorViewModel.Event) -> Unit, ) { - val descriptor = state.descriptor ?: return - val pullRefreshState = rememberPullToRefreshState() Box( Modifier @@ -78,16 +76,16 @@ fun DescriptorScreen( isRefreshing = state.isRefreshing, onRefresh = { onEvent(DescriptorViewModel.Event.FetchUpdatedDescriptor) }, state = pullRefreshState, - enabled = descriptor.source is Descriptor.Source.Installed, + enabled = state.descriptor?.source is Descriptor.Source.Installed, ) .background(MaterialTheme.colorScheme.background), ) { Column { - val descriptorColor = descriptor.color ?: MaterialTheme.colorScheme.primary + val descriptorColor = state.descriptor?.color ?: MaterialTheme.colorScheme.primary val onDescriptorColor = LocalCustomColors.current.onDescriptor TopBar( title = { - Text(descriptor.title.invoke()) + Text(state.descriptor?.title?.invoke().orEmpty()) }, navigationIcon = { IconButton(onClick = { onEvent(DescriptorViewModel.Event.BackClicked) }) { @@ -113,6 +111,8 @@ fun DescriptorScreen( .padding(WindowInsets.navigationBars.asPaddingValues()) .padding(bottom = 32.dp), ) { + val descriptor = state.descriptor ?: return + DescriptorDetails(state, onEvent) descriptor.metadata()?.let { diff --git a/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/settings/category/SettingsCategoryScreen.kt b/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/settings/category/SettingsCategoryScreen.kt index cb0e4ad8..e0c07bcb 100644 --- a/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/settings/category/SettingsCategoryScreen.kt +++ b/composeApp/src/commonMain/kotlin/org/ooni/probe/ui/settings/category/SettingsCategoryScreen.kt @@ -56,12 +56,10 @@ fun SettingsCategoryScreen( state: SettingsCategoryViewModel.State, onEvent: (SettingsCategoryViewModel.Event) -> Unit, ) { - val category = state.category ?: return - Column(Modifier.background(MaterialTheme.colorScheme.background)) { TopBar( title = { - Text(stringResource(category.title)) + Text(state.category?.title?.let { stringResource(it) }.orEmpty()) }, navigationIcon = { IconButton(onClick = { onEvent(SettingsCategoryViewModel.Event.BackClicked) }) { @@ -77,6 +75,7 @@ fun SettingsCategoryScreen( .verticalScroll(rememberScrollState()) .padding(WindowInsets.navigationBars.asPaddingValues()), ) { + val category = state.category ?: return Column { category.settings?.forEach { preferenceItem -> when (preferenceItem.type) {