From ee30ff28f6f0e0dc68cc5be1c8a7c4732a8ea931 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Sun, 24 Sep 2023 18:36:43 -0400 Subject: [PATCH] UI Improvements for Hidden Words --- .../amethyst/ui/note/NoteCompose.kt | 17 ++++++++++++---- .../ui/screen/loggedIn/HiddenUsersScreen.kt | 20 ++++++++++--------- .../vitorpamplona/amethyst/ui/theme/Shape.kt | 3 +++ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt index ae8e2ae40..d3b1d1e8b 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt @@ -2250,14 +2250,23 @@ fun RemoveButton(onClick: () -> Unit) { } @Composable -fun AddButton(text: Int = R.string.add, onClick: () -> Unit) { +fun AddButton( + text: Int = R.string.add, + isActive: Boolean = true, + modifier: Modifier = Modifier.padding(start = 3.dp), + onClick: () -> Unit +) { Button( - modifier = Modifier.padding(start = 3.dp), - onClick = onClick, + modifier = modifier, + onClick = { + if (isActive) { + onClick() + } + }, shape = ButtonBorder, colors = ButtonDefaults .buttonColors( - backgroundColor = MaterialTheme.colors.primary + backgroundColor = if (isActive) MaterialTheme.colors.primary else Color.Gray ), contentPadding = PaddingValues(vertical = 0.dp, horizontal = 16.dp) ) { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HiddenUsersScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HiddenUsersScreen.kt index 298d345a2..3faa5a440 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HiddenUsersScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/HiddenUsersScreen.kt @@ -50,7 +50,7 @@ import androidx.lifecycle.map import androidx.lifecycle.viewmodel.compose.viewModel import com.vitorpamplona.amethyst.LocalPreferences import com.vitorpamplona.amethyst.R -import com.vitorpamplona.amethyst.ui.navigation.SendButton +import com.vitorpamplona.amethyst.ui.note.AddButton import com.vitorpamplona.amethyst.ui.screen.NostrHiddenAccountsFeedViewModel import com.vitorpamplona.amethyst.ui.screen.NostrHiddenWordsFeedViewModel import com.vitorpamplona.amethyst.ui.screen.NostrSpammerAccountsFeedViewModel @@ -59,6 +59,8 @@ import com.vitorpamplona.amethyst.ui.screen.RefreshingFeedUserFeedView import com.vitorpamplona.amethyst.ui.screen.StringFeedView import com.vitorpamplona.amethyst.ui.screen.UserFeedViewModel import com.vitorpamplona.amethyst.ui.theme.ButtonBorder +import com.vitorpamplona.amethyst.ui.theme.HorzPadding +import com.vitorpamplona.amethyst.ui.theme.Size10dp import com.vitorpamplona.amethyst.ui.theme.StdPadding import com.vitorpamplona.amethyst.ui.theme.TabRowHeight import com.vitorpamplona.amethyst.ui.theme.placeholderText @@ -202,7 +204,7 @@ private fun HiddenWordsFeed( @Composable private fun AddMuteWordTextField(accountViewModel: AccountViewModel) { - Row { + Row(modifier = Modifier.padding(vertical = Size10dp)) { val currentWordToAdd = remember { mutableStateOf("") } @@ -229,17 +231,17 @@ private fun AddMuteWordTextField(accountViewModel: AccountViewModel) { ), keyboardActions = KeyboardActions( onSend = { - accountViewModel.hide(currentWordToAdd.value) - currentWordToAdd.value = "" + if (hasChanged) { + accountViewModel.hide(currentWordToAdd.value) + currentWordToAdd.value = "" + } } ), singleLine = true, trailingIcon = { - if (hasChanged) { - SendButton { - accountViewModel.hide(currentWordToAdd.value) - currentWordToAdd.value = "" - } + AddButton(isActive = hasChanged, modifier = HorzPadding) { + accountViewModel.hide(currentWordToAdd.value) + currentWordToAdd.value = "" } } ) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt index bf7074b88..7eca5b4db 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Shape.kt @@ -76,6 +76,9 @@ val StdPadding = Modifier.padding(10.dp) val HalfHorzPadding = Modifier.padding(horizontal = 5.dp) val HalfVertPadding = Modifier.padding(vertical = 5.dp) +val HorzPadding = Modifier.padding(horizontal = 10.dp) +val VertPadding = Modifier.padding(vertical = 10.dp) + val Size6Modifier = Modifier.size(6.dp) val Size10Modifier = Modifier.size(10.dp) val Size15Modifier = Modifier.size(15.dp)