Skip to content

Commit

Permalink
refactor: Extract Screens content into functions
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Oct 21, 2024
1 parent 513db09 commit 1c79f46
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un
UploadProgressScreen()
}
composable<UploadSuccessDestination> {
UploadSuccessScreen(
transferType = TransferType.MAIL, // TODO: Use correct TransferType instead of hard-coded value.
)
// TODO: Use correct TransferType instead of hard-coded value
UploadSuccessScreen(transferType = TransferType.MAIL)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,30 @@ fun UploadSuccessEmailScreen() {
onClick = { /* TODO */ },
)
},
content = {
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
content = { Content() },
)
}

IllustratedMessageBlock(
icon = AppIllus.UploadSuccessEmail.image(),
title = R.string.uploadSuccessEmailTitle,
description = R.string.uploadSuccessEmailDescription,
)
@Composable
private fun Content() {
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {

Spacer(Modifier.height(Margin.Medium))
IllustratedMessageBlock(
icon = AppIllus.UploadSuccessEmail.image(),
title = R.string.uploadSuccessEmailTitle,
description = R.string.uploadSuccessEmailDescription,
)

EmailAddressChip("[email protected]") // TODO: Use correct email instead of hard-coded value.
}
},
)
Spacer(Modifier.height(Margin.Medium))

EmailAddressChip("[email protected]") // TODO: Use correct email instead of hard-coded value.
}
}

@PreviewAllWindows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows

@Composable
fun UploadSuccessQrScreen(transferType: TransferType) {

val uploadSuccessTitle = if (transferType == TransferType.QR_CODE) {
R.string.uploadSuccessQrTitle
} else {
R.string.uploadSuccessLinkTitle
}

BottomStickyButtonScaffold(
topBar = { BrandTopAppBar() },
topButton = {
Expand All @@ -66,54 +59,64 @@ fun UploadSuccessQrScreen(transferType: TransferType) {
onClick = { /* TODO */ },
)
},
content = {
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
content = { Content(transferType) },
)
}

@Composable
private fun Content(transferType: TransferType) {

val uploadSuccessTitle = if (transferType == TransferType.QR_CODE) {
R.string.uploadSuccessQrTitle
} else {
R.string.uploadSuccessLinkTitle
}

Image(
imageVector = AppIllus.UploadSuccessQr.image(),
contentDescription = null,
)
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {

Spacer(Modifier.height(Margin.XLarge))
Image(
imageVector = AppIllus.UploadSuccessQr.image(),
contentDescription = null,
)

Text(
text = stringResource(uploadSuccessTitle),
style = SwissTransferTheme.typography.h1,
color = SwissTransferTheme.colors.primaryTextColor,
)
Spacer(Modifier.height(Margin.XLarge))

Spacer(Modifier.height(Margin.XLarge))
Text(
text = stringResource(uploadSuccessTitle),
style = SwissTransferTheme.typography.h1,
color = SwissTransferTheme.colors.primaryTextColor,
)

QrCode()
Spacer(Modifier.height(Margin.XLarge))

if (transferType != TransferType.QR_CODE) {
Spacer(Modifier.height(Margin.XXLarge))
Text(
text = stringResource(R.string.uploadSuccessLinkDescription),
style = SwissTransferTheme.typography.bodyRegular,
textAlign = TextAlign.Center,
color = SwissTransferTheme.colors.secondaryTextColor,
modifier = Modifier
.alpha(1.0f)
.widthIn(max = Dimens.DescriptionWidth),
)
}
}
QrCode()

// TODO: What do we want to do with this button placement?
LargeButton(
modifier = Modifier.padding(Margin.Medium),
style = ButtonType.SECONDARY,
titleRes = R.string.buttonCopyLink,
onClick = { /* TODO */ },
if (transferType != TransferType.QR_CODE) {
Spacer(Modifier.height(Margin.XXLarge))
Text(
text = stringResource(R.string.uploadSuccessLinkDescription),
style = SwissTransferTheme.typography.bodyRegular,
textAlign = TextAlign.Center,
color = SwissTransferTheme.colors.secondaryTextColor,
modifier = Modifier
.alpha(1.0f)
.widthIn(max = Dimens.DescriptionWidth),
)
},
}
}

// TODO: What do we want to do with this button placement?
LargeButton(
modifier = Modifier.padding(Margin.Medium),
style = ButtonType.SECONDARY,
titleRes = R.string.buttonCopyLink,
onClick = { /* TODO */ },
)
}

Expand Down

0 comments on commit 1c79f46

Please sign in to comment.