Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GEN-2544 New design/payments #2314

Merged
merged 25 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
564aadd
add new package
panasetskaya Nov 18, 2024
84325db
fix lint cannot determine the type
panasetskaya Nov 18, 2024
966b193
paymentsDestination, in prod
panasetskaya Nov 18, 2024
9fb0912
PaymentDetailsDestination
panasetskaya Nov 18, 2024
44e3621
Merge branch 'develop' into new-design/payments
panasetskaya Nov 18, 2024
e53eb38
base migration
panasetskaya Nov 18, 2024
992b765
history
panasetskaya Nov 18, 2024
4d490f1
fix padding and insets
panasetskaya Nov 18, 2024
c08bf68
wrap width
panasetskaya Nov 18, 2024
3f63eb9
getting rid of lint errors
panasetskaya Nov 18, 2024
cededcb
ktlint
panasetskaya Nov 18, 2024
1d11d99
Merge branch 'develop' into new-design/payments
panasetskaya Nov 19, 2024
d20a788
some bs changes
panasetskaya Nov 19, 2024
430eed2
some bs changes
panasetskaya Nov 19, 2024
2f0a296
insurances - put the error section in the middle
panasetskaya Nov 19, 2024
63ad649
insurances - put the error section in the middle
panasetskaya Nov 19, 2024
92a5c10
remove button at the payment details notification
panasetskaya Nov 19, 2024
ecb9d58
change topAppBar colors
panasetskaya Nov 19, 2024
4ca1d7d
remove extra padding
panasetskaya Nov 20, 2024
e36db45
add surface
panasetskaya Nov 20, 2024
a3b4797
Merge branch 'develop' into new-design/payments
panasetskaya Nov 20, 2024
ca962ce
error section extra insets remove
panasetskaya Nov 20, 2024
06d9481
correct shapes, remove extra insets
panasetskaya Nov 20, 2024
f75526a
change priority if insurance is to be canceled. change tint for go ba…
panasetskaya Nov 20, 2024
32ae51c
if pastCharge is the last one, use the upcomingPayment date for the i…
panasetskaya Nov 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -42,6 +43,7 @@ fun HedvigScaffold(
onActionClick = dropUnlessResumed(block = navigateUp),
topAppBarActions = topAppBarActions,
windowInsets = topAppbarInsets,
customTopAppBarColors = customTopAppBarColors,
)
Column(
horizontalAlignment = itemsColumnHorizontalAlignment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -87,10 +88,23 @@ 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()
Expand All @@ -117,6 +131,7 @@ fun TopAppBar(
TopAppBarActionType.CLOSE -> HedvigIcons.Close
},
contentDescription = null,
tint = TopAppBarTokens.ContentColor.value,
)
},
)
Expand Down Expand Up @@ -197,3 +212,8 @@ internal object TopAppBarDefaults {
.union(WindowInsets.displayCutout)
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top)
}

data class TopAppBarColors(
val containerColor: Color,
val contentColor: Color,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") }
Expand All @@ -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 ->
Expand All @@ -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") }
Expand All @@ -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") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,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().padding(horizontal = 16.dp),
)
Spacer(Modifier.weight(1f))
}
} else {
InsuranceScreenContent(
uiState = state,
Expand Down Expand Up @@ -394,6 +399,16 @@ private fun PreviewInsuranceDestinationAnimation() {

private class InsuranceUiStateProvider : CollectionPreviewParameterProvider<InsuranceUiState>(
listOf(
InsuranceUiState(
contracts = listOf(),
crossSells = listOf(),
hasError = true,
isLoading = false,
isRetrying = false,
quantityOfCancelledInsurances = 0,
showNotificationBadge = false,
shouldSuggestMovingFlow = true,
),
InsuranceUiState(
contracts = listOf(),
crossSells = listOf(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
5 changes: 1 addition & 4 deletions app/feature/feature-payments/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -57,7 +55,6 @@ dependencies {
implementation(projects.navigationComposeTyped)
implementation(projects.navigationCore)
implementation(projects.notificationPermission)
implementation(projects.placeholder)
implementation(projects.pullrefresh)
implementation(projects.theme)
testImplementation(libs.coroutines.test)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -73,11 +76,12 @@ internal data class PaymentDetails(
val memberCharge: MemberCharge,
val pastCharges: List<MemberCharge>?,
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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

This file was deleted.

Loading
Loading