EditUserProfileState.userId cannot be null.
It simplifies a bit the codebase.
This commit is contained in:
parent
49f74bf09a
commit
9e519def63
3 changed files with 13 additions and 17 deletions
|
|
@ -24,7 +24,7 @@ import io.element.android.libraries.permissions.api.PermissionsState
|
||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
|
|
||||||
data class EditUserProfileState(
|
data class EditUserProfileState(
|
||||||
val userId: UserId?,
|
val userId: UserId,
|
||||||
val displayName: String,
|
val displayName: String,
|
||||||
val userAvatarUrl: Uri?,
|
val userAvatarUrl: Uri?,
|
||||||
val avatarActions: ImmutableList<AvatarAction>,
|
val avatarActions: ImmutableList<AvatarAction>,
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ fun EditUserProfileView(
|
||||||
) {
|
) {
|
||||||
Spacer(modifier = Modifier.height(24.dp))
|
Spacer(modifier = Modifier.height(24.dp))
|
||||||
EditableAvatarView(
|
EditableAvatarView(
|
||||||
matrixId = state.userId?.value,
|
matrixId = state.userId.value,
|
||||||
displayName = state.displayName,
|
displayName = state.displayName,
|
||||||
avatarUrl = state.userAvatarUrl,
|
avatarUrl = state.userAvatarUrl,
|
||||||
avatarSize = AvatarSize.RoomHeader,
|
avatarSize = AvatarSize.RoomHeader,
|
||||||
|
|
@ -122,14 +122,12 @@ fun EditUserProfileView(
|
||||||
modifier = Modifier.align(Alignment.CenterHorizontally),
|
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
state.userId?.let {
|
Text(
|
||||||
Text(
|
modifier = Modifier.fillMaxWidth(),
|
||||||
modifier = Modifier.fillMaxWidth(),
|
text = state.userId.value,
|
||||||
text = it.value,
|
style = ElementTheme.typography.fontBodyLgRegular,
|
||||||
style = ElementTheme.typography.fontBodyLgRegular,
|
textAlign = TextAlign.Center,
|
||||||
textAlign = TextAlign.Center,
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
Spacer(modifier = Modifier.height(40.dp))
|
Spacer(modifier = Modifier.height(40.dp))
|
||||||
LabelledOutlinedTextField(
|
LabelledOutlinedTextField(
|
||||||
label = stringResource(R.string.screen_edit_profile_display_name),
|
label = stringResource(R.string.screen_edit_profile_display_name),
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ import io.element.android.libraries.designsystem.theme.components.Icon
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun EditableAvatarView(
|
fun EditableAvatarView(
|
||||||
matrixId: String?,
|
matrixId: String,
|
||||||
displayName: String?,
|
displayName: String?,
|
||||||
avatarUrl: Uri?,
|
avatarUrl: Uri?,
|
||||||
avatarSize: AvatarSize,
|
avatarSize: AvatarSize,
|
||||||
|
|
@ -65,12 +65,10 @@ fun EditableAvatarView(
|
||||||
) {
|
) {
|
||||||
when (avatarUrl?.scheme) {
|
when (avatarUrl?.scheme) {
|
||||||
null, "mxc" -> {
|
null, "mxc" -> {
|
||||||
matrixId?.let {
|
Avatar(
|
||||||
Avatar(
|
avatarData = AvatarData(matrixId, displayName, avatarUrl?.toString(), size = avatarSize),
|
||||||
avatarData = AvatarData(it, displayName, avatarUrl?.toString(), size = avatarSize),
|
modifier = Modifier.fillMaxSize(),
|
||||||
modifier = Modifier.fillMaxSize(),
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
UnsavedAvatar(
|
UnsavedAvatar(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue