Update ConfigureRoomView space selection
This commit is contained in:
parent
fd34bb0bb4
commit
7b3ceeb19b
2 changed files with 42 additions and 47 deletions
|
|
@ -14,7 +14,9 @@ import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.ColumnScope
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.consumeWindowInsets
|
import androidx.compose.foundation.layout.consumeWindowInsets
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.imePadding
|
import androidx.compose.foundation.layout.imePadding
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
|
|
@ -105,7 +107,6 @@ fun ConfigureRoomView(
|
||||||
.imePadding()
|
.imePadding()
|
||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
.consumeWindowInsets(padding),
|
.consumeWindowInsets(padding),
|
||||||
verticalArrangement = Arrangement.spacedBy(16.dp),
|
|
||||||
) {
|
) {
|
||||||
RoomNameWithAvatar(
|
RoomNameWithAvatar(
|
||||||
isSpace = isSpace,
|
isSpace = isSpace,
|
||||||
|
|
@ -115,6 +116,7 @@ fun ConfigureRoomView(
|
||||||
onAvatarClick = ::onAvatarClick,
|
onAvatarClick = ::onAvatarClick,
|
||||||
onChangeRoomName = { state.eventSink(ConfigureRoomEvents.RoomNameChanged(it)) },
|
onChangeRoomName = { state.eventSink(ConfigureRoomEvents.RoomNameChanged(it)) },
|
||||||
)
|
)
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
RoomTopic(
|
RoomTopic(
|
||||||
modifier = Modifier.padding(horizontal = 16.dp),
|
modifier = Modifier.padding(horizontal = 16.dp),
|
||||||
topic = state.config.topic.orEmpty(),
|
topic = state.config.topic.orEmpty(),
|
||||||
|
|
@ -122,6 +124,7 @@ fun ConfigureRoomView(
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!state.config.isSpace && state.spaces.isNotEmpty()) {
|
if (!state.config.isSpace && state.spaces.isNotEmpty()) {
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
SelectParentSpaceOptions(
|
SelectParentSpaceOptions(
|
||||||
spaces = state.spaces,
|
spaces = state.spaces,
|
||||||
selectedSpace = state.config.parentSpace,
|
selectedSpace = state.config.parentSpace,
|
||||||
|
|
@ -272,12 +275,13 @@ private fun RoomTopic(
|
||||||
internal fun ConfigureRoomOptions(
|
internal fun ConfigureRoomOptions(
|
||||||
title: String,
|
title: String,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
hasDivider: Boolean = true,
|
||||||
content: @Composable ColumnScope.() -> Unit,
|
content: @Composable ColumnScope.() -> Unit,
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = modifier.selectableGroup()
|
modifier = modifier.selectableGroup()
|
||||||
) {
|
) {
|
||||||
ListSectionHeader(title = title)
|
ListSectionHeader(title = title, hasDivider = hasDivider)
|
||||||
content()
|
content()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
package io.element.android.features.createroom.impl.configureroom
|
package io.element.android.features.createroom.impl.configureroom
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.ColumnScope
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
|
@ -21,7 +20,7 @@ import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import io.element.android.compound.tokens.generated.CompoundIcons
|
import io.element.android.compound.theme.ElementTheme
|
||||||
import io.element.android.features.createroom.impl.R
|
import io.element.android.features.createroom.impl.R
|
||||||
import io.element.android.libraries.designsystem.components.avatar.Avatar
|
import io.element.android.libraries.designsystem.components.avatar.Avatar
|
||||||
import io.element.android.libraries.designsystem.components.avatar.AvatarData
|
import io.element.android.libraries.designsystem.components.avatar.AvatarData
|
||||||
|
|
@ -30,7 +29,6 @@ import io.element.android.libraries.designsystem.components.avatar.AvatarType
|
||||||
import io.element.android.libraries.designsystem.components.list.ListItemContent
|
import io.element.android.libraries.designsystem.components.list.ListItemContent
|
||||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||||
import io.element.android.libraries.designsystem.theme.components.IconSource
|
|
||||||
import io.element.android.libraries.designsystem.theme.components.ListItem
|
import io.element.android.libraries.designsystem.theme.components.ListItem
|
||||||
import io.element.android.libraries.designsystem.theme.components.ListSectionHeader
|
import io.element.android.libraries.designsystem.theme.components.ListSectionHeader
|
||||||
import io.element.android.libraries.designsystem.theme.components.ModalBottomSheet
|
import io.element.android.libraries.designsystem.theme.components.ModalBottomSheet
|
||||||
|
|
@ -55,6 +53,7 @@ internal fun SelectParentSpaceOptions(
|
||||||
var displaySelectSpaceBottomSheet by remember { mutableStateOf(false) }
|
var displaySelectSpaceBottomSheet by remember { mutableStateOf(false) }
|
||||||
ConfigureRoomOptions(
|
ConfigureRoomOptions(
|
||||||
title = stringResource(CommonStrings.common_space),
|
title = stringResource(CommonStrings.common_space),
|
||||||
|
hasDivider = false,
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
) {
|
) {
|
||||||
ListItem(
|
ListItem(
|
||||||
|
|
@ -62,22 +61,20 @@ internal fun SelectParentSpaceOptions(
|
||||||
Text(
|
Text(
|
||||||
text = selectedSpace?.displayName
|
text = selectedSpace?.displayName
|
||||||
?: stringResource(R.string.screen_create_room_space_selection_no_space_title),
|
?: stringResource(R.string.screen_create_room_space_selection_no_space_title),
|
||||||
maxLines = 1
|
maxLines = 1,
|
||||||
)
|
color = if (selectedSpace != null) {
|
||||||
},
|
ElementTheme.colors.textPrimary
|
||||||
supportingContent = {
|
|
||||||
Text(
|
|
||||||
text = if (selectedSpace != null) {
|
|
||||||
selectedSpace.canonicalAlias?.value.orEmpty()
|
|
||||||
} else {
|
} else {
|
||||||
stringResource(R.string.screen_create_room_space_selection_no_space_description)
|
ElementTheme.colors.textSecondary
|
||||||
},
|
}
|
||||||
maxLines = 1
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
leadingContent = if (selectedSpace == null) {
|
supportingContent = selectedSpace?.canonicalAlias?.let { alias ->
|
||||||
ListItemContent.Icon(IconSource.Vector(CompoundIcons.Home()))
|
{
|
||||||
} else {
|
Text(text = alias.value, maxLines = 1)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
leadingContent = selectedSpace?.let {
|
||||||
ListItemContent.Custom({
|
ListItemContent.Custom({
|
||||||
val avatarData = AvatarData(
|
val avatarData = AvatarData(
|
||||||
id = selectedSpace.roomId.value,
|
id = selectedSpace.roomId.value,
|
||||||
|
|
@ -119,7 +116,7 @@ internal fun SelectParentSpaceOptions(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ColumnScope.SelectParentSpaceBottomSheet(
|
private fun SelectParentSpaceBottomSheet(
|
||||||
spaces: ImmutableList<SpaceRoom>,
|
spaces: ImmutableList<SpaceRoom>,
|
||||||
selectedSpace: SpaceRoom?,
|
selectedSpace: SpaceRoom?,
|
||||||
onSelectSpace: (SpaceRoom?) -> Unit,
|
onSelectSpace: (SpaceRoom?) -> Unit,
|
||||||
|
|
@ -133,19 +130,10 @@ private fun ColumnScope.SelectParentSpaceBottomSheet(
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = {
|
headlineContent = {
|
||||||
Text(
|
Text(
|
||||||
stringResource(R.string.screen_create_room_space_selection_no_space_title),
|
text = stringResource(R.string.screen_create_room_space_selection_no_space_option),
|
||||||
maxLines = 1
|
maxLines = 1
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
supportingContent = {
|
|
||||||
Text(
|
|
||||||
stringResource(R.string.screen_create_room_space_selection_no_space_description),
|
|
||||||
maxLines = 1
|
|
||||||
)
|
|
||||||
},
|
|
||||||
leadingContent = ListItemContent.Icon(
|
|
||||||
IconSource.Vector(CompoundIcons.Home())
|
|
||||||
),
|
|
||||||
trailingContent = ListItemContent.RadioButton(
|
trailingContent = ListItemContent.RadioButton(
|
||||||
selected = selectedSpace == null
|
selected = selectedSpace == null
|
||||||
),
|
),
|
||||||
|
|
@ -157,29 +145,31 @@ private fun ColumnScope.SelectParentSpaceBottomSheet(
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = {
|
headlineContent = {
|
||||||
Text(
|
Text(
|
||||||
space.displayName,
|
text = space.displayName,
|
||||||
maxLines = 1
|
maxLines = 1
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
supportingContent = {
|
supportingContent = space.canonicalAlias?.let { alias ->
|
||||||
Text(
|
{
|
||||||
space.canonicalAlias?.value.orEmpty(),
|
Text(
|
||||||
maxLines = 1
|
text = alias.value,
|
||||||
)
|
maxLines = 1
|
||||||
|
)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
leadingContent = ListItemContent.Custom({
|
leadingContent = ListItemContent.Custom({
|
||||||
val avatarData =
|
val avatarData =
|
||||||
AvatarData(
|
AvatarData(
|
||||||
id = space.roomId.value,
|
id = space.roomId.value,
|
||||||
name = space.displayName,
|
name = space.displayName,
|
||||||
url = space.avatarUrl,
|
url = space.avatarUrl,
|
||||||
size = AvatarSize.SelectParentSpace,
|
size = AvatarSize.SelectParentSpace,
|
||||||
)
|
|
||||||
Avatar(
|
|
||||||
avatarData = avatarData,
|
|
||||||
avatarType = AvatarType.Space()
|
|
||||||
)
|
)
|
||||||
}),
|
Avatar(
|
||||||
|
avatarData = avatarData,
|
||||||
|
avatarType = AvatarType.Space()
|
||||||
|
)
|
||||||
|
}),
|
||||||
trailingContent = ListItemContent.RadioButton(
|
trailingContent = ListItemContent.RadioButton(
|
||||||
selected = selectedSpace == space
|
selected = selectedSpace == space
|
||||||
),
|
),
|
||||||
|
|
@ -201,7 +191,8 @@ internal fun SelectParentSpaceBottomSheetPreview() =
|
||||||
canonicalAlias = RoomAlias(
|
canonicalAlias = RoomAlias(
|
||||||
"#a-room-alias:example.org"
|
"#a-room-alias:example.org"
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
|
aSpaceRoom()
|
||||||
),
|
),
|
||||||
selectedSpace = null,
|
selectedSpace = null,
|
||||||
) {}
|
) {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue