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

fix: Use the right BottomSheet when a transfer is expired #162

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import com.infomaniak.swisstransfer.ui.images.illus.ArrowDownRightCurved
import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SwissTransferBottomSheet(
modifier: Modifier = Modifier,
Expand All @@ -55,25 +54,40 @@ fun SwissTransferBottomSheet(
bottomButton: @Composable ((Modifier) -> Unit)? = null,
content: @Composable (() -> Unit)? = null,
) {
ModalBottomSheet(
SwissTransferBottomSheet(
modifier = modifier,
onDismissRequest = onDismissRequest,
) {
BottomSheetContent(
imageVector = imageVector,
titleRes = titleRes,
descriptionRes = descriptionRes,
content = content,
topButton = topButton,
bottomButton = bottomButton,
)
imageVector = imageVector,
title = titleRes?.let { stringResource(titleRes) },
description = descriptionRes?.let { stringResource(descriptionRes) },
topButton = topButton,
bottomButton = bottomButton,
content = content,
)
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SwissTransferBottomSheet(
modifier: Modifier = Modifier,
onDismissRequest: () -> Unit,
imageVector: ImageVector? = null,
title: String? = null,
description: String? = null,
topButton: @Composable ((Modifier) -> Unit)? = null,
bottomButton: @Composable ((Modifier) -> Unit)? = null,
content: @Composable (() -> Unit)? = null,
) {
ModalBottomSheet(onDismissRequest, modifier) {
BottomSheetContent(imageVector, title, description, content, topButton, bottomButton)
}
}

@Composable
private fun BottomSheetContent(
imageVector: ImageVector?,
@StringRes titleRes: Int?,
@StringRes descriptionRes: Int?,
title: String?,
description: String?,
content: @Composable (() -> Unit)?,
topButton: @Composable ((Modifier) -> Unit)? = null,
bottomButton: @Composable ((Modifier) -> Unit)? = null,
Expand All @@ -89,19 +103,19 @@ private fun BottomSheetContent(
Spacer(modifier = Modifier.height(Margin.Large))
}

titleRes?.let {
title?.let {
Text(
text = stringResource(it),
text = it,
style = SwissTransferTheme.typography.bodyMedium,
color = SwissTransferTheme.colors.primaryTextColor,
textAlign = TextAlign.Center,
)
Spacer(modifier = Modifier.height(Margin.Large))
}

descriptionRes?.let {
description?.let {
Text(
text = stringResource(it),
text = it,
style = SwissTransferTheme.typography.bodyRegular,
color = SwissTransferTheme.colors.secondaryTextColor,
)
Expand All @@ -116,6 +130,7 @@ private fun BottomSheetContent(
DoubleButtonCombo(topButton = topButton, bottomButton = bottomButton)
}
}

@Preview
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL)
@Composable
Expand All @@ -124,8 +139,8 @@ private fun BottomSheetDefaultsPreview() {
Surface {
BottomSheetContent(
imageVector = AppIllus.ArrowDownRightCurved,
titleRes = R.string.appName,
descriptionRes = R.string.sentEmptyTitle,
title = stringResource(R.string.appName),
description = stringResource(R.string.sentEmptyTitle),
content = {
Box(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,18 @@
*/
package com.infomaniak.swisstransfer.ui.components.transfer

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import com.infomaniak.core2.FORMAT_DATE_SIMPLE
import com.infomaniak.core2.format
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.components.EmptyState
import com.infomaniak.swisstransfer.ui.components.LargeButton
import com.infomaniak.swisstransfer.ui.components.SwissTransferBottomSheet
import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons
import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus
import com.infomaniak.swisstransfer.ui.images.icons.Bin
import com.infomaniak.swisstransfer.ui.images.illus.mascotDead.MascotDead
import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows
import java.util.Date
Expand Down Expand Up @@ -70,16 +64,10 @@ fun TransferExpiredBottomSheet(
onClick = onDeleteTransferClicked,
)
},
) {
Column {
Spacer(modifier = Modifier.height(Margin.Medium))
EmptyState(
icon = AppIllus.MascotDead.image(),
titleRes = R.string.transferExpiredTitle,
description = descriptionText,
)
}
}
imageVector = AppIllus.MascotDead.image(),
title = stringResource(R.string.transferExpiredTitle),
description = descriptionText,
)
}

@PreviewAllWindows
Expand Down
Loading