From f67ff43eb36fe1fdda2afee70c581fb65d04bb42 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 4 Oct 2023 09:20:46 -0400 Subject: [PATCH] Moves the Post button on chat screens to a > Button --- .../amethyst/ui/navigation/DrawerContent.kt | 1 - .../ui/screen/loggedIn/ChannelScreen.kt | 10 +++---- .../ui/screen/loggedIn/ChatroomScreen.kt | 28 ++++++++++++++----- .../vitorpamplona/amethyst/ui/theme/Shape.kt | 4 +-- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt index f6be5f8ab..db6956c9d 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt @@ -253,7 +253,6 @@ fun ProfileContent( @Composable private fun EditStatusBox(baseAccountUser: User, accountViewModel: AccountViewModel) { - val scope = rememberCoroutineScope() val focusManager = LocalFocusManager.current LoadStatuses(user = baseAccountUser, accountViewModel) { statuses -> diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt index 83aeaf9f0..e169e1e39 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChannelScreen.kt @@ -94,7 +94,6 @@ import com.vitorpamplona.amethyst.service.connectivitystatus.ConnectivityStatus import com.vitorpamplona.amethyst.ui.actions.NewChannelView import com.vitorpamplona.amethyst.ui.actions.NewMessageTagger import com.vitorpamplona.amethyst.ui.actions.NewPostViewModel -import com.vitorpamplona.amethyst.ui.actions.PostButton import com.vitorpamplona.amethyst.ui.actions.UploadFromGallery import com.vitorpamplona.amethyst.ui.components.LoadNote import com.vitorpamplona.amethyst.ui.components.RobohashAsyncImageProxy @@ -389,13 +388,12 @@ fun EditFieldRow( }, textStyle = LocalTextStyle.current.copy(textDirection = TextDirection.Content), trailingIcon = { - PostButton( - onPost = { - onSendNewMessage() - }, + ThinSendButton( isActive = channelScreenModel.message.text.isNotBlank() && !channelScreenModel.isUploadingImage, modifier = EditFieldTrailingIconModifier - ) + ) { + onSendNewMessage() + } }, leadingIcon = { UploadFromGallery( diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomScreen.kt index 7264426ac..bae8e2b2e 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ChatroomScreen.kt @@ -21,10 +21,10 @@ import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.EditNote +import androidx.compose.material.icons.filled.Send import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Divider -import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.LocalTextStyle @@ -87,6 +87,7 @@ import com.vitorpamplona.amethyst.ui.theme.ButtonBorder import com.vitorpamplona.amethyst.ui.theme.EditFieldBorder import com.vitorpamplona.amethyst.ui.theme.EditFieldModifier import com.vitorpamplona.amethyst.ui.theme.EditFieldTrailingIconModifier +import com.vitorpamplona.amethyst.ui.theme.Size20Modifier import com.vitorpamplona.amethyst.ui.theme.Size30Modifier import com.vitorpamplona.amethyst.ui.theme.Size34dp import com.vitorpamplona.amethyst.ui.theme.StdPadding @@ -330,7 +331,6 @@ fun ChatroomScreen( } } -@OptIn(ExperimentalMaterial3Api::class) @Composable fun PrivateMessageEditFieldRow( channelScreenModel: NewPostViewModel, @@ -362,13 +362,12 @@ fun PrivateMessageEditFieldRow( ) }, trailingIcon = { - PostButton( - onPost = { - onSendNewMessage() - }, + ThinSendButton( isActive = channelScreenModel.message.text.isNotBlank() && !channelScreenModel.isUploadingImage, modifier = EditFieldTrailingIconModifier - ) + ) { + onSendNewMessage() + } }, leadingIcon = { Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(horizontal = 6.dp)) { @@ -483,6 +482,21 @@ fun NewFeatureNIP24AlertDialog(accountViewModel: AccountViewModel, onConfirm: () ) } +@Composable +fun ThinSendButton(isActive: Boolean, modifier: Modifier, onClick: () -> Unit) { + IconButton( + enabled = isActive, + modifier = modifier, + onClick = onClick + ) { + Icon( + imageVector = Icons.Default.Send, + null, + modifier = Size20Modifier + ) + } +} + @Composable fun ChatroomHeader( room: ChatroomKey, 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 ac5f5feba..61b123926 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 @@ -137,8 +137,8 @@ val EditFieldModifier = Modifier .padding(start = 10.dp, end = 10.dp, bottom = 10.dp, top = 5.dp) .fillMaxWidth() val EditFieldTrailingIconModifier = Modifier - .height(32.dp) - .padding(start = 5.dp, end = 10.dp) + .height(26.dp) + .padding(start = 5.dp, end = 0.dp) val EditFieldLeadingIconModifier = Modifier .height(32.dp) .padding(start = 2.dp)