Lambda parameters in a composable function should be in present tense, not past tense.

https://mrmans0n.github.io/compose-rules/rules/#naming-parameters-properly
This commit is contained in:
Benoit Marty 2024-05-29 10:48:29 +02:00
parent 0ba5537082
commit 37d9a9f5a9
250 changed files with 1698 additions and 1698 deletions

View file

@ -115,8 +115,8 @@ class PreferencesFlowNode @AssistedInject constructor(
plugins<PreferencesEntryPoint.Callback>().forEach { it.onOpenBugReport() }
}
override fun onSecureBackupClicked() {
plugins<PreferencesEntryPoint.Callback>().forEach { it.onSecureBackupClicked() }
override fun onSecureBackupClick() {
plugins<PreferencesEntryPoint.Callback>().forEach { it.onSecureBackupClick() }
}
override fun onOpenAnalytics() {
@ -151,7 +151,7 @@ class PreferencesFlowNode @AssistedInject constructor(
backstack.push(NavTarget.BlockedUsers)
}
override fun onSignOutClicked() {
override fun onSignOutClick() {
backstack.push(NavTarget.SignOut)
}
}
@ -180,7 +180,7 @@ class PreferencesFlowNode @AssistedInject constructor(
backstack.push(NavTarget.EditDefaultNotificationSetting(isOneToOne))
}
override fun onTroubleshootNotificationsClicked() {
override fun onTroubleshootNotificationsClick() {
backstack.push(NavTarget.TroubleshootNotifications)
}
}
@ -219,8 +219,8 @@ class PreferencesFlowNode @AssistedInject constructor(
}
NavTarget.SignOut -> {
val callBack: LogoutEntryPoint.Callback = object : LogoutEntryPoint.Callback {
override fun onChangeRecoveryKeyClicked() {
plugins<PreferencesEntryPoint.Callback>().forEach { it.onSecureBackupClicked() }
override fun onChangeRecoveryKeyClick() {
plugins<PreferencesEntryPoint.Callback>().forEach { it.onSecureBackupClick() }
}
}
logoutEntryPoint.nodeBuilder(this, buildContext)

View file

@ -36,7 +36,7 @@ class AboutNode @AssistedInject constructor(
@Assisted plugins: List<Plugin>,
private val presenter: AboutPresenter,
) : Node(buildContext, plugins = plugins) {
private fun onElementLegalClicked(
private fun onElementLegalClick(
activity: Activity,
darkTheme: Boolean,
elementLegal: ElementLegal,
@ -51,9 +51,9 @@ class AboutNode @AssistedInject constructor(
val state = presenter.present()
AboutView(
state = state,
onBackPressed = ::navigateUp,
onElementLegalClicked = { elementLegal ->
onElementLegalClicked(activity, isDark, elementLegal)
onBackClick = ::navigateUp,
onElementLegalClick = { elementLegal ->
onElementLegalClick(activity, isDark, elementLegal)
},
modifier = modifier
)

View file

@ -29,19 +29,19 @@ import io.element.android.libraries.ui.strings.CommonStrings
@Composable
fun AboutView(
state: AboutState,
onElementLegalClicked: (ElementLegal) -> Unit,
onBackPressed: () -> Unit,
onElementLegalClick: (ElementLegal) -> Unit,
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
) {
PreferencePage(
modifier = modifier,
onBackPressed = onBackPressed,
onBackClick = onBackClick,
title = stringResource(id = CommonStrings.common_about)
) {
state.elementLegals.forEach { elementLegal ->
PreferenceText(
title = stringResource(id = elementLegal.titleRes),
onClick = { onElementLegalClicked(elementLegal) }
onClick = { onElementLegalClick(elementLegal) }
)
}
}
@ -52,7 +52,7 @@ fun AboutView(
internal fun AboutViewPreview(@PreviewParameter(AboutStateProvider::class) state: AboutState) = ElementPreview {
AboutView(
state = state,
onElementLegalClicked = {},
onBackPressed = {},
onElementLegalClick = {},
onBackClick = {},
)
}

View file

@ -38,7 +38,7 @@ class AdvancedSettingsNode @AssistedInject constructor(
AdvancedSettingsView(
state = state,
modifier = modifier,
onBackPressed = ::navigateUp
onBackClick = ::navigateUp
)
}
}

View file

@ -38,12 +38,12 @@ import kotlinx.collections.immutable.toImmutableList
@Composable
fun AdvancedSettingsView(
state: AdvancedSettingsState,
onBackPressed: () -> Unit,
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
) {
PreferencePage(
modifier = modifier,
onBackPressed = onBackPressed,
onBackClick = onBackClick,
title = stringResource(id = CommonStrings.common_advanced_settings)
) {
ListItem(
@ -87,7 +87,7 @@ fun AdvancedSettingsView(
SingleSelectionDialog(
options = getOptions(),
initialSelection = themes.indexOf(state.theme),
onOptionSelected = {
onSelectOption = {
state.eventSink(
AdvancedSettingsEvents.SetTheme(
themes[it]
@ -121,5 +121,5 @@ private fun Theme.toHumanReadable(): String {
@Composable
internal fun AdvancedSettingsViewPreview(@PreviewParameter(AdvancedSettingsStateProvider::class) state: AdvancedSettingsState) =
ElementPreview {
AdvancedSettingsView(state = state, onBackPressed = { })
AdvancedSettingsView(state = state, onBackClick = { })
}

View file

@ -37,7 +37,7 @@ class AnalyticsSettingsNode @AssistedInject constructor(
val state = presenter.present()
AnalyticsSettingsView(
state = state,
onBackPressed = ::navigateUp,
onBackClick = ::navigateUp,
modifier = modifier
)
}

View file

@ -29,12 +29,12 @@ import io.element.android.libraries.ui.strings.CommonStrings
@Composable
fun AnalyticsSettingsView(
state: AnalyticsSettingsState,
onBackPressed: () -> Unit,
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
) {
PreferencePage(
modifier = modifier,
onBackPressed = onBackPressed,
onBackClick = onBackClick,
title = stringResource(id = CommonStrings.common_analytics)
) {
AnalyticsPreferencesView(
@ -48,6 +48,6 @@ fun AnalyticsSettingsView(
internal fun AnalyticsSettingsViewPreview(@PreviewParameter(AnalyticsSettingsStateProvider::class) state: AnalyticsSettingsState) = ElementPreview {
AnalyticsSettingsView(
state = state,
onBackPressed = {},
onBackClick = {},
)
}

View file

@ -37,7 +37,7 @@ class BlockedUsersNode @AssistedInject constructor(
val state = presenter.present()
BlockedUsersView(
state = state,
onBackPressed = ::navigateUp,
onBackClick = ::navigateUp,
modifier = modifier,
)
}

View file

@ -51,7 +51,7 @@ import io.element.android.libraries.ui.strings.CommonStrings
@Composable
fun BlockedUsersView(
state: BlockedUsersState,
onBackPressed: () -> Unit,
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
) {
Box(modifier = modifier) {
@ -65,7 +65,7 @@ fun BlockedUsersView(
)
},
navigationIcon = {
BackButton(onClick = onBackPressed)
BackButton(onClick = onBackClick)
}
)
}
@ -110,7 +110,7 @@ fun BlockedUsersView(
title = stringResource(R.string.screen_blocked_users_unblock_alert_title),
content = stringResource(R.string.screen_blocked_users_unblock_alert_description),
submitText = stringResource(R.string.screen_blocked_users_unblock_alert_action),
onSubmitClicked = { state.eventSink(BlockedUsersEvents.ConfirmUnblock) },
onSubmitClick = { state.eventSink(BlockedUsersEvents.ConfirmUnblock) },
onDismiss = { state.eventSink(BlockedUsersEvents.Cancel) }
)
}
@ -136,7 +136,7 @@ internal fun BlockedUsersViewPreview(@PreviewParameter(BlockedUsersStatePreviewP
ElementPreview {
BlockedUsersView(
state = state,
onBackPressed = {}
onBackClick = {}
)
}
}

View file

@ -59,7 +59,7 @@ class DeveloperSettingsNode @AssistedInject constructor(
modifier = modifier,
onOpenShowkase = ::openShowkase,
onOpenConfigureTracing = ::onOpenConfigureTracing,
onBackPressed = ::navigateUp
onBackClick = ::navigateUp
)
}
}

View file

@ -39,12 +39,12 @@ fun DeveloperSettingsView(
state: DeveloperSettingsState,
onOpenShowkase: () -> Unit,
onOpenConfigureTracing: () -> Unit,
onBackPressed: () -> Unit,
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
) {
PreferencePage(
modifier = modifier,
onBackPressed = onBackPressed,
onBackClick = onBackClick,
title = stringResource(id = CommonStrings.common_developer_options)
) {
// Note: this is OK to hardcode strings in this debug screen.
@ -141,6 +141,6 @@ internal fun DeveloperSettingsViewPreview(@PreviewParameter(DeveloperSettingsSta
state = state,
onOpenShowkase = {},
onOpenConfigureTracing = {},
onBackPressed = {}
onBackClick = {}
)
}

View file

@ -37,7 +37,7 @@ class ConfigureTracingNode @AssistedInject constructor(
val state = presenter.present()
ConfigureTracingView(
state = state,
onBackPressed = ::navigateUp,
onBackClick = ::navigateUp,
modifier = modifier
)
}

View file

@ -62,7 +62,7 @@ import kotlinx.collections.immutable.ImmutableMap
@Composable
fun ConfigureTracingView(
state: ConfigureTracingState,
onBackPressed: () -> Unit,
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
) {
var showMenu by remember { mutableStateOf(false) }
@ -75,7 +75,7 @@ fun ConfigureTracingView(
topBar = {
TopAppBar(
navigationIcon = {
BackButton(onClick = onBackPressed)
BackButton(onClick = onBackClick)
},
title = {
Text(
@ -234,6 +234,6 @@ internal fun ConfigureTracingViewPreview(
) = ElementPreview {
ConfigureTracingView(
state = state,
onBackPressed = {},
onBackClick = {},
)
}

View file

@ -35,7 +35,7 @@ class NotificationSettingsNode @AssistedInject constructor(
) : Node(buildContext, plugins = plugins) {
interface Callback : Plugin {
fun editDefaultNotificationMode(isOneToOne: Boolean)
fun onTroubleshootNotificationsClicked()
fun onTroubleshootNotificationsClick()
}
private val callbacks = plugins<Callback>()
@ -44,8 +44,8 @@ class NotificationSettingsNode @AssistedInject constructor(
callbacks.forEach { it.editDefaultNotificationMode(isOneToOne) }
}
private fun onTroubleshootNotificationsClicked() {
callbacks.forEach { it.onTroubleshootNotificationsClicked() }
private fun onTroubleshootNotificationsClick() {
callbacks.forEach { it.onTroubleshootNotificationsClick() }
}
@Composable
@ -54,8 +54,8 @@ class NotificationSettingsNode @AssistedInject constructor(
NotificationSettingsView(
state = state,
onOpenEditDefault = { openEditDefault(isOneToOne = it) },
onBackPressed = ::navigateUp,
onTroubleshootNotificationsClicked = ::onTroubleshootNotificationsClicked,
onBackClick = ::navigateUp,
onTroubleshootNotificationsClick = ::onTroubleshootNotificationsClick,
modifier = modifier,
)
}

View file

@ -56,8 +56,8 @@ import kotlinx.collections.immutable.toImmutableList
fun NotificationSettingsView(
state: NotificationSettingsState,
onOpenEditDefault: (isOneToOne: Boolean) -> Unit,
onTroubleshootNotificationsClicked: () -> Unit,
onBackPressed: () -> Unit,
onTroubleshootNotificationsClick: () -> Unit,
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
) {
OnLifecycleEvent { _, event ->
@ -68,27 +68,27 @@ fun NotificationSettingsView(
}
PreferencePage(
modifier = modifier,
onBackPressed = onBackPressed,
onBackClick = onBackClick,
title = stringResource(id = R.string.screen_notification_settings_title)
) {
when (state.matrixSettings) {
is NotificationSettingsState.MatrixSettings.Invalid -> InvalidNotificationSettingsView(
showError = state.matrixSettings.fixFailed,
onContinueClicked = { state.eventSink(NotificationSettingsEvents.FixConfigurationMismatch) },
onContinueClick = { state.eventSink(NotificationSettingsEvents.FixConfigurationMismatch) },
onDismissError = { state.eventSink(NotificationSettingsEvents.ClearConfigurationMismatchError) },
)
NotificationSettingsState.MatrixSettings.Uninitialized -> return@PreferencePage
is NotificationSettingsState.MatrixSettings.Valid -> NotificationSettingsContentView(
matrixSettings = state.matrixSettings,
state = state,
onNotificationsEnabledChanged = { state.eventSink(NotificationSettingsEvents.SetNotificationsEnabled(it)) },
onGroupChatsClicked = { onOpenEditDefault(false) },
onDirectChatsClicked = { onOpenEditDefault(true) },
onMentionNotificationsChanged = { state.eventSink(NotificationSettingsEvents.SetAtRoomNotificationsEnabled(it)) },
onNotificationsEnabledChange = { state.eventSink(NotificationSettingsEvents.SetNotificationsEnabled(it)) },
onGroupChatsClick = { onOpenEditDefault(false) },
onDirectChatsClick = { onOpenEditDefault(true) },
onMentionNotificationsChange = { state.eventSink(NotificationSettingsEvents.SetAtRoomNotificationsEnabled(it)) },
// TODO We are removing the call notification toggle until support for call notifications has been added
// onCallsNotificationsChanged = { state.eventSink(NotificationSettingsEvents.SetCallNotificationsEnabled(it)) },
onInviteForMeNotificationsChanged = { state.eventSink(NotificationSettingsEvents.SetInviteForMeNotificationsEnabled(it)) },
onTroubleshootNotificationsClicked = onTroubleshootNotificationsClicked,
onInviteForMeNotificationsChange = { state.eventSink(NotificationSettingsEvents.SetInviteForMeNotificationsEnabled(it)) },
onTroubleshootNotificationsClick = onTroubleshootNotificationsClick,
)
}
AsyncActionView(
@ -104,14 +104,14 @@ fun NotificationSettingsView(
private fun NotificationSettingsContentView(
matrixSettings: NotificationSettingsState.MatrixSettings.Valid,
state: NotificationSettingsState,
onNotificationsEnabledChanged: (Boolean) -> Unit,
onGroupChatsClicked: () -> Unit,
onDirectChatsClicked: () -> Unit,
onMentionNotificationsChanged: (Boolean) -> Unit,
onNotificationsEnabledChange: (Boolean) -> Unit,
onGroupChatsClick: () -> Unit,
onDirectChatsClick: () -> Unit,
onMentionNotificationsChange: (Boolean) -> Unit,
// TODO We are removing the call notification toggle until support for call notifications has been added
// onCallsNotificationsChanged: (Boolean) -> Unit,
onInviteForMeNotificationsChanged: (Boolean) -> Unit,
onTroubleshootNotificationsClicked: () -> Unit,
onInviteForMeNotificationsChange: (Boolean) -> Unit,
onTroubleshootNotificationsClick: () -> Unit,
) {
val context = LocalContext.current
val systemSettings: NotificationSettingsState.AppSettings = state.appSettings
@ -132,7 +132,7 @@ private fun NotificationSettingsContentView(
PreferenceSwitch(
title = stringResource(id = R.string.screen_notification_settings_enable_notifications),
isChecked = systemSettings.appNotificationsEnabled,
onCheckedChange = onNotificationsEnabledChanged
onCheckedChange = onNotificationsEnabledChange
)
if (systemSettings.appNotificationsEnabled) {
@ -140,13 +140,13 @@ private fun NotificationSettingsContentView(
PreferenceText(
title = stringResource(id = R.string.screen_notification_settings_group_chats),
subtitle = getTitleForRoomNotificationMode(mode = matrixSettings.defaultGroupNotificationMode),
onClick = onGroupChatsClicked
onClick = onGroupChatsClick
)
PreferenceText(
title = stringResource(id = R.string.screen_notification_settings_direct_chats),
subtitle = getTitleForRoomNotificationMode(mode = matrixSettings.defaultOneToOneNotificationMode),
onClick = onDirectChatsClicked
onClick = onDirectChatsClick
)
}
@ -155,7 +155,7 @@ private fun NotificationSettingsContentView(
modifier = Modifier,
title = stringResource(id = R.string.screen_notification_settings_room_mention_label),
isChecked = matrixSettings.atRoomNotificationsEnabled,
onCheckedChange = onMentionNotificationsChanged
onCheckedChange = onMentionNotificationsChange
)
}
PreferenceCategory(title = stringResource(id = R.string.screen_notification_settings_additional_settings_section_title)) {
@ -171,14 +171,14 @@ private fun NotificationSettingsContentView(
modifier = Modifier,
title = stringResource(id = R.string.screen_notification_settings_invite_for_me_label),
isChecked = matrixSettings.inviteForMeNotificationsEnabled,
onCheckedChange = onInviteForMeNotificationsChanged
onCheckedChange = onInviteForMeNotificationsChange
)
}
PreferenceCategory(title = stringResource(id = R.string.troubleshoot_notifications_entry_point_section)) {
PreferenceText(
modifier = Modifier,
title = stringResource(id = R.string.troubleshoot_notifications_entry_point_title),
onClick = onTroubleshootNotificationsClicked
onClick = onTroubleshootNotificationsClick
)
}
if (state.showAdvancedSettings) {
@ -218,7 +218,7 @@ private fun NotificationSettingsContentView(
ListOption(title = it)
}.toImmutableList(),
initialSelection = state.availablePushDistributors.indexOf(state.currentPushDistributor.dataOrNull()),
onOptionSelected = { index ->
onSelectOption = { index ->
state.eventSink(
NotificationSettingsEvents.SetPushProvider(index)
)
@ -242,14 +242,14 @@ private fun getTitleForRoomNotificationMode(mode: RoomNotificationMode?) =
@Composable
private fun InvalidNotificationSettingsView(
showError: Boolean,
onContinueClicked: () -> Unit,
onContinueClick: () -> Unit,
onDismissError: () -> Unit,
) {
DialogLikeBannerMolecule(
title = stringResource(R.string.screen_notification_settings_configuration_mismatch),
content = stringResource(R.string.screen_notification_settings_configuration_mismatch_description),
onSubmitClicked = onContinueClicked,
onDismissClicked = null,
onSubmitClick = onContinueClick,
onDismissClick = null,
)
if (showError) {
@ -266,8 +266,8 @@ private fun InvalidNotificationSettingsView(
internal fun NotificationSettingsViewPreview(@PreviewParameter(NotificationSettingsStateProvider::class) state: NotificationSettingsState) = ElementPreview {
NotificationSettingsView(
state = state,
onBackPressed = {},
onBackClick = {},
onOpenEditDefault = {},
onTroubleshootNotificationsClicked = {},
onTroubleshootNotificationsClick = {},
)
}

View file

@ -30,7 +30,7 @@ import io.element.android.libraries.matrix.api.room.RoomNotificationMode
@Composable
fun DefaultNotificationSettingOption(
mode: RoomNotificationMode,
onOptionSelected: (RoomNotificationMode) -> Unit,
onSelectOption: (RoomNotificationMode) -> Unit,
displayMentionsOnlyDisclaimer: Boolean,
modifier: Modifier = Modifier,
isSelected: Boolean = false,
@ -51,7 +51,7 @@ fun DefaultNotificationSettingOption(
headlineContent = { Text(title) },
supportingContent = subtitle?.let { { Text(it) } },
trailingContent = ListItemContent.RadioButton(selected = isSelected),
onClick = { onOptionSelected(mode) },
onClick = { onSelectOption(mode) },
)
}
@ -63,19 +63,19 @@ internal fun DefaultNotificationSettingOptionPreview() = ElementPreview {
mode = RoomNotificationMode.ALL_MESSAGES,
isSelected = true,
displayMentionsOnlyDisclaimer = false,
onOptionSelected = {},
onSelectOption = {},
)
DefaultNotificationSettingOption(
mode = RoomNotificationMode.MENTIONS_AND_KEYWORDS_ONLY,
isSelected = false,
displayMentionsOnlyDisclaimer = false,
onOptionSelected = {},
onSelectOption = {},
)
DefaultNotificationSettingOption(
mode = RoomNotificationMode.MENTIONS_AND_KEYWORDS_ONLY,
isSelected = false,
displayMentionsOnlyDisclaimer = true,
onOptionSelected = {},
onSelectOption = {},
)
}
}

View file

@ -58,7 +58,7 @@ class EditDefaultNotificationSettingNode @AssistedInject constructor(
EditDefaultNotificationSettingView(
state = state,
openRoomNotificationSettings = { openRoomNotificationSettings(it) },
onBackPressed = ::navigateUp,
onBackClick = ::navigateUp,
modifier = modifier,
)
}

View file

@ -47,7 +47,7 @@ import io.element.android.libraries.ui.strings.CommonStrings
fun EditDefaultNotificationSettingView(
state: EditDefaultNotificationSettingState,
openRoomNotificationSettings: (roomId: RoomId) -> Unit,
onBackPressed: () -> Unit,
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
) {
val title = if (state.isOneToOne) {
@ -57,7 +57,7 @@ fun EditDefaultNotificationSettingView(
}
PreferencePage(
modifier = modifier,
onBackPressed = onBackPressed,
onBackClick = onBackClick,
title = stringResource(id = title)
) {
// Only ALL_MESSAGES and MENTIONS_AND_KEYWORDS_ONLY are valid global defaults.
@ -79,7 +79,7 @@ fun EditDefaultNotificationSettingView(
mode = item,
isSelected = state.mode == item,
displayMentionsOnlyDisclaimer = state.displayMentionsOnlyDisclaimer,
onOptionSelected = { state.eventSink(EditDefaultNotificationSettingStateEvents.SetNotificationMode(it)) }
onSelectOption = { state.eventSink(EditDefaultNotificationSettingStateEvents.SetNotificationMode(it)) }
)
}
}
@ -140,6 +140,6 @@ internal fun EditDefaultNotificationSettingViewPreview(
EditDefaultNotificationSettingView(
state = state,
openRoomNotificationSettings = {},
onBackPressed = {},
onBackClick = {},
)
}

View file

@ -44,7 +44,7 @@ class PreferencesRootNode @AssistedInject constructor(
) : Node(buildContext, plugins = plugins) {
interface Callback : Plugin {
fun onOpenBugReport()
fun onSecureBackupClicked()
fun onSecureBackupClick()
fun onOpenAnalytics()
fun onOpenAbout()
fun onOpenDeveloperSettings()
@ -53,15 +53,15 @@ class PreferencesRootNode @AssistedInject constructor(
fun onOpenAdvancedSettings()
fun onOpenUserProfile(matrixUser: MatrixUser)
fun onOpenBlockedUsers()
fun onSignOutClicked()
fun onSignOutClick()
}
private fun onOpenBugReport() {
plugins<Callback>().forEach { it.onOpenBugReport() }
}
private fun onSecureBackupClicked() {
plugins<Callback>().forEach { it.onSecureBackupClicked() }
private fun onSecureBackupClick() {
plugins<Callback>().forEach { it.onSecureBackupClick() }
}
private fun onOpenDeveloperSettings() {
@ -80,7 +80,7 @@ class PreferencesRootNode @AssistedInject constructor(
plugins<Callback>().forEach { it.onOpenAbout() }
}
private fun onManageAccountClicked(
private fun onManageAccountClick(
activity: Activity,
url: String?,
isDark: Boolean,
@ -117,8 +117,8 @@ class PreferencesRootNode @AssistedInject constructor(
plugins<Callback>().forEach { it.onOpenBlockedUsers() }
}
private fun onSignOutClicked() {
plugins<Callback>().forEach { it.onSignOutClicked() }
private fun onSignOutClick() {
plugins<Callback>().forEach { it.onSignOutClick() }
}
@Composable
@ -129,23 +129,23 @@ class PreferencesRootNode @AssistedInject constructor(
PreferencesRootView(
state = state,
modifier = modifier,
onBackPressed = this::navigateUp,
onBackClick = this::navigateUp,
onOpenRageShake = this::onOpenBugReport,
onOpenAnalytics = this::onOpenAnalytics,
onOpenAbout = this::onOpenAbout,
onSecureBackupClicked = this::onSecureBackupClicked,
onSecureBackupClick = this::onSecureBackupClick,
onOpenDeveloperSettings = this::onOpenDeveloperSettings,
onOpenAdvancedSettings = this::onOpenAdvancedSettings,
onManageAccountClicked = { onManageAccountClicked(activity, it, isDark) },
onManageAccountClick = { onManageAccountClick(activity, it, isDark) },
onOpenNotificationSettings = this::onOpenNotificationSettings,
onOpenLockScreenSettings = this::onOpenLockScreenSettings,
onOpenUserProfile = this::onOpenUserProfile,
onOpenBlockedUsers = this::onOpenBlockedUsers,
onSignOutClicked = {
onSignOutClick = {
if (state.directLogoutState.canDoDirectSignOut) {
state.directLogoutState.eventSink(DirectLogoutEvents.Logout(ignoreSdkError = false))
} else {
onSignOutClicked()
onSignOutClick()
}
},
)

View file

@ -52,9 +52,9 @@ import io.element.android.libraries.ui.strings.CommonStrings
@Composable
fun PreferencesRootView(
state: PreferencesRootState,
onBackPressed: () -> Unit,
onSecureBackupClicked: () -> Unit,
onManageAccountClicked: (url: String) -> Unit,
onBackClick: () -> Unit,
onSecureBackupClick: () -> Unit,
onManageAccountClick: (url: String) -> Unit,
onOpenAnalytics: () -> Unit,
onOpenRageShake: () -> Unit,
onOpenLockScreenSettings: () -> Unit,
@ -64,7 +64,7 @@ fun PreferencesRootView(
onOpenNotificationSettings: () -> Unit,
onOpenUserProfile: (MatrixUser) -> Unit,
onOpenBlockedUsers: () -> Unit,
onSignOutClicked: () -> Unit,
onSignOutClick: () -> Unit,
modifier: Modifier = Modifier,
) {
val snackbarHostState = rememberSnackbarHostState(snackbarMessage = state.snackbarMessage)
@ -72,7 +72,7 @@ fun PreferencesRootView(
// Include pref from other modules
PreferencePage(
modifier = modifier,
onBackPressed = onBackPressed,
onBackClick = onBackClick,
title = stringResource(id = CommonStrings.common_settings),
snackbarHost = { SnackbarHost(snackbarHostState) }
) {
@ -88,13 +88,13 @@ fun PreferencesRootView(
state = state,
onOpenNotificationSettings = onOpenNotificationSettings,
onOpenLockScreenSettings = onOpenLockScreenSettings,
onSecureBackupClicked = onSecureBackupClicked,
onSecureBackupClick = onSecureBackupClick,
)
// 'Account' section
ManageAccountSection(
state = state,
onManageAccountClicked = onManageAccountClicked,
onManageAccountClick = onManageAccountClick,
onOpenBlockedUsers = onOpenBlockedUsers
)
@ -106,7 +106,7 @@ fun PreferencesRootView(
onOpenRageShake = onOpenRageShake,
onOpenAdvancedSettings = onOpenAdvancedSettings,
onOpenDeveloperSettings = onOpenDeveloperSettings,
onSignOutClicked = onSignOutClicked,
onSignOutClick = onSignOutClick,
)
Footer(
@ -121,7 +121,7 @@ private fun ColumnScope.ManageAppSection(
state: PreferencesRootState,
onOpenNotificationSettings: () -> Unit,
onOpenLockScreenSettings: () -> Unit,
onSecureBackupClicked: () -> Unit,
onSecureBackupClick: () -> Unit,
) {
if (state.showNotificationSettings) {
ListItem(
@ -142,7 +142,7 @@ private fun ColumnScope.ManageAppSection(
headlineContent = { Text(stringResource(id = CommonStrings.common_chat_backup)) },
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.KeySolid())),
trailingContent = ListItemContent.Badge.takeIf { state.showSecureBackupBadge },
onClick = onSecureBackupClicked,
onClick = onSecureBackupClick,
)
}
if (state.showNotificationSettings || state.showLockScreenSettings || state.showSecureBackup) {
@ -153,7 +153,7 @@ private fun ColumnScope.ManageAppSection(
@Composable
private fun ColumnScope.ManageAccountSection(
state: PreferencesRootState,
onManageAccountClicked: (url: String) -> Unit,
onManageAccountClick: (url: String) -> Unit,
onOpenBlockedUsers: () -> Unit,
) {
state.accountManagementUrl?.let { url ->
@ -161,7 +161,7 @@ private fun ColumnScope.ManageAccountSection(
headlineContent = { Text(stringResource(id = CommonStrings.action_manage_account)) },
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.UserProfile())),
trailingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.PopOut())),
onClick = { onManageAccountClicked(url) },
onClick = { onManageAccountClick(url) },
)
}
@ -170,7 +170,7 @@ private fun ColumnScope.ManageAccountSection(
headlineContent = { Text(stringResource(id = CommonStrings.action_manage_devices)) },
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Devices())),
trailingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.PopOut())),
onClick = { onManageAccountClicked(url) },
onClick = { onManageAccountClick(url) },
)
}
@ -195,7 +195,7 @@ private fun ColumnScope.GeneralSection(
onOpenRageShake: () -> Unit,
onOpenAdvancedSettings: () -> Unit,
onOpenDeveloperSettings: () -> Unit,
onSignOutClicked: () -> Unit,
onSignOutClick: () -> Unit,
) {
ListItem(
headlineContent = { Text(stringResource(id = CommonStrings.common_about)) },
@ -226,7 +226,7 @@ private fun ColumnScope.GeneralSection(
headlineContent = { Text(stringResource(id = CommonStrings.action_signout)) },
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.SignOut())),
style = ListItemStyle.Destructive,
onClick = onSignOutClicked,
onClick = onSignOutClick,
)
}
@ -279,18 +279,18 @@ internal fun PreferencesRootViewDarkPreview(@PreviewParameter(MatrixUserProvider
private fun ContentToPreview(matrixUser: MatrixUser) {
PreferencesRootView(
state = aPreferencesRootState(myUser = matrixUser),
onBackPressed = {},
onBackClick = {},
onOpenAnalytics = {},
onOpenRageShake = {},
onOpenDeveloperSettings = {},
onOpenAdvancedSettings = {},
onOpenAbout = {},
onSecureBackupClicked = {},
onManageAccountClicked = {},
onSecureBackupClick = {},
onManageAccountClick = {},
onOpenNotificationSettings = {},
onOpenLockScreenSettings = {},
onOpenUserProfile = {},
onOpenBlockedUsers = {},
onSignOutClicked = {},
onSignOutClick = {},
)
}

View file

@ -47,8 +47,8 @@ class EditUserProfileNode @AssistedInject constructor(
val state = presenter.present()
EditUserProfileView(
state = state,
onBackPressed = ::navigateUp,
onProfileEdited = ::navigateUp,
onBackClick = ::navigateUp,
onEditProfileSuccess = ::navigateUp,
modifier = modifier
)
}

View file

@ -60,14 +60,14 @@ import io.element.android.libraries.ui.strings.CommonStrings
@Composable
fun EditUserProfileView(
state: EditUserProfileState,
onBackPressed: () -> Unit,
onProfileEdited: () -> Unit,
onBackClick: () -> Unit,
onEditProfileSuccess: () -> Unit,
modifier: Modifier = Modifier,
) {
val focusManager = LocalFocusManager.current
val isAvatarActionsSheetVisible = remember { mutableStateOf(false) }
fun onAvatarClicked() {
fun onAvatarClick() {
focusManager.clearFocus()
isAvatarActionsSheetVisible.value = true
}
@ -82,7 +82,7 @@ fun EditUserProfileView(
style = ElementTheme.typography.aliasScreenTitle,
)
},
navigationIcon = { BackButton(onClick = onBackPressed) },
navigationIcon = { BackButton(onClick = onBackClick) },
actions = {
TextButton(
text = stringResource(CommonStrings.action_save),
@ -110,7 +110,7 @@ fun EditUserProfileView(
displayName = state.displayName,
avatarUrl = state.userAvatarUrl,
avatarSize = AvatarSize.RoomHeader,
onAvatarClicked = { onAvatarClicked() },
onAvatarClick = { onAvatarClick() },
modifier = Modifier.align(Alignment.CenterHorizontally),
)
Spacer(modifier = Modifier.height(16.dp))
@ -134,7 +134,7 @@ fun EditUserProfileView(
actions = state.avatarActions,
isVisible = isAvatarActionsSheetVisible.value,
onDismiss = { isAvatarActionsSheetVisible.value = false },
onActionSelected = { state.eventSink(EditUserProfileEvents.HandleAvatarAction(it)) }
onSelectAction = { state.eventSink(EditUserProfileEvents.HandleAvatarAction(it)) }
)
AsyncActionView(
@ -144,7 +144,7 @@ fun EditUserProfileView(
progressText = stringResource(R.string.screen_edit_profile_updating_details),
)
},
onSuccess = { onProfileEdited() },
onSuccess = { onEditProfileSuccess() },
errorTitle = { stringResource(R.string.screen_edit_profile_error_title) },
errorMessage = { stringResource(R.string.screen_edit_profile_error) },
onErrorDismiss = { state.eventSink(EditUserProfileEvents.CancelSaveChanges) },
@ -160,8 +160,8 @@ fun EditUserProfileView(
internal fun EditUserProfileViewPreview(@PreviewParameter(EditUserProfileStateProvider::class) state: EditUserProfileState) =
ElementPreview {
EditUserProfileView(
onBackPressed = {},
onProfileEdited = {},
onBackClick = {},
onEditProfileSuccess = {},
state = state,
)
}

View file

@ -46,7 +46,7 @@ class AdvancedSettingsViewTest {
state = aAdvancedSettingsState(
eventSink = eventsRecorder
),
onBackPressed = it
onBackClick = it
)
rule.pressBack()
}
@ -104,12 +104,12 @@ class AdvancedSettingsViewTest {
private fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setAdvancedSettingsView(
state: AdvancedSettingsState,
onBackPressed: () -> Unit = EnsureNeverCalled(),
onBackClick: () -> Unit = EnsureNeverCalled(),
) {
setContent {
AdvancedSettingsView(
state = state,
onBackPressed = onBackPressed,
onBackClick = onBackClick,
)
}
}

View file

@ -49,7 +49,7 @@ class BlockedUserViewTest {
aBlockedUsersState(
eventSink = eventsRecorder
),
onBackClicked = callback,
onBackClick = callback,
)
rule.pressBack()
}
@ -98,12 +98,12 @@ class BlockedUserViewTest {
private fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setLogoutView(
state: BlockedUsersState,
onBackClicked: () -> Unit = EnsureNeverCalled(),
onBackClick: () -> Unit = EnsureNeverCalled(),
) {
setContent {
BlockedUsersView(
state = state,
onBackPressed = onBackClicked,
onBackClick = onBackClick,
)
}
}

View file

@ -48,7 +48,7 @@ class DeveloperSettingsViewTest {
state = aDeveloperSettingsState(
eventSink = eventsRecorder
),
onBackPressed = it
onBackClick = it
)
rule.pressBack()
}
@ -115,14 +115,14 @@ private fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setDevel
state: DeveloperSettingsState,
onOpenShowkase: () -> Unit = EnsureNeverCalled(),
onOpenConfigureTracing: () -> Unit = EnsureNeverCalled(),
onBackPressed: () -> Unit = EnsureNeverCalled()
onBackClick: () -> Unit = EnsureNeverCalled()
) {
setContent {
DeveloperSettingsView(
state = state,
onOpenShowkase = onOpenShowkase,
onOpenConfigureTracing = onOpenConfigureTracing,
onBackPressed = onBackPressed,
onBackClick = onBackClick,
)
}
}

View file

@ -52,7 +52,7 @@ class NotificationSettingsViewTest {
state = aValidNotificationSettingsState(
eventSink = eventsRecorder
),
onBackPressed = it
onBackClick = it
)
rule.pressBack()
}
@ -68,7 +68,7 @@ class NotificationSettingsViewTest {
state = aValidNotificationSettingsState(
eventSink = eventsRecorder
),
onTroubleshootNotificationsClicked = it
onTroubleshootNotificationsClick = it
)
rule.clickOn(R.string.troubleshoot_notifications_entry_point_title)
}
@ -292,15 +292,15 @@ class NotificationSettingsViewTest {
private fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setNotificationSettingsView(
state: NotificationSettingsState,
onOpenEditDefault: (isOneToOne: Boolean) -> Unit = EnsureNeverCalledWithParam(),
onTroubleshootNotificationsClicked: () -> Unit = EnsureNeverCalled(),
onBackPressed: () -> Unit = EnsureNeverCalled(),
onTroubleshootNotificationsClick: () -> Unit = EnsureNeverCalled(),
onBackClick: () -> Unit = EnsureNeverCalled(),
) {
setContent {
NotificationSettingsView(
state = state,
onOpenEditDefault = onOpenEditDefault,
onTroubleshootNotificationsClicked = onTroubleshootNotificationsClicked,
onBackPressed = onBackPressed,
onTroubleshootNotificationsClick = onTroubleshootNotificationsClick,
onBackClick = onBackClick,
)
}
}