Fix QR offscreen not scrollable w/Thomas' code

This commit is contained in:
Andrew 2024-06-15 14:08:20 +09:30
parent 2f9dbe27c8
commit bd679b0889

View File

@ -6,13 +6,19 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding 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.material.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier 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.res.stringResource
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameter
@ -88,30 +94,47 @@ fun NewConversationScreen(
) { ) {
Column(modifier = Modifier.background(LocalColors.current.backgroundSecondary)) { Column(modifier = Modifier.background(LocalColors.current.backgroundSecondary)) {
AppBar(stringResource(R.string.dialog_new_conversation_title), onClose = delegate::onDialogClosePressed) AppBar(stringResource(R.string.dialog_new_conversation_title), onClose = delegate::onDialogClosePressed)
ItemButton(textId = R.string.messageNew, icon = R.drawable.ic_message, onClick = delegate::onNewMessageSelected) Surface(
Divider(startIndent = LocalDimensions.current.dividerIndent) modifier = Modifier.nestedScroll(rememberNestedScrollInteropConnection())
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( Column(
text = stringResource(R.string.accountIdYours), modifier = Modifier.verticalScroll(rememberScrollState())
style = xl ) {
) Items(accountId, delegate)
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))
} }
} }
} }
/**
* 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))
}
}