mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Limit usage of nullable callback.
This commit is contained in:
+2
-2
@@ -21,14 +21,14 @@ interface RoomMemberModerationRenderer {
|
|||||||
*
|
*
|
||||||
* @param state the state produced by the moderation presenter.
|
* @param state the state produced by the moderation presenter.
|
||||||
* @param onSelectAction called when the user picks an action, so the host screen can navigate if that action needs its own screen.
|
* @param onSelectAction called when the user picks an action, so the host screen can navigate if that action needs its own screen.
|
||||||
* @param onAvatarClick called when the user taps the member's avatar, or `null` to make it non-interactive.
|
* @param onAvatarClick called when the user taps the member's avatar, only if the user has an avatar.
|
||||||
* @param modifier layout modifier for the container.
|
* @param modifier layout modifier for the container.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun Render(
|
fun Render(
|
||||||
state: RoomMemberModerationState,
|
state: RoomMemberModerationState,
|
||||||
onSelectAction: (ModerationAction, MatrixUser) -> Unit,
|
onSelectAction: (ModerationAction, MatrixUser) -> Unit,
|
||||||
onAvatarClick: ((MatrixUser) -> Unit)?,
|
onAvatarClick: (MatrixUser) -> Unit,
|
||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-2
@@ -25,11 +25,16 @@ class DefaultRoomMemberModerationRenderer : RoomMemberModerationRenderer {
|
|||||||
override fun Render(
|
override fun Render(
|
||||||
state: RoomMemberModerationState,
|
state: RoomMemberModerationState,
|
||||||
onSelectAction: (ModerationAction, MatrixUser) -> Unit,
|
onSelectAction: (ModerationAction, MatrixUser) -> Unit,
|
||||||
onAvatarClick: ((MatrixUser) -> Unit)?,
|
onAvatarClick: (MatrixUser) -> Unit,
|
||||||
modifier: Modifier
|
modifier: Modifier
|
||||||
) {
|
) {
|
||||||
if (state is InternalRoomMemberModerationState) {
|
if (state is InternalRoomMemberModerationState) {
|
||||||
RoomMemberModerationView(modifier = modifier, state = state, onSelectAction = onSelectAction, onAvatarClick = onAvatarClick)
|
RoomMemberModerationView(
|
||||||
|
modifier = modifier,
|
||||||
|
state = state,
|
||||||
|
onSelectAction = onSelectAction,
|
||||||
|
onAvatarClick = onAvatarClick,
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
SideEffect {
|
SideEffect {
|
||||||
Timber.d("RoomMemberModerationRenderer: Render called with unsupported state: $state")
|
Timber.d("RoomMemberModerationRenderer: Render called with unsupported state: $state")
|
||||||
|
|||||||
+4
-4
@@ -66,7 +66,7 @@ import timber.log.Timber
|
|||||||
fun RoomMemberModerationView(
|
fun RoomMemberModerationView(
|
||||||
state: InternalRoomMemberModerationState,
|
state: InternalRoomMemberModerationState,
|
||||||
onSelectAction: (ModerationAction, MatrixUser) -> Unit,
|
onSelectAction: (ModerationAction, MatrixUser) -> Unit,
|
||||||
onAvatarClick: ((MatrixUser) -> Unit)?,
|
onAvatarClick: (MatrixUser) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
Box(modifier = modifier) {
|
Box(modifier = modifier) {
|
||||||
@@ -218,7 +218,7 @@ private fun RoomMemberActionsBottomSheet(
|
|||||||
user: MatrixUser,
|
user: MatrixUser,
|
||||||
actions: ImmutableList<ModerationActionState>,
|
actions: ImmutableList<ModerationActionState>,
|
||||||
onSelectAction: (ModerationAction, MatrixUser) -> Unit,
|
onSelectAction: (ModerationAction, MatrixUser) -> Unit,
|
||||||
onAvatarClick: ((MatrixUser) -> Unit)? = null,
|
onAvatarClick: (MatrixUser) -> Unit,
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
) {
|
) {
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
@@ -248,10 +248,10 @@ private fun RoomMemberActionsBottomSheet(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(bottom = 24.dp)
|
.padding(bottom = 24.dp)
|
||||||
.align(Alignment.CenterHorizontally)
|
.align(Alignment.CenterHorizontally)
|
||||||
.clickable(enabled = user.avatarUrl != null && onAvatarClick != null) {
|
.clickable(enabled = user.avatarUrl != null) {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
bottomSheetState.hide()
|
bottomSheetState.hide()
|
||||||
onAvatarClick?.invoke(user)
|
onAvatarClick(user)
|
||||||
onDismiss()
|
onDismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user