From 564aadd7ada2987d2c3ad610db55048f0b21bae2 Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Mon, 18 Nov 2024 10:50:43 +0100 Subject: [PATCH 01/22] add new package --- .../ContractDetailDestination.kt | 1 - .../feature/payments/di/PaymentsModule.kt | 8 +-- .../payments/navigation/PaymentsGraph.kt | 16 +++--- .../details/PaymentDetailExpandableCard.kt | 2 +- .../details/PaymentDetailsDestination.kt | 4 +- .../details/PaymentDetailsViewModel.kt | 2 +- .../discounts/AddDiscountBottomSheet.kt | 2 +- .../{ => ui}/discounts/DiscountRow.kt | 2 +- .../discounts/DiscountsDestination.kt | 4 +- .../{ => ui}/discounts/DiscountsPresenter.kt | 2 +- .../{ => ui}/discounts/DiscountsViewModel.kt | 2 +- .../history/PaymentHistoryDestination.kt | 14 ++--- .../history/PaymentHistoryViewModel.kt | 2 +- .../{ => ui}/payments/PaymentsDestination.kt | 51 ++++++++++++++----- .../{ => ui}/payments/PaymentsPresenter.kt | 8 ++- .../{ => ui}/payments/PaymentsViewModel.kt | 2 +- 16 files changed, 73 insertions(+), 49 deletions(-) rename app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/{ => ui}/details/PaymentDetailExpandableCard.kt (99%) rename app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/{ => ui}/details/PaymentDetailsDestination.kt (99%) rename app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/{ => ui}/details/PaymentDetailsViewModel.kt (97%) rename app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/{ => ui}/discounts/AddDiscountBottomSheet.kt (97%) rename app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/{ => ui}/discounts/DiscountRow.kt (99%) rename app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/{ => ui}/discounts/DiscountsDestination.kt (98%) rename app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/{ => ui}/discounts/DiscountsPresenter.kt (98%) rename app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/{ => ui}/discounts/DiscountsViewModel.kt (91%) rename app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/{ => ui}/history/PaymentHistoryDestination.kt (94%) rename app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/{ => ui}/history/PaymentHistoryViewModel.kt (97%) rename app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/{ => ui}/payments/PaymentsDestination.kt (94%) rename app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/{ => ui}/payments/PaymentsPresenter.kt (94%) rename app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/{ => ui}/payments/PaymentsViewModel.kt (91%) diff --git a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurancedetail/ContractDetailDestination.kt b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurancedetail/ContractDetailDestination.kt index 7d5fc03481..66381110a3 100644 --- a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurancedetail/ContractDetailDestination.kt +++ b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurancedetail/ContractDetailDestination.kt @@ -33,7 +33,6 @@ import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/di/PaymentsModule.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/di/PaymentsModule.kt index ed70a4e53d..e2742bdea4 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/di/PaymentsModule.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/di/PaymentsModule.kt @@ -12,9 +12,6 @@ import com.hedvig.android.feature.payments.data.GetDiscountsUseCase import com.hedvig.android.feature.payments.data.GetDiscountsUseCaseImpl import com.hedvig.android.feature.payments.data.GetPaymentsHistoryUseCase import com.hedvig.android.feature.payments.data.GetPaymentsHistoryUseCaseImpl -import com.hedvig.android.feature.payments.details.PaymentDetailsViewModel -import com.hedvig.android.feature.payments.discounts.DiscountsViewModel -import com.hedvig.android.feature.payments.history.PaymentHistoryViewModel import com.hedvig.android.feature.payments.overview.data.AddDiscountUseCase import com.hedvig.android.feature.payments.overview.data.AddDiscountUseCaseImpl import com.hedvig.android.feature.payments.overview.data.GetForeverInformationUseCase @@ -23,7 +20,10 @@ import com.hedvig.android.feature.payments.overview.data.GetUpcomingPaymentUseCa import com.hedvig.android.feature.payments.overview.data.GetUpcomingPaymentUseCaseDemo import com.hedvig.android.feature.payments.overview.data.GetUpcomingPaymentUseCaseImpl import com.hedvig.android.feature.payments.overview.data.GetUpcomingPaymentUseCaseProvider -import com.hedvig.android.feature.payments.payments.PaymentsViewModel +import com.hedvig.android.feature.payments.ui.details.PaymentDetailsViewModel +import com.hedvig.android.feature.payments.ui.discounts.DiscountsViewModel +import com.hedvig.android.feature.payments.ui.history.PaymentHistoryViewModel +import com.hedvig.android.feature.payments.ui.payments.PaymentsViewModel import com.hedvig.android.market.MarketManager import kotlinx.datetime.Clock import org.koin.core.module.dsl.viewModel diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/navigation/PaymentsGraph.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/navigation/PaymentsGraph.kt index 157ebe0dfb..329adbd031 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/navigation/PaymentsGraph.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/navigation/PaymentsGraph.kt @@ -4,14 +4,14 @@ import androidx.navigation.NavGraphBuilder import androidx.navigation.navDeepLink import com.hedvig.android.core.buildconstants.HedvigBuildConstants import com.hedvig.android.core.designsystem.material3.motion.MotionDefaults -import com.hedvig.android.feature.payments.details.PaymentDetailsDestination -import com.hedvig.android.feature.payments.details.PaymentDetailsViewModel -import com.hedvig.android.feature.payments.discounts.DiscountsDestination -import com.hedvig.android.feature.payments.discounts.DiscountsViewModel -import com.hedvig.android.feature.payments.history.PaymentHistoryDestination -import com.hedvig.android.feature.payments.history.PaymentHistoryViewModel -import com.hedvig.android.feature.payments.payments.PaymentsDestination -import com.hedvig.android.feature.payments.payments.PaymentsViewModel +import com.hedvig.android.feature.payments.ui.details.PaymentDetailsDestination +import com.hedvig.android.feature.payments.ui.details.PaymentDetailsViewModel +import com.hedvig.android.feature.payments.ui.discounts.DiscountsDestination +import com.hedvig.android.feature.payments.ui.discounts.DiscountsViewModel +import com.hedvig.android.feature.payments.ui.history.PaymentHistoryDestination +import com.hedvig.android.feature.payments.ui.history.PaymentHistoryViewModel +import com.hedvig.android.feature.payments.ui.payments.PaymentsDestination +import com.hedvig.android.feature.payments.ui.payments.PaymentsViewModel import com.hedvig.android.language.LanguageService import com.hedvig.android.navigation.compose.navdestination import com.hedvig.android.navigation.compose.navgraph diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/details/PaymentDetailExpandableCard.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailExpandableCard.kt similarity index 99% rename from app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/details/PaymentDetailExpandableCard.kt rename to app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailExpandableCard.kt index a02e3c0eb1..a4c6488950 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/details/PaymentDetailExpandableCard.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailExpandableCard.kt @@ -1,4 +1,4 @@ -package com.hedvig.android.feature.payments.details +package com.hedvig.android.feature.payments.ui.details import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.expandVertically diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/details/PaymentDetailsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt similarity index 99% rename from app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/details/PaymentDetailsDestination.kt rename to app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt index d02d12f6e6..d0de4abe56 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/details/PaymentDetailsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt @@ -1,4 +1,4 @@ -package com.hedvig.android.feature.payments.details +package com.hedvig.android.feature.payments.ui.details import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -62,9 +62,9 @@ import com.hedvig.android.feature.payments.chargeHistoryPreviewData import com.hedvig.android.feature.payments.data.MemberCharge import com.hedvig.android.feature.payments.data.PaymentConnection import com.hedvig.android.feature.payments.data.PaymentDetails -import com.hedvig.android.feature.payments.discounts.DiscountRows import com.hedvig.android.feature.payments.paymentDetailsPreviewData import com.hedvig.android.feature.payments.paymentOverViewPreviewData +import com.hedvig.android.feature.payments.ui.discounts.DiscountRows import hedvig.resources.R import kotlinx.datetime.toJavaLocalDate diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/details/PaymentDetailsViewModel.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsViewModel.kt similarity index 97% rename from app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/details/PaymentDetailsViewModel.kt rename to app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsViewModel.kt index 98a9072573..2d1d4f2785 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/details/PaymentDetailsViewModel.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsViewModel.kt @@ -1,4 +1,4 @@ -package com.hedvig.android.feature.payments.details +package com.hedvig.android.feature.payments.ui.details import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/discounts/AddDiscountBottomSheet.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheet.kt similarity index 97% rename from app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/discounts/AddDiscountBottomSheet.kt rename to app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheet.kt index d459deb128..7b267609ee 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/discounts/AddDiscountBottomSheet.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheet.kt @@ -1,4 +1,4 @@ -package com.hedvig.android.feature.payments.discounts +package com.hedvig.android.feature.payments.ui.discounts import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/discounts/DiscountRow.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt similarity index 99% rename from app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/discounts/DiscountRow.kt rename to app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt index ed97c667f4..ecf3f8a0e2 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/discounts/DiscountRow.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt @@ -1,4 +1,4 @@ -package com.hedvig.android.feature.payments.discounts +package com.hedvig.android.feature.payments.ui.discounts import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/discounts/DiscountsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt similarity index 98% rename from app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/discounts/DiscountsDestination.kt rename to app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt index 3a44d0a114..8f14120d42 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/discounts/DiscountsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt @@ -1,4 +1,4 @@ -package com.hedvig.android.feature.payments.discounts +package com.hedvig.android.feature.payments.ui.discounts import android.content.ClipData import android.content.ClipboardManager @@ -279,7 +279,7 @@ private fun ForeverSection( @HedvigPreview private fun PaymentDetailsScreenPreview( @PreviewParameter( - com.hedvig.android.compose.ui.preview.BooleanCollectionPreviewParameterProvider::class, + BooleanCollectionPreviewParameterProvider::class, ) hasForeverAndDiscounts: Boolean, ) { HedvigTheme { diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/discounts/DiscountsPresenter.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsPresenter.kt similarity index 98% rename from app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/discounts/DiscountsPresenter.kt rename to app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsPresenter.kt index 9cf24910f9..5ec5ff654c 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/discounts/DiscountsPresenter.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsPresenter.kt @@ -1,4 +1,4 @@ -package com.hedvig.android.feature.payments.discounts +package com.hedvig.android.feature.payments.ui.discounts import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/discounts/DiscountsViewModel.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsViewModel.kt similarity index 91% rename from app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/discounts/DiscountsViewModel.kt rename to app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsViewModel.kt index d4be89619c..8dd165ec79 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/discounts/DiscountsViewModel.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsViewModel.kt @@ -1,4 +1,4 @@ -package com.hedvig.android.feature.payments.discounts +package com.hedvig.android.feature.payments.ui.discounts import com.hedvig.android.feature.payments.data.GetDiscountsOverviewUseCase import com.hedvig.android.feature.payments.overview.data.AddDiscountUseCase diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/history/PaymentHistoryDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt similarity index 94% rename from app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/history/PaymentHistoryDestination.kt rename to app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt index 590ece9402..e34625b9c9 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/history/PaymentHistoryDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt @@ -1,4 +1,4 @@ -package com.hedvig.android.feature.payments.history +package com.hedvig.android.feature.payments.ui.history import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Spacer @@ -20,6 +20,8 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.hedvig.android.compose.ui.preview.TripleBooleanCollectionPreviewParameterProvider +import com.hedvig.android.compose.ui.preview.TripleCase import com.hedvig.android.core.designsystem.component.error.HedvigErrorSection import com.hedvig.android.core.designsystem.component.information.HedvigInformationSection import com.hedvig.android.core.designsystem.component.progress.HedvigFullScreenCenterAlignedProgress @@ -206,8 +208,8 @@ private fun PaymentHistory.PastCharges.YearCharges.Charge.color(): Color { @HedvigPreview internal fun PaymentHistoryScreenPreview( @PreviewParameter( - com.hedvig.android.compose.ui.preview.TripleBooleanCollectionPreviewParameterProvider::class, - ) cases: com.hedvig.android.compose.ui.preview.TripleCase, + TripleBooleanCollectionPreviewParameterProvider::class, + ) cases: TripleCase, ) { HedvigTheme { Surface(color = MaterialTheme.colorScheme.background) { @@ -223,8 +225,8 @@ internal fun PaymentHistoryScreenPreview( } PaymentHistorySuccessScreen( paymentHistory = when (cases) { - com.hedvig.android.compose.ui.preview.TripleCase.FIRST -> PaymentHistory.NoHistoryData - com.hedvig.android.compose.ui.preview.TripleCase.SECOND -> PaymentHistory.PastCharges( + TripleCase.FIRST -> PaymentHistory.NoHistoryData + TripleCase.SECOND -> PaymentHistory.PastCharges( listOf( PaymentHistory.PastCharges.YearCharges( year = 2021, @@ -234,7 +236,7 @@ internal fun PaymentHistoryScreenPreview( false, ) - com.hedvig.android.compose.ui.preview.TripleCase.THIRD -> PaymentHistory.PastCharges( + TripleCase.THIRD -> PaymentHistory.PastCharges( List(3) { PaymentHistory.PastCharges.YearCharges( year = 2021 + it, diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/history/PaymentHistoryViewModel.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryViewModel.kt similarity index 97% rename from app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/history/PaymentHistoryViewModel.kt rename to app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryViewModel.kt index f9bb197cfc..eec4f549d3 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/history/PaymentHistoryViewModel.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryViewModel.kt @@ -1,4 +1,4 @@ -package com.hedvig.android.feature.payments.history +package com.hedvig.android.feature.payments.ui.history import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/payments/PaymentsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt similarity index 94% rename from app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/payments/PaymentsDestination.kt rename to app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt index 1a321a05c5..d324382df6 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/payments/PaymentsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt @@ -1,4 +1,4 @@ -package com.hedvig.android.feature.payments.payments +package com.hedvig.android.feature.payments.ui.payments import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.core.MutableTransitionState @@ -70,11 +70,11 @@ import com.hedvig.android.core.ui.text.HorizontalItemsWithMaximumSpaceTaken import com.hedvig.android.core.uidata.UiCurrencyCode import com.hedvig.android.core.uidata.UiMoney import com.hedvig.android.design.system.hedvig.HedvigTheme -import com.hedvig.android.feature.payments.payments.PaymentsUiState.Content.ConnectedPaymentInfo.Connected -import com.hedvig.android.feature.payments.payments.PaymentsUiState.Content.ConnectedPaymentInfo.NotConnected -import com.hedvig.android.feature.payments.payments.PaymentsUiState.Content.ConnectedPaymentInfo.Pending -import com.hedvig.android.feature.payments.payments.PaymentsUiState.Content.UpcomingPayment -import com.hedvig.android.feature.payments.payments.PaymentsUiState.Content.UpcomingPaymentInfo +import com.hedvig.android.feature.payments.ui.payments.PaymentsUiState.Content.ConnectedPaymentInfo.Connected +import com.hedvig.android.feature.payments.ui.payments.PaymentsUiState.Content.ConnectedPaymentInfo.NotConnected +import com.hedvig.android.feature.payments.ui.payments.PaymentsUiState.Content.ConnectedPaymentInfo.Pending +import com.hedvig.android.feature.payments.ui.payments.PaymentsUiState.Content.UpcomingPayment +import com.hedvig.android.feature.payments.ui.payments.PaymentsUiState.Content.UpcomingPaymentInfo import com.hedvig.android.placeholder.PlaceholderHighlight import com.hedvig.android.placeholder.placeholder import com.hedvig.android.placeholder.shimmer @@ -510,7 +510,11 @@ private class PaymentsStatePreviewProvider : CollectionPreviewParameterProvider< isRetrying = false, upcomingPayment = UpcomingPayment.NoUpcomingPayment, upcomingPaymentInfo = UpcomingPaymentInfo.NoInfo, - connectedPaymentInfo = Connected("Card", "****1234", true), + connectedPaymentInfo = Connected( + "Card", + "****1234", + true, + ), ), ) add( @@ -522,7 +526,11 @@ private class PaymentsStatePreviewProvider : CollectionPreviewParameterProvider< "rdg", ), upcomingPaymentInfo = UpcomingPaymentInfo.NoInfo, - connectedPaymentInfo = Connected("Card", "****1234", true), + connectedPaymentInfo = Connected( + "Card", + "****1234", + true, + ), ), ) add( @@ -534,7 +542,11 @@ private class PaymentsStatePreviewProvider : CollectionPreviewParameterProvider< "iky", ), upcomingPaymentInfo = UpcomingPaymentInfo.InProgress, - connectedPaymentInfo = Connected("Card", "****1234", true), + connectedPaymentInfo = Connected( + "Card", + "****1234", + true, + ), ), ) add( @@ -549,7 +561,11 @@ private class PaymentsStatePreviewProvider : CollectionPreviewParameterProvider< Clock.System.now().toLocalDateTime(TimeZone.UTC).date, Clock.System.now().minus(30.days).toLocalDateTime(TimeZone.UTC).date, ), - connectedPaymentInfo = Connected("Card", "****1234", true), + connectedPaymentInfo = Connected( + "Card", + "****1234", + true, + ), ), ) add( @@ -573,7 +589,10 @@ private class PaymentsStatePreviewProvider : CollectionPreviewParameterProvider< "qrdfgeth", ), upcomingPaymentInfo = UpcomingPaymentInfo.NoInfo, - connectedPaymentInfo = NotConnected(null, true), + connectedPaymentInfo = NotConnected( + null, + true, + ), ), ) add( @@ -585,7 +604,10 @@ private class PaymentsStatePreviewProvider : CollectionPreviewParameterProvider< "qrdfgeth2", ), upcomingPaymentInfo = UpcomingPaymentInfo.NoInfo, - connectedPaymentInfo = NotConnected(null, false), + connectedPaymentInfo = NotConnected( + null, + false, + ), ), ) add( @@ -600,7 +622,10 @@ private class PaymentsStatePreviewProvider : CollectionPreviewParameterProvider< Clock.System.now().toLocalDateTime(TimeZone.UTC).date, Clock.System.now().minus(30.days).toLocalDateTime(TimeZone.UTC).date, ), - connectedPaymentInfo = NotConnected(null, true), + connectedPaymentInfo = NotConnected( + null, + true, + ), ), ) add( diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/payments/PaymentsPresenter.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsPresenter.kt similarity index 94% rename from app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/payments/PaymentsPresenter.kt rename to app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsPresenter.kt index 15f93d2331..6f71212cb9 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/payments/PaymentsPresenter.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsPresenter.kt @@ -1,4 +1,4 @@ -package com.hedvig.android.feature.payments.payments +package com.hedvig.android.feature.payments.ui.payments import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -15,8 +15,6 @@ import com.hedvig.android.feature.payments.data.PaymentConnection.NeedsSetup import com.hedvig.android.feature.payments.data.PaymentConnection.Pending import com.hedvig.android.feature.payments.data.PaymentConnection.Unknown import com.hedvig.android.feature.payments.overview.data.GetUpcomingPaymentUseCase -import com.hedvig.android.feature.payments.payments.PaymentsUiState.Content.ConnectedPaymentInfo -import com.hedvig.android.feature.payments.payments.PaymentsUiState.Content.ConnectedPaymentInfo.Connected import com.hedvig.android.market.Market import com.hedvig.android.market.MarketManager import com.hedvig.android.molecule.public.MoleculePresenter @@ -78,13 +76,13 @@ internal class PaymentsPresenter( PaymentsUiState.Content.UpcomingPaymentInfo.NoInfo }, connectedPaymentInfo = when (val paymentConnection = paymentOverview.paymentConnection) { - is Active -> Connected( + is Active -> PaymentsUiState.Content.ConnectedPaymentInfo.Connected( displayName = paymentConnection.displayName, maskedAccountNumber = paymentConnection.displayValue, allowChangingConnectedBankAccount = allowChangingConnectedBankAccount, ) - Pending -> ConnectedPaymentInfo.Pending + Pending -> PaymentsUiState.Content.ConnectedPaymentInfo.Pending NeedsSetup, Unknown, null, diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/payments/PaymentsViewModel.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsViewModel.kt similarity index 91% rename from app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/payments/PaymentsViewModel.kt rename to app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsViewModel.kt index dc08030338..424b2e24aa 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/payments/PaymentsViewModel.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsViewModel.kt @@ -1,4 +1,4 @@ -package com.hedvig.android.feature.payments.payments +package com.hedvig.android.feature.payments.ui.payments import com.hedvig.android.core.demomode.Provider import com.hedvig.android.feature.payments.overview.data.GetUpcomingPaymentUseCase From 84325dbe96228235da53ba061d8be51ec5c04db0 Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Mon, 18 Nov 2024 10:53:03 +0100 Subject: [PATCH 02/22] fix lint cannot determine the type --- .../feature/payments/ui/history/PaymentHistoryDestination.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt index e34625b9c9..9258d74f3a 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt @@ -75,7 +75,7 @@ private fun PaymentHistoryScreen( val (paymentHistory: PaymentHistory, onChargeClickedAfterTransform: (String) -> Unit) = remember(uiState.paymentHistory) { if (uiState.paymentHistory.isEmpty()) { - PaymentHistory.NoHistoryData to { _ -> } + PaymentHistory.NoHistoryData to { s: String -> } } else { PaymentHistory.PastCharges( chargesInYear = uiState.paymentHistory.sortedBy { it.dueDate }.groupBy { it.dueDate.year } From 966b1930eb53c9c9a9b2b709185fb90376949e8c Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Mon, 18 Nov 2024 12:03:12 +0100 Subject: [PATCH 03/22] paymentsDestination, in prod --- .../system/hedvig/HedvigInformationSection.kt | 44 +++ .../design/system/hedvig/icon/Clock.kt | 1 + .../ContractDetailDestination.kt | 1 - app/feature/feature-payments/build.gradle.kts | 5 +- .../payments/navigation/PaymentsGraph.kt | 2 +- .../ui/details/PaymentDetailExpandableCard.kt | 61 ++-- .../ui/discounts/DiscountsDestination.kt | 75 ++--- .../ui/payments/PaymentsDestination.kt | 262 +++++++++--------- 8 files changed, 247 insertions(+), 204 deletions(-) create mode 100644 app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigInformationSection.kt diff --git a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigInformationSection.kt b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigInformationSection.kt new file mode 100644 index 0000000000..ddeacfb2cc --- /dev/null +++ b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigInformationSection.kt @@ -0,0 +1,44 @@ +package com.hedvig.android.design.system.hedvig + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.safeDrawing +import androidx.compose.foundation.layout.windowInsetsPadding +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import com.hedvig.android.design.system.hedvig.EmptyStateDefaults.EmptyStateButtonStyle.NoButton +import hedvig.resources.R + +@Composable +fun HedvigInformationSection( + title: String, + modifier: Modifier = Modifier, + subTitle: String? = null, + onButtonClick: (() -> Unit)? = null, + buttonText: String = stringResource(id = R.string.ALERT_OK), + windowInsets: WindowInsets = WindowInsets.safeDrawing, +) { + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Center, + modifier = modifier + .windowInsetsPadding(windowInsets) + .padding(horizontal = 16.dp), + ) { + val buttonStyle = if (onButtonClick!=null) EmptyStateDefaults.EmptyStateButtonStyle.Button( + buttonText = buttonText, + onButtonClick = onButtonClick, + ) else NoButton + EmptyState( + text = title, + description = subTitle, + iconStyle = EmptyStateDefaults.EmptyStateIconStyle.INFO, + buttonStyle = buttonStyle, + ) + } +} diff --git a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/icon/Clock.kt b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/icon/Clock.kt index ba07146072..c833f09d91 100644 --- a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/icon/Clock.kt +++ b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/icon/Clock.kt @@ -17,6 +17,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.hedvig.android.design.system.hedvig.HedvigTheme +//Icons.Hedvig.Waiting in the old DS @Suppress("UnusedReceiverParameter") val HedvigIcons.Clock: ImageVector get() { diff --git a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurancedetail/ContractDetailDestination.kt b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurancedetail/ContractDetailDestination.kt index 66381110a3..c1b1d02d98 100644 --- a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurancedetail/ContractDetailDestination.kt +++ b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurancedetail/ContractDetailDestination.kt @@ -35,7 +35,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope -import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource diff --git a/app/feature/feature-payments/build.gradle.kts b/app/feature/feature-payments/build.gradle.kts index ea1af79e60..13cb22f6fe 100644 --- a/app/feature/feature-payments/build.gradle.kts +++ b/app/feature/feature-payments/build.gradle.kts @@ -15,6 +15,7 @@ android { dependencies { implementation(libs.androidx.compose.runtime) + implementation(libs.androidx.compose.foundation) implementation(libs.androidx.lifecycle.compose) implementation(libs.apollo.normalizedCache) implementation(libs.apollo.runtime) @@ -33,10 +34,7 @@ dependencies { implementation(projects.coreCommonPublic) implementation(projects.coreDatastorePublic) implementation(projects.coreDemoMode) - implementation(projects.coreDesignSystem) - implementation(projects.coreIcons) implementation(projects.coreResources) - implementation(projects.coreUi) implementation(projects.coreUiData) implementation(projects.dataContractAndroid) implementation(projects.dataContractPublic) @@ -56,7 +54,6 @@ dependencies { implementation(projects.navigationComposeTyped) implementation(projects.navigationCore) implementation(projects.notificationPermission) - implementation(projects.placeholder) implementation(projects.pullrefresh) implementation(projects.theme) testImplementation(libs.coroutines.test) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/navigation/PaymentsGraph.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/navigation/PaymentsGraph.kt index 329adbd031..6462e30e45 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/navigation/PaymentsGraph.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/navigation/PaymentsGraph.kt @@ -3,7 +3,7 @@ package com.hedvig.android.feature.payments.navigation import androidx.navigation.NavGraphBuilder import androidx.navigation.navDeepLink import com.hedvig.android.core.buildconstants.HedvigBuildConstants -import com.hedvig.android.core.designsystem.material3.motion.MotionDefaults +import com.hedvig.android.design.system.hedvig.MotionDefaults import com.hedvig.android.feature.payments.ui.details.PaymentDetailsDestination import com.hedvig.android.feature.payments.ui.details.PaymentDetailsViewModel import com.hedvig.android.feature.payments.ui.discounts.DiscountsDestination diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailExpandableCard.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailExpandableCard.kt index a4c6488950..89a1ae4fe9 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailExpandableCard.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailExpandableCard.kt @@ -14,13 +14,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width -import androidx.compose.material.icons.Icons -import androidx.compose.material3.HorizontalDivider -import androidx.compose.material3.Icon -import androidx.compose.material3.LocalContentColor -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface -import androidx.compose.material3.Text + import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment @@ -29,15 +23,20 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import com.hedvig.android.core.designsystem.component.card.HedvigCard -import com.hedvig.android.core.designsystem.preview.HedvigPreview -import com.hedvig.android.core.designsystem.theme.HedvigTheme -import com.hedvig.android.core.icons.Hedvig -import com.hedvig.android.core.icons.hedvig.normal.ChevronDown -import com.hedvig.android.core.ui.rememberHedvigMonthDateTimeFormatter -import com.hedvig.android.core.ui.text.HorizontalItemsWithMaximumSpaceTaken import com.hedvig.android.core.uidata.UiCurrencyCode import com.hedvig.android.core.uidata.UiMoney +import com.hedvig.android.design.system.hedvig.HedvigCard +import com.hedvig.android.design.system.hedvig.HedvigPreview +import com.hedvig.android.design.system.hedvig.HedvigText +import com.hedvig.android.design.system.hedvig.HedvigTheme +import com.hedvig.android.design.system.hedvig.HorizontalDivider +import com.hedvig.android.design.system.hedvig.HorizontalItemsWithMaximumSpaceTaken +import com.hedvig.android.design.system.hedvig.Icon +import com.hedvig.android.design.system.hedvig.LocalContentColor +import com.hedvig.android.design.system.hedvig.Surface +import com.hedvig.android.design.system.hedvig.datepicker.rememberHedvigMonthDateTimeFormatter +import com.hedvig.android.design.system.hedvig.icon.ChevronDown +import com.hedvig.android.design.system.hedvig.icon.HedvigIcons import com.hedvig.android.design.system.hedvig.ripple import com.hedvig.android.feature.payments.data.MemberCharge import hedvig.resources.R @@ -74,7 +73,7 @@ internal fun PaymentDetailExpandableCard( ), ) { HorizontalItemsWithMaximumSpaceTaken( - startSlot = { Text(displayName) }, + startSlot = { HedvigText(displayName) }, spaceBetween = 8.dp, endSlot = { Row( @@ -82,23 +81,23 @@ internal fun PaymentDetailExpandableCard( horizontalArrangement = Arrangement.End, verticalAlignment = Alignment.CenterVertically, ) { - Text( + HedvigText( text = totalAmount, textAlign = TextAlign.End, ) Spacer(Modifier.width(4.dp)) Icon( - imageVector = Icons.Hedvig.ChevronDown, + imageVector = HedvigIcons.ChevronDown, contentDescription = null, - tint = MaterialTheme.colorScheme.onSurfaceVariant, + tint = HedvigTheme.colorScheme.fillSecondary, modifier = Modifier.size(16.dp), ) } }, ) - Text( + HedvigText( text = subtitle, - color = MaterialTheme.colorScheme.onSurfaceVariant, + color = HedvigTheme.colorScheme.textSecondary, ) AnimatedVisibility( visible = isExpanded, @@ -111,7 +110,7 @@ internal fun PaymentDetailExpandableCard( HorizontalItemsWithMaximumSpaceTaken( startSlot = { - Text( + HedvigText( text = it.toString(dateTimeFormatter), color = it.toColor(), ) @@ -122,7 +121,7 @@ internal fun PaymentDetailExpandableCard( horizontalArrangement = Arrangement.End, verticalAlignment = Alignment.CenterVertically, ) { - Text( + HedvigText( text = it.amount.toString(), textAlign = TextAlign.End, color = it.toSubtitleColor(), @@ -131,9 +130,9 @@ internal fun PaymentDetailExpandableCard( }, ) if (it.isPreviouslyFailedCharge) { - Text( + HedvigText( text = stringResource(id = R.string.PAYMENTS_OUTSTANDING_PAYMENT), - style = MaterialTheme.typography.labelMedium, + style = HedvigTheme.typography.label, //todo: check here! color = it.toSubtitleColor(), ) } @@ -145,7 +144,7 @@ internal fun PaymentDetailExpandableCard( Row { HorizontalItemsWithMaximumSpaceTaken( startSlot = { - Text(stringResource(id = R.string.PAYMENTS_SUBTOTAL)) + HedvigText(stringResource(id = R.string.PAYMENTS_SUBTOTAL)) }, endSlot = { Row( @@ -153,7 +152,7 @@ internal fun PaymentDetailExpandableCard( horizontalArrangement = Arrangement.End, verticalAlignment = Alignment.CenterVertically, ) { - Text( + HedvigText( text = totalAmount, textAlign = TextAlign.End, ) @@ -177,7 +176,7 @@ private fun MemberCharge.ChargeBreakdown.Period.toString(dateTimeFormatter: Date @Composable private fun MemberCharge.ChargeBreakdown.Period.toColor(): Color { return if (isPreviouslyFailedCharge) { - MaterialTheme.colorScheme.error + HedvigTheme.colorScheme.signalRedText //todo: check here! } else { LocalContentColor.current } @@ -186,9 +185,9 @@ private fun MemberCharge.ChargeBreakdown.Period.toColor(): Color { @Composable private fun MemberCharge.ChargeBreakdown.Period.toSubtitleColor(): Color { return if (isPreviouslyFailedCharge) { - MaterialTheme.colorScheme.error + HedvigTheme.colorScheme.signalRedText //todo: check here! } else { - MaterialTheme.colorScheme.onSurfaceVariant + HedvigTheme.colorScheme.textSecondary } } @@ -196,7 +195,7 @@ private fun MemberCharge.ChargeBreakdown.Period.toSubtitleColor(): Color { @HedvigPreview private fun PaymentDetailExpandableCardPreview() { HedvigTheme { - Surface(color = MaterialTheme.colorScheme.background) { + Surface(color = HedvigTheme.colorScheme.backgroundPrimary) { PaymentDetailExpandableCard( displayName = "Bilförsäkring", subtitle = "ABH 234", @@ -238,7 +237,7 @@ private fun PaymentDetailExpandableCardPreview() { @HedvigPreview private fun PaymentDetailExpandableCardExpandedPreview() { HedvigTheme { - Surface(color = MaterialTheme.colorScheme.background) { + Surface(color = HedvigTheme.colorScheme.backgroundPrimary) { PaymentDetailExpandableCard( displayName = "Bilförsäkring", subtitle = "ABH 234", diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt index 8f14120d42..439701d69c 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt @@ -65,6 +65,22 @@ import com.hedvig.android.core.ui.scaffold.HedvigScaffold import com.hedvig.android.core.ui.text.HorizontalItemsWithMaximumSpaceTaken import com.hedvig.android.core.uidata.UiCurrencyCode import com.hedvig.android.core.uidata.UiMoney +import com.hedvig.android.design.system.hedvig.ButtonDefaults.ButtonStyle +import com.hedvig.android.design.system.hedvig.HedvigButton +import com.hedvig.android.design.system.hedvig.HedvigCard +import com.hedvig.android.design.system.hedvig.HedvigNotificationCard +import com.hedvig.android.design.system.hedvig.HedvigPreview +import com.hedvig.android.design.system.hedvig.HedvigScaffold +import com.hedvig.android.design.system.hedvig.HedvigText +import com.hedvig.android.design.system.hedvig.HedvigTheme +import com.hedvig.android.design.system.hedvig.HorizontalItemsWithMaximumSpaceTaken +import com.hedvig.android.design.system.hedvig.Icon +import com.hedvig.android.design.system.hedvig.NotificationDefaults +import com.hedvig.android.design.system.hedvig.Surface +import com.hedvig.android.design.system.hedvig.icon.Campaign +import com.hedvig.android.design.system.hedvig.icon.HedvigIcons +import com.hedvig.android.design.system.hedvig.icon.InfoFilled +import com.hedvig.android.design.system.hedvig.minimumInteractiveComponentSize import com.hedvig.android.feature.payments.data.Discount import com.hedvig.android.feature.payments.overview.data.ForeverInformation import hedvig.resources.R @@ -132,17 +148,17 @@ private fun DiscountsScreen( Spacer(modifier = Modifier.height(16.dp)) HorizontalItemsWithMaximumSpaceTaken( startSlot = { - Text(stringResource(id = R.string.PAYMENTS_CAMPAIGNS_INFO_TITLE)) + HedvigText(stringResource(id = R.string.PAYMENTS_CAMPAIGNS_INFO_TITLE)) }, endSlot = { Icon( - imageVector = Icons.Hedvig.InfoFilled, - tint = MaterialTheme.colorScheme.onSurfaceVariant, + imageVector = HedvigIcons.InfoFilled, + tint = HedvigTheme.colorScheme.fillSecondary, contentDescription = "Info icon", modifier = Modifier .wrapContentSize(Alignment.CenterEnd) .size(16.dp) - .clip(MaterialTheme.shapes.squircleLarge) + .clip(HedvigTheme.shapes.cornerLarge) .clickable { showInfoBottomSheet = true } .minimumInteractiveComponentSize(), ) @@ -152,9 +168,9 @@ private fun DiscountsScreen( val discounts = uiState.discounts if (discounts.isEmpty()) { Spacer(modifier = Modifier.height(16.dp)) - Text( + HedvigText( text = stringResource(id = R.string.PAYMENTS_NO_CAMPAIGN_CODE_ADDED), - color = MaterialTheme.colorScheme.onSurfaceVariant, + color = HedvigTheme.colorScheme.textSecondary, ) } else { Spacer(modifier = Modifier.height(16.dp)) @@ -162,7 +178,9 @@ private fun DiscountsScreen( } Spacer(modifier = Modifier.height(16.dp)) - HedvigSecondaryContainedButton( + HedvigButton( + buttonStyle = ButtonStyle.Secondary, + enabled = true, text = stringResource(id = R.string.PAYMENTS_ADD_CAMPAIGN_CODE), onClick = { onShowBottomSheet() }, ) @@ -196,20 +214,20 @@ private fun ForeverSection( } HorizontalItemsWithMaximumSpaceTaken( startSlot = { - Text( + HedvigText( stringResource(R.string.PAYMENTS_REFERRALS_INFO_TITLE), modifier = Modifier.wrapContentSize(Alignment.CenterStart), ) }, endSlot = { Icon( - imageVector = Icons.Hedvig.InfoFilled, - tint = MaterialTheme.colorScheme.onSurfaceVariant, + imageVector = HedvigIcons.InfoFilled, + tint = HedvigTheme.colorScheme.fillSecondary, contentDescription = null, modifier = Modifier .wrapContentSize(Alignment.CenterEnd) .size(16.dp) - .clip(MaterialTheme.shapes.squircleLarge) + .clip(HedvigTheme.shapes.cornerLarge) .clickable { showForeverInfoBottomSheet = true } .minimumInteractiveComponentSize(), ) @@ -220,11 +238,6 @@ private fun ForeverSection( HorizontalItemsWithMaximumSpaceTaken( startSlot = { HedvigCard( - colors = CardDefaults.cardColors( - containerColor = MaterialTheme.colorScheme.secondaryContainedButtonContainer, - contentColor = MaterialTheme.colorScheme.onSecondaryContainedButtonContainer, - ), - shape = MaterialTheme.shapes.squircleSmall, onClick = { context.getSystemService()?.setPrimaryClip( ClipData.newPlainText(null, foreverInformation.foreverCode), @@ -232,9 +245,9 @@ private fun ForeverSection( }, modifier = Modifier.wrapContentSize(Alignment.TopStart), ) { - Text( + HedvigText( text = foreverInformation.foreverCode, - style = MaterialTheme.typography.bodyMedium, + style = HedvigTheme.typography.bodySmall, modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp), ) } @@ -244,7 +257,7 @@ private fun ForeverSection( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.End, ) { - Text( + HedvigText( stringResource( R.string.OFFER_COST_AND_PREMIUM_PERIOD_ABBREVIATION, "-${foreverInformation.currentMonthlyDiscountFromForever}", @@ -256,21 +269,13 @@ private fun ForeverSection( spaceBetween = 8.dp, ) Spacer(modifier = Modifier.height(16.dp)) - VectorInfoCard( - text = stringResource(R.string.PAYMENTS_REFERRALS_INFO_DESCRIPTION), - iconColor = MaterialTheme.colorScheme.typeElement, - icon = Icons.Hedvig.Campaign, - colors = CardDefaults.outlinedCardColors( - containerColor = MaterialTheme.colorScheme.typeContainer, - contentColor = MaterialTheme.colorScheme.onTypeContainer, - ), - underTextContent = { - InfoCardTextButton( - modifier = Modifier.fillMaxWidth(), - text = stringResource(R.string.important_message_read_more), - onClick = navigateToForever, - ) - }, + HedvigNotificationCard( + message = stringResource(R.string.PAYMENTS_REFERRALS_INFO_DESCRIPTION), + priority = NotificationDefaults.NotificationPriority.Campaign, + style = NotificationDefaults.InfoCardStyle.Button( + buttonText = stringResource(R.string.important_message_read_more), + onButtonClick = navigateToForever, + ) ) } } @@ -283,7 +288,7 @@ private fun PaymentDetailsScreenPreview( ) hasForeverAndDiscounts: Boolean, ) { HedvigTheme { - Surface(color = MaterialTheme.colorScheme.background) { + Surface(color = HedvigTheme.colorScheme.backgroundPrimary) { DiscountsScreen( uiState = DiscountsUiState( discounts = if (hasForeverAndDiscounts) { diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt index d324382df6..502683d28d 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt @@ -21,24 +21,15 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.systemBars import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.windowInsetsPadding +import androidx.compose.foundation.layout.windowInsetsTopHeight import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.icons.Icons -import androidx.compose.material3.ButtonDefaults -import androidx.compose.material3.HorizontalDivider -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface -import androidx.compose.material3.Text -import androidx.compose.material3.TopAppBar -import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign @@ -47,37 +38,37 @@ import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameter import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.hedvig.android.core.common.safeCast -import com.hedvig.android.core.designsystem.component.button.HedvigContainedSmallButton -import com.hedvig.android.core.designsystem.component.button.HedvigSecondaryContainedButton -import com.hedvig.android.core.designsystem.component.card.HedvigCard -import com.hedvig.android.core.designsystem.component.error.HedvigErrorSection -import com.hedvig.android.core.designsystem.component.information.HedvigInformationSection -import com.hedvig.android.core.designsystem.material3.containedButtonContainer -import com.hedvig.android.core.designsystem.material3.onContainedButtonContainer -import com.hedvig.android.core.designsystem.material3.typeElement -import com.hedvig.android.core.designsystem.preview.HedvigPreview -import com.hedvig.android.core.icons.Hedvig -import com.hedvig.android.core.icons.hedvig.normal.ChevronRight -import com.hedvig.android.core.icons.hedvig.normal.CreditCard -import com.hedvig.android.core.icons.hedvig.normal.Waiting -import com.hedvig.android.core.icons.hedvig.small.hedvig.Campaign -import com.hedvig.android.core.ui.infocard.VectorErrorCard -import com.hedvig.android.core.ui.infocard.VectorInfoCard -import com.hedvig.android.core.ui.infocard.VectorWarningCard -import com.hedvig.android.core.ui.rememberHedvigDateTimeFormatter -import com.hedvig.android.core.ui.rememberHedvigMonthDateTimeFormatter -import com.hedvig.android.core.ui.text.HorizontalItemsWithMaximumSpaceTaken import com.hedvig.android.core.uidata.UiCurrencyCode import com.hedvig.android.core.uidata.UiMoney +import com.hedvig.android.design.system.hedvig.ButtonDefaults.ButtonStyle +import com.hedvig.android.design.system.hedvig.HedvigButton +import com.hedvig.android.design.system.hedvig.HedvigCard +import com.hedvig.android.design.system.hedvig.HedvigErrorSection +import com.hedvig.android.design.system.hedvig.HedvigInformationSection +import com.hedvig.android.design.system.hedvig.HedvigNotificationCard +import com.hedvig.android.design.system.hedvig.HedvigPreview +import com.hedvig.android.design.system.hedvig.HedvigText import com.hedvig.android.design.system.hedvig.HedvigTheme +import com.hedvig.android.design.system.hedvig.HorizontalDivider +import com.hedvig.android.design.system.hedvig.HorizontalItemsWithMaximumSpaceTaken +import com.hedvig.android.design.system.hedvig.Icon +import com.hedvig.android.design.system.hedvig.NotificationDefaults +import com.hedvig.android.design.system.hedvig.Surface +import com.hedvig.android.design.system.hedvig.datepicker.rememberHedvigDateTimeFormatter +import com.hedvig.android.design.system.hedvig.datepicker.rememberHedvigMonthDateTimeFormatter +import com.hedvig.android.design.system.hedvig.icon.Campaign +import com.hedvig.android.design.system.hedvig.icon.Card +import com.hedvig.android.design.system.hedvig.icon.ChevronRight +import com.hedvig.android.design.system.hedvig.icon.Clock +import com.hedvig.android.design.system.hedvig.icon.HedvigIcons +import com.hedvig.android.design.system.hedvig.placeholder.PlaceholderHighlight +import com.hedvig.android.design.system.hedvig.placeholder.hedvigPlaceholder +import com.hedvig.android.design.system.hedvig.placeholder.shimmer import com.hedvig.android.feature.payments.ui.payments.PaymentsUiState.Content.ConnectedPaymentInfo.Connected import com.hedvig.android.feature.payments.ui.payments.PaymentsUiState.Content.ConnectedPaymentInfo.NotConnected import com.hedvig.android.feature.payments.ui.payments.PaymentsUiState.Content.ConnectedPaymentInfo.Pending import com.hedvig.android.feature.payments.ui.payments.PaymentsUiState.Content.UpcomingPayment import com.hedvig.android.feature.payments.ui.payments.PaymentsUiState.Content.UpcomingPaymentInfo -import com.hedvig.android.placeholder.PlaceholderHighlight -import com.hedvig.android.placeholder.placeholder -import com.hedvig.android.placeholder.shimmer import com.hedvig.android.pullrefresh.PullRefreshDefaults import com.hedvig.android.pullrefresh.PullRefreshIndicator import com.hedvig.android.pullrefresh.pullRefresh @@ -129,40 +120,46 @@ private fun PaymentsScreen( ) Box( modifier = Modifier - .fillMaxSize() - .pullRefresh(pullRefreshState), + .fillMaxSize() + .pullRefresh(pullRefreshState), ) { - Surface(color = MaterialTheme.colorScheme.background, modifier = Modifier.fillMaxSize()) { - Column(modifier = Modifier.verticalScroll(rememberScrollState())) { - TopAppBar( - title = { - Text( - text = stringResource(R.string.PROFILE_PAYMENT_TITLE), - style = HedvigTheme.typography.headlineSmall, - ) - }, - colors = TopAppBarDefaults.topAppBarColors( - containerColor = Color.Transparent, - ), + Column( + Modifier + .fillMaxSize() + .verticalScroll(rememberScrollState()) + .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), + ) { + Spacer(Modifier.windowInsetsTopHeight(WindowInsets.safeDrawing)) + Row( + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .height(64.dp) + .fillMaxWidth() + .padding(horizontal = 16.dp), + ) { + HedvigText( + text = stringResource(R.string.TAB_REFERRALS_TITLE), + style = HedvigTheme.typography.headlineSmall, ) - Spacer(Modifier.height(8.dp)) - when (uiState) { - PaymentsUiState.Error -> HedvigErrorSection(onButtonClick = onRetry, Modifier.weight(1f)) - else -> { - PaymentsContent( - uiState = uiState, - onUpcomingPaymentClicked = { upcomingPayment -> - onUpcomingPaymentClicked(upcomingPayment.id) - }, - onChangeBankAccount = onChangeBankAccount, - onDiscountClicked = onDiscountClicked, - onPaymentHistoryClicked = onPaymentHistoryClicked, - ) - Spacer(Modifier.height(16.dp)) - } + } + Spacer(Modifier.height(8.dp)) //todo: maybe 16? + when (uiState) { + PaymentsUiState.Error -> HedvigErrorSection(onButtonClick = onRetry, Modifier.weight(1f)) + else -> { + PaymentsContent( + uiState = uiState, + onUpcomingPaymentClicked = { upcomingPayment -> + onUpcomingPaymentClicked(upcomingPayment.id) + }, + onChangeBankAccount = onChangeBankAccount, + onDiscountClicked = onDiscountClicked, + onPaymentHistoryClicked = onPaymentHistoryClicked, + ) + Spacer(Modifier.height(16.dp)) } - Spacer(Modifier.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom))) } + Spacer(Modifier.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom))) } PullRefreshIndicator( refreshing = isRefreshing, @@ -194,15 +191,15 @@ private fun PaymentsContent( upcomingPayment = upcomingPayment as? UpcomingPayment.Content, onCardClicked = onUpcomingPaymentClicked, modifier = Modifier - .padding(horizontal = 16.dp) - .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), + .padding(horizontal = 16.dp) + .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), ) } UpcomingPaymentInfoCard( upcomingPaymentInfo = (uiState as? PaymentsUiState.Content)?.upcomingPaymentInfo, modifier = Modifier - .padding(horizontal = 16.dp) - .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), + .padding(horizontal = 16.dp) + .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), ) val showConnectedPaymentInfo = uiState is PaymentsUiState.Content && uiState.connectedPaymentInfo is NotConnected && @@ -217,8 +214,8 @@ private fun PaymentsContent( connectedPaymentInfo = (uiState as? PaymentsUiState.Content)?.connectedPaymentInfo as? NotConnected, onChangeBankAccount = onChangeBankAccount, modifier = Modifier - .padding(horizontal = 16.dp) - .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), + .padding(horizontal = 16.dp) + .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), ) } @@ -228,13 +225,15 @@ private fun PaymentsContent( is Connected -> { if (connectedPaymentInfo.allowChangingConnectedBankAccount) { Spacer(Modifier.weight(1f)) - HedvigSecondaryContainedButton( + HedvigButton( text = stringResource(R.string.PROFILE_PAYMENT_CHANGE_BANK_ACCOUNT), onClick = onChangeBankAccount, + enabled = true, + buttonStyle = ButtonStyle.Secondary, modifier = Modifier - .padding(horizontal = 16.dp) - .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)) - .placeholder(uiState.isRetrying, highlight = PlaceholderHighlight.shimmer()), + .padding(horizontal = 16.dp) + .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)) + .hedvigPlaceholder(uiState.isRetrying, highlight = PlaceholderHighlight.shimmer()), ) } } @@ -242,11 +241,12 @@ private fun PaymentsContent( is NotConnected -> {} Pending -> { - VectorInfoCard( - text = stringResource(R.string.MY_PAYMENT_UPDATING_MESSAGE), + HedvigNotificationCard( + message = stringResource(R.string.MY_PAYMENT_UPDATING_MESSAGE), + priority = NotificationDefaults.NotificationPriority.Info, modifier = Modifier - .padding(horizontal = 16.dp) - .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), + .padding(horizontal = 16.dp) + .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), ) } } @@ -269,21 +269,15 @@ private fun CardNotConnectedWarningCard( } else { stringResource(id = R.string.info_card_missing_payment_body) } - VectorWarningCard( - text = text, + HedvigNotificationCard( + message = text, + style = NotificationDefaults.InfoCardStyle.Button( + buttonText = stringResource(id = R.string.PROFILE_PAYMENT_CONNECT_DIRECT_DEBIT_TITLE), + onButtonClick = onChangeBankAccount, + ), + priority = NotificationDefaults.NotificationPriority.Attention, modifier = modifier, - ) { - HedvigContainedSmallButton( - text = stringResource(id = R.string.PROFILE_PAYMENT_CONNECT_DIRECT_DEBIT_TITLE), - onClick = onChangeBankAccount, - colors = ButtonDefaults.buttonColors( - containerColor = MaterialTheme.colorScheme.containedButtonContainer, - contentColor = MaterialTheme.colorScheme.onContainedButtonContainer, - ), - textStyle = MaterialTheme.typography.bodyMedium, - modifier = Modifier.fillMaxWidth(), - ) - } + ) } @Composable @@ -292,13 +286,17 @@ private fun UpcomingPaymentInfoCard(upcomingPaymentInfo: UpcomingPaymentInfo?, m when (upcomingPaymentInfo) { UpcomingPaymentInfo.NoInfo -> {} UpcomingPaymentInfo.InProgress -> { - VectorInfoCard(text = stringResource(id = R.string.PAYMENTS_IN_PROGRESS)) + HedvigNotificationCard( + message = stringResource(id = R.string.PAYMENTS_IN_PROGRESS), + priority = NotificationDefaults.NotificationPriority.Info, + ) } is UpcomingPaymentInfo.PaymentFailed -> { val monthDateFormatter = rememberHedvigMonthDateTimeFormatter() - VectorErrorCard( - text = stringResource( + HedvigNotificationCard( + priority = NotificationDefaults.NotificationPriority.Attention, + message = stringResource( R.string.PAYMENTS_MISSED_PAYMENT, monthDateFormatter.format(upcomingPaymentInfo.failedPaymentStartDate.toJavaLocalDate()), monthDateFormatter.format(upcomingPaymentInfo.failedPaymentEndDate.toJavaLocalDate()), @@ -318,41 +316,41 @@ private fun PaymentsListItems( onPaymentHistoryClicked: () -> Unit, ) { val listItemsSideSpacingModifier = - Modifier - .padding(horizontal = 16.dp) - .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)) + Modifier + .padding(horizontal = 16.dp) + .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)) Column { PaymentsListItem( text = stringResource(R.string.PAYMENTS_DISCOUNTS_SECTION_TITLE), icon = { Icon( - imageVector = Icons.Hedvig.Campaign, + imageVector = HedvigIcons.Campaign, contentDescription = null, - tint = MaterialTheme.colorScheme.typeElement, + tint = HedvigTheme.colorScheme.signalGreenElement, //todo: check here! modifier = Modifier.size(24.dp), ) }, modifier = Modifier - .clickable(onClick = onDiscountClicked) - .then(listItemsSideSpacingModifier) - .padding(vertical = 16.dp) - .fillMaxWidth(), + .clickable(onClick = onDiscountClicked) + .then(listItemsSideSpacingModifier) + .padding(vertical = 16.dp) + .fillMaxWidth(), ) HorizontalDivider(modifier = listItemsSideSpacingModifier) PaymentsListItem( text = stringResource(R.string.PAYMENTS_PAYMENT_HISTORY_BUTTON_LABEL), icon = { Icon( - imageVector = Icons.Hedvig.Waiting, + imageVector = HedvigIcons.Clock, contentDescription = null, modifier = Modifier.size(24.dp), ) }, modifier = Modifier - .clickable(onClick = onPaymentHistoryClicked) - .then(listItemsSideSpacingModifier) - .padding(vertical = 16.dp) - .fillMaxWidth(), + .clickable(onClick = onPaymentHistoryClicked) + .then(listItemsSideSpacingModifier) + .padding(vertical = 16.dp) + .fillMaxWidth(), ) if (uiState is PaymentsUiState.Content) { if (uiState.connectedPaymentInfo is Connected) { @@ -361,22 +359,22 @@ private fun PaymentsListItems( text = uiState.connectedPaymentInfo.displayName, icon = { Icon( - imageVector = Icons.Hedvig.CreditCard, + imageVector = HedvigIcons.Card, contentDescription = null, modifier = Modifier.size(24.dp), ) }, endSlot = { - Text( + HedvigText( text = uiState.connectedPaymentInfo.maskedAccountNumber, - color = MaterialTheme.colorScheme.onSurfaceVariant, + color = HedvigTheme.colorScheme.textSecondary, textAlign = TextAlign.End, ) }, modifier = listItemsSideSpacingModifier - .padding(vertical = 16.dp) - .fillMaxWidth() - .placeholder(uiState.isRetrying, highlight = PlaceholderHighlight.shimmer()), + .padding(vertical = 16.dp) + .fillMaxWidth() + .hedvigPlaceholder(uiState.isRetrying, highlight = PlaceholderHighlight.shimmer()), ) } } @@ -400,14 +398,14 @@ private fun PaymentAmountCard( ) { Column( modifier = Modifier - .padding(horizontal = 16.dp, vertical = 12.dp) - .fillMaxWidth(), + .padding(horizontal = 16.dp, vertical = 12.dp) + .fillMaxWidth(), ) { HorizontalItemsWithMaximumSpaceTaken( startSlot = { - Text( + HedvigText( stringResource(R.string.PAYMENTS_UPCOMING_PAYMENT), - Modifier.placeholder( + Modifier.hedvigPlaceholder( visible = upcomingPayment == null, highlight = PlaceholderHighlight.shimmer(), ), @@ -418,13 +416,13 @@ private fun PaymentAmountCard( horizontalArrangement = Arrangement.End, verticalAlignment = Alignment.CenterVertically, modifier = Modifier - .wrapContentWidth(Alignment.End) - .placeholder( - visible = upcomingPayment == null, - highlight = PlaceholderHighlight.shimmer(), - ), + .wrapContentWidth(Alignment.End) + .hedvigPlaceholder( + visible = upcomingPayment == null, + highlight = PlaceholderHighlight.shimmer(), + ), ) { - Text( + HedvigText( text = if (upcomingPayment != null) { upcomingPayment.netAmount.toString() } else { @@ -434,9 +432,9 @@ private fun PaymentAmountCard( ) Spacer(Modifier.width(8.dp)) Icon( - imageVector = Icons.Hedvig.ChevronRight, + imageVector = HedvigIcons.ChevronRight, contentDescription = null, - tint = MaterialTheme.colorScheme.onSurfaceVariant, + tint = HedvigTheme.colorScheme.fillSecondary, modifier = Modifier.size(16.dp), ) } @@ -444,14 +442,14 @@ private fun PaymentAmountCard( spaceBetween = 4.dp, ) Spacer(Modifier.height(2.dp)) - Text( + HedvigText( text = if (upcomingPayment != null) { rememberHedvigDateTimeFormatter().format(upcomingPayment.dueDate.toJavaLocalDate()) } else { "22 Jul 2024" }, - color = MaterialTheme.colorScheme.onSurfaceVariant, - modifier = Modifier.placeholder( + color = HedvigTheme.colorScheme.textSecondary, + modifier = Modifier.hedvigPlaceholder( visible = upcomingPayment == null, highlight = PlaceholderHighlight.shimmer(), ), @@ -474,7 +472,7 @@ private fun PaymentsListItem( horizontalArrangement = Arrangement.spacedBy(16.dp), ) { icon() - Text(text) + HedvigText(text) } }, endSlot = { endSlot() }, @@ -487,8 +485,8 @@ private fun PaymentsListItem( private fun PreviewPaymentScreen( @PreviewParameter(PaymentsStatePreviewProvider::class) uiState: PaymentsUiState, ) { - com.hedvig.android.core.designsystem.theme.HedvigTheme { - Surface(color = MaterialTheme.colorScheme.background) { + HedvigTheme { + Surface(color = HedvigTheme.colorScheme.backgroundPrimary) { PaymentsScreen( uiState = uiState, { _ -> }, From 9fb09121b8b5ea1e74315f4eca9350aae3340b63 Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Mon, 18 Nov 2024 14:03:11 +0100 Subject: [PATCH 04/22] PaymentDetailsDestination --- .../design/system/hedvig/HedvigScaffold.kt | 2 + .../android/design/system/hedvig/TopAppBar.kt | 11 +- .../ui/details/PaymentDetailsDestination.kt | 197 ++++++++---------- .../payments/ui/discounts/DiscountRow.kt | 73 +++---- 4 files changed, 126 insertions(+), 157 deletions(-) diff --git a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigScaffold.kt b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigScaffold.kt index d10c074eb8..3f4d0be631 100644 --- a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigScaffold.kt +++ b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigScaffold.kt @@ -28,6 +28,7 @@ fun HedvigScaffold( topAppBarActionType: TopAppBarActionType = TopAppBarActionType.BACK, itemsColumnHorizontalAlignment: Alignment.Horizontal = Alignment.Start, topAppBarActions: @Composable RowScope.() -> Unit = {}, + customTopAppBarColors: TopAppBarColors? = null, content: @Composable ColumnScope.() -> Unit, ) { Surface( @@ -42,6 +43,7 @@ fun HedvigScaffold( onActionClick = dropUnlessResumed(block = navigateUp), topAppBarActions = topAppBarActions, windowInsets = topAppbarInsets, + customTopAppBarColors = customTopAppBarColors ) Column( horizontalAlignment = itemsColumnHorizontalAlignment, diff --git a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/TopAppBar.kt b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/TopAppBar.kt index 7adf0d150f..c1c8753c5b 100644 --- a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/TopAppBar.kt +++ b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/TopAppBar.kt @@ -23,6 +23,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.hedvig.android.design.system.hedvig.TopAppBarDefaults.windowInsets @@ -87,10 +88,11 @@ fun TopAppBar( modifier: Modifier = Modifier, topAppBarActions: @Composable (RowScope.() -> Unit)? = null, windowInsets: WindowInsets = TopAppBarDefaults.windowInsets, + customTopAppBarColors: TopAppBarColors? = null ) { Surface( - color = TopAppBarTokens.ContainerColor.value, - contentColor = TopAppBarTokens.ContentColor.value, + color = if (customTopAppBarColors!=null) customTopAppBarColors.containerColor else TopAppBarTokens.ContainerColor.value, + contentColor = if (customTopAppBarColors!=null) customTopAppBarColors.contentColor else TopAppBarTokens.ContentColor.value, modifier = modifier .windowInsetsPadding(windowInsets) .fillMaxWidth() @@ -197,3 +199,8 @@ internal object TopAppBarDefaults { .union(WindowInsets.displayCutout) .only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top) } + +data class TopAppBarColors( + val containerColor: Color, + val contentColor: Color +) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt index d0de4abe56..c613ecff37 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt @@ -12,16 +12,6 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width -import androidx.compose.material.icons.Icons -import androidx.compose.material3.ButtonDefaults -import androidx.compose.material3.CardDefaults -import androidx.compose.material3.HorizontalDivider -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface -import androidx.compose.material3.Text -import androidx.compose.material3.TopAppBarColors -import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -36,28 +26,23 @@ import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.hedvig.android.core.designsystem.component.bottomsheet.HedvigInfoBottomSheet -import com.hedvig.android.core.designsystem.component.button.HedvigContainedSmallButton -import com.hedvig.android.core.designsystem.component.error.HedvigErrorSection -import com.hedvig.android.core.designsystem.component.progress.HedvigFullScreenCenterAlignedProgress -import com.hedvig.android.core.designsystem.material3.containedButtonContainer -import com.hedvig.android.core.designsystem.material3.infoContainer -import com.hedvig.android.core.designsystem.material3.infoElement -import com.hedvig.android.core.designsystem.material3.onContainedButtonContainer -import com.hedvig.android.core.designsystem.material3.onInfoContainer -import com.hedvig.android.core.designsystem.material3.onTypeContainer -import com.hedvig.android.core.designsystem.material3.squircleMedium -import com.hedvig.android.core.designsystem.material3.typeContainer -import com.hedvig.android.core.designsystem.preview.HedvigPreview -import com.hedvig.android.core.designsystem.theme.HedvigTheme -import com.hedvig.android.core.icons.Hedvig -import com.hedvig.android.core.icons.hedvig.normal.InfoFilled -import com.hedvig.android.core.icons.hedvig.normal.WarningFilled -import com.hedvig.android.core.icons.hedvig.small.hedvig.Checkmark -import com.hedvig.android.core.ui.infocard.VectorInfoCard -import com.hedvig.android.core.ui.rememberHedvigDateTimeFormatter -import com.hedvig.android.core.ui.scaffold.HedvigScaffold -import com.hedvig.android.core.ui.text.HorizontalItemsWithMaximumSpaceTaken +import com.hedvig.android.design.system.hedvig.HedvigErrorSection +import com.hedvig.android.design.system.hedvig.HedvigFullScreenCenterAlignedProgress +import com.hedvig.android.design.system.hedvig.HedvigNotificationCard +import com.hedvig.android.design.system.hedvig.HedvigPreview +import com.hedvig.android.design.system.hedvig.HedvigScaffold +import com.hedvig.android.design.system.hedvig.HedvigText +import com.hedvig.android.design.system.hedvig.HedvigTheme +import com.hedvig.android.design.system.hedvig.HorizontalDivider +import com.hedvig.android.design.system.hedvig.HorizontalItemsWithMaximumSpaceTaken +import com.hedvig.android.design.system.hedvig.Icon +import com.hedvig.android.design.system.hedvig.NotificationDefaults +import com.hedvig.android.design.system.hedvig.Surface +import com.hedvig.android.design.system.hedvig.TopAppBarColors +import com.hedvig.android.design.system.hedvig.datepicker.rememberHedvigDateTimeFormatter +import com.hedvig.android.design.system.hedvig.icon.HedvigIcons +import com.hedvig.android.design.system.hedvig.icon.InfoFilled +import com.hedvig.android.design.system.hedvig.icon.WarningFilled import com.hedvig.android.feature.payments.chargeHistoryPreviewData import com.hedvig.android.feature.payments.data.MemberCharge import com.hedvig.android.feature.payments.data.PaymentConnection @@ -117,7 +102,7 @@ private fun MemberChargeDetailsScreen( HedvigScaffold( topAppBarText = dateTimeFormatter.format(uiState.paymentDetails.memberCharge.dueDate.toJavaLocalDate()), navigateUp = navigateUp, - topAppBarColors = uiState.paymentDetails.memberCharge.topAppBarColors(), + customTopAppBarColors = uiState.paymentDetails.memberCharge.topAppBarColors(), ) { Column(modifier = Modifier.padding(16.dp)) { var showBottomSheet by remember { mutableStateOf(false) } @@ -146,11 +131,13 @@ private fun MemberChargeDetailsScreen( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, ) { - Text(text = stringResource(id = R.string.payments_carried_adjustment)) - Text(text = it.toString()) + HedvigText(text = stringResource(id = R.string.payments_carried_adjustment)) + HedvigText(text = it.toString()) } Spacer(modifier = Modifier.height(8.dp)) - VectorInfoCard(text = stringResource(id = R.string.payments_carried_adjustment_info)) + HedvigNotificationCard( + priority = NotificationDefaults.NotificationPriority.Info, + message = stringResource(id = R.string.payments_carried_adjustment_info)) Spacer(modifier = Modifier.height(16.dp)) } @@ -160,17 +147,19 @@ private fun MemberChargeDetailsScreen( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, ) { - Text(text = stringResource(id = R.string.payments_settlement_adjustment)) - Text(text = it.toString()) + HedvigText(text = stringResource(id = R.string.payments_settlement_adjustment)) + HedvigText(text = it.toString()) } Spacer(modifier = Modifier.height(8.dp)) - VectorInfoCard(text = stringResource(id = R.string.payments_settlement_adjustment_info)) + HedvigNotificationCard( + priority = NotificationDefaults.NotificationPriority.Info, + message = stringResource(id = R.string.payments_settlement_adjustment_info)) Spacer(modifier = Modifier.height(16.dp)) } if (uiState.paymentDetails.memberCharge.discounts.isNotEmpty()) { Spacer(modifier = Modifier.height(16.dp)) - Text(stringResource(R.string.PAYMENTS_DISCOUNTS_SECTION_TITLE)) + HedvigText(stringResource(R.string.PAYMENTS_DISCOUNTS_SECTION_TITLE)) Spacer(modifier = Modifier.height(16.dp)) DiscountRows(uiState.paymentDetails.memberCharge.discounts) Spacer(modifier = Modifier.height(16.dp)) @@ -178,7 +167,7 @@ private fun MemberChargeDetailsScreen( HorizontalItemsWithMaximumSpaceTaken( startSlot = { - Text(stringResource(R.string.payment_details_receipt_card_total)) + HedvigText(stringResource(R.string.payment_details_receipt_card_total)) }, endSlot = { Row( @@ -186,15 +175,15 @@ private fun MemberChargeDetailsScreen( verticalAlignment = Alignment.CenterVertically, ) { if (uiState.paymentDetails.memberCharge.grossAmount != uiState.paymentDetails.memberCharge.netAmount) { - Text( + HedvigText( text = uiState.paymentDetails.memberCharge.grossAmount.toString(), textAlign = TextAlign.End, textDecoration = TextDecoration.LineThrough, - color = MaterialTheme.colorScheme.onSurfaceVariant, + color = HedvigTheme.colorScheme.textSecondary, ) Spacer(Modifier.width(6.dp)) } - Text( + HedvigText( text = uiState.paymentDetails.memberCharge.netAmount.toString(), textAlign = TextAlign.End, ) @@ -206,14 +195,14 @@ private fun MemberChargeDetailsScreen( HorizontalItemsWithMaximumSpaceTaken( startSlot = { - Text(stringResource(id = R.string.PAYMENTS_PAYMENT_DUE)) + HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_DUE)) }, endSlot = { - Text( + HedvigText( text = dateTimeFormatter.format(uiState.paymentDetails.memberCharge.dueDate.toJavaLocalDate()), textAlign = TextAlign.End, modifier = Modifier.fillMaxWidth(), - color = MaterialTheme.colorScheme.onSurfaceVariant, + color = HedvigTheme.colorScheme.textSecondary, ) }, modifier = Modifier.padding(vertical = 16.dp), @@ -221,58 +210,42 @@ private fun MemberChargeDetailsScreen( when (uiState.paymentDetails.memberCharge.status) { MemberCharge.MemberChargeStatus.UPCOMING -> {} - MemberCharge.MemberChargeStatus.SUCCESS -> VectorInfoCard( - text = stringResource(id = R.string.PAYMENTS_PAYMENT_SUCCESSFUL), - icon = Icons.Hedvig.Checkmark, - iconColor = MaterialTheme.colorScheme.onTypeContainer, - colors = CardDefaults.outlinedCardColors( - containerColor = MaterialTheme.colorScheme.typeContainer, - contentColor = MaterialTheme.colorScheme.onTypeContainer, - ), - underTextContent = null, - ) + MemberCharge.MemberChargeStatus.SUCCESS -> + HedvigNotificationCard( + priority = NotificationDefaults.NotificationPriority.Campaign, + //so here we have the same color that was in the old DS - green; but the icon doesn't match (it was checkmark, + //we don't have Checkmark icon in the new NotificationCards. so I've put withIcon = false here + withIcon = false, + style = NotificationDefaults.InfoCardStyle.Default, + message = stringResource(id = R.string.PAYMENTS_PAYMENT_SUCCESSFUL) + ) - MemberCharge.MemberChargeStatus.PENDING -> VectorInfoCard( - text = stringResource(id = R.string.PAYMENTS_IN_PROGRESS), - icon = Icons.Hedvig.InfoFilled, - iconColor = MaterialTheme.colorScheme.infoElement, - colors = CardDefaults.outlinedCardColors( - containerColor = MaterialTheme.colorScheme.infoContainer, - contentColor = MaterialTheme.colorScheme.onInfoContainer, - ), - underTextContent = null, + + MemberCharge.MemberChargeStatus.PENDING -> HedvigNotificationCard( + message = stringResource(id = R.string.PAYMENTS_IN_PROGRESS), + style = NotificationDefaults.InfoCardStyle.Default, + priority = NotificationDefaults.NotificationPriority.Info, + withIcon = true, ) - MemberCharge.MemberChargeStatus.FAILED -> VectorInfoCard( - text = stringResource( + MemberCharge.MemberChargeStatus.FAILED -> HedvigNotificationCard( + message = stringResource( id = R.string.PAYMENTS_PAYMENT_FAILED, uiState.paymentDetails.getNextCharge(uiState.paymentDetails.memberCharge)?.let { dateTimeFormatter.format(it.dueDate.toJavaLocalDate()) } ?: "-", ), - icon = Icons.Hedvig.WarningFilled, - iconColor = MaterialTheme.colorScheme.error, - colors = CardDefaults.outlinedCardColors( - containerColor = MaterialTheme.colorScheme.errorContainer, - contentColor = MaterialTheme.colorScheme.onErrorContainer, + priority = NotificationDefaults.NotificationPriority.Attention, + withIcon = true, + style = NotificationDefaults.InfoCardStyle.Button( + buttonText = stringResource(R.string.PAYMENTS_VIEW_PAYMENT), + onButtonClick = { + val nextCharge = uiState.paymentDetails.getNextCharge(uiState.paymentDetails.memberCharge) + if (nextCharge != null) { + onFailedChargeClick(nextCharge.id) + } + }, ), - underTextContent = { - HedvigContainedSmallButton( - text = stringResource(R.string.PAYMENTS_VIEW_PAYMENT), - onClick = { - val nextCharge = uiState.paymentDetails.getNextCharge(uiState.paymentDetails.memberCharge) - if (nextCharge != null) { - onFailedChargeClick(nextCharge.id) - } - }, - colors = ButtonDefaults.buttonColors( - containerColor = MaterialTheme.colorScheme.containedButtonContainer, - contentColor = MaterialTheme.colorScheme.onContainedButtonContainer, - ), - textStyle = MaterialTheme.typography.bodyMedium, - modifier = Modifier.fillMaxWidth(), - ) - }, ) MemberCharge.MemberChargeStatus.UNKNOWN -> {} @@ -283,7 +256,7 @@ private fun MemberChargeDetailsScreen( Spacer(Modifier.height(32.dp)) HorizontalItemsWithMaximumSpaceTaken( startSlot = { - Text(stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_TITLE)) + HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_TITLE)) }, endSlot = { Box( @@ -295,13 +268,13 @@ private fun MemberChargeDetailsScreen( modifier = Modifier .fillMaxHeight() .width(32.dp) - .clip(MaterialTheme.shapes.squircleMedium) + .clip(HedvigTheme.shapes.cornerMedium) .clickable { showBottomSheet = true }, contentAlignment = Alignment.Center, ) { Icon( - imageVector = Icons.Hedvig.InfoFilled, - tint = MaterialTheme.colorScheme.onSurfaceVariant, + imageVector =HedvigIcons.InfoFilled, + tint = HedvigTheme.colorScheme.fillSecondary, contentDescription = "Info icon", modifier = Modifier.size(16.dp), ) @@ -314,14 +287,14 @@ private fun MemberChargeDetailsScreen( HorizontalItemsWithMaximumSpaceTaken( startSlot = { - Text(stringResource(id = R.string.PAYMENTS_PAYMENT_METHOD)) + HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_METHOD)) }, endSlot = { - Text( + HedvigText( text = stringResource(id = R.string.PAYMENTS_AUTOGIRO_LABEL), textAlign = TextAlign.End, modifier = Modifier.fillMaxWidth(), - color = MaterialTheme.colorScheme.onSurfaceVariant, + color = HedvigTheme.colorScheme.textSecondary, ) }, modifier = Modifier.padding(vertical = 16.dp), @@ -330,14 +303,14 @@ private fun MemberChargeDetailsScreen( HorizontalItemsWithMaximumSpaceTaken( startSlot = { - Text(stringResource(id = R.string.PAYMENTS_ACCOUNT)) + HedvigText(stringResource(id = R.string.PAYMENTS_ACCOUNT)) }, endSlot = { - Text( + HedvigText( text = paymentConnection.displayValue, textAlign = TextAlign.End, modifier = Modifier.fillMaxWidth(), - color = MaterialTheme.colorScheme.onSurfaceVariant, + color = HedvigTheme.colorScheme.textSecondary, ) }, modifier = Modifier.padding(vertical = 16.dp), @@ -345,13 +318,13 @@ private fun MemberChargeDetailsScreen( HorizontalDivider() HorizontalItemsWithMaximumSpaceTaken( - startSlot = { Text(stringResource(id = R.string.PAYMENTS_BANK_LABEL)) }, + startSlot = { HedvigText(stringResource(id = R.string.PAYMENTS_BANK_LABEL)) }, endSlot = { - Text( + HedvigText( text = paymentConnection.displayName, textAlign = TextAlign.End, modifier = Modifier.fillMaxWidth(), - color = MaterialTheme.colorScheme.onSurfaceVariant, + color = HedvigTheme.colorScheme.textSecondary, ) }, modifier = Modifier.padding(vertical = 16.dp), @@ -364,19 +337,13 @@ private fun MemberChargeDetailsScreen( } @Composable -private fun MemberCharge.topAppBarColors(): TopAppBarColors { +private fun MemberCharge.topAppBarColors(): TopAppBarColors? { return if (this.status == MemberCharge.MemberChargeStatus.FAILED) { - TopAppBarDefaults.topAppBarColors( - titleContentColor = MaterialTheme.colorScheme.error, - containerColor = MaterialTheme.colorScheme.background, - scrolledContainerColor = MaterialTheme.colorScheme.surface, + TopAppBarColors( + contentColor = HedvigTheme.colorScheme.backgroundPrimary, + containerColor = HedvigTheme.colorScheme.signalRedText ) - } else { - TopAppBarDefaults.topAppBarColors( - containerColor = MaterialTheme.colorScheme.background, - scrolledContainerColor = MaterialTheme.colorScheme.surface, - ) - } + } else null } @Composable @@ -384,7 +351,7 @@ private fun MemberCharge.topAppBarColors(): TopAppBarColors { @HedvigPreview private fun PaymentDetailsScreenPreview() { HedvigTheme { - Surface(color = MaterialTheme.colorScheme.background) { + Surface(color = HedvigTheme.colorScheme.backgroundPrimary) { MemberChargeDetailsScreen( uiState = PaymentDetailsUiState.Success( PaymentDetails( diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt index ecf3f8a0e2..bc37e2724c 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt @@ -6,24 +6,21 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.wrapContentSize -import androidx.compose.material3.HorizontalDivider -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface -import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import com.hedvig.android.core.designsystem.component.information.HedvigPill -import com.hedvig.android.core.designsystem.material3.DisabledAlpha -import com.hedvig.android.core.designsystem.material3.onSecondaryContainedButtonContainer -import com.hedvig.android.core.designsystem.material3.secondaryContainedButtonContainer -import com.hedvig.android.core.designsystem.preview.HedvigPreview -import com.hedvig.android.core.designsystem.theme.HedvigTheme -import com.hedvig.android.core.ui.rememberHedvigDateTimeFormatter -import com.hedvig.android.core.ui.text.HorizontalItemsWithMaximumSpaceTaken +import com.hedvig.android.design.system.hedvig.HedvigPreview +import com.hedvig.android.design.system.hedvig.HedvigText +import com.hedvig.android.design.system.hedvig.HedvigTheme +import com.hedvig.android.design.system.hedvig.HighlightLabel +import com.hedvig.android.design.system.hedvig.HighlightLabelDefaults +import com.hedvig.android.design.system.hedvig.HorizontalDivider +import com.hedvig.android.design.system.hedvig.HorizontalItemsWithMaximumSpaceTaken +import com.hedvig.android.design.system.hedvig.Surface +import com.hedvig.android.design.system.hedvig.datepicker.rememberHedvigDateTimeFormatter import com.hedvig.android.feature.payments.data.Discount import com.hedvig.android.feature.payments.discountsPreviewData import hedvig.resources.R @@ -50,25 +47,21 @@ private fun DiscountRow(discount: Discount, modifier: Modifier = Modifier) { Column(modifier = modifier) { HorizontalItemsWithMaximumSpaceTaken( startSlot = { - HedvigPill( - text = discount.code, - color = MaterialTheme.colorScheme.secondaryContainedButtonContainer, - contentColor = if (discountIsExpired) { - MaterialTheme.colorScheme.onSurface.copy(DisabledAlpha) - } else { - MaterialTheme.colorScheme.onSecondaryContainedButtonContainer - }, - modifier = Modifier.wrapContentSize(Alignment.CenterStart), + HighlightLabel( + labelText = discount.code, + color = if (discountIsExpired) HighlightLabelDefaults.HighlightColor.Grey(HighlightLabelDefaults.HighlightShade.LIGHT) + else HighlightLabelDefaults.HighlightColor.Blue(HighlightLabelDefaults.HighlightShade.LIGHT), + size = HighlightLabelDefaults.HighLightSize.Small ) }, endSlot = { - discount.amount?.let { discount -> - Text( + discount.amount?.let { discountAmount -> + HedvigText( text = stringResource(R.string.OFFER_COST_AND_PREMIUM_PERIOD_ABBREVIATION, discount.toString()), color = if (discountIsExpired) { - MaterialTheme.colorScheme.onSurface.copy(DisabledAlpha) + HedvigTheme.colorScheme.textDisabled } else { - MaterialTheme.colorScheme.onSurfaceVariant + HedvigTheme.colorScheme.textSecondary }, textAlign = TextAlign.End, modifier = Modifier.wrapContentSize(Alignment.CenterEnd), @@ -84,14 +77,14 @@ private fun DiscountRow(discount: Discount, modifier: Modifier = Modifier) { horizontalAlignment = Alignment.Start, ) { discount.displayName?.let { - Text( + HedvigText( text = it, color = if (discountIsExpired) { - MaterialTheme.colorScheme.onSurface.copy(DisabledAlpha) + HedvigTheme.colorScheme.textDisabled } else { - MaterialTheme.colorScheme.onSurfaceVariant + HedvigTheme.colorScheme.textSecondary }, - style = MaterialTheme.typography.bodyMedium, + style = HedvigTheme.typography.bodySmall, ) } val bottomText = if (discount.isReferral) { @@ -100,14 +93,14 @@ private fun DiscountRow(discount: Discount, modifier: Modifier = Modifier) { discount.description } if (bottomText != null) { - Text( + HedvigText( text = bottomText, color = if (discountIsExpired) { - MaterialTheme.colorScheme.onSurface.copy(DisabledAlpha) + HedvigTheme.colorScheme.textDisabled } else { - MaterialTheme.colorScheme.onSurfaceVariant + HedvigTheme.colorScheme.textSecondary }, - style = MaterialTheme.typography.bodyMedium, + style = HedvigTheme.typography.bodySmall, ) } } @@ -116,27 +109,27 @@ private fun DiscountRow(discount: Discount, modifier: Modifier = Modifier) { val dateTimeFormatter = rememberHedvigDateTimeFormatter() when (discount.expiredState) { is Discount.ExpiredState.AlreadyExpired -> { - Text( + HedvigText( text = stringResource( id = R.string.PAYMENTS_EXPIRED_DATE, dateTimeFormatter.format(discount.expiredState.expirationDate.toJavaLocalDate()), ), textAlign = TextAlign.End, - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.error, + style = HedvigTheme.typography.bodySmall, + color = HedvigTheme.colorScheme.signalRedText, modifier = Modifier.fillMaxWidth(), ) } is Discount.ExpiredState.ExpiringInTheFuture -> { - Text( + HedvigText( text = stringResource( id = R.string.PAYMENTS_VALID_UNTIL, dateTimeFormatter.format(discount.expiredState.expirationDate.toJavaLocalDate()), ), textAlign = TextAlign.End, - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.onSurfaceVariant, + style = HedvigTheme.typography.bodySmall, + color = HedvigTheme.colorScheme.textSecondary, modifier = Modifier.fillMaxWidth(), ) } @@ -153,7 +146,7 @@ private fun DiscountRow(discount: Discount, modifier: Modifier = Modifier) { @HedvigPreview private fun DiscountRowsPreview() { HedvigTheme { - Surface(color = MaterialTheme.colorScheme.background) { + Surface(color = HedvigTheme.colorScheme.backgroundPrimary) { Column { DiscountRows(discounts = discountsPreviewData) } From e53eb384b7ae970c5c1c4c708b5877a2c5d53720 Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Mon, 18 Nov 2024 16:05:00 +0100 Subject: [PATCH 05/22] base migration --- .../design/system/hedvig/HedvigBottomSheet.kt | 2 +- .../system/hedvig/HedvigInformationSection.kt | 16 +-- .../design/system/hedvig/HedvigScaffold.kt | 2 +- .../android/design/system/hedvig/TopAppBar.kt | 20 +++- .../design/system/hedvig/icon/Clock.kt | 2 +- .../EnterNewAddressDestination.kt | 1 - .../ui/details/PaymentDetailExpandableCard.kt | 7 +- .../ui/details/PaymentDetailsDestination.kt | 50 +++++---- ...et.kt => AddDiscountBottomSheetContent.kt} | 41 +++---- .../payments/ui/discounts/DiscountRow.kt | 9 +- .../ui/discounts/DiscountsDestination.kt | 102 +++++++----------- .../ui/history/PaymentHistoryDestination.kt | 44 ++++---- .../ui/payments/PaymentsDestination.kt | 88 +++++++-------- 13 files changed, 199 insertions(+), 185 deletions(-) rename app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/{AddDiscountBottomSheet.kt => AddDiscountBottomSheetContent.kt} (60%) diff --git a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigBottomSheet.kt b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigBottomSheet.kt index 44bac19bd7..bf3d2e630b 100644 --- a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigBottomSheet.kt +++ b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigBottomSheet.kt @@ -236,7 +236,7 @@ private fun DragHandle(modifier: Modifier = Modifier) { .background( shape = HedvigTheme.shapes.cornerSmall, color = bottomSheetColors.chipColor, - ) + ), ) } diff --git a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigInformationSection.kt b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigInformationSection.kt index ddeacfb2cc..cfa2e2ece3 100644 --- a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigInformationSection.kt +++ b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigInformationSection.kt @@ -20,7 +20,7 @@ fun HedvigInformationSection( modifier: Modifier = Modifier, subTitle: String? = null, onButtonClick: (() -> Unit)? = null, - buttonText: String = stringResource(id = R.string.ALERT_OK), + buttonText: String = stringResource(id = R.string.ALERT_OK), windowInsets: WindowInsets = WindowInsets.safeDrawing, ) { Column( @@ -30,14 +30,18 @@ fun HedvigInformationSection( .windowInsetsPadding(windowInsets) .padding(horizontal = 16.dp), ) { - val buttonStyle = if (onButtonClick!=null) EmptyStateDefaults.EmptyStateButtonStyle.Button( - buttonText = buttonText, - onButtonClick = onButtonClick, - ) else NoButton + val buttonStyle = if (onButtonClick != null) { + EmptyStateDefaults.EmptyStateButtonStyle.Button( + buttonText = buttonText, + onButtonClick = onButtonClick, + ) + } else { + NoButton + } EmptyState( text = title, description = subTitle, - iconStyle = EmptyStateDefaults.EmptyStateIconStyle.INFO, + iconStyle = EmptyStateDefaults.EmptyStateIconStyle.INFO, buttonStyle = buttonStyle, ) } diff --git a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigScaffold.kt b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigScaffold.kt index 3f4d0be631..1268909381 100644 --- a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigScaffold.kt +++ b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigScaffold.kt @@ -43,7 +43,7 @@ fun HedvigScaffold( onActionClick = dropUnlessResumed(block = navigateUp), topAppBarActions = topAppBarActions, windowInsets = topAppbarInsets, - customTopAppBarColors = customTopAppBarColors + customTopAppBarColors = customTopAppBarColors, ) Column( horizontalAlignment = itemsColumnHorizontalAlignment, diff --git a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/TopAppBar.kt b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/TopAppBar.kt index c1c8753c5b..cbed326050 100644 --- a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/TopAppBar.kt +++ b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/TopAppBar.kt @@ -88,11 +88,23 @@ fun TopAppBar( modifier: Modifier = Modifier, topAppBarActions: @Composable (RowScope.() -> Unit)? = null, windowInsets: WindowInsets = TopAppBarDefaults.windowInsets, - customTopAppBarColors: TopAppBarColors? = null + customTopAppBarColors: TopAppBarColors? = null, ) { Surface( - color = if (customTopAppBarColors!=null) customTopAppBarColors.containerColor else TopAppBarTokens.ContainerColor.value, - contentColor = if (customTopAppBarColors!=null) customTopAppBarColors.contentColor else TopAppBarTokens.ContentColor.value, + color = if (customTopAppBarColors != + null + ) { + customTopAppBarColors.containerColor + } else { + TopAppBarTokens.ContainerColor.value + }, + contentColor = if (customTopAppBarColors != + null + ) { + customTopAppBarColors.contentColor + } else { + TopAppBarTokens.ContentColor.value + }, modifier = modifier .windowInsetsPadding(windowInsets) .fillMaxWidth() @@ -202,5 +214,5 @@ internal object TopAppBarDefaults { data class TopAppBarColors( val containerColor: Color, - val contentColor: Color + val contentColor: Color, ) diff --git a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/icon/Clock.kt b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/icon/Clock.kt index c833f09d91..3e443e4c9d 100644 --- a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/icon/Clock.kt +++ b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/icon/Clock.kt @@ -17,7 +17,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.hedvig.android.design.system.hedvig.HedvigTheme -//Icons.Hedvig.Waiting in the old DS +// Icons.Hedvig.Waiting in the old DS @Suppress("UnusedReceiverParameter") val HedvigIcons.Clock: ImageVector get() { diff --git a/app/feature/feature-movingflow/src/main/kotlin/com/hedvig/android/feature/movingflow/ui/enternewaddress/EnterNewAddressDestination.kt b/app/feature/feature-movingflow/src/main/kotlin/com/hedvig/android/feature/movingflow/ui/enternewaddress/EnterNewAddressDestination.kt index dc75cfd245..86c438e2d8 100644 --- a/app/feature/feature-movingflow/src/main/kotlin/com/hedvig/android/feature/movingflow/ui/enternewaddress/EnterNewAddressDestination.kt +++ b/app/feature/feature-movingflow/src/main/kotlin/com/hedvig/android/feature/movingflow/ui/enternewaddress/EnterNewAddressDestination.kt @@ -28,7 +28,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.KeyboardCapitalization -import androidx.compose.ui.text.input.KeyboardCapitalization.Companion import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.unit.dp import androidx.core.text.isDigitsOnly diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailExpandableCard.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailExpandableCard.kt index 89a1ae4fe9..5e7d06b967 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailExpandableCard.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailExpandableCard.kt @@ -14,7 +14,6 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width - import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment @@ -132,7 +131,7 @@ internal fun PaymentDetailExpandableCard( if (it.isPreviouslyFailedCharge) { HedvigText( text = stringResource(id = R.string.PAYMENTS_OUTSTANDING_PAYMENT), - style = HedvigTheme.typography.label, //todo: check here! + style = HedvigTheme.typography.label, // todo: check here! color = it.toSubtitleColor(), ) } @@ -176,7 +175,7 @@ private fun MemberCharge.ChargeBreakdown.Period.toString(dateTimeFormatter: Date @Composable private fun MemberCharge.ChargeBreakdown.Period.toColor(): Color { return if (isPreviouslyFailedCharge) { - HedvigTheme.colorScheme.signalRedText //todo: check here! + HedvigTheme.colorScheme.signalRedText // todo: check here! } else { LocalContentColor.current } @@ -185,7 +184,7 @@ private fun MemberCharge.ChargeBreakdown.Period.toColor(): Color { @Composable private fun MemberCharge.ChargeBreakdown.Period.toSubtitleColor(): Color { return if (isPreviouslyFailedCharge) { - HedvigTheme.colorScheme.signalRedText //todo: check here! + HedvigTheme.colorScheme.signalRedText // todo: check here! } else { HedvigTheme.colorScheme.textSecondary } diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt index c613ecff37..8bdfb50bd6 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt @@ -26,6 +26,7 @@ import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.hedvig.android.design.system.hedvig.HedvigBottomSheet import com.hedvig.android.design.system.hedvig.HedvigErrorSection import com.hedvig.android.design.system.hedvig.HedvigFullScreenCenterAlignedProgress import com.hedvig.android.design.system.hedvig.HedvigNotificationCard @@ -42,7 +43,6 @@ import com.hedvig.android.design.system.hedvig.TopAppBarColors import com.hedvig.android.design.system.hedvig.datepicker.rememberHedvigDateTimeFormatter import com.hedvig.android.design.system.hedvig.icon.HedvigIcons import com.hedvig.android.design.system.hedvig.icon.InfoFilled -import com.hedvig.android.design.system.hedvig.icon.WarningFilled import com.hedvig.android.feature.payments.chargeHistoryPreviewData import com.hedvig.android.feature.payments.data.MemberCharge import com.hedvig.android.feature.payments.data.PaymentConnection @@ -95,6 +95,7 @@ private fun MemberChargeDetailsScreen( HedvigErrorSection(onButtonClick = reload, modifier = Modifier.weight(1f)) } } + PaymentDetailsUiState.Loading -> HedvigFullScreenCenterAlignedProgress() is PaymentDetailsUiState.Success -> { val dateTimeFormatter = rememberHedvigDateTimeFormatter() @@ -106,13 +107,21 @@ private fun MemberChargeDetailsScreen( ) { Column(modifier = Modifier.padding(16.dp)) { var showBottomSheet by remember { mutableStateOf(false) } - if (showBottomSheet) { - HedvigInfoBottomSheet( - onDismissed = { showBottomSheet = false }, - title = stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_TITLE), - body = stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_DESCRIPTION), + HedvigBottomSheet( + isVisible = showBottomSheet, + onVisibleChange = { visible -> + if (!visible) { + showBottomSheet = false + } + }, + ) { + HedvigText(text = stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_TITLE)) + HedvigText( + text = stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_DESCRIPTION), + color = HedvigTheme.colorScheme.textSecondary, ) } + uiState.paymentDetails.memberCharge.chargeBreakdowns.forEach { chargeBreakdown -> PaymentDetailExpandableCard( displayName = chargeBreakdown.contractDisplayName, @@ -137,7 +146,8 @@ private fun MemberChargeDetailsScreen( Spacer(modifier = Modifier.height(8.dp)) HedvigNotificationCard( priority = NotificationDefaults.NotificationPriority.Info, - message = stringResource(id = R.string.payments_carried_adjustment_info)) + message = stringResource(id = R.string.payments_carried_adjustment_info), + ) Spacer(modifier = Modifier.height(16.dp)) } @@ -153,7 +163,8 @@ private fun MemberChargeDetailsScreen( Spacer(modifier = Modifier.height(8.dp)) HedvigNotificationCard( priority = NotificationDefaults.NotificationPriority.Info, - message = stringResource(id = R.string.payments_settlement_adjustment_info)) + message = stringResource(id = R.string.payments_settlement_adjustment_info), + ) Spacer(modifier = Modifier.height(16.dp)) } @@ -202,7 +213,7 @@ private fun MemberChargeDetailsScreen( text = dateTimeFormatter.format(uiState.paymentDetails.memberCharge.dueDate.toJavaLocalDate()), textAlign = TextAlign.End, modifier = Modifier.fillMaxWidth(), - color = HedvigTheme.colorScheme.textSecondary, + color = HedvigTheme.colorScheme.textSecondary, ) }, modifier = Modifier.padding(vertical = 16.dp), @@ -213,14 +224,13 @@ private fun MemberChargeDetailsScreen( MemberCharge.MemberChargeStatus.SUCCESS -> HedvigNotificationCard( priority = NotificationDefaults.NotificationPriority.Campaign, - //so here we have the same color that was in the old DS - green; but the icon doesn't match (it was checkmark, - //we don't have Checkmark icon in the new NotificationCards. so I've put withIcon = false here + // so here we have the same color that was in the old DS - green; but the icon doesn't match (it was checkmark, + // we don't have Checkmark icon in the new NotificationCards. so I've put withIcon = false here withIcon = false, style = NotificationDefaults.InfoCardStyle.Default, - message = stringResource(id = R.string.PAYMENTS_PAYMENT_SUCCESSFUL) + message = stringResource(id = R.string.PAYMENTS_PAYMENT_SUCCESSFUL), ) - MemberCharge.MemberChargeStatus.PENDING -> HedvigNotificationCard( message = stringResource(id = R.string.PAYMENTS_IN_PROGRESS), style = NotificationDefaults.InfoCardStyle.Default, @@ -273,8 +283,8 @@ private fun MemberChargeDetailsScreen( contentAlignment = Alignment.Center, ) { Icon( - imageVector =HedvigIcons.InfoFilled, - tint = HedvigTheme.colorScheme.fillSecondary, + imageVector = HedvigIcons.InfoFilled, + tint = HedvigTheme.colorScheme.fillSecondary, contentDescription = "Info icon", modifier = Modifier.size(16.dp), ) @@ -310,7 +320,7 @@ private fun MemberChargeDetailsScreen( text = paymentConnection.displayValue, textAlign = TextAlign.End, modifier = Modifier.fillMaxWidth(), - color = HedvigTheme.colorScheme.textSecondary, + color = HedvigTheme.colorScheme.textSecondary, ) }, modifier = Modifier.padding(vertical = 16.dp), @@ -324,7 +334,7 @@ private fun MemberChargeDetailsScreen( text = paymentConnection.displayName, textAlign = TextAlign.End, modifier = Modifier.fillMaxWidth(), - color = HedvigTheme.colorScheme.textSecondary, + color = HedvigTheme.colorScheme.textSecondary, ) }, modifier = Modifier.padding(vertical = 16.dp), @@ -341,9 +351,11 @@ private fun MemberCharge.topAppBarColors(): TopAppBarColors? { return if (this.status == MemberCharge.MemberChargeStatus.FAILED) { TopAppBarColors( contentColor = HedvigTheme.colorScheme.backgroundPrimary, - containerColor = HedvigTheme.colorScheme.signalRedText + containerColor = HedvigTheme.colorScheme.signalRedText, ) - } else null + } else { + null + } } @Composable diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheet.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt similarity index 60% rename from app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheet.kt rename to app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt index 7b267609ee..f94cf95c31 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheet.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt @@ -5,9 +5,6 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface -import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -17,40 +14,48 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import com.hedvig.android.core.designsystem.component.button.HedvigContainedButton -import com.hedvig.android.core.designsystem.component.textfield.HedvigTextField -import com.hedvig.android.core.designsystem.preview.HedvigPreview -import com.hedvig.android.core.designsystem.theme.HedvigTheme +import com.hedvig.android.design.system.hedvig.HedvigButton +import com.hedvig.android.design.system.hedvig.HedvigPreview +import com.hedvig.android.design.system.hedvig.HedvigText +import com.hedvig.android.design.system.hedvig.HedvigTextField +import com.hedvig.android.design.system.hedvig.HedvigTextFieldDefaults +import com.hedvig.android.design.system.hedvig.HedvigTextFieldDefaults.TextFieldSize +import com.hedvig.android.design.system.hedvig.HedvigTheme +import com.hedvig.android.design.system.hedvig.Surface import hedvig.resources.R @Composable -internal fun AddDiscountBottomSheet(isLoading: Boolean, errorMessage: String?, onAddDiscount: (String) -> Unit) { +internal fun AddDiscountBottomSheetContent(isLoading: Boolean, errorMessage: String?, onAddDiscount: (String) -> Unit) { var discountCodeInput by remember { mutableStateOf("") } Column( modifier = Modifier.padding(horizontal = 16.dp), ) { Spacer(Modifier.height(16.dp)) - Text( + HedvigText( text = stringResource(id = R.string.PAYMENTS_ADD_CAMPAIGN_CODE), textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth(), ) Spacer(Modifier.height(24.dp)) HedvigTextField( - value = discountCodeInput, - errorText = errorMessage, + text = discountCodeInput, + errorState = if (errorMessage != + null + ) { + HedvigTextFieldDefaults.ErrorState.Error.WithMessage(errorMessage) + } else { + HedvigTextFieldDefaults.ErrorState.NoError + }, + textFieldSize = TextFieldSize.Medium, onValueChange = { discountCodeInput = it }, - label = { - Text(text = stringResource(id = R.string.REFERRAL_ADDCOUPON_INPUTPLACEHOLDER)) - }, - withNewDesign = true, + labelText = stringResource(id = R.string.REFERRAL_ADDCOUPON_INPUTPLACEHOLDER), modifier = Modifier.fillMaxWidth(), ) Spacer(Modifier.height(16.dp)) - HedvigContainedButton( + HedvigButton( text = stringResource(id = R.string.PAYMENTS_ADD_CODE_BUTTON_LABEL), enabled = discountCodeInput.isNotBlank(), onClick = { @@ -66,8 +71,8 @@ internal fun AddDiscountBottomSheet(isLoading: Boolean, errorMessage: String?, o @HedvigPreview private fun AddDiscountBottomSheetPreview() { HedvigTheme { - Surface(color = MaterialTheme.colorScheme.background) { - AddDiscountBottomSheet( + Surface(color = HedvigTheme.colorScheme.backgroundPrimary) { + AddDiscountBottomSheetContent( isLoading = false, errorMessage = null, onAddDiscount = {}, diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt index bc37e2724c..87e0dc4902 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt @@ -49,9 +49,12 @@ private fun DiscountRow(discount: Discount, modifier: Modifier = Modifier) { startSlot = { HighlightLabel( labelText = discount.code, - color = if (discountIsExpired) HighlightLabelDefaults.HighlightColor.Grey(HighlightLabelDefaults.HighlightShade.LIGHT) - else HighlightLabelDefaults.HighlightColor.Blue(HighlightLabelDefaults.HighlightShade.LIGHT), - size = HighlightLabelDefaults.HighLightSize.Small + color = if (discountIsExpired) { + HighlightLabelDefaults.HighlightColor.Grey(HighlightLabelDefaults.HighlightShade.LIGHT) + } else { + HighlightLabelDefaults.HighlightColor.Blue(HighlightLabelDefaults.HighlightShade.LIGHT) + }, + size = HighlightLabelDefaults.HighLightSize.Small, ) }, endSlot = { diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt index 439701d69c..1669fc98fc 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt @@ -10,23 +10,12 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsetsSides import androidx.compose.foundation.layout.asPaddingValues -import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.only import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.safeDrawing import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.wrapContentSize -import androidx.compose.material.icons.Icons -import androidx.compose.material3.BottomSheetDefaults -import androidx.compose.material3.CardDefaults -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.ModalBottomSheet -import androidx.compose.material3.Surface -import androidx.compose.material3.Text -import androidx.compose.material3.minimumInteractiveComponentSize -import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -43,29 +32,10 @@ import androidx.compose.ui.unit.dp import androidx.core.content.getSystemService import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.hedvig.android.compose.ui.preview.BooleanCollectionPreviewParameterProvider -import com.hedvig.android.core.designsystem.component.bottomsheet.HedvigInfoBottomSheet -import com.hedvig.android.core.designsystem.component.button.HedvigSecondaryContainedButton -import com.hedvig.android.core.designsystem.component.card.HedvigCard -import com.hedvig.android.core.designsystem.material3.onSecondaryContainedButtonContainer -import com.hedvig.android.core.designsystem.material3.onTypeContainer -import com.hedvig.android.core.designsystem.material3.secondaryContainedButtonContainer -import com.hedvig.android.core.designsystem.material3.squircleLarge -import com.hedvig.android.core.designsystem.material3.squircleLargeTop -import com.hedvig.android.core.designsystem.material3.squircleSmall -import com.hedvig.android.core.designsystem.material3.typeContainer -import com.hedvig.android.core.designsystem.material3.typeElement -import com.hedvig.android.core.designsystem.preview.HedvigPreview -import com.hedvig.android.core.designsystem.theme.HedvigTheme -import com.hedvig.android.core.icons.Hedvig -import com.hedvig.android.core.icons.hedvig.normal.InfoFilled -import com.hedvig.android.core.icons.hedvig.small.hedvig.Campaign -import com.hedvig.android.core.ui.infocard.InfoCardTextButton -import com.hedvig.android.core.ui.infocard.VectorInfoCard -import com.hedvig.android.core.ui.scaffold.HedvigScaffold -import com.hedvig.android.core.ui.text.HorizontalItemsWithMaximumSpaceTaken import com.hedvig.android.core.uidata.UiCurrencyCode import com.hedvig.android.core.uidata.UiMoney import com.hedvig.android.design.system.hedvig.ButtonDefaults.ButtonStyle +import com.hedvig.android.design.system.hedvig.HedvigBottomSheet import com.hedvig.android.design.system.hedvig.HedvigButton import com.hedvig.android.design.system.hedvig.HedvigCard import com.hedvig.android.design.system.hedvig.HedvigNotificationCard @@ -77,7 +47,6 @@ import com.hedvig.android.design.system.hedvig.HorizontalItemsWithMaximumSpaceTa import com.hedvig.android.design.system.hedvig.Icon import com.hedvig.android.design.system.hedvig.NotificationDefaults import com.hedvig.android.design.system.hedvig.Surface -import com.hedvig.android.design.system.hedvig.icon.Campaign import com.hedvig.android.design.system.hedvig.icon.HedvigIcons import com.hedvig.android.design.system.hedvig.icon.InfoFilled import com.hedvig.android.design.system.hedvig.minimumInteractiveComponentSize @@ -117,31 +86,35 @@ private fun DiscountsScreen( navigateUp = navigateUp, ) { var showInfoBottomSheet by remember { mutableStateOf(false) } - if (showInfoBottomSheet) { - HedvigInfoBottomSheet( - onDismissed = { showInfoBottomSheet = false }, - title = stringResource(R.string.PAYMENTS_CAMPAIGNS_INFO_TITLE), - body = stringResource(R.string.PAYMENTS_CAMPAIGNS_INFO_DESCRIPTION), + HedvigBottomSheet( + isVisible = showInfoBottomSheet, + onVisibleChange = { visible -> + if (!visible) { + showInfoBottomSheet = false + } + }, + ) { + HedvigText(text = stringResource(R.string.PAYMENTS_CAMPAIGNS_INFO_TITLE)) + HedvigText( + text = stringResource(R.string.PAYMENTS_CAMPAIGNS_INFO_DESCRIPTION), + color = HedvigTheme.colorScheme.textSecondary, ) } - if (uiState.showAddDiscountBottomSheet) { - val sheetState = rememberModalBottomSheetState(true) - ModalBottomSheet( - containerColor = MaterialTheme.colorScheme.background, - onDismissRequest = onDismissBottomSheet, - shape = MaterialTheme.shapes.squircleLargeTop, - sheetState = sheetState, - tonalElevation = 0.dp, - contentWindowInsets = { BottomSheetDefaults.windowInsets.only(WindowInsetsSides.Top) }, - ) { - AddDiscountBottomSheet( - onAddDiscount = { code -> - onSubmitDiscountCode(code) - }, - errorMessage = uiState.discountError, - isLoading = uiState.isAddingDiscount, - ) - } + HedvigBottomSheet( + isVisible = uiState.showAddDiscountBottomSheet, + onVisibleChange = { visible -> + if (!visible) { + onDismissBottomSheet() + } + }, + ) { + AddDiscountBottomSheetContent( + onAddDiscount = { code -> + onSubmitDiscountCode(code) + }, + errorMessage = uiState.discountError, + isLoading = uiState.isAddingDiscount, + ) } Column(modifier = Modifier.padding(horizontal = 16.dp)) { @@ -205,11 +178,18 @@ private fun ForeverSection( Column(modifier) { val incentive = foreverInformation.potentialDiscountAmountPerNewReferral.toString() var showForeverInfoBottomSheet by remember { mutableStateOf(false) } - if (showForeverInfoBottomSheet) { - HedvigInfoBottomSheet( - onDismissed = { showForeverInfoBottomSheet = false }, - title = stringResource(R.string.referrals_info_sheet_headline), - body = stringResource(R.string.referrals_info_sheet_body, incentive), + HedvigBottomSheet( + isVisible = showForeverInfoBottomSheet, + onVisibleChange = { visible -> + if (!visible) { + showForeverInfoBottomSheet = false + } + }, + ) { + HedvigText(text = stringResource(R.string.referrals_info_sheet_headline)) + HedvigText( + text = stringResource(R.string.referrals_info_sheet_body, incentive), + color = HedvigTheme.colorScheme.textSecondary, ) } HorizontalItemsWithMaximumSpaceTaken( @@ -275,7 +255,7 @@ private fun ForeverSection( style = NotificationDefaults.InfoCardStyle.Button( buttonText = stringResource(R.string.important_message_read_more), onButtonClick = navigateToForever, - ) + ), ) } } diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt index 9258d74f3a..0ffdb110e6 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt @@ -5,10 +5,6 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.material3.HorizontalDivider -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface -import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.remember @@ -22,17 +18,21 @@ import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.hedvig.android.compose.ui.preview.TripleBooleanCollectionPreviewParameterProvider import com.hedvig.android.compose.ui.preview.TripleCase -import com.hedvig.android.core.designsystem.component.error.HedvigErrorSection -import com.hedvig.android.core.designsystem.component.information.HedvigInformationSection -import com.hedvig.android.core.designsystem.component.progress.HedvigFullScreenCenterAlignedProgress -import com.hedvig.android.core.designsystem.preview.HedvigPreview -import com.hedvig.android.core.designsystem.theme.HedvigTheme -import com.hedvig.android.core.ui.infocard.VectorInfoCard -import com.hedvig.android.core.ui.rememberHedvigMonthDateTimeFormatter -import com.hedvig.android.core.ui.scaffold.HedvigScaffold -import com.hedvig.android.core.ui.text.HorizontalItemsWithMaximumSpaceTaken import com.hedvig.android.core.uidata.UiCurrencyCode import com.hedvig.android.core.uidata.UiMoney +import com.hedvig.android.design.system.hedvig.HedvigErrorSection +import com.hedvig.android.design.system.hedvig.HedvigFullScreenCenterAlignedProgress +import com.hedvig.android.design.system.hedvig.HedvigInformationSection +import com.hedvig.android.design.system.hedvig.HedvigNotificationCard +import com.hedvig.android.design.system.hedvig.HedvigPreview +import com.hedvig.android.design.system.hedvig.HedvigScaffold +import com.hedvig.android.design.system.hedvig.HedvigText +import com.hedvig.android.design.system.hedvig.HedvigTheme +import com.hedvig.android.design.system.hedvig.HorizontalDivider +import com.hedvig.android.design.system.hedvig.HorizontalItemsWithMaximumSpaceTaken +import com.hedvig.android.design.system.hedvig.NotificationDefaults +import com.hedvig.android.design.system.hedvig.Surface +import com.hedvig.android.design.system.hedvig.datepicker.rememberHedvigMonthDateTimeFormatter import com.hedvig.android.feature.payments.data.MemberCharge import hedvig.resources.R import kotlinx.datetime.LocalDate @@ -121,7 +121,6 @@ private fun PaymentHistorySuccessScreen( PaymentHistory.NoHistoryData -> { HedvigInformationSection( title = stringResource(R.string.PAYMENTS_NO_HISTORY_DATA), - withDefaultVerticalSpacing = true, modifier = Modifier.weight(1f), ) } @@ -133,21 +132,21 @@ private fun PaymentHistorySuccessScreen( if (yearIndex != 0) { Spacer(Modifier.height(16.dp)) } - Text(text = "${yearCharges.year}", modifier = Modifier.padding(horizontal = 18.dp)) + HedvigText(text = "${yearCharges.year}", modifier = Modifier.padding(horizontal = 18.dp)) yearCharges.charge.forEachIndexed { chargeIndex, charge -> if (chargeIndex != 0) { HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp)) } HorizontalItemsWithMaximumSpaceTaken( startSlot = { - Text( + HedvigText( text = dateTimeFormatter.format(charge.dueDate.toJavaLocalDate()), color = charge.color(), modifier = Modifier.padding(start = 2.dp), ) }, endSlot = { - Text( + HedvigText( text = charge.netAmount.toString(), color = charge.color(), textAlign = TextAlign.End, @@ -163,8 +162,9 @@ private fun PaymentHistorySuccessScreen( } } if (paymentHistory.showInfoAboutOlderCharges) { - VectorInfoCard( - text = stringResource(id = R.string.PAYMENTS_HISTORY_INFO), + HedvigNotificationCard( + message = stringResource(id = R.string.PAYMENTS_HISTORY_INFO), + priority = NotificationDefaults.NotificationPriority.Info, modifier = Modifier.padding(horizontal = 16.dp), ) } @@ -198,9 +198,9 @@ private sealed interface PaymentHistory { @Composable private fun PaymentHistory.PastCharges.YearCharges.Charge.color(): Color { return if (hasFailedCharge) { - MaterialTheme.colorScheme.error + HedvigTheme.colorScheme.signalRedText } else { - MaterialTheme.colorScheme.onSurfaceVariant + HedvigTheme.colorScheme.textSecondary } } @@ -212,7 +212,7 @@ internal fun PaymentHistoryScreenPreview( ) cases: TripleCase, ) { HedvigTheme { - Surface(color = MaterialTheme.colorScheme.background) { + Surface(color = HedvigTheme.colorScheme.backgroundPrimary) { val buildChargesList: (Int) -> List = { numberOfCharges -> List(numberOfCharges) { index -> PaymentHistory.PastCharges.YearCharges.Charge( diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt index d861ca3fb4..1b180dd9b7 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt @@ -120,30 +120,30 @@ private fun PaymentsScreen( ) Box( modifier = Modifier - .fillMaxSize() - .pullRefresh(pullRefreshState), + .fillMaxSize() + .pullRefresh(pullRefreshState), ) { Column( - Modifier - .fillMaxSize() - .verticalScroll(rememberScrollState()) - .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), + Modifier + .fillMaxSize() + .verticalScroll(rememberScrollState()) + .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), ) { Spacer(Modifier.windowInsetsTopHeight(WindowInsets.safeDrawing)) Row( horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically, modifier = Modifier - .height(64.dp) - .fillMaxWidth() - .padding(horizontal = 16.dp), + .height(64.dp) + .fillMaxWidth() + .padding(horizontal = 16.dp), ) { HedvigText( - text = stringResource(R.string.TAB_REFERRALS_TITLE), + text = stringResource(R.string.PROFILE_PAYMENT_TITLE), style = HedvigTheme.typography.headlineSmall, ) } - Spacer(Modifier.height(8.dp)) //todo: maybe 16? + Spacer(Modifier.height(8.dp)) // todo: maybe 16? when (uiState) { PaymentsUiState.Error -> HedvigErrorSection(onButtonClick = onRetry, Modifier.weight(1f)) else -> { @@ -191,15 +191,15 @@ private fun PaymentsContent( upcomingPayment = upcomingPayment as? UpcomingPayment.Content, onCardClicked = onUpcomingPaymentClicked, modifier = Modifier - .padding(horizontal = 16.dp) - .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), + .padding(horizontal = 16.dp) + .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), ) } UpcomingPaymentInfoCard( upcomingPaymentInfo = (uiState as? PaymentsUiState.Content)?.upcomingPaymentInfo, modifier = Modifier - .padding(horizontal = 16.dp) - .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), + .padding(horizontal = 16.dp) + .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), ) val showConnectedPaymentInfo = uiState is PaymentsUiState.Content && uiState.connectedPaymentInfo is NotConnected && @@ -214,8 +214,8 @@ private fun PaymentsContent( connectedPaymentInfo = (uiState as? PaymentsUiState.Content)?.connectedPaymentInfo as? NotConnected, onChangeBankAccount = onChangeBankAccount, modifier = Modifier - .padding(horizontal = 16.dp) - .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), + .padding(horizontal = 16.dp) + .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), ) } @@ -231,9 +231,9 @@ private fun PaymentsContent( enabled = true, buttonStyle = ButtonStyle.Secondary, modifier = Modifier - .padding(horizontal = 16.dp) - .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)) - .hedvigPlaceholder(uiState.isRetrying, highlight = PlaceholderHighlight.shimmer()), + .padding(horizontal = 16.dp) + .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)) + .hedvigPlaceholder(uiState.isRetrying, highlight = PlaceholderHighlight.shimmer()), ) } } @@ -245,8 +245,8 @@ private fun PaymentsContent( message = stringResource(R.string.MY_PAYMENT_UPDATING_MESSAGE), priority = NotificationDefaults.NotificationPriority.Info, modifier = Modifier - .padding(horizontal = 16.dp) - .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), + .padding(horizontal = 16.dp) + .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), ) } } @@ -316,9 +316,9 @@ private fun PaymentsListItems( onPaymentHistoryClicked: () -> Unit, ) { val listItemsSideSpacingModifier = - Modifier - .padding(horizontal = 16.dp) - .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)) + Modifier + .padding(horizontal = 16.dp) + .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)) Column { PaymentsListItem( text = stringResource(R.string.PAYMENTS_DISCOUNTS_SECTION_TITLE), @@ -326,15 +326,15 @@ private fun PaymentsListItems( Icon( imageVector = HedvigIcons.Campaign, contentDescription = null, - tint = HedvigTheme.colorScheme.signalGreenElement, //todo: check here! + tint = HedvigTheme.colorScheme.signalGreenElement, // todo: check here! modifier = Modifier.size(24.dp), ) }, modifier = Modifier - .clickable(onClick = onDiscountClicked) - .then(listItemsSideSpacingModifier) - .padding(vertical = 16.dp) - .fillMaxWidth(), + .clickable(onClick = onDiscountClicked) + .then(listItemsSideSpacingModifier) + .padding(vertical = 16.dp) + .fillMaxWidth(), ) HorizontalDivider(modifier = listItemsSideSpacingModifier) PaymentsListItem( @@ -347,10 +347,10 @@ private fun PaymentsListItems( ) }, modifier = Modifier - .clickable(onClick = onPaymentHistoryClicked) - .then(listItemsSideSpacingModifier) - .padding(vertical = 16.dp) - .fillMaxWidth(), + .clickable(onClick = onPaymentHistoryClicked) + .then(listItemsSideSpacingModifier) + .padding(vertical = 16.dp) + .fillMaxWidth(), ) if (uiState is PaymentsUiState.Content) { if (uiState.connectedPaymentInfo is Connected) { @@ -372,9 +372,9 @@ private fun PaymentsListItems( ) }, modifier = listItemsSideSpacingModifier - .padding(vertical = 16.dp) - .fillMaxWidth() - .hedvigPlaceholder(uiState.isRetrying, highlight = PlaceholderHighlight.shimmer()), + .padding(vertical = 16.dp) + .fillMaxWidth() + .hedvigPlaceholder(uiState.isRetrying, highlight = PlaceholderHighlight.shimmer()), ) } } @@ -398,8 +398,8 @@ private fun PaymentAmountCard( ) { Column( modifier = Modifier - .padding(horizontal = 16.dp, vertical = 12.dp) - .fillMaxWidth(), + .padding(horizontal = 16.dp, vertical = 12.dp) + .fillMaxWidth(), ) { HorizontalItemsWithMaximumSpaceTaken( startSlot = { @@ -416,11 +416,11 @@ private fun PaymentAmountCard( horizontalArrangement = Arrangement.End, verticalAlignment = Alignment.CenterVertically, modifier = Modifier - .wrapContentWidth(Alignment.End) - .hedvigPlaceholder( - visible = upcomingPayment == null, - highlight = PlaceholderHighlight.shimmer(), - ), + .wrapContentWidth(Alignment.End) + .hedvigPlaceholder( + visible = upcomingPayment == null, + highlight = PlaceholderHighlight.shimmer(), + ), ) { HedvigText( text = if (upcomingPayment != null) { From 992b765de87422669c1a96dafdbfa37baa937e75 Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Mon, 18 Nov 2024 16:39:56 +0100 Subject: [PATCH 06/22] history --- .../feature/payments/ui/history/PaymentHistoryDestination.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt index 0ffdb110e6..fdbc473b3f 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt @@ -2,6 +2,7 @@ package com.hedvig.android.feature.payments.ui.history import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -119,10 +120,12 @@ private fun PaymentHistorySuccessScreen( ) { when (paymentHistory) { PaymentHistory.NoHistoryData -> { + Spacer(Modifier.weight(1f)) HedvigInformationSection( title = stringResource(R.string.PAYMENTS_NO_HISTORY_DATA), - modifier = Modifier.weight(1f), + modifier = Modifier.fillMaxSize(), ) + Spacer(Modifier.weight(1f)) } is PaymentHistory.PastCharges -> { From 4d490f137989fd77a29f659ebcb09c3dedf8407b Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Mon, 18 Nov 2024 16:50:19 +0100 Subject: [PATCH 07/22] fix padding and insets --- .../feature/payments/ui/details/PaymentDetailsDestination.kt | 4 ++++ .../payments/ui/discounts/AddDiscountBottomSheetContent.kt | 1 + .../android/feature/payments/ui/discounts/DiscountRow.kt | 2 +- .../feature/payments/ui/discounts/DiscountsDestination.kt | 5 +++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt index 8bdfb50bd6..be6f760f2a 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt @@ -6,10 +6,13 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.safeDrawing import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.runtime.Composable @@ -109,6 +112,7 @@ private fun MemberChargeDetailsScreen( var showBottomSheet by remember { mutableStateOf(false) } HedvigBottomSheet( isVisible = showBottomSheet, + sheetPadding = WindowInsets.safeDrawing.asPaddingValues(), onVisibleChange = { visible -> if (!visible) { showBottomSheet = false diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt index f94cf95c31..6e37d0e6d0 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt @@ -58,6 +58,7 @@ internal fun AddDiscountBottomSheetContent(isLoading: Boolean, errorMessage: Str HedvigButton( text = stringResource(id = R.string.PAYMENTS_ADD_CODE_BUTTON_LABEL), enabled = discountCodeInput.isNotBlank(), + modifier = Modifier.fillMaxWidth(), onClick = { onAddDiscount(discountCodeInput) }, diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt index 87e0dc4902..9e5ba1b4fe 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt @@ -60,7 +60,7 @@ private fun DiscountRow(discount: Discount, modifier: Modifier = Modifier) { endSlot = { discount.amount?.let { discountAmount -> HedvigText( - text = stringResource(R.string.OFFER_COST_AND_PREMIUM_PERIOD_ABBREVIATION, discount.toString()), + text = stringResource(R.string.OFFER_COST_AND_PREMIUM_PERIOD_ABBREVIATION, discountAmount.toString()), color = if (discountIsExpired) { HedvigTheme.colorScheme.textDisabled } else { diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt index 1669fc98fc..da8b56484d 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt @@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsetsSides import androidx.compose.foundation.layout.asPaddingValues +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.only import androidx.compose.foundation.layout.padding @@ -88,6 +89,7 @@ private fun DiscountsScreen( var showInfoBottomSheet by remember { mutableStateOf(false) } HedvigBottomSheet( isVisible = showInfoBottomSheet, + sheetPadding = WindowInsets.safeDrawing.asPaddingValues(), onVisibleChange = { visible -> if (!visible) { showInfoBottomSheet = false @@ -102,6 +104,7 @@ private fun DiscountsScreen( } HedvigBottomSheet( isVisible = uiState.showAddDiscountBottomSheet, + sheetPadding = WindowInsets.safeDrawing.asPaddingValues(), onVisibleChange = { visible -> if (!visible) { onDismissBottomSheet() @@ -153,6 +156,7 @@ private fun DiscountsScreen( Spacer(modifier = Modifier.height(16.dp)) HedvigButton( buttonStyle = ButtonStyle.Secondary, + modifier = Modifier.fillMaxWidth(), enabled = true, text = stringResource(id = R.string.PAYMENTS_ADD_CAMPAIGN_CODE), onClick = { onShowBottomSheet() }, @@ -180,6 +184,7 @@ private fun ForeverSection( var showForeverInfoBottomSheet by remember { mutableStateOf(false) } HedvigBottomSheet( isVisible = showForeverInfoBottomSheet, + sheetPadding = WindowInsets.safeDrawing.asPaddingValues(), onVisibleChange = { visible -> if (!visible) { showForeverInfoBottomSheet = false From c08bf68e4f77d7907c0d1a4710f4c154749a46d7 Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Mon, 18 Nov 2024 20:07:55 +0100 Subject: [PATCH 08/22] wrap width --- .../feature/home/home/ui/HomeLayout.kt | 1 - .../payments/ui/discounts/DiscountRow.kt | 24 ++++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/ui/HomeLayout.kt b/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/ui/HomeLayout.kt index e086ab6a2b..5ff7fc2d25 100644 --- a/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/ui/HomeLayout.kt +++ b/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/ui/HomeLayout.kt @@ -33,7 +33,6 @@ import androidx.compose.ui.util.fastFirstOrNull import androidx.compose.ui.util.fastForEachIndexed import androidx.compose.ui.util.fastSumBy import com.hedvig.android.design.system.hedvig.ButtonDefaults.ButtonSize.Large -import com.hedvig.android.design.system.hedvig.ButtonDefaults.ButtonSize.Medium import com.hedvig.android.design.system.hedvig.HedvigButton import com.hedvig.android.design.system.hedvig.HedvigText import com.hedvig.android.design.system.hedvig.HedvigTextButton diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt index 9e5ba1b4fe..0b684a83d5 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt @@ -2,10 +2,12 @@ package com.hedvig.android.feature.payments.ui.discounts import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -47,15 +49,19 @@ private fun DiscountRow(discount: Discount, modifier: Modifier = Modifier) { Column(modifier = modifier) { HorizontalItemsWithMaximumSpaceTaken( startSlot = { - HighlightLabel( - labelText = discount.code, - color = if (discountIsExpired) { - HighlightLabelDefaults.HighlightColor.Grey(HighlightLabelDefaults.HighlightShade.LIGHT) - } else { - HighlightLabelDefaults.HighlightColor.Blue(HighlightLabelDefaults.HighlightShade.LIGHT) - }, - size = HighlightLabelDefaults.HighLightSize.Small, - ) + Row { + HighlightLabel( + labelText = discount.code, + modifier = Modifier.wrapContentWidth(), + color = if (discountIsExpired) { + HighlightLabelDefaults.HighlightColor.Grey(HighlightLabelDefaults.HighlightShade.LIGHT) + } else { + HighlightLabelDefaults.HighlightColor.Blue(HighlightLabelDefaults.HighlightShade.LIGHT) + }, + size = HighlightLabelDefaults.HighLightSize.Small, + ) + } + }, endSlot = { discount.amount?.let { discountAmount -> From 3f63eb917bbfac164425a49a2f57fa1349669b10 Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Mon, 18 Nov 2024 20:09:56 +0100 Subject: [PATCH 09/22] getting rid of lint errors --- .../android/feature/home/home/ui/HomeLayout.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/ui/HomeLayout.kt b/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/ui/HomeLayout.kt index 5ff7fc2d25..878e2181c0 100644 --- a/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/ui/HomeLayout.kt +++ b/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/ui/HomeLayout.kt @@ -208,8 +208,8 @@ private fun PreviewHomeLayoutCenteredContent() { Surface(color = HedvigTheme.colorScheme.backgroundPrimary, modifier = Modifier.fillMaxSize()) { BoxWithConstraints { PreviewHomeLayout( - maxWidth = constraints.maxWidth, - maxHeight = constraints.maxHeight, + maxWidth = this.constraints.maxWidth, + maxHeight = this.constraints.maxHeight, claimStatusCards = { Column(Modifier.padding(horizontal = 16.dp), Arrangement.spacedBy(8.dp)) { PreviewBox { HedvigText("claim status card") } @@ -228,8 +228,8 @@ private fun PreviewHomeLayoutCenteredContentWithSomeBottomAttachedContent() { Surface(color = HedvigTheme.colorScheme.backgroundPrimary, modifier = Modifier.fillMaxSize()) { BoxWithConstraints { PreviewHomeLayout( - maxWidth = constraints.maxWidth, - maxHeight = constraints.maxHeight, + maxWidth = this.constraints.maxWidth, + maxHeight = this.constraints.maxHeight, memberReminderCards = { Column(Modifier.padding(horizontal = 16.dp), Arrangement.spacedBy(8.dp)) { repeat(1) { index -> @@ -250,8 +250,8 @@ private fun PreviewHomeLayoutNonCenteredNonScrollableContent() { Surface(color = HedvigTheme.colorScheme.backgroundPrimary, modifier = Modifier.fillMaxSize()) { BoxWithConstraints { PreviewHomeLayout( - maxWidth = constraints.maxWidth, - maxHeight = constraints.maxHeight, + maxWidth = this.constraints.maxWidth, + maxHeight = this.constraints.maxHeight, veryImportantMessages = { Column(Modifier.padding(horizontal = 16.dp), Arrangement.spacedBy(8.dp)) { PreviewBox(0) { HedvigText("Important message") } @@ -277,8 +277,8 @@ private fun PreviewHomeLayoutScrollingContent() { Surface(color = HedvigTheme.colorScheme.backgroundPrimary, modifier = Modifier.fillMaxSize()) { BoxWithConstraints { PreviewHomeLayout( - maxWidth = constraints.maxWidth, - maxHeight = constraints.maxHeight, + maxWidth = this.constraints.maxWidth, + maxHeight = this.constraints.maxHeight, claimStatusCards = { Column(Modifier.padding(horizontal = 16.dp), Arrangement.spacedBy(8.dp)) { PreviewBox { HedvigText("claim status card") } From cededcba923c636b05350ddf7da481178b30a7c8 Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Mon, 18 Nov 2024 20:10:07 +0100 Subject: [PATCH 10/22] ktlint --- .../hedvig/android/feature/payments/ui/discounts/DiscountRow.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt index 0b684a83d5..371e6f3a9a 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt @@ -61,7 +61,6 @@ private fun DiscountRow(discount: Discount, modifier: Modifier = Modifier) { size = HighlightLabelDefaults.HighLightSize.Small, ) } - }, endSlot = { discount.amount?.let { discountAmount -> From d20a788e16dcb22c4f9e93deb67a671a22a92eff Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Tue, 19 Nov 2024 10:24:57 +0100 Subject: [PATCH 11/22] some bs changes --- .../data/GetInsuranceContractsUseCase.kt | 2 + .../ui/details/PaymentDetailsDestination.kt | 584 +++++++++--------- .../AddDiscountBottomSheetContent.kt | 21 +- .../ui/discounts/DiscountsDestination.kt | 4 +- 4 files changed, 313 insertions(+), 298 deletions(-) diff --git a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt index 85a447c1ff..944d8e73c9 100644 --- a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt +++ b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt @@ -13,6 +13,7 @@ import com.hedvig.android.core.common.formatSsn import com.hedvig.android.data.productvariant.toProductVariant import com.hedvig.android.featureflags.FeatureManager import com.hedvig.android.featureflags.flags.Feature +import com.hedvig.android.logger.logcat import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import octopus.InsuranceContractsQuery @@ -38,6 +39,7 @@ internal class GetInsuranceContractsUseCaseImpl( featureManager.isFeatureEnabled(Feature.TIER), ) { insuranceQueryResponse, isEditCoInsuredEnabled, isMovingFlowFlagEnabled, isTierEnabled -> either { + val insuranceQueryData = insuranceQueryResponse.bind() val contractHolderDisplayName = insuranceQueryData.getContractHolderDisplayName() val contractHolderSSN = insuranceQueryData.currentMember.ssn?.let { formatSsn(it) } diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt index be6f760f2a..74ed597ef9 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt @@ -6,13 +6,10 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.safeDrawing import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.runtime.Composable @@ -58,330 +55,331 @@ import kotlinx.datetime.toJavaLocalDate @Composable internal fun PaymentDetailsDestination( - viewModel: PaymentDetailsViewModel, - onFailedChargeClick: (String?) -> Unit, - navigateUp: () -> Unit, + viewModel: PaymentDetailsViewModel, + onFailedChargeClick: (String?) -> Unit, + navigateUp: () -> Unit, ) { - var selectedCharge by remember { mutableStateOf(null) } - val uiState by viewModel.uiState.collectAsStateWithLifecycle() + var selectedCharge by remember { mutableStateOf(null) } + val uiState by viewModel.uiState.collectAsStateWithLifecycle() - MemberChargeDetailsScreen( - uiState = uiState, - navigateUp = navigateUp, - selectedCharge = selectedCharge, - onCardClick = { clickedCharge -> - selectedCharge = if (selectedCharge == clickedCharge) { - null - } else { - clickedCharge - } - }, - onFailedChargeClick = onFailedChargeClick, - reload = { viewModel.emit(PaymentDetailsEvent.Reload) }, - ) + MemberChargeDetailsScreen( + uiState = uiState, + navigateUp = navigateUp, + selectedCharge = selectedCharge, + onCardClick = { clickedCharge -> + selectedCharge = if (selectedCharge == clickedCharge) { + null + } else { + clickedCharge + } + }, + onFailedChargeClick = onFailedChargeClick, + reload = { viewModel.emit(PaymentDetailsEvent.Reload) }, + ) } @Composable private fun MemberChargeDetailsScreen( - uiState: PaymentDetailsUiState, - selectedCharge: MemberCharge.ChargeBreakdown?, - onCardClick: (MemberCharge.ChargeBreakdown) -> Unit, - reload: () -> Unit, - onFailedChargeClick: (String?) -> Unit, - navigateUp: () -> Unit, + uiState: PaymentDetailsUiState, + selectedCharge: MemberCharge.ChargeBreakdown?, + onCardClick: (MemberCharge.ChargeBreakdown) -> Unit, + reload: () -> Unit, + onFailedChargeClick: (String?) -> Unit, + navigateUp: () -> Unit, ) { - when (uiState) { - PaymentDetailsUiState.Failure -> { - HedvigScaffold( - navigateUp = navigateUp, - ) { - HedvigErrorSection(onButtonClick = reload, modifier = Modifier.weight(1f)) - } - } + when (uiState) { + PaymentDetailsUiState.Failure -> { + HedvigScaffold( + navigateUp = navigateUp, + ) { + HedvigErrorSection(onButtonClick = reload, modifier = Modifier.weight(1f)) + } + } - PaymentDetailsUiState.Loading -> HedvigFullScreenCenterAlignedProgress() - is PaymentDetailsUiState.Success -> { - val dateTimeFormatter = rememberHedvigDateTimeFormatter() + PaymentDetailsUiState.Loading -> HedvigFullScreenCenterAlignedProgress() + is PaymentDetailsUiState.Success -> { + val dateTimeFormatter = rememberHedvigDateTimeFormatter() - HedvigScaffold( - topAppBarText = dateTimeFormatter.format(uiState.paymentDetails.memberCharge.dueDate.toJavaLocalDate()), - navigateUp = navigateUp, - customTopAppBarColors = uiState.paymentDetails.memberCharge.topAppBarColors(), - ) { - Column(modifier = Modifier.padding(16.dp)) { - var showBottomSheet by remember { mutableStateOf(false) } - HedvigBottomSheet( - isVisible = showBottomSheet, - sheetPadding = WindowInsets.safeDrawing.asPaddingValues(), - onVisibleChange = { visible -> - if (!visible) { - showBottomSheet = false - } - }, - ) { - HedvigText(text = stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_TITLE)) - HedvigText( - text = stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_DESCRIPTION), - color = HedvigTheme.colorScheme.textSecondary, - ) - } + HedvigScaffold( + topAppBarText = dateTimeFormatter.format(uiState.paymentDetails.memberCharge.dueDate.toJavaLocalDate()), + navigateUp = navigateUp, + customTopAppBarColors = uiState.paymentDetails.memberCharge.topAppBarColors(), + ) { + Column(modifier = Modifier.padding(16.dp)) { + var showBottomSheet by remember { mutableStateOf(false) } + HedvigBottomSheet( + isVisible = showBottomSheet, + onVisibleChange = { visible -> + if (!visible) { + showBottomSheet = false + } + }, + ) { + HedvigText(text = stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_TITLE)) + HedvigText( + text = stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_DESCRIPTION), + color = HedvigTheme.colorScheme.textSecondary, + ) + } - uiState.paymentDetails.memberCharge.chargeBreakdowns.forEach { chargeBreakdown -> - PaymentDetailExpandableCard( - displayName = chargeBreakdown.contractDisplayName, - subtitle = chargeBreakdown.contractDetails, - totalAmount = chargeBreakdown.grossAmount.toString(), - periods = chargeBreakdown.periods, - isExpanded = selectedCharge == chargeBreakdown, - onClick = { onCardClick(chargeBreakdown) }, - ) - Spacer(modifier = Modifier.height(8.dp)) - } + uiState.paymentDetails.memberCharge.chargeBreakdowns.forEach { chargeBreakdown -> + PaymentDetailExpandableCard( + displayName = chargeBreakdown.contractDisplayName, + subtitle = chargeBreakdown.contractDetails, + totalAmount = chargeBreakdown.grossAmount.toString(), + periods = chargeBreakdown.periods, + isExpanded = selectedCharge == chargeBreakdown, + onClick = { onCardClick(chargeBreakdown) }, + ) + Spacer(modifier = Modifier.height(8.dp)) + } - uiState.paymentDetails.memberCharge.carriedAdjustmentIfAboveZero()?.let { - Spacer(modifier = Modifier.height(16.dp)) - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween, - ) { - HedvigText(text = stringResource(id = R.string.payments_carried_adjustment)) - HedvigText(text = it.toString()) - } - Spacer(modifier = Modifier.height(8.dp)) - HedvigNotificationCard( - priority = NotificationDefaults.NotificationPriority.Info, - message = stringResource(id = R.string.payments_carried_adjustment_info), - ) - Spacer(modifier = Modifier.height(16.dp)) - } + uiState.paymentDetails.memberCharge.carriedAdjustmentIfAboveZero()?.let { + Spacer(modifier = Modifier.height(16.dp)) + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, + ) { + HedvigText(text = stringResource(id = R.string.payments_carried_adjustment)) + HedvigText(text = it.toString()) + } + Spacer(modifier = Modifier.height(8.dp)) + HedvigNotificationCard( + priority = NotificationDefaults.NotificationPriority.Info, + message = stringResource(id = R.string.payments_carried_adjustment_info), + ) + Spacer(modifier = Modifier.height(16.dp)) + } - uiState.paymentDetails.memberCharge.settlementAdjustmentIfAboveZero()?.let { - Spacer(modifier = Modifier.height(16.dp)) - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween, - ) { - HedvigText(text = stringResource(id = R.string.payments_settlement_adjustment)) - HedvigText(text = it.toString()) - } - Spacer(modifier = Modifier.height(8.dp)) - HedvigNotificationCard( - priority = NotificationDefaults.NotificationPriority.Info, - message = stringResource(id = R.string.payments_settlement_adjustment_info), - ) - Spacer(modifier = Modifier.height(16.dp)) - } + uiState.paymentDetails.memberCharge.settlementAdjustmentIfAboveZero()?.let { + Spacer(modifier = Modifier.height(16.dp)) + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, + ) { + HedvigText(text = stringResource(id = R.string.payments_settlement_adjustment)) + HedvigText(text = it.toString()) + } + Spacer(modifier = Modifier.height(8.dp)) + HedvigNotificationCard( + priority = NotificationDefaults.NotificationPriority.Info, + message = stringResource(id = R.string.payments_settlement_adjustment_info), + ) + Spacer(modifier = Modifier.height(16.dp)) + } - if (uiState.paymentDetails.memberCharge.discounts.isNotEmpty()) { - Spacer(modifier = Modifier.height(16.dp)) - HedvigText(stringResource(R.string.PAYMENTS_DISCOUNTS_SECTION_TITLE)) - Spacer(modifier = Modifier.height(16.dp)) - DiscountRows(uiState.paymentDetails.memberCharge.discounts) - Spacer(modifier = Modifier.height(16.dp)) - } + if (uiState.paymentDetails.memberCharge.discounts.isNotEmpty()) { + Spacer(modifier = Modifier.height(16.dp)) + HedvigText(stringResource(R.string.PAYMENTS_DISCOUNTS_SECTION_TITLE)) + Spacer(modifier = Modifier.height(16.dp)) + DiscountRows(uiState.paymentDetails.memberCharge.discounts) + Spacer(modifier = Modifier.height(16.dp)) + } - HorizontalItemsWithMaximumSpaceTaken( - startSlot = { - HedvigText(stringResource(R.string.payment_details_receipt_card_total)) - }, - endSlot = { - Row( - horizontalArrangement = Arrangement.End, - verticalAlignment = Alignment.CenterVertically, - ) { - if (uiState.paymentDetails.memberCharge.grossAmount != uiState.paymentDetails.memberCharge.netAmount) { - HedvigText( - text = uiState.paymentDetails.memberCharge.grossAmount.toString(), - textAlign = TextAlign.End, - textDecoration = TextDecoration.LineThrough, - color = HedvigTheme.colorScheme.textSecondary, - ) - Spacer(Modifier.width(6.dp)) - } - HedvigText( - text = uiState.paymentDetails.memberCharge.netAmount.toString(), - textAlign = TextAlign.End, - ) - } - }, - ) - Spacer(modifier = Modifier.height(16.dp)) - HorizontalDivider() + HorizontalItemsWithMaximumSpaceTaken( + startSlot = { + HedvigText(stringResource(R.string.payment_details_receipt_card_total)) + }, + endSlot = { + Row( + horizontalArrangement = Arrangement.End, + verticalAlignment = Alignment.CenterVertically, + ) { + if (uiState.paymentDetails.memberCharge.grossAmount != uiState.paymentDetails.memberCharge.netAmount) { + HedvigText( + text = uiState.paymentDetails.memberCharge.grossAmount.toString(), + textAlign = TextAlign.End, + textDecoration = TextDecoration.LineThrough, + color = HedvigTheme.colorScheme.textSecondary, + ) + Spacer(Modifier.width(6.dp)) + } + HedvigText( + text = uiState.paymentDetails.memberCharge.netAmount.toString(), + textAlign = TextAlign.End, + ) + } + }, + ) + Spacer(modifier = Modifier.height(16.dp)) + HorizontalDivider() - HorizontalItemsWithMaximumSpaceTaken( - startSlot = { - HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_DUE)) - }, - endSlot = { - HedvigText( - text = dateTimeFormatter.format(uiState.paymentDetails.memberCharge.dueDate.toJavaLocalDate()), - textAlign = TextAlign.End, - modifier = Modifier.fillMaxWidth(), - color = HedvigTheme.colorScheme.textSecondary, - ) - }, - modifier = Modifier.padding(vertical = 16.dp), - ) + HorizontalItemsWithMaximumSpaceTaken( + startSlot = { + HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_DUE)) + }, + endSlot = { + HedvigText( + text = dateTimeFormatter.format(uiState.paymentDetails.memberCharge.dueDate.toJavaLocalDate()), + textAlign = TextAlign.End, + modifier = Modifier.fillMaxWidth(), + color = HedvigTheme.colorScheme.textSecondary, + ) + }, + modifier = Modifier.padding(vertical = 16.dp), + ) - when (uiState.paymentDetails.memberCharge.status) { - MemberCharge.MemberChargeStatus.UPCOMING -> {} - MemberCharge.MemberChargeStatus.SUCCESS -> - HedvigNotificationCard( - priority = NotificationDefaults.NotificationPriority.Campaign, - // so here we have the same color that was in the old DS - green; but the icon doesn't match (it was checkmark, - // we don't have Checkmark icon in the new NotificationCards. so I've put withIcon = false here - withIcon = false, - style = NotificationDefaults.InfoCardStyle.Default, - message = stringResource(id = R.string.PAYMENTS_PAYMENT_SUCCESSFUL), - ) + when (uiState.paymentDetails.memberCharge.status) { + MemberCharge.MemberChargeStatus.UPCOMING -> {} + MemberCharge.MemberChargeStatus.SUCCESS -> + HedvigNotificationCard( + priority = NotificationDefaults.NotificationPriority.Campaign, + // so here we have the same color that was in the old DS - green; but the icon doesn't match (it was checkmark, + // we don't have Checkmark icon in the new NotificationCards. so I've put withIcon = false here + withIcon = false, + style = NotificationDefaults.InfoCardStyle.Default, + message = stringResource(id = R.string.PAYMENTS_PAYMENT_SUCCESSFUL), + ) - MemberCharge.MemberChargeStatus.PENDING -> HedvigNotificationCard( - message = stringResource(id = R.string.PAYMENTS_IN_PROGRESS), - style = NotificationDefaults.InfoCardStyle.Default, - priority = NotificationDefaults.NotificationPriority.Info, - withIcon = true, - ) + MemberCharge.MemberChargeStatus.PENDING -> HedvigNotificationCard( + message = stringResource(id = R.string.PAYMENTS_IN_PROGRESS), + style = NotificationDefaults.InfoCardStyle.Default, + priority = NotificationDefaults.NotificationPriority.Info, + withIcon = true, + ) - MemberCharge.MemberChargeStatus.FAILED -> HedvigNotificationCard( - message = stringResource( - id = R.string.PAYMENTS_PAYMENT_FAILED, - uiState.paymentDetails.getNextCharge(uiState.paymentDetails.memberCharge)?.let { - dateTimeFormatter.format(it.dueDate.toJavaLocalDate()) - } ?: "-", - ), - priority = NotificationDefaults.NotificationPriority.Attention, - withIcon = true, - style = NotificationDefaults.InfoCardStyle.Button( - buttonText = stringResource(R.string.PAYMENTS_VIEW_PAYMENT), - onButtonClick = { - val nextCharge = uiState.paymentDetails.getNextCharge(uiState.paymentDetails.memberCharge) - if (nextCharge != null) { - onFailedChargeClick(nextCharge.id) - } - }, - ), - ) + MemberCharge.MemberChargeStatus.FAILED -> HedvigNotificationCard( + message = stringResource( + id = R.string.PAYMENTS_PAYMENT_FAILED, + uiState.paymentDetails.getNextCharge(uiState.paymentDetails.memberCharge) + ?.let { + dateTimeFormatter.format(it.dueDate.toJavaLocalDate()) + } ?: "-", + ), + priority = NotificationDefaults.NotificationPriority.Attention, + withIcon = true, + style = NotificationDefaults.InfoCardStyle.Button( + buttonText = stringResource(R.string.PAYMENTS_VIEW_PAYMENT), + onButtonClick = { + val nextCharge = + uiState.paymentDetails.getNextCharge(uiState.paymentDetails.memberCharge) + if (nextCharge != null) { + onFailedChargeClick(nextCharge.id) + } + }, + ), + ) - MemberCharge.MemberChargeStatus.UNKNOWN -> {} - } + MemberCharge.MemberChargeStatus.UNKNOWN -> {} + } - val paymentConnection = uiState.paymentDetails.paymentConnection - if (paymentConnection is PaymentConnection.Active) { - Spacer(Modifier.height(32.dp)) - HorizontalItemsWithMaximumSpaceTaken( - startSlot = { - HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_TITLE)) - }, - endSlot = { - Box( - contentAlignment = Alignment.CenterEnd, - modifier = Modifier - .fillMaxWidth(), - ) { - Box( - modifier = Modifier - .fillMaxHeight() - .width(32.dp) - .clip(HedvigTheme.shapes.cornerMedium) - .clickable { showBottomSheet = true }, - contentAlignment = Alignment.Center, - ) { - Icon( - imageVector = HedvigIcons.InfoFilled, - tint = HedvigTheme.colorScheme.fillSecondary, - contentDescription = "Info icon", - modifier = Modifier.size(16.dp), - ) - } - } - }, - modifier = Modifier.padding(vertical = 16.dp), - ) - HorizontalDivider() + val paymentConnection = uiState.paymentDetails.paymentConnection + if (paymentConnection is PaymentConnection.Active) { + Spacer(Modifier.height(32.dp)) + HorizontalItemsWithMaximumSpaceTaken( + startSlot = { + HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_TITLE)) + }, + endSlot = { + Box( + contentAlignment = Alignment.CenterEnd, + modifier = Modifier + .fillMaxWidth(), + ) { + Box( + modifier = Modifier + .fillMaxHeight() + .width(32.dp) + .clip(HedvigTheme.shapes.cornerMedium) + .clickable { showBottomSheet = true }, + contentAlignment = Alignment.Center, + ) { + Icon( + imageVector = HedvigIcons.InfoFilled, + tint = HedvigTheme.colorScheme.fillSecondary, + contentDescription = "Info icon", + modifier = Modifier.size(16.dp), + ) + } + } + }, + modifier = Modifier.padding(vertical = 16.dp), + ) + HorizontalDivider() - HorizontalItemsWithMaximumSpaceTaken( - startSlot = { - HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_METHOD)) - }, - endSlot = { - HedvigText( - text = stringResource(id = R.string.PAYMENTS_AUTOGIRO_LABEL), - textAlign = TextAlign.End, - modifier = Modifier.fillMaxWidth(), - color = HedvigTheme.colorScheme.textSecondary, - ) - }, - modifier = Modifier.padding(vertical = 16.dp), - ) - HorizontalDivider() + HorizontalItemsWithMaximumSpaceTaken( + startSlot = { + HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_METHOD)) + }, + endSlot = { + HedvigText( + text = stringResource(id = R.string.PAYMENTS_AUTOGIRO_LABEL), + textAlign = TextAlign.End, + modifier = Modifier.fillMaxWidth(), + color = HedvigTheme.colorScheme.textSecondary, + ) + }, + modifier = Modifier.padding(vertical = 16.dp), + ) + HorizontalDivider() - HorizontalItemsWithMaximumSpaceTaken( - startSlot = { - HedvigText(stringResource(id = R.string.PAYMENTS_ACCOUNT)) - }, - endSlot = { - HedvigText( - text = paymentConnection.displayValue, - textAlign = TextAlign.End, - modifier = Modifier.fillMaxWidth(), - color = HedvigTheme.colorScheme.textSecondary, - ) - }, - modifier = Modifier.padding(vertical = 16.dp), - ) - HorizontalDivider() + HorizontalItemsWithMaximumSpaceTaken( + startSlot = { + HedvigText(stringResource(id = R.string.PAYMENTS_ACCOUNT)) + }, + endSlot = { + HedvigText( + text = paymentConnection.displayValue, + textAlign = TextAlign.End, + modifier = Modifier.fillMaxWidth(), + color = HedvigTheme.colorScheme.textSecondary, + ) + }, + modifier = Modifier.padding(vertical = 16.dp), + ) + HorizontalDivider() - HorizontalItemsWithMaximumSpaceTaken( - startSlot = { HedvigText(stringResource(id = R.string.PAYMENTS_BANK_LABEL)) }, - endSlot = { - HedvigText( - text = paymentConnection.displayName, - textAlign = TextAlign.End, - modifier = Modifier.fillMaxWidth(), - color = HedvigTheme.colorScheme.textSecondary, - ) - }, - modifier = Modifier.padding(vertical = 16.dp), - ) - } + HorizontalItemsWithMaximumSpaceTaken( + startSlot = { HedvigText(stringResource(id = R.string.PAYMENTS_BANK_LABEL)) }, + endSlot = { + HedvigText( + text = paymentConnection.displayName, + textAlign = TextAlign.End, + modifier = Modifier.fillMaxWidth(), + color = HedvigTheme.colorScheme.textSecondary, + ) + }, + modifier = Modifier.padding(vertical = 16.dp), + ) + } + } + } } - } } - } } @Composable private fun MemberCharge.topAppBarColors(): TopAppBarColors? { - return if (this.status == MemberCharge.MemberChargeStatus.FAILED) { - TopAppBarColors( - contentColor = HedvigTheme.colorScheme.backgroundPrimary, - containerColor = HedvigTheme.colorScheme.signalRedText, - ) - } else { - null - } + return if (this.status == MemberCharge.MemberChargeStatus.FAILED) { + TopAppBarColors( + contentColor = HedvigTheme.colorScheme.backgroundPrimary, + containerColor = HedvigTheme.colorScheme.signalRedText, + ) + } else { + null + } } @Composable @Preview(device = "spec:width=1080px,height=3500px,dpi=440") @HedvigPreview private fun PaymentDetailsScreenPreview() { - HedvigTheme { - Surface(color = HedvigTheme.colorScheme.backgroundPrimary) { - MemberChargeDetailsScreen( - uiState = PaymentDetailsUiState.Success( - PaymentDetails( - memberCharge = paymentDetailsPreviewData, - pastCharges = chargeHistoryPreviewData, - paymentConnection = paymentOverViewPreviewData.paymentConnection, - ), - ), - selectedCharge = null, - onCardClick = {}, - navigateUp = {}, - onFailedChargeClick = {}, - reload = {}, - ) + HedvigTheme { + Surface(color = HedvigTheme.colorScheme.backgroundPrimary) { + MemberChargeDetailsScreen( + uiState = PaymentDetailsUiState.Success( + PaymentDetails( + memberCharge = paymentDetailsPreviewData, + pastCharges = chargeHistoryPreviewData, + paymentConnection = paymentOverViewPreviewData.paymentConnection, + ), + ), + selectedCharge = null, + onCardClick = {}, + navigateUp = {}, + onFailedChargeClick = {}, + reload = {}, + ) + } } - } } diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt index 6e37d0e6d0..f82ab0b951 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt @@ -2,9 +2,12 @@ package com.hedvig.android.feature.payments.ui.discounts import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.safeDrawing +import androidx.compose.foundation.layout.windowInsetsBottomHeight import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -17,6 +20,7 @@ import androidx.compose.ui.unit.dp import com.hedvig.android.design.system.hedvig.HedvigButton import com.hedvig.android.design.system.hedvig.HedvigPreview import com.hedvig.android.design.system.hedvig.HedvigText +import com.hedvig.android.design.system.hedvig.HedvigTextButton import com.hedvig.android.design.system.hedvig.HedvigTextField import com.hedvig.android.design.system.hedvig.HedvigTextFieldDefaults import com.hedvig.android.design.system.hedvig.HedvigTextFieldDefaults.TextFieldSize @@ -25,7 +29,11 @@ import com.hedvig.android.design.system.hedvig.Surface import hedvig.resources.R @Composable -internal fun AddDiscountBottomSheetContent(isLoading: Boolean, errorMessage: String?, onAddDiscount: (String) -> Unit) { +internal fun AddDiscountBottomSheetContent( + isLoading: Boolean, + errorMessage: String?, + onAddDiscount: (String) -> Unit, + onDismiss: () -> Unit) { var discountCodeInput by remember { mutableStateOf("") } Column( modifier = Modifier.padding(horizontal = 16.dp), @@ -64,7 +72,15 @@ internal fun AddDiscountBottomSheetContent(isLoading: Boolean, errorMessage: Str }, isLoading = isLoading, ) - Spacer(Modifier.height(32.dp)) + Spacer(Modifier.height(8.dp)) + HedvigTextButton ( + text = stringResource(id = R.string.general_cancel_button), + enabled = true, + modifier = Modifier.fillMaxWidth(), + onClick = onDismiss, + ) + Spacer(Modifier.height(8.dp)) + Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing)) } } @@ -77,6 +93,7 @@ private fun AddDiscountBottomSheetPreview() { isLoading = false, errorMessage = null, onAddDiscount = {}, + onDismiss = {} ) } } diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt index da8b56484d..8b1c806817 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt @@ -89,7 +89,6 @@ private fun DiscountsScreen( var showInfoBottomSheet by remember { mutableStateOf(false) } HedvigBottomSheet( isVisible = showInfoBottomSheet, - sheetPadding = WindowInsets.safeDrawing.asPaddingValues(), onVisibleChange = { visible -> if (!visible) { showInfoBottomSheet = false @@ -104,7 +103,6 @@ private fun DiscountsScreen( } HedvigBottomSheet( isVisible = uiState.showAddDiscountBottomSheet, - sheetPadding = WindowInsets.safeDrawing.asPaddingValues(), onVisibleChange = { visible -> if (!visible) { onDismissBottomSheet() @@ -117,6 +115,7 @@ private fun DiscountsScreen( }, errorMessage = uiState.discountError, isLoading = uiState.isAddingDiscount, + onDismiss = onDismissBottomSheet ) } @@ -184,7 +183,6 @@ private fun ForeverSection( var showForeverInfoBottomSheet by remember { mutableStateOf(false) } HedvigBottomSheet( isVisible = showForeverInfoBottomSheet, - sheetPadding = WindowInsets.safeDrawing.asPaddingValues(), onVisibleChange = { visible -> if (!visible) { showForeverInfoBottomSheet = false From 430eed26b4ef2e060002f0dd2ae5a00b8f1dcbeb Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Tue, 19 Nov 2024 11:09:54 +0100 Subject: [PATCH 12/22] some bs changes --- .../ui/details/PaymentDetailsDestination.kt | 587 +++++++++--------- .../ui/discounts/DiscountsDestination.kt | 8 + 2 files changed, 304 insertions(+), 291 deletions(-) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt index 74ed597ef9..2397c91aa8 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt @@ -6,12 +6,15 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.safeDrawing import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.windowInsetsBottomHeight import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -55,331 +58,333 @@ import kotlinx.datetime.toJavaLocalDate @Composable internal fun PaymentDetailsDestination( - viewModel: PaymentDetailsViewModel, - onFailedChargeClick: (String?) -> Unit, - navigateUp: () -> Unit, + viewModel: PaymentDetailsViewModel, + onFailedChargeClick: (String?) -> Unit, + navigateUp: () -> Unit, ) { - var selectedCharge by remember { mutableStateOf(null) } - val uiState by viewModel.uiState.collectAsStateWithLifecycle() + var selectedCharge by remember { mutableStateOf(null) } + val uiState by viewModel.uiState.collectAsStateWithLifecycle() - MemberChargeDetailsScreen( - uiState = uiState, - navigateUp = navigateUp, - selectedCharge = selectedCharge, - onCardClick = { clickedCharge -> - selectedCharge = if (selectedCharge == clickedCharge) { - null - } else { - clickedCharge - } - }, - onFailedChargeClick = onFailedChargeClick, - reload = { viewModel.emit(PaymentDetailsEvent.Reload) }, - ) + MemberChargeDetailsScreen( + uiState = uiState, + navigateUp = navigateUp, + selectedCharge = selectedCharge, + onCardClick = { clickedCharge -> + selectedCharge = if (selectedCharge == clickedCharge) { + null + } else { + clickedCharge + } + }, + onFailedChargeClick = onFailedChargeClick, + reload = { viewModel.emit(PaymentDetailsEvent.Reload) }, + ) } @Composable private fun MemberChargeDetailsScreen( - uiState: PaymentDetailsUiState, - selectedCharge: MemberCharge.ChargeBreakdown?, - onCardClick: (MemberCharge.ChargeBreakdown) -> Unit, - reload: () -> Unit, - onFailedChargeClick: (String?) -> Unit, - navigateUp: () -> Unit, + uiState: PaymentDetailsUiState, + selectedCharge: MemberCharge.ChargeBreakdown?, + onCardClick: (MemberCharge.ChargeBreakdown) -> Unit, + reload: () -> Unit, + onFailedChargeClick: (String?) -> Unit, + navigateUp: () -> Unit, ) { - when (uiState) { - PaymentDetailsUiState.Failure -> { - HedvigScaffold( - navigateUp = navigateUp, - ) { - HedvigErrorSection(onButtonClick = reload, modifier = Modifier.weight(1f)) - } - } + when (uiState) { + PaymentDetailsUiState.Failure -> { + HedvigScaffold( + navigateUp = navigateUp, + ) { + HedvigErrorSection(onButtonClick = reload, modifier = Modifier.weight(1f)) + } + } - PaymentDetailsUiState.Loading -> HedvigFullScreenCenterAlignedProgress() - is PaymentDetailsUiState.Success -> { - val dateTimeFormatter = rememberHedvigDateTimeFormatter() + PaymentDetailsUiState.Loading -> HedvigFullScreenCenterAlignedProgress() + is PaymentDetailsUiState.Success -> { + val dateTimeFormatter = rememberHedvigDateTimeFormatter() - HedvigScaffold( - topAppBarText = dateTimeFormatter.format(uiState.paymentDetails.memberCharge.dueDate.toJavaLocalDate()), - navigateUp = navigateUp, - customTopAppBarColors = uiState.paymentDetails.memberCharge.topAppBarColors(), - ) { - Column(modifier = Modifier.padding(16.dp)) { - var showBottomSheet by remember { mutableStateOf(false) } - HedvigBottomSheet( - isVisible = showBottomSheet, - onVisibleChange = { visible -> - if (!visible) { - showBottomSheet = false - } - }, - ) { - HedvigText(text = stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_TITLE)) - HedvigText( - text = stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_DESCRIPTION), - color = HedvigTheme.colorScheme.textSecondary, - ) - } + HedvigScaffold( + topAppBarText = dateTimeFormatter.format(uiState.paymentDetails.memberCharge.dueDate.toJavaLocalDate()), + navigateUp = navigateUp, + customTopAppBarColors = uiState.paymentDetails.memberCharge.topAppBarColors(), + ) { + Column(modifier = Modifier.padding(16.dp)) { + var showBottomSheet by remember { mutableStateOf(false) } + HedvigBottomSheet( + isVisible = showBottomSheet, + onVisibleChange = { visible -> + if (!visible) { + showBottomSheet = false + } + }, + ) { + HedvigText(text = stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_TITLE)) + HedvigText( + text = stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_DESCRIPTION), + color = HedvigTheme.colorScheme.textSecondary, + ) + Spacer(Modifier.height(16.dp)) + Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing)) + } - uiState.paymentDetails.memberCharge.chargeBreakdowns.forEach { chargeBreakdown -> - PaymentDetailExpandableCard( - displayName = chargeBreakdown.contractDisplayName, - subtitle = chargeBreakdown.contractDetails, - totalAmount = chargeBreakdown.grossAmount.toString(), - periods = chargeBreakdown.periods, - isExpanded = selectedCharge == chargeBreakdown, - onClick = { onCardClick(chargeBreakdown) }, - ) - Spacer(modifier = Modifier.height(8.dp)) - } + uiState.paymentDetails.memberCharge.chargeBreakdowns.forEach { chargeBreakdown -> + PaymentDetailExpandableCard( + displayName = chargeBreakdown.contractDisplayName, + subtitle = chargeBreakdown.contractDetails, + totalAmount = chargeBreakdown.grossAmount.toString(), + periods = chargeBreakdown.periods, + isExpanded = selectedCharge == chargeBreakdown, + onClick = { onCardClick(chargeBreakdown) }, + ) + Spacer(modifier = Modifier.height(8.dp)) + } - uiState.paymentDetails.memberCharge.carriedAdjustmentIfAboveZero()?.let { - Spacer(modifier = Modifier.height(16.dp)) - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween, - ) { - HedvigText(text = stringResource(id = R.string.payments_carried_adjustment)) - HedvigText(text = it.toString()) - } - Spacer(modifier = Modifier.height(8.dp)) - HedvigNotificationCard( - priority = NotificationDefaults.NotificationPriority.Info, - message = stringResource(id = R.string.payments_carried_adjustment_info), - ) - Spacer(modifier = Modifier.height(16.dp)) - } + uiState.paymentDetails.memberCharge.carriedAdjustmentIfAboveZero()?.let { + Spacer(modifier = Modifier.height(16.dp)) + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, + ) { + HedvigText(text = stringResource(id = R.string.payments_carried_adjustment)) + HedvigText(text = it.toString()) + } + Spacer(modifier = Modifier.height(8.dp)) + HedvigNotificationCard( + priority = NotificationDefaults.NotificationPriority.Info, + message = stringResource(id = R.string.payments_carried_adjustment_info), + ) + Spacer(modifier = Modifier.height(16.dp)) + } - uiState.paymentDetails.memberCharge.settlementAdjustmentIfAboveZero()?.let { - Spacer(modifier = Modifier.height(16.dp)) - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween, - ) { - HedvigText(text = stringResource(id = R.string.payments_settlement_adjustment)) - HedvigText(text = it.toString()) - } - Spacer(modifier = Modifier.height(8.dp)) - HedvigNotificationCard( - priority = NotificationDefaults.NotificationPriority.Info, - message = stringResource(id = R.string.payments_settlement_adjustment_info), - ) - Spacer(modifier = Modifier.height(16.dp)) - } + uiState.paymentDetails.memberCharge.settlementAdjustmentIfAboveZero()?.let { + Spacer(modifier = Modifier.height(16.dp)) + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, + ) { + HedvigText(text = stringResource(id = R.string.payments_settlement_adjustment)) + HedvigText(text = it.toString()) + } + Spacer(modifier = Modifier.height(8.dp)) + HedvigNotificationCard( + priority = NotificationDefaults.NotificationPriority.Info, + message = stringResource(id = R.string.payments_settlement_adjustment_info), + ) + Spacer(modifier = Modifier.height(16.dp)) + } - if (uiState.paymentDetails.memberCharge.discounts.isNotEmpty()) { - Spacer(modifier = Modifier.height(16.dp)) - HedvigText(stringResource(R.string.PAYMENTS_DISCOUNTS_SECTION_TITLE)) - Spacer(modifier = Modifier.height(16.dp)) - DiscountRows(uiState.paymentDetails.memberCharge.discounts) - Spacer(modifier = Modifier.height(16.dp)) - } + if (uiState.paymentDetails.memberCharge.discounts.isNotEmpty()) { + Spacer(modifier = Modifier.height(16.dp)) + HedvigText(stringResource(R.string.PAYMENTS_DISCOUNTS_SECTION_TITLE)) + Spacer(modifier = Modifier.height(16.dp)) + DiscountRows(uiState.paymentDetails.memberCharge.discounts) + Spacer(modifier = Modifier.height(16.dp)) + } - HorizontalItemsWithMaximumSpaceTaken( - startSlot = { - HedvigText(stringResource(R.string.payment_details_receipt_card_total)) - }, - endSlot = { - Row( - horizontalArrangement = Arrangement.End, - verticalAlignment = Alignment.CenterVertically, - ) { - if (uiState.paymentDetails.memberCharge.grossAmount != uiState.paymentDetails.memberCharge.netAmount) { - HedvigText( - text = uiState.paymentDetails.memberCharge.grossAmount.toString(), - textAlign = TextAlign.End, - textDecoration = TextDecoration.LineThrough, - color = HedvigTheme.colorScheme.textSecondary, - ) - Spacer(Modifier.width(6.dp)) - } - HedvigText( - text = uiState.paymentDetails.memberCharge.netAmount.toString(), - textAlign = TextAlign.End, - ) - } - }, - ) - Spacer(modifier = Modifier.height(16.dp)) - HorizontalDivider() + HorizontalItemsWithMaximumSpaceTaken( + startSlot = { + HedvigText(stringResource(R.string.payment_details_receipt_card_total)) + }, + endSlot = { + Row( + horizontalArrangement = Arrangement.End, + verticalAlignment = Alignment.CenterVertically, + ) { + if (uiState.paymentDetails.memberCharge.grossAmount != uiState.paymentDetails.memberCharge.netAmount) { + HedvigText( + text = uiState.paymentDetails.memberCharge.grossAmount.toString(), + textAlign = TextAlign.End, + textDecoration = TextDecoration.LineThrough, + color = HedvigTheme.colorScheme.textSecondary, + ) + Spacer(Modifier.width(6.dp)) + } + HedvigText( + text = uiState.paymentDetails.memberCharge.netAmount.toString(), + textAlign = TextAlign.End, + ) + } + }, + ) + Spacer(modifier = Modifier.height(16.dp)) + HorizontalDivider() - HorizontalItemsWithMaximumSpaceTaken( - startSlot = { - HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_DUE)) - }, - endSlot = { - HedvigText( - text = dateTimeFormatter.format(uiState.paymentDetails.memberCharge.dueDate.toJavaLocalDate()), - textAlign = TextAlign.End, - modifier = Modifier.fillMaxWidth(), - color = HedvigTheme.colorScheme.textSecondary, - ) - }, - modifier = Modifier.padding(vertical = 16.dp), - ) + HorizontalItemsWithMaximumSpaceTaken( + startSlot = { + HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_DUE)) + }, + endSlot = { + HedvigText( + text = dateTimeFormatter.format(uiState.paymentDetails.memberCharge.dueDate.toJavaLocalDate()), + textAlign = TextAlign.End, + modifier = Modifier.fillMaxWidth(), + color = HedvigTheme.colorScheme.textSecondary, + ) + }, + modifier = Modifier.padding(vertical = 16.dp), + ) - when (uiState.paymentDetails.memberCharge.status) { - MemberCharge.MemberChargeStatus.UPCOMING -> {} - MemberCharge.MemberChargeStatus.SUCCESS -> - HedvigNotificationCard( - priority = NotificationDefaults.NotificationPriority.Campaign, - // so here we have the same color that was in the old DS - green; but the icon doesn't match (it was checkmark, - // we don't have Checkmark icon in the new NotificationCards. so I've put withIcon = false here - withIcon = false, - style = NotificationDefaults.InfoCardStyle.Default, - message = stringResource(id = R.string.PAYMENTS_PAYMENT_SUCCESSFUL), - ) + when (uiState.paymentDetails.memberCharge.status) { + MemberCharge.MemberChargeStatus.UPCOMING -> {} + MemberCharge.MemberChargeStatus.SUCCESS -> + HedvigNotificationCard( + priority = NotificationDefaults.NotificationPriority.Campaign, + // so here we have the same color that was in the old DS - green; but the icon doesn't match (it was checkmark, + // we don't have Checkmark icon in the new NotificationCards. so I've put withIcon = false here + withIcon = false, + style = NotificationDefaults.InfoCardStyle.Default, + message = stringResource(id = R.string.PAYMENTS_PAYMENT_SUCCESSFUL), + ) - MemberCharge.MemberChargeStatus.PENDING -> HedvigNotificationCard( - message = stringResource(id = R.string.PAYMENTS_IN_PROGRESS), - style = NotificationDefaults.InfoCardStyle.Default, - priority = NotificationDefaults.NotificationPriority.Info, - withIcon = true, - ) + MemberCharge.MemberChargeStatus.PENDING -> HedvigNotificationCard( + message = stringResource(id = R.string.PAYMENTS_IN_PROGRESS), + style = NotificationDefaults.InfoCardStyle.Default, + priority = NotificationDefaults.NotificationPriority.Info, + withIcon = true, + ) - MemberCharge.MemberChargeStatus.FAILED -> HedvigNotificationCard( - message = stringResource( - id = R.string.PAYMENTS_PAYMENT_FAILED, - uiState.paymentDetails.getNextCharge(uiState.paymentDetails.memberCharge) - ?.let { - dateTimeFormatter.format(it.dueDate.toJavaLocalDate()) - } ?: "-", - ), - priority = NotificationDefaults.NotificationPriority.Attention, - withIcon = true, - style = NotificationDefaults.InfoCardStyle.Button( - buttonText = stringResource(R.string.PAYMENTS_VIEW_PAYMENT), - onButtonClick = { - val nextCharge = - uiState.paymentDetails.getNextCharge(uiState.paymentDetails.memberCharge) - if (nextCharge != null) { - onFailedChargeClick(nextCharge.id) - } - }, - ), - ) + MemberCharge.MemberChargeStatus.FAILED -> HedvigNotificationCard( + message = stringResource( + id = R.string.PAYMENTS_PAYMENT_FAILED, + uiState.paymentDetails.getNextCharge(uiState.paymentDetails.memberCharge) + ?.let { + dateTimeFormatter.format(it.dueDate.toJavaLocalDate()) + } ?: "-", + ), + priority = NotificationDefaults.NotificationPriority.Attention, + withIcon = true, + style = NotificationDefaults.InfoCardStyle.Button( + buttonText = stringResource(R.string.PAYMENTS_VIEW_PAYMENT), + onButtonClick = { + val nextCharge = + uiState.paymentDetails.getNextCharge(uiState.paymentDetails.memberCharge) + if (nextCharge != null) { + onFailedChargeClick(nextCharge.id) + } + }, + ), + ) - MemberCharge.MemberChargeStatus.UNKNOWN -> {} - } + MemberCharge.MemberChargeStatus.UNKNOWN -> {} + } - val paymentConnection = uiState.paymentDetails.paymentConnection - if (paymentConnection is PaymentConnection.Active) { - Spacer(Modifier.height(32.dp)) - HorizontalItemsWithMaximumSpaceTaken( - startSlot = { - HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_TITLE)) - }, - endSlot = { - Box( - contentAlignment = Alignment.CenterEnd, - modifier = Modifier - .fillMaxWidth(), - ) { - Box( - modifier = Modifier - .fillMaxHeight() - .width(32.dp) - .clip(HedvigTheme.shapes.cornerMedium) - .clickable { showBottomSheet = true }, - contentAlignment = Alignment.Center, - ) { - Icon( - imageVector = HedvigIcons.InfoFilled, - tint = HedvigTheme.colorScheme.fillSecondary, - contentDescription = "Info icon", - modifier = Modifier.size(16.dp), - ) - } - } - }, - modifier = Modifier.padding(vertical = 16.dp), - ) - HorizontalDivider() + val paymentConnection = uiState.paymentDetails.paymentConnection + if (paymentConnection is PaymentConnection.Active) { + Spacer(Modifier.height(32.dp)) + HorizontalItemsWithMaximumSpaceTaken( + startSlot = { + HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_TITLE)) + }, + endSlot = { + Box( + contentAlignment = Alignment.CenterEnd, + modifier = Modifier + .fillMaxWidth(), + ) { + Box( + modifier = Modifier + .fillMaxHeight() + .width(32.dp) + .clip(HedvigTheme.shapes.cornerMedium) + .clickable { showBottomSheet = true }, + contentAlignment = Alignment.Center, + ) { + Icon( + imageVector = HedvigIcons.InfoFilled, + tint = HedvigTheme.colorScheme.fillSecondary, + contentDescription = "Info icon", + modifier = Modifier.size(16.dp), + ) + } + } + }, + modifier = Modifier.padding(vertical = 16.dp), + ) + HorizontalDivider() - HorizontalItemsWithMaximumSpaceTaken( - startSlot = { - HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_METHOD)) - }, - endSlot = { - HedvigText( - text = stringResource(id = R.string.PAYMENTS_AUTOGIRO_LABEL), - textAlign = TextAlign.End, - modifier = Modifier.fillMaxWidth(), - color = HedvigTheme.colorScheme.textSecondary, - ) - }, - modifier = Modifier.padding(vertical = 16.dp), - ) - HorizontalDivider() + HorizontalItemsWithMaximumSpaceTaken( + startSlot = { + HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_METHOD)) + }, + endSlot = { + HedvigText( + text = stringResource(id = R.string.PAYMENTS_AUTOGIRO_LABEL), + textAlign = TextAlign.End, + modifier = Modifier.fillMaxWidth(), + color = HedvigTheme.colorScheme.textSecondary, + ) + }, + modifier = Modifier.padding(vertical = 16.dp), + ) + HorizontalDivider() - HorizontalItemsWithMaximumSpaceTaken( - startSlot = { - HedvigText(stringResource(id = R.string.PAYMENTS_ACCOUNT)) - }, - endSlot = { - HedvigText( - text = paymentConnection.displayValue, - textAlign = TextAlign.End, - modifier = Modifier.fillMaxWidth(), - color = HedvigTheme.colorScheme.textSecondary, - ) - }, - modifier = Modifier.padding(vertical = 16.dp), - ) - HorizontalDivider() + HorizontalItemsWithMaximumSpaceTaken( + startSlot = { + HedvigText(stringResource(id = R.string.PAYMENTS_ACCOUNT)) + }, + endSlot = { + HedvigText( + text = paymentConnection.displayValue, + textAlign = TextAlign.End, + modifier = Modifier.fillMaxWidth(), + color = HedvigTheme.colorScheme.textSecondary, + ) + }, + modifier = Modifier.padding(vertical = 16.dp), + ) + HorizontalDivider() - HorizontalItemsWithMaximumSpaceTaken( - startSlot = { HedvigText(stringResource(id = R.string.PAYMENTS_BANK_LABEL)) }, - endSlot = { - HedvigText( - text = paymentConnection.displayName, - textAlign = TextAlign.End, - modifier = Modifier.fillMaxWidth(), - color = HedvigTheme.colorScheme.textSecondary, - ) - }, - modifier = Modifier.padding(vertical = 16.dp), - ) - } - } - } + HorizontalItemsWithMaximumSpaceTaken( + startSlot = { HedvigText(stringResource(id = R.string.PAYMENTS_BANK_LABEL)) }, + endSlot = { + HedvigText( + text = paymentConnection.displayName, + textAlign = TextAlign.End, + modifier = Modifier.fillMaxWidth(), + color = HedvigTheme.colorScheme.textSecondary, + ) + }, + modifier = Modifier.padding(vertical = 16.dp), + ) + } } + } } + } } @Composable private fun MemberCharge.topAppBarColors(): TopAppBarColors? { - return if (this.status == MemberCharge.MemberChargeStatus.FAILED) { - TopAppBarColors( - contentColor = HedvigTheme.colorScheme.backgroundPrimary, - containerColor = HedvigTheme.colorScheme.signalRedText, - ) - } else { - null - } + return if (this.status == MemberCharge.MemberChargeStatus.FAILED) { + TopAppBarColors( + contentColor = HedvigTheme.colorScheme.backgroundPrimary, + containerColor = HedvigTheme.colorScheme.signalRedText, + ) + } else { + null + } } @Composable @Preview(device = "spec:width=1080px,height=3500px,dpi=440") @HedvigPreview private fun PaymentDetailsScreenPreview() { - HedvigTheme { - Surface(color = HedvigTheme.colorScheme.backgroundPrimary) { - MemberChargeDetailsScreen( - uiState = PaymentDetailsUiState.Success( - PaymentDetails( - memberCharge = paymentDetailsPreviewData, - pastCharges = chargeHistoryPreviewData, - paymentConnection = paymentOverViewPreviewData.paymentConnection, - ), - ), - selectedCharge = null, - onCardClick = {}, - navigateUp = {}, - onFailedChargeClick = {}, - reload = {}, - ) - } + HedvigTheme { + Surface(color = HedvigTheme.colorScheme.backgroundPrimary) { + MemberChargeDetailsScreen( + uiState = PaymentDetailsUiState.Success( + PaymentDetails( + memberCharge = paymentDetailsPreviewData, + pastCharges = chargeHistoryPreviewData, + paymentConnection = paymentOverViewPreviewData.paymentConnection, + ), + ), + selectedCharge = null, + onCardClick = {}, + navigateUp = {}, + onFailedChargeClick = {}, + reload = {}, + ) } + } } diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt index 8b1c806817..a6f8b9b9a5 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt @@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.only import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.safeDrawing import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.windowInsetsBottomHeight import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -43,6 +44,7 @@ import com.hedvig.android.design.system.hedvig.HedvigNotificationCard import com.hedvig.android.design.system.hedvig.HedvigPreview import com.hedvig.android.design.system.hedvig.HedvigScaffold import com.hedvig.android.design.system.hedvig.HedvigText +import com.hedvig.android.design.system.hedvig.HedvigTextButton import com.hedvig.android.design.system.hedvig.HedvigTheme import com.hedvig.android.design.system.hedvig.HorizontalItemsWithMaximumSpaceTaken import com.hedvig.android.design.system.hedvig.Icon @@ -100,6 +102,9 @@ private fun DiscountsScreen( text = stringResource(R.string.PAYMENTS_CAMPAIGNS_INFO_DESCRIPTION), color = HedvigTheme.colorScheme.textSecondary, ) + Spacer(Modifier.height(16.dp)) + Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing)) + } HedvigBottomSheet( isVisible = uiState.showAddDiscountBottomSheet, @@ -194,6 +199,9 @@ private fun ForeverSection( text = stringResource(R.string.referrals_info_sheet_body, incentive), color = HedvigTheme.colorScheme.textSecondary, ) + Spacer(Modifier.height(16.dp)) + Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing)) + } HorizontalItemsWithMaximumSpaceTaken( startSlot = { From 2f0a2967ec22513e7cd5bda2093630d70bdb831e Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Tue, 19 Nov 2024 11:24:00 +0100 Subject: [PATCH 13/22] insurances - put the error section in the middle --- .../insurance/InsuranceDestination.kt | 25 ++++++++++++++++--- .../ui/details/PaymentDetailsDestination.kt | 2 +- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/InsuranceDestination.kt b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/InsuranceDestination.kt index a149fa771c..db4acc521c 100644 --- a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/InsuranceDestination.kt +++ b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/InsuranceDestination.kt @@ -28,6 +28,7 @@ import androidx.compose.runtime.rememberUpdatedState import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource @@ -60,6 +61,7 @@ import com.hedvig.android.design.system.hedvig.InsuranceCardPlaceholder import com.hedvig.android.design.system.hedvig.NotificationDefaults.InfoCardStyle import com.hedvig.android.design.system.hedvig.NotificationDefaults.NotificationPriority import com.hedvig.android.design.system.hedvig.Surface +import com.hedvig.android.design.system.hedvig.debugBorder import com.hedvig.android.design.system.hedvig.rememberPreviewImageLoader import com.hedvig.android.feature.insurances.data.InsuranceAgreement import com.hedvig.android.feature.insurances.data.InsuranceContract @@ -155,16 +157,21 @@ private fun InsuranceScreen( } AnimatedContent( targetState = uiState, + Modifier.weight(1f), transitionSpec = { fadeIn() togetherWith fadeOut() }, label = "uiState", ) { state -> if (state.hasError) { - HedvigErrorSection( - onButtonClick = reload, - modifier = Modifier.fillMaxSize(), - ) + Column { + Spacer(Modifier.weight(1f)) + HedvigErrorSection( + onButtonClick = reload, + modifier = Modifier.fillMaxSize(), + ) + Spacer(Modifier.weight(1f)) + } } else { InsuranceScreenContent( uiState = state, @@ -394,6 +401,16 @@ private fun PreviewInsuranceDestinationAnimation() { private class InsuranceUiStateProvider : CollectionPreviewParameterProvider( listOf( + InsuranceUiState( + contracts = listOf(), + crossSells = listOf(), + hasError = true, + isLoading = false, + isRetrying = false, + quantityOfCancelledInsurances = 0, + showNotificationBadge = false, + shouldSuggestMovingFlow = true, + ), InsuranceUiState( contracts = listOf(), crossSells = listOf(), diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt index 2397c91aa8..67240a4c6f 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt @@ -251,7 +251,7 @@ private fun MemberChargeDetailsScreen( dateTimeFormatter.format(it.dueDate.toJavaLocalDate()) } ?: "-", ), - priority = NotificationDefaults.NotificationPriority.Attention, + priority = NotificationDefaults.NotificationPriority.Error, withIcon = true, style = NotificationDefaults.InfoCardStyle.Button( buttonText = stringResource(R.string.PAYMENTS_VIEW_PAYMENT), From 63ad6490bd860f550edd783d2ccbeddbd4b24f9a Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Tue, 19 Nov 2024 11:27:59 +0100 Subject: [PATCH 14/22] insurances - put the error section in the middle --- .../feature/insurances/insurance/InsuranceDestination.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/InsuranceDestination.kt b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/InsuranceDestination.kt index db4acc521c..1782c81a8b 100644 --- a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/InsuranceDestination.kt +++ b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/InsuranceDestination.kt @@ -168,7 +168,7 @@ private fun InsuranceScreen( Spacer(Modifier.weight(1f)) HedvigErrorSection( onButtonClick = reload, - modifier = Modifier.fillMaxSize(), + modifier = Modifier.fillMaxSize().padding(horizontal = 16.dp), ) Spacer(Modifier.weight(1f)) } From 92a5c108cf0ed275bb4d9bc0a5c08d46d8a40150 Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Tue, 19 Nov 2024 14:04:33 +0100 Subject: [PATCH 15/22] remove button at the payment details notification --- .../design/system/hedvig/HedvigBottomSheet.kt | 1 - .../ui/AddCoInsuredBottomSheetContent.kt | 6 +-- .../center/data/GetMemberActionsUseCase.kt | 12 +++--- .../home/home/data/GetHomeDataUseCase.kt | 10 ++--- .../data/GetInsuranceContractsUseCase.kt | 2 - .../insurance/InsuranceDestination.kt | 2 - .../presentation/InsurancePresenter.kt | 4 +- ...seCoverageLevelAndDeductibleDestination.kt | 1 - .../payments/navigation/PaymentsGraph.kt | 11 +---- .../ui/details/PaymentDetailExpandableCard.kt | 6 +-- .../ui/details/PaymentDetailsDestination.kt | 42 ++++++++----------- .../AddDiscountBottomSheetContent.kt | 7 ++-- .../payments/ui/discounts/DiscountRow.kt | 5 ++- .../ui/discounts/DiscountsDestination.kt | 26 +++++++++--- .../ui/history/PaymentHistoryDestination.kt | 2 +- .../ui/payments/PaymentsDestination.kt | 11 ++--- .../GetMemberRemindersUseCase.kt | 8 ++-- .../foreverui/ui/ui/EditCodeBottomSheet.kt | 4 +- .../comparison/ui/ComparisonDestination.kt | 1 - .../bottomSheet/BottomSheetShowcase.kt | 3 -- 20 files changed, 79 insertions(+), 85 deletions(-) diff --git a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigBottomSheet.kt b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigBottomSheet.kt index 2f0666cb56..17b638140e 100644 --- a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigBottomSheet.kt +++ b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/HedvigBottomSheet.kt @@ -39,7 +39,6 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Shape import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import com.hedvig.android.design.system.hedvig.ButtonDefaults.ButtonStyle.Ghost import com.hedvig.android.design.system.hedvig.icon.ArrowDown import com.hedvig.android.design.system.hedvig.icon.HedvigIcons import com.hedvig.android.design.system.hedvig.tokens.BottomSheetTokens diff --git a/app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/ui/AddCoInsuredBottomSheetContent.kt b/app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/ui/AddCoInsuredBottomSheetContent.kt index ca5927936c..4487328bdc 100644 --- a/app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/ui/AddCoInsuredBottomSheetContent.kt +++ b/app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/ui/AddCoInsuredBottomSheetContent.kt @@ -215,9 +215,9 @@ private fun SelectableHedvigCard(text: String, isSelected: Boolean, onClick: () Row( verticalAlignment = Alignment.CenterVertically, modifier = Modifier - .heightIn(72.dp) - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 10.dp), + .heightIn(72.dp) + .fillMaxWidth() + .padding(horizontal = 16.dp, vertical = 10.dp), ) { Text( text = text, diff --git a/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/data/GetMemberActionsUseCase.kt b/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/data/GetMemberActionsUseCase.kt index 44206ed3bb..77fc7cc688 100644 --- a/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/data/GetMemberActionsUseCase.kt +++ b/app/feature/feature-help-center/src/main/kotlin/com/hedvig/android/feature/help/center/data/GetMemberActionsUseCase.kt @@ -42,12 +42,12 @@ internal class GetMemberActionsUseCaseImpl( .bind().currentMember.memberActions }, ) { - isCoInsuredFeatureOn, - isMovingFeatureOn, - isConnectPaymentFeatureOn, - isTierEnabled, - market, - memberActions, + isCoInsuredFeatureOn, + isMovingFeatureOn, + isConnectPaymentFeatureOn, + isTierEnabled, + market, + memberActions, -> MemberAction( isCancelInsuranceEnabled = memberActions?.isCancelInsuranceEnabled ?: false, diff --git a/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/data/GetHomeDataUseCase.kt b/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/data/GetHomeDataUseCase.kt index 058bcef20c..ed44f787c4 100644 --- a/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/data/GetHomeDataUseCase.kt +++ b/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/data/GetHomeDataUseCase.kt @@ -71,11 +71,11 @@ internal class GetHomeDataUseCaseImpl( featureManager.isFeatureEnabled(Feature.HELP_CENTER), ) { isChatDisabled, isHelpCenterEnabled -> isChatDisabled to isHelpCenterEnabled }, ) { - homeQueryDataResult, - unreadMessageCountResult, - isEligibleToShowTheChatIconResult, - memberReminders, - (isChatDisabled, isHelpCenterEnabled), + homeQueryDataResult, + unreadMessageCountResult, + isEligibleToShowTheChatIconResult, + memberReminders, + (isChatDisabled, isHelpCenterEnabled), -> either { val homeQueryData: HomeQuery.Data = homeQueryDataResult.bind() diff --git a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt index 944d8e73c9..85a447c1ff 100644 --- a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt +++ b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/data/GetInsuranceContractsUseCase.kt @@ -13,7 +13,6 @@ import com.hedvig.android.core.common.formatSsn import com.hedvig.android.data.productvariant.toProductVariant import com.hedvig.android.featureflags.FeatureManager import com.hedvig.android.featureflags.flags.Feature -import com.hedvig.android.logger.logcat import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import octopus.InsuranceContractsQuery @@ -39,7 +38,6 @@ internal class GetInsuranceContractsUseCaseImpl( featureManager.isFeatureEnabled(Feature.TIER), ) { insuranceQueryResponse, isEditCoInsuredEnabled, isMovingFlowFlagEnabled, isTierEnabled -> either { - val insuranceQueryData = insuranceQueryResponse.bind() val contractHolderDisplayName = insuranceQueryData.getContractHolderDisplayName() val contractHolderSSN = insuranceQueryData.currentMember.ssn?.let { formatSsn(it) } diff --git a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/InsuranceDestination.kt b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/InsuranceDestination.kt index 1782c81a8b..8ed7335d5c 100644 --- a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/InsuranceDestination.kt +++ b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/InsuranceDestination.kt @@ -28,7 +28,6 @@ import androidx.compose.runtime.rememberUpdatedState import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource @@ -61,7 +60,6 @@ import com.hedvig.android.design.system.hedvig.InsuranceCardPlaceholder import com.hedvig.android.design.system.hedvig.NotificationDefaults.InfoCardStyle import com.hedvig.android.design.system.hedvig.NotificationDefaults.NotificationPriority import com.hedvig.android.design.system.hedvig.Surface -import com.hedvig.android.design.system.hedvig.debugBorder import com.hedvig.android.design.system.hedvig.rememberPreviewImageLoader import com.hedvig.android.feature.insurances.data.InsuranceAgreement import com.hedvig.android.feature.insurances.data.InsuranceContract diff --git a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/presentation/InsurancePresenter.kt b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/presentation/InsurancePresenter.kt index ab10679fb8..a17fbb379c 100644 --- a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/presentation/InsurancePresenter.kt +++ b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurance/presentation/InsurancePresenter.kt @@ -149,8 +149,8 @@ private suspend fun loadInsuranceData( { getInsuranceContractsUseCase.invoke(forceNetworkFetch).first().bind() }, { getCrossSellsUseCase.invoke().bind() }, ) { - contracts: List, - crossSellsData: List, + contracts: List, + crossSellsData: List, -> val insuranceCards = contracts .filterNot(InsuranceContract::isTerminated) diff --git a/app/feature/feature-movingflow/src/main/kotlin/com/hedvig/android/feature/movingflow/ui/chosecoveragelevelanddeductible/ChoseCoverageLevelAndDeductibleDestination.kt b/app/feature/feature-movingflow/src/main/kotlin/com/hedvig/android/feature/movingflow/ui/chosecoveragelevelanddeductible/ChoseCoverageLevelAndDeductibleDestination.kt index ba082d5325..e477523e20 100644 --- a/app/feature/feature-movingflow/src/main/kotlin/com/hedvig/android/feature/movingflow/ui/chosecoveragelevelanddeductible/ChoseCoverageLevelAndDeductibleDestination.kt +++ b/app/feature/feature-movingflow/src/main/kotlin/com/hedvig/android/feature/movingflow/ui/chosecoveragelevelanddeductible/ChoseCoverageLevelAndDeductibleDestination.kt @@ -192,7 +192,6 @@ private fun ChoseCoverageLevelAndDeductibleScreen( Spacer(Modifier.height(8.dp)) CoverageCard(content.tiersInfo, onSelectCoverageOption, onSelectDeductibleOption) Spacer(Modifier.height(8.dp)) - // todo Add comparison API results here if (content.tiersInfo.coverageOptions.isNotEmpty()) { HedvigTextButton( text = stringResource(R.string.TIER_FLOW_COMPARE_BUTTON), diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/navigation/PaymentsGraph.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/navigation/PaymentsGraph.kt index 6462e30e45..18876b74d1 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/navigation/PaymentsGraph.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/navigation/PaymentsGraph.kt @@ -49,7 +49,7 @@ fun NavGraphBuilder.paymentsGraph( onDiscountClicked = { with(navigator) { backStackEntry.navigate(PaymentsDestinations.Discounts) } }, - onUpcomingPaymentClicked = { memberChargeId: String? -> + onPaymentClicked = { memberChargeId: String? -> with(navigator) { backStackEntry.navigate( PaymentsDestinations.Details( @@ -65,15 +65,6 @@ fun NavGraphBuilder.paymentsGraph( val viewModel: PaymentDetailsViewModel = koinViewModel(parameters = { parametersOf(this.memberChargeId) }) PaymentDetailsDestination( viewModel = viewModel, - onFailedChargeClick = { memberChargeId: String? -> - with(navigator) { - backStackEntry.navigate( - PaymentsDestinations.Details( - memberChargeId, - ), - ) - } - }, navigateUp = navigator::navigateUp, ) } diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailExpandableCard.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailExpandableCard.kt index 5e7d06b967..6b27f2633d 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailExpandableCard.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailExpandableCard.kt @@ -131,7 +131,7 @@ internal fun PaymentDetailExpandableCard( if (it.isPreviouslyFailedCharge) { HedvigText( text = stringResource(id = R.string.PAYMENTS_OUTSTANDING_PAYMENT), - style = HedvigTheme.typography.label, // todo: check here! + style = HedvigTheme.typography.label, color = it.toSubtitleColor(), ) } @@ -175,7 +175,7 @@ private fun MemberCharge.ChargeBreakdown.Period.toString(dateTimeFormatter: Date @Composable private fun MemberCharge.ChargeBreakdown.Period.toColor(): Color { return if (isPreviouslyFailedCharge) { - HedvigTheme.colorScheme.signalRedText // todo: check here! + HedvigTheme.colorScheme.signalRedElement } else { LocalContentColor.current } @@ -184,7 +184,7 @@ private fun MemberCharge.ChargeBreakdown.Period.toColor(): Color { @Composable private fun MemberCharge.ChargeBreakdown.Period.toSubtitleColor(): Color { return if (isPreviouslyFailedCharge) { - HedvigTheme.colorScheme.signalRedText // todo: check here! + HedvigTheme.colorScheme.signalRedElement } else { HedvigTheme.colorScheme.textSecondary } diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt index 67240a4c6f..36cc1af043 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt @@ -36,6 +36,7 @@ import com.hedvig.android.design.system.hedvig.HedvigNotificationCard import com.hedvig.android.design.system.hedvig.HedvigPreview import com.hedvig.android.design.system.hedvig.HedvigScaffold import com.hedvig.android.design.system.hedvig.HedvigText +import com.hedvig.android.design.system.hedvig.HedvigTextButton import com.hedvig.android.design.system.hedvig.HedvigTheme import com.hedvig.android.design.system.hedvig.HorizontalDivider import com.hedvig.android.design.system.hedvig.HorizontalItemsWithMaximumSpaceTaken @@ -57,11 +58,7 @@ import hedvig.resources.R import kotlinx.datetime.toJavaLocalDate @Composable -internal fun PaymentDetailsDestination( - viewModel: PaymentDetailsViewModel, - onFailedChargeClick: (String?) -> Unit, - navigateUp: () -> Unit, -) { +internal fun PaymentDetailsDestination(viewModel: PaymentDetailsViewModel, navigateUp: () -> Unit) { var selectedCharge by remember { mutableStateOf(null) } val uiState by viewModel.uiState.collectAsStateWithLifecycle() @@ -76,7 +73,6 @@ internal fun PaymentDetailsDestination( clickedCharge } }, - onFailedChargeClick = onFailedChargeClick, reload = { viewModel.emit(PaymentDetailsEvent.Reload) }, ) } @@ -87,7 +83,6 @@ private fun MemberChargeDetailsScreen( selectedCharge: MemberCharge.ChargeBreakdown?, onCardClick: (MemberCharge.ChargeBreakdown) -> Unit, reload: () -> Unit, - onFailedChargeClick: (String?) -> Unit, navigateUp: () -> Unit, ) { when (uiState) { @@ -123,7 +118,16 @@ private fun MemberChargeDetailsScreen( text = stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_DESCRIPTION), color = HedvigTheme.colorScheme.textSecondary, ) - Spacer(Modifier.height(16.dp)) + Spacer(Modifier.height(8.dp)) + HedvigTextButton( + text = stringResource(id = R.string.general_close_button), + enabled = true, + modifier = Modifier.fillMaxWidth(), + onClick = { + showBottomSheet = false + }, + ) + Spacer(Modifier.height(8.dp)) Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing)) } @@ -253,16 +257,7 @@ private fun MemberChargeDetailsScreen( ), priority = NotificationDefaults.NotificationPriority.Error, withIcon = true, - style = NotificationDefaults.InfoCardStyle.Button( - buttonText = stringResource(R.string.PAYMENTS_VIEW_PAYMENT), - onButtonClick = { - val nextCharge = - uiState.paymentDetails.getNextCharge(uiState.paymentDetails.memberCharge) - if (nextCharge != null) { - onFailedChargeClick(nextCharge.id) - } - }, - ), + style = NotificationDefaults.InfoCardStyle.Default, ) MemberCharge.MemberChargeStatus.UNKNOWN -> {} @@ -283,10 +278,10 @@ private fun MemberChargeDetailsScreen( ) { Box( modifier = Modifier - .fillMaxHeight() - .width(32.dp) - .clip(HedvigTheme.shapes.cornerMedium) - .clickable { showBottomSheet = true }, + .fillMaxHeight() + .width(32.dp) + .clip(HedvigTheme.shapes.cornerMedium) + .clickable { showBottomSheet = true }, contentAlignment = Alignment.Center, ) { Icon( @@ -357,7 +352,7 @@ private fun MemberChargeDetailsScreen( private fun MemberCharge.topAppBarColors(): TopAppBarColors? { return if (this.status == MemberCharge.MemberChargeStatus.FAILED) { TopAppBarColors( - contentColor = HedvigTheme.colorScheme.backgroundPrimary, + contentColor = HedvigTheme.colorScheme.textWhite, containerColor = HedvigTheme.colorScheme.signalRedText, ) } else { @@ -382,7 +377,6 @@ private fun PaymentDetailsScreenPreview() { selectedCharge = null, onCardClick = {}, navigateUp = {}, - onFailedChargeClick = {}, reload = {}, ) } diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt index f82ab0b951..165b2ca9bc 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt @@ -33,7 +33,8 @@ internal fun AddDiscountBottomSheetContent( isLoading: Boolean, errorMessage: String?, onAddDiscount: (String) -> Unit, - onDismiss: () -> Unit) { + onDismiss: () -> Unit, +) { var discountCodeInput by remember { mutableStateOf("") } Column( modifier = Modifier.padding(horizontal = 16.dp), @@ -73,7 +74,7 @@ internal fun AddDiscountBottomSheetContent( isLoading = isLoading, ) Spacer(Modifier.height(8.dp)) - HedvigTextButton ( + HedvigTextButton( text = stringResource(id = R.string.general_cancel_button), enabled = true, modifier = Modifier.fillMaxWidth(), @@ -93,7 +94,7 @@ private fun AddDiscountBottomSheetPreview() { isLoading = false, errorMessage = null, onAddDiscount = {}, - onDismiss = {} + onDismiss = {}, ) } } diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt index 371e6f3a9a..f7eb1f18c3 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountRow.kt @@ -52,7 +52,8 @@ private fun DiscountRow(discount: Discount, modifier: Modifier = Modifier) { Row { HighlightLabel( labelText = discount.code, - modifier = Modifier.wrapContentWidth(), + modifier = Modifier + .wrapContentWidth(), color = if (discountIsExpired) { HighlightLabelDefaults.HighlightColor.Grey(HighlightLabelDefaults.HighlightShade.LIGHT) } else { @@ -124,7 +125,7 @@ private fun DiscountRow(discount: Discount, modifier: Modifier = Modifier) { ), textAlign = TextAlign.End, style = HedvigTheme.typography.bodySmall, - color = HedvigTheme.colorScheme.signalRedText, + color = HedvigTheme.colorScheme.signalRedElement, modifier = Modifier.fillMaxWidth(), ) } diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt index a6f8b9b9a5..877c0a6f8d 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt @@ -102,9 +102,17 @@ private fun DiscountsScreen( text = stringResource(R.string.PAYMENTS_CAMPAIGNS_INFO_DESCRIPTION), color = HedvigTheme.colorScheme.textSecondary, ) - Spacer(Modifier.height(16.dp)) + Spacer(Modifier.height(8.dp)) + HedvigTextButton( + text = stringResource(id = R.string.general_close_button), + enabled = true, + modifier = Modifier.fillMaxWidth(), + onClick = { + showInfoBottomSheet = false + }, + ) + Spacer(Modifier.height(8.dp)) Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing)) - } HedvigBottomSheet( isVisible = uiState.showAddDiscountBottomSheet, @@ -120,7 +128,7 @@ private fun DiscountsScreen( }, errorMessage = uiState.discountError, isLoading = uiState.isAddingDiscount, - onDismiss = onDismissBottomSheet + onDismiss = onDismissBottomSheet, ) } @@ -199,9 +207,17 @@ private fun ForeverSection( text = stringResource(R.string.referrals_info_sheet_body, incentive), color = HedvigTheme.colorScheme.textSecondary, ) - Spacer(Modifier.height(16.dp)) + Spacer(Modifier.height(8.dp)) + HedvigTextButton( + text = stringResource(id = R.string.general_close_button), + enabled = true, + modifier = Modifier.fillMaxWidth(), + onClick = { + showForeverInfoBottomSheet = false + }, + ) + Spacer(Modifier.height(8.dp)) Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing)) - } HorizontalItemsWithMaximumSpaceTaken( startSlot = { diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt index fdbc473b3f..408e48cfb6 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt @@ -201,7 +201,7 @@ private sealed interface PaymentHistory { @Composable private fun PaymentHistory.PastCharges.YearCharges.Charge.color(): Color { return if (hasFailedCharge) { - HedvigTheme.colorScheme.signalRedText + HedvigTheme.colorScheme.signalRedElement } else { HedvigTheme.colorScheme.textSecondary } diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt index 1b180dd9b7..ccfd00a50e 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt @@ -83,7 +83,7 @@ import kotlinx.datetime.toLocalDateTime @Composable internal fun PaymentsDestination( viewModel: PaymentsViewModel, - onUpcomingPaymentClicked: (memberChargeId: String?) -> Unit, + onPaymentClicked: (memberChargeId: String?) -> Unit, onDiscountClicked: () -> Unit, onPaymentHistoryClicked: () -> Unit, onChangeBankAccount: () -> Unit, @@ -91,7 +91,7 @@ internal fun PaymentsDestination( val uiState by viewModel.uiState.collectAsStateWithLifecycle() PaymentsScreen( uiState = uiState, - onUpcomingPaymentClicked = onUpcomingPaymentClicked, + onUpcomingPaymentClicked = onPaymentClicked, onChangeBankAccount = onChangeBankAccount, onDiscountClicked = onDiscountClicked, onPaymentHistoryClicked = onPaymentHistoryClicked, @@ -143,7 +143,7 @@ private fun PaymentsScreen( style = HedvigTheme.typography.headlineSmall, ) } - Spacer(Modifier.height(8.dp)) // todo: maybe 16? + Spacer(Modifier.height(8.dp)) when (uiState) { PaymentsUiState.Error -> HedvigErrorSection(onButtonClick = onRetry, Modifier.weight(1f)) else -> { @@ -232,6 +232,7 @@ private fun PaymentsContent( buttonStyle = ButtonStyle.Secondary, modifier = Modifier .padding(horizontal = 16.dp) + .fillMaxWidth() .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)) .hedvigPlaceholder(uiState.isRetrying, highlight = PlaceholderHighlight.shimmer()), ) @@ -295,7 +296,7 @@ private fun UpcomingPaymentInfoCard(upcomingPaymentInfo: UpcomingPaymentInfo?, m is UpcomingPaymentInfo.PaymentFailed -> { val monthDateFormatter = rememberHedvigMonthDateTimeFormatter() HedvigNotificationCard( - priority = NotificationDefaults.NotificationPriority.Attention, + priority = NotificationDefaults.NotificationPriority.Error, message = stringResource( R.string.PAYMENTS_MISSED_PAYMENT, monthDateFormatter.format(upcomingPaymentInfo.failedPaymentStartDate.toJavaLocalDate()), @@ -326,7 +327,7 @@ private fun PaymentsListItems( Icon( imageVector = HedvigIcons.Campaign, contentDescription = null, - tint = HedvigTheme.colorScheme.signalGreenElement, // todo: check here! + tint = HedvigTheme.colorScheme.signalGreenElement, modifier = Modifier.size(24.dp), ) }, diff --git a/app/member-reminders/member-reminders-public/src/main/kotlin/com/hedvig/android/memberreminders/GetMemberRemindersUseCase.kt b/app/member-reminders/member-reminders-public/src/main/kotlin/com/hedvig/android/memberreminders/GetMemberRemindersUseCase.kt index 19025630e3..1b36e11f7c 100644 --- a/app/member-reminders/member-reminders-public/src/main/kotlin/com/hedvig/android/memberreminders/GetMemberRemindersUseCase.kt +++ b/app/member-reminders/member-reminders-public/src/main/kotlin/com/hedvig/android/memberreminders/GetMemberRemindersUseCase.kt @@ -50,10 +50,10 @@ internal class GetMemberRemindersUseCaseImpl( emit(coInsuredInfo) }, ) { - enableNotifications: MemberReminder.EnableNotifications?, - connectPayment: MemberReminder.PaymentReminder?, - upcomingRenewalReminders: NonEmptyList?, - coInsuredInfo: NonEmptyList?, + enableNotifications: MemberReminder.EnableNotifications?, + connectPayment: MemberReminder.PaymentReminder?, + upcomingRenewalReminders: NonEmptyList?, + coInsuredInfo: NonEmptyList?, -> MemberReminders( connectPayment = connectPayment, diff --git a/app/shared/forever-ui/src/main/kotlin/com/hedvig/android/shared/foreverui/ui/ui/EditCodeBottomSheet.kt b/app/shared/forever-ui/src/main/kotlin/com/hedvig/android/shared/foreverui/ui/ui/EditCodeBottomSheet.kt index 169a865e6b..f0b8b9add7 100644 --- a/app/shared/forever-ui/src/main/kotlin/com/hedvig/android/shared/foreverui/ui/ui/EditCodeBottomSheet.kt +++ b/app/shared/forever-ui/src/main/kotlin/com/hedvig/android/shared/foreverui/ui/ui/EditCodeBottomSheet.kt @@ -83,8 +83,8 @@ internal fun EditCodeBottomSheet( ) }, modifier = Modifier - .focusRequester(focusRequester) - .fillMaxWidth(), + .focusRequester(focusRequester) + .fillMaxWidth(), ) Spacer(Modifier.height(8.dp)) HedvigButton( diff --git a/app/shared/tier-comparison/src/main/kotlin/com/hedvig/android/shared/tier/comparison/ui/ComparisonDestination.kt b/app/shared/tier-comparison/src/main/kotlin/com/hedvig/android/shared/tier/comparison/ui/ComparisonDestination.kt index f6500a97d1..2ffd8eb0ea 100644 --- a/app/shared/tier-comparison/src/main/kotlin/com/hedvig/android/shared/tier/comparison/ui/ComparisonDestination.kt +++ b/app/shared/tier-comparison/src/main/kotlin/com/hedvig/android/shared/tier/comparison/ui/ComparisonDestination.kt @@ -13,7 +13,6 @@ import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.IntrinsicSize -import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.WindowInsets diff --git a/micro-apps/design-showcase/src/main/kotlin/com/hedvig/android/sample/design/showcase/bottomSheet/BottomSheetShowcase.kt b/micro-apps/design-showcase/src/main/kotlin/com/hedvig/android/sample/design/showcase/bottomSheet/BottomSheetShowcase.kt index 18f423557e..849846174c 100644 --- a/micro-apps/design-showcase/src/main/kotlin/com/hedvig/android/sample/design/showcase/bottomSheet/BottomSheetShowcase.kt +++ b/micro-apps/design-showcase/src/main/kotlin/com/hedvig/android/sample/design/showcase/bottomSheet/BottomSheetShowcase.kt @@ -87,7 +87,6 @@ private fun BottomSheetWithList(isBottomSheetVisible: Boolean, onVisibleChange: HedvigBottomSheet( isVisible = isBottomSheetVisible, onVisibleChange = onVisibleChange, - bottomButtonText = "Close", ) { Column( Modifier @@ -127,7 +126,6 @@ private fun BottomSheetWithLongList(isBottomSheetVisible: Boolean, onVisibleChan HedvigBottomSheet( isVisible = isBottomSheetVisible, onVisibleChange = onVisibleChange, - bottomButtonText = "Close", ) { Column( Modifier @@ -158,7 +156,6 @@ private fun BottomSheetWithEditText(isBottomSheetVisible: Boolean, onVisibleChan HedvigBottomSheet( isVisible = isBottomSheetVisible, onVisibleChange = onVisibleChange, - bottomButtonText = "Close", ) { Column( Modifier From ecb9d58821a552a309e66c24918350246f4d6c31 Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Tue, 19 Nov 2024 14:52:56 +0100 Subject: [PATCH 16/22] change topAppBar colors --- .../feature/payments/ui/details/PaymentDetailsDestination.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt index 36cc1af043..49874bfd31 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt @@ -352,8 +352,8 @@ private fun MemberChargeDetailsScreen( private fun MemberCharge.topAppBarColors(): TopAppBarColors? { return if (this.status == MemberCharge.MemberChargeStatus.FAILED) { TopAppBarColors( - contentColor = HedvigTheme.colorScheme.textWhite, - containerColor = HedvigTheme.colorScheme.signalRedText, + contentColor = HedvigTheme.colorScheme.signalRedElement, + containerColor = HedvigTheme.colorScheme.backgroundPrimary, ) } else { null From 4ca1d7d993d7ff115ccbe2bc0e33530defe6c884 Mon Sep 17 00:00:00 2001 From: panasetskaya <90948269+panasetskaya@users.noreply.github.com> Date: Wed, 20 Nov 2024 08:40:50 +0100 Subject: [PATCH 17/22] remove extra padding Co-authored-by: stylianosgakis --- .../payments/ui/discounts/AddDiscountBottomSheetContent.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt index 165b2ca9bc..57a24a7356 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt @@ -36,9 +36,7 @@ internal fun AddDiscountBottomSheetContent( onDismiss: () -> Unit, ) { var discountCodeInput by remember { mutableStateOf("") } - Column( - modifier = Modifier.padding(horizontal = 16.dp), - ) { + Column { Spacer(Modifier.height(16.dp)) HedvigText( text = stringResource(id = R.string.PAYMENTS_ADD_CAMPAIGN_CODE), From e36db45864538b3bf5b9f2e867bd5d2d5c43b61b Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Wed, 20 Nov 2024 09:54:06 +0100 Subject: [PATCH 18/22] add surface --- .../android/feature/payments/ui/payments/PaymentsDestination.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt index ccfd00a50e..61339e5f96 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt @@ -123,6 +123,7 @@ private fun PaymentsScreen( .fillMaxSize() .pullRefresh(pullRefreshState), ) { + Surface(color = HedvigTheme.colorScheme.backgroundPrimary) { Column( Modifier .fillMaxSize() @@ -168,6 +169,7 @@ private fun PaymentsScreen( modifier = Modifier.align(Alignment.TopCenter), ) } + } } @Composable From ca962cea64b39892d7e157595bbb5bc952eac1db Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Wed, 20 Nov 2024 10:14:03 +0100 Subject: [PATCH 19/22] error section extra insets remove --- .../ui/payments/PaymentsDestination.kt | 84 ++++++++++--------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt index 61339e5f96..5a0f6f20a4 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt @@ -14,6 +14,7 @@ import androidx.compose.foundation.layout.WindowInsetsSides import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.ime import androidx.compose.foundation.layout.only import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.safeDrawing @@ -124,51 +125,53 @@ private fun PaymentsScreen( .pullRefresh(pullRefreshState), ) { Surface(color = HedvigTheme.colorScheme.backgroundPrimary) { - Column( - Modifier - .fillMaxSize() - .verticalScroll(rememberScrollState()) - .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), - ) { - Spacer(Modifier.windowInsetsTopHeight(WindowInsets.safeDrawing)) - Row( - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .height(64.dp) - .fillMaxWidth() - .padding(horizontal = 16.dp), + Column( + Modifier + .fillMaxSize() + .verticalScroll(rememberScrollState()) + .windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)), ) { - HedvigText( - text = stringResource(R.string.PROFILE_PAYMENT_TITLE), - style = HedvigTheme.typography.headlineSmall, - ) - } - Spacer(Modifier.height(8.dp)) - when (uiState) { - PaymentsUiState.Error -> HedvigErrorSection(onButtonClick = onRetry, Modifier.weight(1f)) - else -> { - PaymentsContent( - uiState = uiState, - onUpcomingPaymentClicked = { upcomingPayment -> - onUpcomingPaymentClicked(upcomingPayment.id) - }, - onChangeBankAccount = onChangeBankAccount, - onDiscountClicked = onDiscountClicked, - onPaymentHistoryClicked = onPaymentHistoryClicked, + Spacer(Modifier.windowInsetsTopHeight(WindowInsets.safeDrawing)) + Row( + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .height(64.dp) + .fillMaxWidth() + .padding(horizontal = 16.dp), + ) { + HedvigText( + text = stringResource(R.string.PROFILE_PAYMENT_TITLE), + style = HedvigTheme.typography.headlineSmall, ) - Spacer(Modifier.height(16.dp)) } + when (uiState) { + PaymentsUiState.Error -> HedvigErrorSection( + onButtonClick = onRetry, + Modifier.weight(1f), + windowInsets = WindowInsets.ime) + else -> { + PaymentsContent( + uiState = uiState, + onUpcomingPaymentClicked = { upcomingPayment -> + onUpcomingPaymentClicked(upcomingPayment.id) + }, + onChangeBankAccount = onChangeBankAccount, + onDiscountClicked = onDiscountClicked, + onPaymentHistoryClicked = onPaymentHistoryClicked, + ) + Spacer(Modifier.height(16.dp)) + } + } + Spacer(Modifier.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom))) } - Spacer(Modifier.windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom))) + PullRefreshIndicator( + refreshing = isRefreshing, + state = pullRefreshState, + scale = true, + modifier = Modifier.align(Alignment.TopCenter), + ) } - PullRefreshIndicator( - refreshing = isRefreshing, - state = pullRefreshState, - scale = true, - modifier = Modifier.align(Alignment.TopCenter), - ) - } } } @@ -185,6 +188,7 @@ private fun PaymentsContent( modifier = modifier, verticalArrangement = Arrangement.spacedBy(8.dp), ) { + Spacer(Modifier.height(8.dp)) val upcomingPayment = (uiState as? PaymentsUiState.Content)?.upcomingPayment if (upcomingPayment == UpcomingPayment.NoUpcomingPayment) { HedvigInformationSection(stringResource(R.string.PAYMENTS_NO_PAYMENTS_IN_PROGRESS)) From 06d948115dc2b5a007f451c026aec31dbd3fd790 Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Wed, 20 Nov 2024 10:41:54 +0100 Subject: [PATCH 20/22] correct shapes, remove extra insets --- .../ui/details/PaymentDetailsDestination.kt | 34 +++++++------------ .../AddDiscountBottomSheetContent.kt | 1 - .../ui/discounts/DiscountsDestination.kt | 4 +-- .../ui/history/PaymentHistoryDestination.kt | 2 +- .../ui/payments/PaymentsDestination.kt | 7 ++-- 5 files changed, 19 insertions(+), 29 deletions(-) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt index 49874bfd31..1b260d9e54 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt @@ -2,12 +2,10 @@ package com.hedvig.android.feature.payments.ui.details import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -15,6 +13,7 @@ import androidx.compose.foundation.layout.safeDrawing import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.windowInsetsBottomHeight +import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -47,6 +46,7 @@ import com.hedvig.android.design.system.hedvig.TopAppBarColors import com.hedvig.android.design.system.hedvig.datepicker.rememberHedvigDateTimeFormatter import com.hedvig.android.design.system.hedvig.icon.HedvigIcons import com.hedvig.android.design.system.hedvig.icon.InfoFilled +import com.hedvig.android.design.system.hedvig.minimumInteractiveComponentSize import com.hedvig.android.feature.payments.chargeHistoryPreviewData import com.hedvig.android.feature.payments.data.MemberCharge import com.hedvig.android.feature.payments.data.PaymentConnection @@ -271,27 +271,17 @@ private fun MemberChargeDetailsScreen( HedvigText(stringResource(id = R.string.PAYMENTS_PAYMENT_DETAILS_INFO_TITLE)) }, endSlot = { - Box( - contentAlignment = Alignment.CenterEnd, + Icon( + imageVector = HedvigIcons.InfoFilled, + tint = HedvigTheme.colorScheme.fillSecondary, + contentDescription = "Info icon", modifier = Modifier - .fillMaxWidth(), - ) { - Box( - modifier = Modifier - .fillMaxHeight() - .width(32.dp) - .clip(HedvigTheme.shapes.cornerMedium) - .clickable { showBottomSheet = true }, - contentAlignment = Alignment.Center, - ) { - Icon( - imageVector = HedvigIcons.InfoFilled, - tint = HedvigTheme.colorScheme.fillSecondary, - contentDescription = "Info icon", - modifier = Modifier.size(16.dp), - ) - } - } + .wrapContentSize(Alignment.CenterEnd) + .size(16.dp) + .clip(HedvigTheme.shapes.cornerXLarge) + .clickable { showBottomSheet = true } + .minimumInteractiveComponentSize(), + ) }, modifier = Modifier.padding(vertical = 16.dp), ) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt index 57a24a7356..dd71e8b78d 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/AddDiscountBottomSheetContent.kt @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.safeDrawing import androidx.compose.foundation.layout.windowInsetsBottomHeight import androidx.compose.runtime.Composable diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt index 877c0a6f8d..29b1f76df0 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/discounts/DiscountsDestination.kt @@ -146,7 +146,7 @@ private fun DiscountsScreen( modifier = Modifier .wrapContentSize(Alignment.CenterEnd) .size(16.dp) - .clip(HedvigTheme.shapes.cornerLarge) + .clip(HedvigTheme.shapes.cornerXLarge) .clickable { showInfoBottomSheet = true } .minimumInteractiveComponentSize(), ) @@ -234,7 +234,7 @@ private fun ForeverSection( modifier = Modifier .wrapContentSize(Alignment.CenterEnd) .size(16.dp) - .clip(HedvigTheme.shapes.cornerLarge) + .clip(HedvigTheme.shapes.cornerXLarge) .clickable { showForeverInfoBottomSheet = true } .minimumInteractiveComponentSize(), ) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt index 408e48cfb6..6eea77c93c 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/history/PaymentHistoryDestination.kt @@ -76,7 +76,7 @@ private fun PaymentHistoryScreen( val (paymentHistory: PaymentHistory, onChargeClickedAfterTransform: (String) -> Unit) = remember(uiState.paymentHistory) { if (uiState.paymentHistory.isEmpty()) { - PaymentHistory.NoHistoryData to { s: String -> } + PaymentHistory.NoHistoryData to { _: String -> } } else { PaymentHistory.PastCharges( chargesInYear = uiState.paymentHistory.sortedBy { it.dueDate }.groupBy { it.dueDate.year } diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt index 5a0f6f20a4..40c3fc661f 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt @@ -14,7 +14,6 @@ import androidx.compose.foundation.layout.WindowInsetsSides import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.ime import androidx.compose.foundation.layout.only import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.safeDrawing @@ -109,7 +108,8 @@ private fun PaymentsScreen( onPaymentHistoryClicked: () -> Unit, onRetry: () -> Unit, ) { - val systemBarInsetTopDp = with(LocalDensity.current) { + val density = LocalDensity.current + val systemBarInsetTopDp = with(density) { WindowInsets.systemBars.getTop(this).toDp() } val isRefreshing = @@ -149,7 +149,8 @@ private fun PaymentsScreen( PaymentsUiState.Error -> HedvigErrorSection( onButtonClick = onRetry, Modifier.weight(1f), - windowInsets = WindowInsets.ime) + windowInsets = WindowInsets.systemBars.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom), + ) else -> { PaymentsContent( uiState = uiState, From f75526aec002a4e9c0eb2fe0a1cac0e87b9eb8df Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Wed, 20 Nov 2024 10:57:11 +0100 Subject: [PATCH 21/22] change priority if insurance is to be canceled. change tint for go back icon --- .../com/hedvig/android/design/system/hedvig/TopAppBar.kt | 1 + .../feature/payments/ui/payments/PaymentsDestination.kt | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/TopAppBar.kt b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/TopAppBar.kt index cbed326050..002fb28e74 100644 --- a/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/TopAppBar.kt +++ b/app/design-system/design-system-hedvig/src/main/kotlin/com/hedvig/android/design/system/hedvig/TopAppBar.kt @@ -131,6 +131,7 @@ fun TopAppBar( TopAppBarActionType.CLOSE -> HedvigIcons.Close }, contentDescription = null, + tint = TopAppBarTokens.ContentColor.value, ) }, ) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt index 40c3fc661f..d5d4ec8ccf 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/payments/PaymentsDestination.kt @@ -277,13 +277,18 @@ private fun CardNotConnectedWarningCard( } else { stringResource(id = R.string.info_card_missing_payment_body) } + val priority = if (connectedPaymentInfo?.dueDateToConnect != null) { + NotificationDefaults.NotificationPriority.Error + } else { + NotificationDefaults.NotificationPriority.Attention + } HedvigNotificationCard( message = text, style = NotificationDefaults.InfoCardStyle.Button( buttonText = stringResource(id = R.string.PROFILE_PAYMENT_CONNECT_DIRECT_DEBIT_TITLE), onButtonClick = onChangeBankAccount, ), - priority = NotificationDefaults.NotificationPriority.Attention, + priority = priority, modifier = modifier, ) } From 32ae51c289fbde29e58f31c791583758ff3c7b48 Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Wed, 20 Nov 2024 11:15:21 +0100 Subject: [PATCH 22/22] if pastCharge is the last one, use the upcomingPayment date for the infobox --- .../payments/data/GetChargeDetailsUseCase.kt | 10 +++++-- .../ui/details/PaymentDetailsDestination.kt | 29 +++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/data/GetChargeDetailsUseCase.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/data/GetChargeDetailsUseCase.kt index b91923f33c..b8b013fa5a 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/data/GetChargeDetailsUseCase.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/data/GetChargeDetailsUseCase.kt @@ -40,11 +40,14 @@ internal class GetChargeDetailsUseCaseImpl( result.currentMember.redeemedCampaigns, result.currentMember.referralInformation, clock, - ).takeIf { it?.id == id } + ) + val futureMemberChargeWithThisId = futureMemberCharge.takeIf { it?.id == id } + val pastMemberCharge = pastCharges.firstOrNull { it.id == id } PaymentDetails( - memberCharge = futureMemberCharge ?: pastMemberCharge ?: raise(ErrorMessage()), + memberCharge = futureMemberChargeWithThisId ?: pastMemberCharge ?: raise(ErrorMessage()), pastCharges = pastCharges, + upComingCharge = futureMemberCharge, paymentConnection = run { val paymentInformation = result.currentMember.paymentInformation when (paymentInformation.status) { @@ -73,11 +76,12 @@ internal data class PaymentDetails( val memberCharge: MemberCharge, val pastCharges: List?, val paymentConnection: PaymentConnection?, + val upComingCharge: MemberCharge?, ) { fun getNextCharge(selectedMemberCharge: MemberCharge): MemberCharge? { val index = (pastCharges?.indexOf(selectedMemberCharge) ?: 0) + 1 return if (pastCharges != null && index > pastCharges.size - 1) { - memberCharge + null } else { pastCharges?.get(index) } diff --git a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt index 1b260d9e54..cb3216c9a5 100644 --- a/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt +++ b/app/feature/feature-payments/src/main/kotlin/com/hedvig/android/feature/payments/ui/details/PaymentDetailsDestination.kt @@ -247,18 +247,22 @@ private fun MemberChargeDetailsScreen( withIcon = true, ) - MemberCharge.MemberChargeStatus.FAILED -> HedvigNotificationCard( - message = stringResource( - id = R.string.PAYMENTS_PAYMENT_FAILED, - uiState.paymentDetails.getNextCharge(uiState.paymentDetails.memberCharge) - ?.let { - dateTimeFormatter.format(it.dueDate.toJavaLocalDate()) - } ?: "-", - ), - priority = NotificationDefaults.NotificationPriority.Error, - withIcon = true, - style = NotificationDefaults.InfoCardStyle.Default, - ) + MemberCharge.MemberChargeStatus.FAILED -> { + val nextCharge = uiState.paymentDetails.getNextCharge(uiState.paymentDetails.memberCharge) + val nextOrFutureCharge = nextCharge ?: uiState.paymentDetails.upComingCharge + HedvigNotificationCard( + message = stringResource( + id = R.string.PAYMENTS_PAYMENT_FAILED, + nextOrFutureCharge + ?.let { + dateTimeFormatter.format(it.dueDate.toJavaLocalDate()) + } ?: "-", + ), + priority = NotificationDefaults.NotificationPriority.Error, + withIcon = true, + style = NotificationDefaults.InfoCardStyle.Default, + ) + } MemberCharge.MemberChargeStatus.UNKNOWN -> {} } @@ -362,6 +366,7 @@ private fun PaymentDetailsScreenPreview() { memberCharge = paymentDetailsPreviewData, pastCharges = chargeHistoryPreviewData, paymentConnection = paymentOverViewPreviewData.paymentConnection, + upComingCharge = paymentDetailsPreviewData, ), ), selectedCharge = null,