Skip to content
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

Make the whole items in advanced settings screen clickable, standarize paddings #2314

Merged
merged 12 commits into from
Jan 30, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import androidx.compose.ui.tooling.preview.Preview
import io.element.android.libraries.designsystem.components.avatar.AvatarSize
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
import io.element.android.libraries.designsystem.theme.components.HorizontalDivider
import io.element.android.libraries.matrix.ui.components.CheckableMatrixUserRow
import io.element.android.libraries.matrix.ui.components.CheckableUnresolvedUserRow
import io.element.android.libraries.matrix.ui.components.CheckableUserRow
import io.element.android.libraries.matrix.ui.components.CheckableUserRowData
import io.element.android.libraries.matrix.ui.components.aMatrixUser
import io.element.android.libraries.matrix.ui.model.getAvatarData
import io.element.android.libraries.matrix.ui.model.getBestName
import io.element.android.libraries.usersearch.api.UserSearchResult

@Composable
Expand All @@ -36,23 +37,24 @@ fun SearchMultipleUsersResultItem(
onCheckedChange: (Boolean) -> Unit,
modifier: Modifier = Modifier,
) {
if (searchResult.isUnresolved) {
CheckableUnresolvedUserRow(
checked = isUserSelected,
modifier = modifier,
val data = if (searchResult.isUnresolved) {
CheckableUserRowData.Unresolved(
avatarData = searchResult.matrixUser.getAvatarData(AvatarSize.UserListItem),
id = searchResult.matrixUser.userId.value,
onCheckedChange = onCheckedChange,
)
} else {
CheckableMatrixUserRow(
checked = isUserSelected,
modifier = modifier,
matrixUser = searchResult.matrixUser,
avatarSize = AvatarSize.UserListItem,
onCheckedChange = onCheckedChange,
CheckableUserRowData.Resolved(
name = searchResult.matrixUser.getBestName(),
subtext = if (searchResult.matrixUser.displayName.isNullOrEmpty()) null else searchResult.matrixUser.userId.value,
avatarData = searchResult.matrixUser.getAvatarData(AvatarSize.UserListItem),
)
}
CheckableUserRow(
checked = isUserSelected,
modifier = modifier,
data = data,
onCheckedChange = onCheckedChange,
)
}

@Preview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ fun AdvancedSettingsView(
},
trailingContent = ListItemContent.Switch(
checked = state.isRichTextEditorEnabled,
onChange = { state.eventSink(AdvancedSettingsEvents.SetRichTextEditorEnabled(it)) },
),
onClick = { state.eventSink(AdvancedSettingsEvents.SetRichTextEditorEnabled(!state.isRichTextEditorEnabled)) }
)
ListItem(
headlineContent = {
Expand All @@ -78,8 +78,8 @@ fun AdvancedSettingsView(
},
trailingContent = ListItemContent.Switch(
checked = state.isDeveloperModeEnabled,
onChange = { state.eventSink(AdvancedSettingsEvents.SetDeveloperModeEnabled(it)) },
),
onClick = { state.eventSink(AdvancedSettingsEvents.SetDeveloperModeEnabled(!state.isDeveloperModeEnabled)) }
)
ListItem(
headlineContent = {
Expand All @@ -90,8 +90,8 @@ fun AdvancedSettingsView(
},
trailingContent = ListItemContent.Switch(
checked = state.isSendPublicReadReceiptsEnabled,
onChange = { state.eventSink(AdvancedSettingsEvents.SetSendPublicReadReceiptsEnabled(it)) },
),
onClick = { state.eventSink(AdvancedSettingsEvents.SetSendPublicReadReceiptsEnabled(!state.isSendPublicReadReceiptsEnabled)) }
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
import io.element.android.libraries.designsystem.theme.components.TextButton
import io.element.android.libraries.designsystem.theme.components.TopAppBar
import io.element.android.libraries.matrix.api.user.MatrixUser
import io.element.android.libraries.matrix.ui.components.CheckableUnresolvedUserRow
import io.element.android.libraries.matrix.ui.components.CheckableUserRow
import io.element.android.libraries.matrix.ui.components.CheckableUserRowData
import io.element.android.libraries.matrix.ui.components.SelectedUsersList
import io.element.android.libraries.matrix.ui.model.getAvatarData
import io.element.android.libraries.matrix.ui.model.getBestName
Expand Down Expand Up @@ -186,18 +186,16 @@

LazyColumn {
itemsIndexed(results) { index, invitableUser ->
if (invitableUser.isUnresolved && !invitableUser.isAlreadyInvited && !invitableUser.isAlreadyJoined) {
CheckableUnresolvedUserRow(
checked = invitableUser.isSelected,
val notInvitedOrJoined = !(invitableUser.isAlreadyInvited || invitableUser.isAlreadyJoined)
val isUnresolved = invitableUser.isUnresolved && notInvitedOrJoined
val enabled = isUnresolved || notInvitedOrJoined
val data = if (isUnresolved) {
CheckableUserRowData.Unresolved(
avatarData = invitableUser.matrixUser.getAvatarData(AvatarSize.UserListItem),
id = invitableUser.matrixUser.userId.value,
onCheckedChange = { onUserToggled(invitableUser.matrixUser) },
modifier = Modifier.fillMaxWidth()
)
} else {
CheckableUserRow(
checked = invitableUser.isSelected,
enabled = !invitableUser.isAlreadyInvited && !invitableUser.isAlreadyJoined,
CheckableUserRowData.Resolved(
avatarData = invitableUser.matrixUser.getAvatarData(AvatarSize.UserListItem),
name = invitableUser.matrixUser.getBestName(),
subtext = when {
Expand All @@ -207,11 +205,16 @@
// Otherwise show the ID, unless that's already used for their name
invitableUser.matrixUser.displayName.isNullOrEmpty().not() -> invitableUser.matrixUser.userId.value
else -> null
},
onCheckedChange = { onUserToggled(invitableUser.matrixUser) },
modifier = Modifier.fillMaxWidth()
}
)
}
CheckableUserRow(
checked = invitableUser.isSelected,
enabled = enabled,
data = data,
onCheckedChange = { onUserToggled(invitableUser.matrixUser) },

Check warning on line 215 in features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/invite/RoomInviteMembersView.kt

View check run for this annotation

Codecov / codecov/patch

features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/invite/RoomInviteMembersView.kt#L215

Added line #L215 was not covered by tests
modifier = Modifier.fillMaxWidth()
)

if (index < results.lastIndex) {
HorizontalDivider()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.material3.CheckboxColors
import androidx.compose.material3.CheckboxDefaults
import androidx.compose.material3.minimumInteractiveComponentSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -57,7 +58,7 @@ fun Checkbox(
onCheckedChange(!checked)
}
},
modifier = modifier,
modifier = modifier.minimumInteractiveComponentSize(),
enabled = enabled,
colors = colors,
interactionSource = interactionSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.material3.RadioButtonColors
import androidx.compose.material3.RadioButtonDefaults
import androidx.compose.material3.minimumInteractiveComponentSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -48,7 +49,7 @@ fun RadioButton(
androidx.compose.material3.RadioButton(
selected = selected,
onClick = onClick,
modifier = modifier,
modifier = modifier.minimumInteractiveComponentSize(),
enabled = enabled,
colors = colors,
interactionSource = interactionSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.SwitchColors
import androidx.compose.material3.SwitchDefaults
import androidx.compose.material3.minimumInteractiveComponentSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -52,7 +53,7 @@ fun Switch(
Material3Switch(
checked = checked,
onCheckedChange = onCheckedChange,
modifier = modifier,
modifier = modifier.minimumInteractiveComponentSize(),
enabled = enabled,
colors = colors,
interactionSource = interactionSource,
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading