diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/start/NewConversationHomeFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/start/NewConversationHomeFragment.kt index c0371e2155..a9272b15da 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/start/NewConversationHomeFragment.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/start/NewConversationHomeFragment.kt @@ -6,13 +6,19 @@ import android.view.View import android.view.ViewGroup import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.ui.Modifier +import androidx.compose.ui.input.nestedscroll.nestedScroll +import androidx.compose.ui.platform.rememberNestedScrollInteropConnection import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter @@ -88,30 +94,47 @@ fun NewConversationScreen( ) { Column(modifier = Modifier.background(LocalColors.current.backgroundSecondary)) { AppBar(stringResource(R.string.dialog_new_conversation_title), onClose = delegate::onDialogClosePressed) - ItemButton(textId = R.string.messageNew, icon = R.drawable.ic_message, onClick = delegate::onNewMessageSelected) - Divider(startIndent = LocalDimensions.current.dividerIndent) - ItemButton(textId = R.string.activity_create_group_title, icon = R.drawable.ic_group, onClick = delegate::onCreateGroupSelected) - Divider(startIndent = LocalDimensions.current.dividerIndent) - ItemButton(textId = R.string.dialog_join_community_title, icon = R.drawable.ic_globe, onClick = delegate::onJoinCommunitySelected) - Divider(startIndent = LocalDimensions.current.dividerIndent) - ItemButton(textId = R.string.activity_settings_invite_button_title, icon = R.drawable.ic_invite_friend, contentDescription = R.string.AccessibilityId_invite_friend_button, onClick = delegate::onInviteFriend) - Column( - modifier = Modifier - .padding(horizontal = LocalDimensions.current.marginMedium) - .padding(top = LocalDimensions.current.itemSpacingMedium) + Surface( + modifier = Modifier.nestedScroll(rememberNestedScrollInteropConnection()) ) { - Text( - text = stringResource(R.string.accountIdYours), - style = xl - ) - Spacer(modifier = Modifier.height(LocalDimensions.current.itemSpacingTiny)) - Text( - text = stringResource(R.string.qrYoursDescription), - color = LocalColors.current.textSecondary, - style = small - ) - Spacer(modifier = Modifier.height(LocalDimensions.current.itemSpacingSmall)) - QrImage(string = accountId, Modifier.contentDescription(R.string.AccessibilityId_qr_code)) + Column( + modifier = Modifier.verticalScroll(rememberScrollState()) + ) { + Items(accountId, delegate) + } } } } + +/** + * Items of the NewConversationHome screen. Use in a [Column] + */ +@Suppress("UnusedReceiverParameter") +@Composable +fun ColumnScope.Items( + accountId: String, + delegate: NewConversationDelegate +) { + ItemButton(textId = R.string.messageNew, icon = R.drawable.ic_message, onClick = delegate::onNewMessageSelected) + Divider(startIndent = LocalDimensions.current.dividerIndent) + ItemButton(textId = R.string.activity_create_group_title, icon = R.drawable.ic_group, onClick = delegate::onCreateGroupSelected) + Divider(startIndent = LocalDimensions.current.dividerIndent) + ItemButton(textId = R.string.dialog_join_community_title, icon = R.drawable.ic_globe, onClick = delegate::onJoinCommunitySelected) + Divider(startIndent = LocalDimensions.current.dividerIndent) + ItemButton(textId = R.string.activity_settings_invite_button_title, icon = R.drawable.ic_invite_friend, contentDescription = R.string.AccessibilityId_invite_friend_button, onClick = delegate::onInviteFriend) + Column( + modifier = Modifier + .padding(horizontal = LocalDimensions.current.marginMedium) + .padding(top = LocalDimensions.current.itemSpacingMedium) + ) { + Text(stringResource(R.string.accountIdYours), style = xl) + Spacer(modifier = Modifier.height(LocalDimensions.current.itemSpacingTiny)) + Text( + text = stringResource(R.string.qrYoursDescription), + color = LocalColors.current.textSecondary, + style = small + ) + Spacer(modifier = Modifier.height(LocalDimensions.current.itemSpacingSmall)) + QrImage(string = accountId, Modifier.contentDescription(R.string.AccessibilityId_qr_code)) + } +} \ No newline at end of file