From 822ec031cc074c5923497913cf0df1e742bbb682 Mon Sep 17 00:00:00 2001 From: Infi Date: Mon, 29 May 2023 23:52:09 +0200 Subject: [PATCH] feat: improve settings screen Signed-off-by: Infi --- .../revolt/screens/settings/SettingsScreen.kt | 208 ++++++++++-------- app/src/main/res/values/strings.xml | 4 + 2 files changed, 123 insertions(+), 89 deletions(-) diff --git a/app/src/main/java/chat/revolt/screens/settings/SettingsScreen.kt b/app/src/main/java/chat/revolt/screens/settings/SettingsScreen.kt index 441cca7c..7bd8a997 100644 --- a/app/src/main/java/chat/revolt/screens/settings/SettingsScreen.kt +++ b/app/src/main/java/chat/revolt/screens/settings/SettingsScreen.kt @@ -4,13 +4,15 @@ import android.widget.Toast import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Build import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.Info import androidx.compose.material.icons.filled.Settings -import androidx.compose.material3.Divider import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -43,95 +45,123 @@ fun SettingsScreen( modifier = Modifier .fillMaxSize() .padding(10.dp) - ) { - SheetClickable( - icon = { modifier -> - Icon( - painter = painterResource(id = R.drawable.ic_palette_24dp), - contentDescription = - stringResource(id = R.string.settings_appearance), - modifier = modifier - ) - }, - label = { textStyle -> - Text( - text = stringResource(id = R.string.settings_appearance), - style = textStyle - ) - }, - modifier = Modifier.testTag("settings_view_appearance") - ) { - navController.navigate("settings/appearance") - } - - SheetClickable( - icon = { modifier -> - Icon( - imageVector = Icons.Default.Info, - contentDescription = stringResource(id = R.string.about), - modifier = modifier - ) - }, - label = { textStyle -> - Text(text = stringResource(id = R.string.about), style = textStyle) - }, - modifier = Modifier.testTag("settings_view_about") - ) { - navController.navigate("about") - } - - if (BuildConfig.DEBUG) { - SheetClickable( - icon = { modifier -> - Icon( - imageVector = Icons.Default.Settings, - contentDescription = "Debug", - modifier = modifier - ) - }, - label = { textStyle -> - Text(text = "Debug", style = textStyle) - }, - modifier = Modifier.testTag("settings_view_debug") + .verticalScroll(rememberScrollState()) ) { - navController.navigate("settings/debug") + Text( + text = stringResource(id = R.string.settings_category_general), + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.padding(bottom = 10.dp, start = 10.dp) + ) + + SheetClickable( + icon = { modifier -> + Icon( + painter = painterResource(id = R.drawable.ic_palette_24dp), + contentDescription = + stringResource(id = R.string.settings_appearance), + modifier = modifier + ) + }, + label = { textStyle -> + Text( + text = stringResource(id = R.string.settings_appearance), + style = textStyle + ) + }, + modifier = Modifier.testTag("settings_view_appearance") + ) { + navController.navigate("settings/appearance") + } + + Text( + text = stringResource(id = R.string.settings_category_miscellaneous), + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.padding(bottom = 10.dp, start = 10.dp, top = 20.dp) + ) + + SheetClickable( + icon = { modifier -> + Icon( + imageVector = Icons.Default.Info, + contentDescription = stringResource(id = R.string.about), + modifier = modifier + ) + }, + label = { textStyle -> + Text(text = stringResource(id = R.string.about), style = textStyle) + }, + modifier = Modifier.testTag("settings_view_about") + ) { + navController.navigate("about") + } + + if (BuildConfig.DEBUG) { + SheetClickable( + icon = { modifier -> + Icon( + imageVector = Icons.Default.Settings, + contentDescription = "Debug", + modifier = modifier + ) + }, + label = { textStyle -> + Text(text = "Debug", style = textStyle) + }, + modifier = Modifier.testTag("settings_view_debug") + ) { + navController.navigate("settings/debug") + } + } + + Text( + text = stringResource( + id = R.string.settings_category_last, + BuildConfig.VERSION_NAME + ), + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.padding(bottom = 10.dp, start = 10.dp, top = 20.dp) + ) + + SheetClickable( + icon = { modifier -> + Icon( + imageVector = Icons.Default.Build, + contentDescription = stringResource(id = R.string.settings_feedback), + modifier = modifier + ) + }, + label = { textStyle -> + Text( + text = stringResource(id = R.string.settings_feedback), + style = textStyle + ) + }, + modifier = Modifier.testTag("settings_view_feedback") + ) { + navController.navigate("settings/feedback") + } + + SheetClickable( + icon = { modifier -> + Icon( + imageVector = Icons.Default.Close, + contentDescription = stringResource(id = R.string.logout), + modifier = modifier + ) + }, + label = { textStyle -> + Text(text = stringResource(id = R.string.logout), style = textStyle) + }, + modifier = Modifier.testTag("settings_view_logout") + ) { + Toast + .makeText( + navController.context, + "Not implemented yet", + Toast.LENGTH_SHORT + ) + .show() + } } - } - - Divider() - - SheetClickable( - icon = { modifier -> - Icon( - imageVector = Icons.Default.Build, - contentDescription = stringResource(id = R.string.settings_feedback), - modifier = modifier - ) - }, - label = { textStyle -> - Text(text = stringResource(id = R.string.settings_feedback), style = textStyle) - }, - modifier = Modifier.testTag("settings_view_feedback") - ) { - navController.navigate("settings/feedback") - } - - SheetClickable( - icon = { modifier -> - Icon( - imageVector = Icons.Default.Close, - contentDescription = stringResource(id = R.string.logout), - modifier = modifier - ) - }, - label = { textStyle -> - Text(text = stringResource(id = R.string.logout), style = textStyle) - }, - modifier = Modifier.testTag("settings_view_logout") - ) { - Toast.makeText(navController.context, "Not implemented yet", Toast.LENGTH_SHORT) - .show() - } - } } } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9f889ed2..b13ee532 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -264,6 +264,10 @@ Then long tap your profile picture to open the settings. Got it + General + Miscellaneous + Revolt v%1$s + Appearance Theme System