Skip to content

Commit

Permalink
FlowStepPage: make onBackClicked nullable and remove canGoBack.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarty committed Nov 7, 2023
1 parent 163bc87 commit 7bd2ccd
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ fun LogoutView(
val eventSink = state.eventSink

FlowStepPage(
canGoBack = true,
onBackClicked = onBackClicked,
title = title(state),
subTitle = subtitle(state),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ fun SecureBackupDisableView(
}
FlowStepPage(
modifier = modifier,
canGoBack = true,
onBackClicked = onBackClicked,
title = stringResource(id = R.string.screen_key_backup_disable_title),
subTitle = stringResource(id = R.string.screen_key_backup_disable_description),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ fun SecureBackupEnableView(
}
FlowStepPage(
modifier = modifier,
canGoBack = true,
onBackClicked = onBackClicked,
title = stringResource(id = R.string.screen_chat_backup_key_backup_action_enable),
iconResourceId = CommonDrawables.ic_key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ fun SecureBackupEnterRecoveryKeyView(

FlowStepPage(
modifier = modifier,
canGoBack = true,
onBackClicked = onBackClicked,
iconResourceId = CommonDrawables.ic_key,
title = stringResource(id = R.string.screen_recovery_key_confirm_title),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ fun SecureBackupSetupView(
) {
FlowStepPage(
modifier = modifier,
canGoBack = state.canGoBack(),
onBackClicked = onBackClicked,
onBackClicked = onBackClicked.takeIf { state.canGoBack() },
title = title(state),
subTitle = subtitle(state),
iconResourceId = CommonDrawables.ic_key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,31 @@ import io.element.android.libraries.theme.ElementTheme

/**
* A Page with:
* - a top bar as TobAppBar with optional back button
* - a top bar as TobAppBar with optional back button (displayed if [onBackClicked] is not null)
* - a header, as IconTitleSubtitleMolecule
* - a content.
* - a footer, as ButtonColumnMolecule
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun FlowStepPage(
canGoBack: Boolean,
onBackClicked: () -> Unit,
iconResourceId: Int?,
title: String,
modifier: Modifier = Modifier,
onBackClicked: (() -> Unit)? = null,
subTitle: String? = null,
content: @Composable () -> Unit = {},
buttons: @Composable ColumnScope.() -> Unit = {},
) {
BackHandler(enabled = canGoBack) {
onBackClicked()
BackHandler(enabled = onBackClicked != null) {
onBackClicked?.invoke()
}
HeaderFooterPage(
modifier = modifier,
topBar = {
TopAppBar(
navigationIcon = {
if (canGoBack) {
if (onBackClicked != null) {
BackButton(onClick = onBackClicked)
}
},
Expand Down Expand Up @@ -94,7 +93,6 @@ fun FlowStepPage(
@Composable
internal fun FlowStepPagePreview() = ElementPreview {
FlowStepPage(
canGoBack = true,
onBackClicked = {},
title = "Title",
subTitle = "Subtitle",
Expand Down

0 comments on commit 7bd2ccd

Please sign in to comment.