From bf8acdcb054b37ea6fc6ec740b718eb1a06a1f12 Mon Sep 17 00:00:00 2001 From: Infi Date: Mon, 12 Jun 2023 17:58:06 +0200 Subject: [PATCH] fix: layout fixes for self user overview Signed-off-by: Infi --- .../screens/settings/SelfUserOverview.kt | 28 ++- .../revolt/screens/settings/SettingsScreen.kt | 237 +++++++++--------- 2 files changed, 137 insertions(+), 128 deletions(-) diff --git a/app/src/main/java/chat/revolt/components/screens/settings/SelfUserOverview.kt b/app/src/main/java/chat/revolt/components/screens/settings/SelfUserOverview.kt index b0ee331c..c4f68e4d 100644 --- a/app/src/main/java/chat/revolt/components/screens/settings/SelfUserOverview.kt +++ b/app/src/main/java/chat/revolt/components/screens/settings/SelfUserOverview.kt @@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width +import androidx.compose.material3.LocalContentColor import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -83,23 +84,26 @@ fun SelfUserOverview() { userId = selfUser.id ?: ULID.makeSpecial(0), avatar = selfUser.avatar, size = 48.dp, - presence = presenceFromStatus(selfUser.status?.presence ?: "offline"), + presence = presenceFromStatus(selfUser.status?.presence ?: "Offline"), ) Spacer(modifier = Modifier.width(12.dp)) - Text(text = AnnotatedString.Builder().apply { - if (selfUser.displayName != null) { - pushStyle(SpanStyle(fontWeight = FontWeight.Bold)) - append(selfUser.displayName) + Text( + text = AnnotatedString.Builder().apply { + if (selfUser.displayName != null) { + pushStyle(SpanStyle(fontWeight = FontWeight.Bold)) + append(selfUser.displayName) + pop() + append("\n") + } + append("${selfUser.username}") + pushStyle(SpanStyle(fontWeight = FontWeight.ExtraLight)) + append("#${selfUser.discriminator}") pop() - append("\n") - } - append("${selfUser.username}") - pushStyle(SpanStyle(fontWeight = FontWeight.ExtraLight)) - append("#${selfUser.discriminator}") - pop() - }.toAnnotatedString()) + }.toAnnotatedString(), + color = if (profile?.background != null) Color.White else LocalContentColor.current, + ) } } } \ No newline at end of file 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 159bf6c9..54a848b1 100644 --- a/app/src/main/java/chat/revolt/screens/settings/SettingsScreen.kt +++ b/app/src/main/java/chat/revolt/screens/settings/SettingsScreen.kt @@ -44,144 +44,149 @@ fun SettingsScreen( navController.popBackStack() }) - SelfUserOverview() - Column( modifier = Modifier .fillMaxSize() - .padding(10.dp) .verticalScroll(rememberScrollState()) ) { - Text( - text = stringResource(id = R.string.settings_category_general), - style = MaterialTheme.typography.bodySmall, - modifier = Modifier.padding(bottom = 10.dp, start = 10.dp) - ) + SelfUserOverview() - 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") + Column( + modifier = Modifier + .fillMaxSize() + .padding(10.dp) ) { - navController.navigate("settings/appearance") - } + Text( + text = stringResource(id = R.string.settings_category_general), + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.padding(bottom = 10.dp, start = 10.dp) + ) - 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", + painter = painterResource(id = R.drawable.ic_palette_24dp), + contentDescription = + stringResource(id = R.string.settings_appearance), modifier = modifier ) }, label = { textStyle -> - Text(text = "Debug", style = textStyle) + Text( + text = stringResource(id = R.string.settings_appearance), + style = textStyle + ) }, - modifier = Modifier.testTag("settings_view_debug") + modifier = Modifier.testTag("settings_view_appearance") ) { - navController.navigate("settings/debug") + navController.navigate("settings/appearance") } - } - SheetClickable( - icon = { modifier -> - Icon( - imageVector = Icons.Default.Settings, - contentDescription = "Closed Beta Updater", - modifier = modifier - ) - }, - label = { textStyle -> - Text(text = "Closed Beta Updater", style = textStyle) - }, - modifier = Modifier.testTag("settings_view_updater") - ) { - navController.navigate("settings/updater") - } + 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) + ) - 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.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") + } - 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") - } + 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") + } + } - 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() + SheetClickable( + icon = { modifier -> + Icon( + imageVector = Icons.Default.Settings, + contentDescription = "Closed Beta Updater", + modifier = modifier + ) + }, + label = { textStyle -> + Text(text = "Closed Beta Updater", style = textStyle) + }, + modifier = Modifier.testTag("settings_view_updater") + ) { + navController.navigate("settings/updater") + } + + 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() + } } } }