Skip to content

Commit

Permalink
UI Improvements for Hidden Words
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorpamplona committed Sep 24, 2023
1 parent 03654b5 commit ee30ff2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -202,7 +204,7 @@ private fun HiddenWordsFeed(

@Composable
private fun AddMuteWordTextField(accountViewModel: AccountViewModel) {
Row {
Row(modifier = Modifier.padding(vertical = Size10dp)) {
val currentWordToAdd = remember {
mutableStateOf("")
}
Expand All @@ -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 = ""
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ee30ff2

Please sign in to comment.