From 919849acc2e1bb4236959a3e62056443fef6c9e3 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 29 May 2024 12:38:14 +0200 Subject: [PATCH] Move `content` @Composable to the end of the parameter list. A @Composable `content` parameter should be moved to be the trailing lambda in a composable function. --- .../features/logout/impl/LogoutView.kt | 5 ++-- .../impl/disable/SecureBackupDisableView.kt | 5 ++-- .../enter/SecureBackupEnterRecoveryKeyView.kt | 5 ++-- .../impl/setup/SecureBackupSetupView.kt | 5 ++-- .../designsystem/atomic/pages/FlowStepPage.kt | 27 +++++++++---------- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutView.kt b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutView.kt index 66f72d478f..9ccd7de985 100644 --- a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutView.kt +++ b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutView.kt @@ -64,7 +64,6 @@ fun LogoutView( subTitle = subtitle(state), iconVector = CompoundIcons.KeySolid(), modifier = modifier, - content = { Content(state) }, buttons = { Buttons( state = state, @@ -74,7 +73,9 @@ fun LogoutView( } ) }, - ) + ) { + Content(state) + } LogoutActionDialog( state.logoutAction, diff --git a/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisableView.kt b/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisableView.kt index ec7076a7c3..845de55e0c 100644 --- a/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisableView.kt +++ b/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisableView.kt @@ -53,9 +53,10 @@ fun SecureBackupDisableView( title = stringResource(id = R.string.screen_key_backup_disable_title), subTitle = stringResource(id = R.string.screen_key_backup_disable_description), iconVector = CompoundIcons.KeyOffSolid(), - content = { Content(state = state) }, buttons = { Buttons(state = state) }, - ) + ) { + Content(state = state) + } AsyncActionView( async = state.disableAction, diff --git a/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/enter/SecureBackupEnterRecoveryKeyView.kt b/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/enter/SecureBackupEnterRecoveryKeyView.kt index 1f93b55735..f18d013014 100644 --- a/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/enter/SecureBackupEnterRecoveryKeyView.kt +++ b/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/enter/SecureBackupEnterRecoveryKeyView.kt @@ -58,9 +58,10 @@ fun SecureBackupEnterRecoveryKeyView( iconVector = CompoundIcons.KeySolid(), title = stringResource(id = R.string.screen_recovery_key_confirm_title), subTitle = stringResource(id = R.string.screen_recovery_key_confirm_description), - content = { Content(state = state) }, buttons = { Buttons(state = state, onCreateRecoveryKey = onCreateNewRecoveryKey) } - ) + ) { + Content(state = state) + } } @Composable diff --git a/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/setup/SecureBackupSetupView.kt b/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/setup/SecureBackupSetupView.kt index d4129a3259..2cefff29b4 100644 --- a/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/setup/SecureBackupSetupView.kt +++ b/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/setup/SecureBackupSetupView.kt @@ -52,9 +52,10 @@ fun SecureBackupSetupView( title = title(state), subTitle = subtitle(state), iconVector = CompoundIcons.KeySolid(), - content = { Content(state) }, buttons = { Buttons(state, onFinish = onSuccess) }, - ) + ) { + Content(state = state) + } if (state.showSaveConfirmationDialog) { ConfirmationDialog( diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/pages/FlowStepPage.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/pages/FlowStepPage.kt index 6d06d37e56..789e4a3a18 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/pages/FlowStepPage.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/atomic/pages/FlowStepPage.kt @@ -54,8 +54,8 @@ fun FlowStepPage( modifier: Modifier = Modifier, onBackClick: (() -> Unit)? = null, subTitle: String? = null, - content: @Composable () -> Unit = {}, buttons: @Composable ColumnScope.() -> Unit = {}, + content: @Composable () -> Unit = {}, ) { BackHandler(enabled = onBackClick != null) { onBackClick?.invoke() @@ -98,21 +98,20 @@ internal fun FlowStepPagePreview() = ElementPreview { title = "Title", subTitle = "Subtitle", iconVector = CompoundIcons.Computer(), - content = { - Box( - Modifier - .fillMaxSize(), - contentAlignment = Alignment.Center - ) { - Text( - text = "Content", - style = ElementTheme.typography.fontHeadingXlBold - ) - } - }, buttons = { TextButton(text = "A button", onClick = { }) Button(text = "Continue", onClick = { }) } - ) + ) { + Box( + Modifier + .fillMaxSize(), + contentAlignment = Alignment.Center + ) { + Text( + text = "Content", + style = ElementTheme.typography.fontHeadingXlBold + ) + } + } }