From b74c56c068d1bb0aa5e23bf2dfa203e998ed1fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCrten?= <sebastian@mobanisto.de> Date: Wed, 11 May 2022 08:26:38 +0200 Subject: [PATCH] Remove some Surface {} elements that are now not needed any longer --- .../conversation/PrivateMessageScreen.kt | 37 ++++---- .../briar/desktop/login/ErrorScreen.kt | 59 ++++++------ .../briar/desktop/login/StartupScreen.kt | 41 ++++----- .../briar/desktop/settings/SettingDetails.kt | 91 +++++++++---------- .../briar/desktop/ui/UiPlaceholder.kt | 14 +-- .../briar/desktop/utils/PreviewUtils.kt | 3 +- 6 files changed, 114 insertions(+), 131 deletions(-) diff --git a/src/main/kotlin/org/briarproject/briar/desktop/conversation/PrivateMessageScreen.kt b/src/main/kotlin/org/briarproject/briar/desktop/conversation/PrivateMessageScreen.kt index d28646d414..1b374b6dc8 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/conversation/PrivateMessageScreen.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/conversation/PrivateMessageScreen.kt @@ -32,7 +32,6 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.Icon import androidx.compose.material.IconButton import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.PersonAdd @@ -133,23 +132,21 @@ fun PendingContactSelected() = Explainer( @Composable fun Explainer(headline: String, text: String, content: @Composable () -> Unit = {}) = - Surface(color = MaterialTheme.colors.background) { - Column( - modifier = Modifier.padding(16.dp).fillMaxSize(), - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally - ) { - BriarLogo(modifier = Modifier.size(200.dp)) - Text( - text = headline, - modifier = Modifier.padding(top = 16.dp, bottom = 4.dp), - style = MaterialTheme.typography.h3 - ) - Text( - text = text, - modifier = Modifier.padding(top = 4.dp, bottom = 16.dp).widthIn(max = PARAGRAPH_WIDTH), - style = MaterialTheme.typography.body2.copy(textAlign = TextAlign.Center) - ) - content() - } + Column( + modifier = Modifier.padding(16.dp).fillMaxSize(), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + BriarLogo(modifier = Modifier.size(200.dp)) + Text( + text = headline, + modifier = Modifier.padding(top = 16.dp, bottom = 4.dp), + style = MaterialTheme.typography.h3 + ) + Text( + text = text, + modifier = Modifier.padding(top = 4.dp, bottom = 16.dp).widthIn(max = PARAGRAPH_WIDTH), + style = MaterialTheme.typography.body2.copy(textAlign = TextAlign.Center) + ) + content() } diff --git a/src/main/kotlin/org/briarproject/briar/desktop/login/ErrorScreen.kt b/src/main/kotlin/org/briarproject/briar/desktop/login/ErrorScreen.kt index beddb1c718..fc3ba64c07 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/login/ErrorScreen.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/login/ErrorScreen.kt @@ -30,7 +30,6 @@ import androidx.compose.material.Button import androidx.compose.material.Icon import androidx.compose.material.IconButton import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowBack @@ -110,39 +109,37 @@ fun ErrorScreen( text: String, onShowAbout: () -> Unit, onBackButton: (() -> Unit)? = null, -) = Surface { - Box { - Column( - modifier = Modifier.fillMaxSize().padding(32.dp), - horizontalAlignment = CenterHorizontally, - verticalArrangement = spacedBy(32.dp) - ) { - Icon( - imageVector = Icons.Filled.Error, - contentDescription = i18n("error"), - modifier = Modifier.size(128.dp), - tint = Red500 - ) +) = Box { + Column( + modifier = Modifier.fillMaxSize().padding(32.dp), + horizontalAlignment = CenterHorizontally, + verticalArrangement = spacedBy(32.dp) + ) { + Icon( + imageVector = Icons.Filled.Error, + contentDescription = i18n("error"), + modifier = Modifier.size(128.dp), + tint = Red500 + ) - Text(i18n("sorry"), style = MaterialTheme.typography.h5) - Text( - text = text, - style = MaterialTheme.typography.body1, - modifier = Modifier.widthIn(max = STARTUP_FIELDS_WIDTH) - ) - } + Text(i18n("sorry"), style = MaterialTheme.typography.h5) + Text( + text = text, + style = MaterialTheme.typography.body1, + modifier = Modifier.widthIn(max = STARTUP_FIELDS_WIDTH) + ) + } - if (onBackButton != null) { - IconButton(onClick = onBackButton) { - Icon(Icons.Filled.ArrowBack, i18n("back")) - } + if (onBackButton != null) { + IconButton(onClick = onBackButton) { + Icon(Icons.Filled.ArrowBack, i18n("back")) } + } - IconButton( - onClick = onShowAbout, - modifier = Modifier.align(Alignment.BottomStart) - ) { - Icon(Icons.Filled.Info, i18n("access.about_briar_desktop")) - } + IconButton( + onClick = onShowAbout, + modifier = Modifier.align(Alignment.BottomStart) + ) { + Icon(Icons.Filled.Info, i18n("access.about_briar_desktop")) } } diff --git a/src/main/kotlin/org/briarproject/briar/desktop/login/StartupScreen.kt b/src/main/kotlin/org/briarproject/briar/desktop/login/StartupScreen.kt index 0485c3e38c..cae1225cf1 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/login/StartupScreen.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/login/StartupScreen.kt @@ -28,7 +28,6 @@ import androidx.compose.foundation.layout.width import androidx.compose.material.Icon import androidx.compose.material.IconButton import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowBack @@ -62,32 +61,30 @@ fun StartupScreenScaffold( onBackButton: () -> Unit = {}, onShowAbout: () -> Unit = {}, content: @Composable () -> Unit -) = Surface { - Box { - Column( - modifier = Modifier.padding(16.dp).fillMaxSize(), - horizontalAlignment = CenterHorizontally - ) { - HeaderLine(title) - content() - } - - if (showBackButton) { - IconButton( - onClick = onBackButton, - modifier = Modifier.align(Alignment.TopStart) - ) { - Icon(Icons.Filled.ArrowBack, i18n("back")) - } - } +) = Box { + Column( + modifier = Modifier.padding(16.dp).fillMaxSize(), + horizontalAlignment = CenterHorizontally + ) { + HeaderLine(title) + content() + } + if (showBackButton) { IconButton( - onClick = onShowAbout, - modifier = Modifier.align(Alignment.BottomStart) + onClick = onBackButton, + modifier = Modifier.align(Alignment.TopStart) ) { - Icon(Icons.Filled.Info, i18n("access.about_briar_desktop")) + Icon(Icons.Filled.ArrowBack, i18n("back")) } } + + IconButton( + onClick = onShowAbout, + modifier = Modifier.align(Alignment.BottomStart) + ) { + Icon(Icons.Filled.Info, i18n("access.about_briar_desktop")) + } } @Composable diff --git a/src/main/kotlin/org/briarproject/briar/desktop/settings/SettingDetails.kt b/src/main/kotlin/org/briarproject/briar/desktop/settings/SettingDetails.kt index 9f07aeb80e..6bfd1c3109 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/settings/SettingDetails.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/settings/SettingDetails.kt @@ -31,7 +31,6 @@ import androidx.compose.foundation.layout.widthIn import androidx.compose.material.MaterialTheme import androidx.compose.material.OutlinedButton import androidx.compose.material.OutlinedExposedDropDownMenu -import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -42,60 +41,58 @@ import org.briarproject.briar.desktop.utils.InternationalizationUtils.i18n @Composable fun SettingDetails(viewModel: SettingsViewModel) { - Surface(Modifier.fillMaxSize()) { - when (viewModel.selectedSetting.value) { - SettingCategory.GENERAL -> { - SettingDetail(i18n("settings.general.title")) {} - } - SettingCategory.DISPLAY -> { - // TODO: Change this to `settings.display.title` once more categories are implemented - SettingDetail(i18n("settings.title")) { - DetailItem { - Text(i18n("settings.display.theme.title")) + when (viewModel.selectedSetting.value) { + SettingCategory.GENERAL -> { + SettingDetail(i18n("settings.general.title")) {} + } + SettingCategory.DISPLAY -> { + // TODO: Change this to `settings.display.title` once more categories are implemented + SettingDetail(i18n("settings.title")) { + DetailItem { + Text(i18n("settings.display.theme.title")) - OutlinedExposedDropDownMenu( - values = viewModel.themesList.map { i18n("settings.display.theme.${it.name.lowercase()}") }, - selectedIndex = viewModel.selectedTheme.value.ordinal, - onChange = { viewModel.selectTheme(viewModel.themesList[it]) }, - modifier = Modifier.widthIn(min = 200.dp) - ) - } + OutlinedExposedDropDownMenu( + values = viewModel.themesList.map { i18n("settings.display.theme.${it.name.lowercase()}") }, + selectedIndex = viewModel.selectedTheme.value.ordinal, + onChange = { viewModel.selectTheme(viewModel.themesList[it]) }, + modifier = Modifier.widthIn(min = 200.dp) + ) + } - DetailItem { - Text(i18n("settings.display.language.title")) + DetailItem { + Text(i18n("settings.display.language.title")) - OutlinedExposedDropDownMenu( - values = viewModel.languageList.map { - if (it == UnencryptedSettings.Language.DEFAULT) i18n("settings.display.language.auto") - else it.locale.getDisplayLanguage(it.locale) - }, - selectedIndex = viewModel.selectedLanguage.value.ordinal, - onChange = { viewModel.selectLanguage(viewModel.languageList[it]) }, - modifier = Modifier.widthIn(min = 200.dp) - ) - } + OutlinedExposedDropDownMenu( + values = viewModel.languageList.map { + if (it == UnencryptedSettings.Language.DEFAULT) i18n("settings.display.language.auto") + else it.locale.getDisplayLanguage(it.locale) + }, + selectedIndex = viewModel.selectedLanguage.value.ordinal, + onChange = { viewModel.selectLanguage(viewModel.languageList[it]) }, + modifier = Modifier.widthIn(min = 200.dp) + ) + } - DetailItem { - Text(i18n("settings.security.title")) + DetailItem { + Text(i18n("settings.security.title")) - OutlinedButton(onClick = viewModel::showChangePasswordDialog) { - Text(i18n("settings.security.password.change")) - } + OutlinedButton(onClick = viewModel::showChangePasswordDialog) { + Text(i18n("settings.security.password.change")) } } } - SettingCategory.CONNECTIONS -> { - SettingDetail(i18n("settings.connections.title")) {} - } - SettingCategory.SECURITY -> { - SettingDetail(i18n("settings.security.title")) {} - } - SettingCategory.NOTIFICATIONS -> { - SettingDetail(i18n("settings.notifications.title")) {} - } - SettingCategory.ACTIONS -> { - SettingDetail(i18n("settings.actions.title")) {} - } + } + SettingCategory.CONNECTIONS -> { + SettingDetail(i18n("settings.connections.title")) {} + } + SettingCategory.SECURITY -> { + SettingDetail(i18n("settings.security.title")) {} + } + SettingCategory.NOTIFICATIONS -> { + SettingDetail(i18n("settings.notifications.title")) {} + } + SettingCategory.ACTIONS -> { + SettingDetail(i18n("settings.actions.title")) {} } } } diff --git a/src/main/kotlin/org/briarproject/briar/desktop/ui/UiPlaceholder.kt b/src/main/kotlin/org/briarproject/briar/desktop/ui/UiPlaceholder.kt index e6ed761255..39c7f93306 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/ui/UiPlaceholder.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/ui/UiPlaceholder.kt @@ -20,19 +20,15 @@ package org.briarproject.briar.desktop.ui import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @Composable -fun UiPlaceholder() = Surface(color = MaterialTheme.colors.background) { - Box( - contentAlignment = Alignment.Center, - modifier = Modifier.fillMaxSize() - ) { - Text("TBD") - } +fun UiPlaceholder() = Box( + contentAlignment = Alignment.Center, + modifier = Modifier.fillMaxSize() +) { + Text("TBD") } diff --git a/src/main/kotlin/org/briarproject/briar/desktop/utils/PreviewUtils.kt b/src/main/kotlin/org/briarproject/briar/desktop/utils/PreviewUtils.kt index 1df0df81ce..fa5c8e5267 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/utils/PreviewUtils.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/utils/PreviewUtils.kt @@ -34,7 +34,6 @@ import androidx.compose.material.DropdownMenu import androidx.compose.material.DropdownMenuItem import androidx.compose.material.Icon import androidx.compose.material.Slider -import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Done @@ -226,7 +225,7 @@ object PreviewUtils { } BriarTheme(isDarkTheme = scope.getBooleanParameter("darkTheme")) { - Surface(Modifier.fillMaxSize(1f)) { + Box(Modifier.fillMaxSize(1f)) { Column(Modifier.padding(10.dp)) { content(scope) } -- GitLab