-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Knocking : update create room flow #3804
Changes from 1 commit
8c989f7
dc9e883
9e2b01e
f0c1dfa
a4be210
68bdc31
1b1884c
59168e4
9aa08ac
0ebb210
ed1d208
4ff1e79
e777539
6f1de0c
24d4270
2ab6289
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright 2024 New Vector Ltd. | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
* Please see LICENSE in the repository root for full details. | ||
*/ | ||
|
||
package io.element.android.features.createroom.impl.components | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.selection.selectable | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.semantics.Role | ||
import androidx.compose.ui.unit.dp | ||
import io.element.android.compound.theme.ElementTheme | ||
import io.element.android.features.createroom.impl.configureroom.RoomAccessItem | ||
import io.element.android.libraries.designsystem.preview.ElementPreview | ||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight | ||
import io.element.android.libraries.designsystem.theme.components.RadioButton | ||
import io.element.android.libraries.designsystem.theme.components.Text | ||
|
||
@Composable | ||
fun RoomAccessOption( | ||
roomAccessItem: RoomAccessItem, | ||
onOptionClick: (RoomAccessItem) -> Unit, | ||
modifier: Modifier = Modifier, | ||
isSelected: Boolean = false, | ||
) { | ||
Row( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably use a |
||
modifier | ||
.fillMaxWidth() | ||
.selectable( | ||
selected = isSelected, | ||
onClick = { onOptionClick(roomAccessItem) }, | ||
role = Role.RadioButton, | ||
) | ||
) { | ||
Column(Modifier.weight(1f)) { | ||
Text( | ||
text = stringResource(roomAccessItem.title), | ||
style = ElementTheme.typography.fontBodyLgRegular, | ||
color = MaterialTheme.colorScheme.primary, | ||
) | ||
Spacer(Modifier.size(8.dp)) | ||
Text( | ||
text = stringResource(roomAccessItem.description), | ||
style = ElementTheme.typography.fontBodySmRegular, | ||
color = MaterialTheme.colorScheme.tertiary, | ||
) | ||
} | ||
RadioButton( | ||
modifier = Modifier | ||
.align(Alignment.CenterVertically) | ||
.size(48.dp), | ||
selected = isSelected, | ||
// null recommended for accessibility with screenreaders | ||
onClick = null | ||
) | ||
} | ||
} | ||
|
||
@PreviewsDayNight | ||
@Composable | ||
internal fun RoomAccessOptionPreview() = ElementPreview { | ||
val aRoomAccessItem = RoomAccessItem.Anyone | ||
Column { | ||
RoomAccessOption( | ||
roomAccessItem = aRoomAccessItem, | ||
onOptionClick = {}, | ||
isSelected = true, | ||
) | ||
RoomAccessOption( | ||
roomAccessItem = aRoomAccessItem, | ||
onOptionClick = {}, | ||
isSelected = false, | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,32 +7,36 @@ | |
|
||
package io.element.android.features.createroom.impl.components | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.selection.selectable | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.semantics.Role | ||
import androidx.compose.ui.unit.dp | ||
import io.element.android.compound.theme.ElementTheme | ||
import io.element.android.features.createroom.impl.configureroom.RoomPrivacyItem | ||
import io.element.android.features.createroom.impl.configureroom.roomPrivacyItems | ||
import io.element.android.features.createroom.impl.configureroom.RoomVisibilityItem | ||
import io.element.android.libraries.designsystem.preview.ElementPreview | ||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight | ||
import io.element.android.libraries.designsystem.theme.components.Icon | ||
import io.element.android.libraries.designsystem.theme.components.RadioButton | ||
import io.element.android.libraries.designsystem.theme.components.Text | ||
|
||
@Composable | ||
fun RoomPrivacyOption( | ||
roomPrivacyItem: RoomPrivacyItem, | ||
onOptionClick: (RoomPrivacyItem) -> Unit, | ||
fun RoomVisibilityOption( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that I think about it, maybe this should use a |
||
roomPrivacyItem: RoomVisibilityItem, | ||
onOptionClick: (RoomVisibilityItem) -> Unit, | ||
modifier: Modifier = Modifier, | ||
isSelected: Boolean = false, | ||
) { | ||
|
@@ -44,28 +48,31 @@ fun RoomPrivacyOption( | |
onClick = { onOptionClick(roomPrivacyItem) }, | ||
role = Role.RadioButton, | ||
) | ||
.padding(8.dp), | ||
) { | ||
Icon( | ||
modifier = Modifier.padding(horizontal = 8.dp), | ||
resourceId = roomPrivacyItem.icon, | ||
contentDescription = null, | ||
tint = MaterialTheme.colorScheme.secondary, | ||
) | ||
|
||
Column( | ||
Modifier | ||
.weight(1f) | ||
.padding(horizontal = 8.dp) | ||
Box( | ||
modifier = modifier | ||
.size(30.dp) | ||
.clip(RoundedCornerShape(8.dp)) | ||
.background(ElementTheme.colors.bgSubtleSecondary) | ||
.padding(3.dp), | ||
contentAlignment = Alignment.Center, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we have |
||
) { | ||
Icon( | ||
resourceId = roomPrivacyItem.icon, | ||
contentDescription = null, | ||
tint = if(isSelected) ElementTheme.colors.iconPrimary else ElementTheme.colors.iconSecondary, | ||
) | ||
} | ||
Spacer(Modifier.size(16.dp)) | ||
Column(Modifier.weight(1f)) { | ||
Text( | ||
text = roomPrivacyItem.title, | ||
text = stringResource(roomPrivacyItem.title), | ||
style = ElementTheme.typography.fontBodyLgRegular, | ||
color = MaterialTheme.colorScheme.primary, | ||
) | ||
Spacer(Modifier.size(3.dp)) | ||
Text( | ||
text = roomPrivacyItem.description, | ||
text = stringResource(roomPrivacyItem.description), | ||
style = ElementTheme.typography.fontBodySmRegular, | ||
color = MaterialTheme.colorScheme.tertiary, | ||
) | ||
|
@@ -85,14 +92,14 @@ fun RoomPrivacyOption( | |
@PreviewsDayNight | ||
@Composable | ||
internal fun RoomPrivacyOptionPreview() = ElementPreview { | ||
val aRoomPrivacyItem = roomPrivacyItems().first() | ||
val aRoomPrivacyItem = RoomVisibilityItem.Private | ||
Column { | ||
RoomPrivacyOption( | ||
RoomVisibilityOption( | ||
roomPrivacyItem = aRoomPrivacyItem, | ||
onOptionClick = {}, | ||
isSelected = true, | ||
) | ||
RoomPrivacyOption( | ||
RoomVisibilityOption( | ||
roomPrivacyItem = aRoomPrivacyItem, | ||
onOptionClick = {}, | ||
isSelected = false, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename to
createRoomConfigWithInvites
?