feature(space) : iterate on SpaceSettings
This commit is contained in:
parent
5f7fda2402
commit
4c9b6100a7
4 changed files with 54 additions and 42 deletions
|
|
@ -31,7 +31,6 @@ class SpaceSettingsPresenter(
|
||||||
memberCount = roomInfo.activeMembersCount,
|
memberCount = roomInfo.activeMembersCount,
|
||||||
showRolesAndPermissions = isUserAdmin,
|
showRolesAndPermissions = isUserAdmin,
|
||||||
showSecurityAndPrivacy = isUserAdmin,
|
showSecurityAndPrivacy = isUserAdmin,
|
||||||
isTombstoned = roomInfo.successorRoom != null,
|
|
||||||
eventSink = {},
|
eventSink = {},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ data class SpaceSettingsState(
|
||||||
val name: String,
|
val name: String,
|
||||||
val canonicalAlias: RoomAlias?,
|
val canonicalAlias: RoomAlias?,
|
||||||
val avatarUrl: String?,
|
val avatarUrl: String?,
|
||||||
val isTombstoned: Boolean,
|
|
||||||
val memberCount: Long,
|
val memberCount: Long,
|
||||||
val showRolesAndPermissions: Boolean,
|
val showRolesAndPermissions: Boolean,
|
||||||
val showSecurityAndPrivacy: Boolean,
|
val showSecurityAndPrivacy: Boolean,
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ fun aSpaceSettingsState(
|
||||||
alias: RoomAlias? = RoomAlias("#spacename:element.io"),
|
alias: RoomAlias? = RoomAlias("#spacename:element.io"),
|
||||||
avatarUrl: String? = null,
|
avatarUrl: String? = null,
|
||||||
memberCount: Long = 100,
|
memberCount: Long = 100,
|
||||||
isTombstoned: Boolean = false,
|
|
||||||
showRolesAndPermissions: Boolean = false,
|
showRolesAndPermissions: Boolean = false,
|
||||||
showSecurityAndPrivacy: Boolean = false,
|
showSecurityAndPrivacy: Boolean = false,
|
||||||
eventSink: (SpaceSettingsEvents) -> Unit = {},
|
eventSink: (SpaceSettingsEvents) -> Unit = {},
|
||||||
|
|
@ -36,7 +35,6 @@ fun aSpaceSettingsState(
|
||||||
name = name,
|
name = name,
|
||||||
canonicalAlias = alias,
|
canonicalAlias = alias,
|
||||||
avatarUrl = avatarUrl,
|
avatarUrl = avatarUrl,
|
||||||
isTombstoned = isTombstoned,
|
|
||||||
memberCount = memberCount,
|
memberCount = memberCount,
|
||||||
showRolesAndPermissions = showRolesAndPermissions,
|
showRolesAndPermissions = showRolesAndPermissions,
|
||||||
showSecurityAndPrivacy = showSecurityAndPrivacy,
|
showSecurityAndPrivacy = showSecurityAndPrivacy,
|
||||||
|
|
|
||||||
|
|
@ -41,13 +41,14 @@ import io.element.android.libraries.designsystem.theme.components.ListItemStyle
|
||||||
import io.element.android.libraries.designsystem.theme.components.Scaffold
|
import io.element.android.libraries.designsystem.theme.components.Scaffold
|
||||||
import io.element.android.libraries.designsystem.theme.components.Text
|
import io.element.android.libraries.designsystem.theme.components.Text
|
||||||
import io.element.android.libraries.designsystem.theme.components.TopAppBar
|
import io.element.android.libraries.designsystem.theme.components.TopAppBar
|
||||||
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
import io.element.android.libraries.ui.strings.CommonStrings
|
import io.element.android.libraries.ui.strings.CommonStrings
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SpaceSettingsView(
|
fun SpaceSettingsView(
|
||||||
state: SpaceSettingsState,
|
state: SpaceSettingsState,
|
||||||
onBackClick: () -> Unit,
|
onBackClick: () -> Unit,
|
||||||
onSpaceInfoClick: ()->Unit,
|
onSpaceInfoClick: () -> Unit,
|
||||||
onMembersClick: () -> Unit,
|
onMembersClick: () -> Unit,
|
||||||
onRolesAndPermissionsClick: () -> Unit,
|
onRolesAndPermissionsClick: () -> Unit,
|
||||||
onSecurityAndPrivacyClick: () -> Unit,
|
onSecurityAndPrivacyClick: () -> Unit,
|
||||||
|
|
@ -65,59 +66,74 @@ fun SpaceSettingsView(
|
||||||
.padding(padding)
|
.padding(padding)
|
||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
) {
|
) {
|
||||||
Row(
|
SpaceInfoSection(
|
||||||
modifier = Modifier
|
roomId = state.roomId,
|
||||||
.fillMaxWidth()
|
name = state.name,
|
||||||
.clickable(onClick = onSpaceInfoClick)
|
avatarUrl = state.avatarUrl,
|
||||||
.padding(16.dp),
|
canonicalAlias = state.canonicalAlias?.value,
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
onSpaceInfoClick = onSpaceInfoClick,
|
||||||
) {
|
)
|
||||||
Avatar(
|
Section(isVisible = state.showSecurityAndPrivacy, content = {
|
||||||
avatarData = AvatarData(state.roomId.value, state.name, state.avatarUrl, AvatarSize.SpaceListItem),
|
|
||||||
avatarType = AvatarType.Space(
|
|
||||||
isTombstoned = state.isTombstoned,
|
|
||||||
),
|
|
||||||
contentDescription = state.avatarUrl?.let { stringResource(CommonStrings.a11y_room_avatar) },
|
|
||||||
)
|
|
||||||
Spacer(Modifier.width(16.dp))
|
|
||||||
Column {
|
|
||||||
Text(
|
|
||||||
text = state.name,
|
|
||||||
style = ElementTheme.typography.fontHeadingMdRegular,
|
|
||||||
color = ElementTheme.colors.textPrimary,
|
|
||||||
)
|
|
||||||
if (state.canonicalAlias != null) {
|
|
||||||
Text(
|
|
||||||
text = state.canonicalAlias.value,
|
|
||||||
style = ElementTheme.typography.fontBodyMdRegular,
|
|
||||||
color = ElementTheme.colors.textSecondary,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Section(isVisible = state.showSecurityAndPrivacy) {
|
|
||||||
SecurityAndPrivacyItem(
|
SecurityAndPrivacyItem(
|
||||||
onClick = onSecurityAndPrivacyClick
|
onClick = onSecurityAndPrivacyClick
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
Section {
|
Section(content = {
|
||||||
MembersItem(state.memberCount, onClick = onMembersClick)
|
MembersItem(state.memberCount, onClick = onMembersClick)
|
||||||
if (state.showRolesAndPermissions) {
|
if (state.showRolesAndPermissions) {
|
||||||
RolesAndPermissionsItem(onClick = onRolesAndPermissionsClick)
|
RolesAndPermissionsItem(onClick = onRolesAndPermissionsClick)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
Section {
|
Section(content = {
|
||||||
LeaveSpaceItem(
|
LeaveSpaceItem(
|
||||||
onClick = onLeaveSpaceClick
|
onClick = onLeaveSpaceClick
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ColumnScope.Section(
|
private fun SpaceInfoSection(
|
||||||
|
roomId: RoomId,
|
||||||
|
name: String,
|
||||||
|
avatarUrl: String?,
|
||||||
|
canonicalAlias: String?,
|
||||||
|
onSpaceInfoClick: () -> Unit,
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.clickable(onClick = onSpaceInfoClick)
|
||||||
|
.padding(16.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Avatar(
|
||||||
|
avatarData = AvatarData(roomId.value, name, avatarUrl, AvatarSize.SpaceListItem),
|
||||||
|
avatarType = AvatarType.Space(),
|
||||||
|
contentDescription = avatarUrl?.let { stringResource(CommonStrings.a11y_avatar) },
|
||||||
|
)
|
||||||
|
Spacer(Modifier.width(16.dp))
|
||||||
|
Column {
|
||||||
|
Text(
|
||||||
|
text = name,
|
||||||
|
style = ElementTheme.typography.fontHeadingMdRegular,
|
||||||
|
color = ElementTheme.colors.textPrimary,
|
||||||
|
)
|
||||||
|
if (canonicalAlias != null) {
|
||||||
|
Text(
|
||||||
|
text = canonicalAlias,
|
||||||
|
style = ElementTheme.typography.fontBodyMdRegular,
|
||||||
|
color = ElementTheme.colors.textSecondary,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun Section(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
isVisible: Boolean = true,
|
isVisible: Boolean = true,
|
||||||
content: @Composable ColumnScope.() -> Unit,
|
content: @Composable ColumnScope.() -> Unit,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue