Skip to content

Commit

Permalink
Merge pull request #1902 from HedvigInsurance/feature/edit-co-insured
Browse files Browse the repository at this point in the history
Edit co insured
  • Loading branch information
hugokallstrom authored Dec 6, 2023
2 parents ba94ed7 + 3d97ddc commit ff73033
Show file tree
Hide file tree
Showing 89 changed files with 4,266 additions and 463 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ query GetUpcomingRenewalReminder {
}
}
upcomingChangedAgreement {
creationCause
activeFrom
certificateUrl
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
query InsuranceContracts {
currentMember {
firstName
lastName
ssn
terminatedContracts {
...ContractFragment
}
Expand All @@ -16,6 +19,16 @@ fragment ContractFragment on Contract {
terminationDate
exposureDisplayName
supportsMoving
supportsCoInsured
coInsured {
firstName
lastName
ssn
birthdate
hasMissingInfo
activatesOn
terminatesOn
}
currentAgreement {
...AgreementFragment
}
Expand All @@ -28,6 +41,7 @@ fragment AgreementFragment on Agreement {
activeFrom
activeTo
certificateUrl
creationCause
displayItems {
...AgreementDisplayItemFragment
}
Expand Down
1 change: 1 addition & 0 deletions app/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ dependencies {
implementation(projects.featureProfile)
implementation(projects.featureTerminateInsurance)
implementation(projects.featureTravelCertificate)
implementation(projects.featureEditCoinsured)
implementation(projects.hanalyticsAndroid)
implementation(projects.hanalyticsCore)
implementation(projects.hanalyticsFeatureFlagsPublic)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import com.hedvig.android.feature.claimtriaging.ClaimTriagingDestination
import com.hedvig.android.feature.claimtriaging.claimTriagingDestinations
import com.hedvig.android.feature.connect.payment.adyen.connectAdyenPaymentGraph
import com.hedvig.android.feature.connect.payment.connectPaymentGraph
import com.hedvig.android.feature.editcoinsured.navigation.EditCoInsuredDestination
import com.hedvig.android.feature.editcoinsured.navigation.editCoInsuredGraph
import com.hedvig.android.feature.forever.navigation.foreverGraph
import com.hedvig.android.feature.home.home.navigation.homeGraph
import com.hedvig.android.feature.insurances.insurance.insuranceGraph
Expand Down Expand Up @@ -124,6 +126,11 @@ internal fun HedvigNavHost(
with(navigator) { backStackEntry.navigate(ClaimDetailsDestination(claimId)) }
},
navigateToPayinScreen = navigateToConnectPayment,
navigateToMissingInfo = { backStackEntry: NavBackStackEntry, contractId: String ->
with(navigator) {
backStackEntry.navigate(EditCoInsuredDestination.AddInfo(contractId))
}
},
openAppSettings = { activityNavigator.openAppSettings(context) },
openUrl = ::openUrl,
imageLoader = imageLoader,
Expand All @@ -147,6 +154,9 @@ internal fun HedvigNavHost(
openWebsite = { uri ->
activityNavigator.openWebsite(context, uri)
},
openUrl = {
openUrl(it)
},
openChat = { backStackEntry ->
with(navigator) {
backStackEntry.navigate(AppDestination.Chat)
Expand All @@ -164,6 +174,16 @@ internal fun HedvigNavHost(
},
hedvigDeepLinkContainer = hedvigDeepLinkContainer,
imageLoader = imageLoader,
startEditCoInsured = { backStackEntry: NavBackStackEntry, contractId: String ->
with(navigator) {
backStackEntry.navigate(EditCoInsuredDestination.AddOrRemove(contractId))
}
},
startEditCoInsuredAddMissingInfo = { backStackEntry: NavBackStackEntry, contractId: String ->
with(navigator) {
backStackEntry.navigate(EditCoInsuredDestination.AddInfo(contractId))
}
},
)
foreverGraph(
hedvigDeepLinkContainer = hedvigDeepLinkContainer,
Expand All @@ -185,6 +205,11 @@ internal fun HedvigNavHost(
with(navigator) { backStackEntry.navigate(AppDestination.PaymentInfo) }
},
navigateToConnectPayment = navigateToConnectPayment,
navigateToAddMissingInfo = { backStackEntry: NavBackStackEntry, contractId: String ->
with(navigator) {
backStackEntry.navigate(EditCoInsuredDestination.AddInfo(contractId))
}
},
openAppSettings = { activityNavigator.openAppSettings(context) },
openUrl = ::openUrl,
)
Expand All @@ -207,6 +232,10 @@ internal fun HedvigNavHost(
)
},
)
editCoInsuredGraph(
navigateUp = navigator::navigateUp,
navController = hedvigAppState.navController,
)
connectAdyenPaymentGraph(navigator)
}
}
Expand Down
2 changes: 2 additions & 0 deletions app/app/src/main/kotlin/com/hedvig/app/ApplicationModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import com.hedvig.android.feature.claim.details.di.claimDetailsModule
import com.hedvig.android.feature.claimtriaging.di.claimTriagingModule
import com.hedvig.android.feature.connect.payment.adyen.di.adyenFeatureModule
import com.hedvig.android.feature.connect.payment.trustly.di.connectPaymentTrustlyModule
import com.hedvig.android.feature.editcoinsured.di.editCoInsuredModule
import com.hedvig.android.feature.forever.di.foreverModule
import com.hedvig.android.feature.home.di.homeModule
import com.hedvig.android.feature.insurances.di.insurancesModule
Expand Down Expand Up @@ -388,6 +389,7 @@ val applicationModule = module {
useCaseModule,
viewModelModule,
workManagerModule,
editCoInsuredModule,
),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.hedvig.android.core.common.android.time

import kotlinx.datetime.Clock
import kotlinx.datetime.LocalDate
import kotlinx.datetime.TimeZone
import kotlinx.datetime.atStartOfDayIn
import kotlinx.datetime.daysUntil
import kotlinx.datetime.toLocalDateTime

fun daysUntil(localDate: LocalDate): Int {
val timeZone = TimeZone.currentSystemDefault()
val startOfToday = Clock.System.now().toLocalDateTime(timeZone).date.atStartOfDayIn(timeZone)
val startOfDayOfRenewal = localDate.atStartOfDayIn(timeZone)
return startOfToday.daysUntil(startOfDayOfRenewal, timeZone)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.unit.dp
import com.hedvig.android.core.designsystem.animation.ThreeDotsLoading
import com.hedvig.android.core.designsystem.material3.onSecondaryContainedButtonContainer
import com.hedvig.android.core.designsystem.material3.secondaryContainedButtonContainer
import com.hedvig.android.core.designsystem.material3.squircleMedium
import com.hedvig.android.core.designsystem.preview.HedvigPreview
import com.hedvig.android.core.designsystem.theme.HedvigTheme
Expand Down Expand Up @@ -52,6 +54,31 @@ fun HedvigContainedButton(
}
}

@Composable
fun HedvigSecondaryContainedButton(
text: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
contentPadding: PaddingValues = PaddingValues(16.dp),
enabled: Boolean = true,
colors: ButtonColors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.secondaryContainedButtonContainer,
contentColor = MaterialTheme.colorScheme.onSecondaryContainedButtonContainer,
disabledContainerColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.12f),
disabledContentColor = MaterialTheme.colorScheme.onPrimary.copy(alpha = 0.38f),
),
) {
HedvigContainedButton(
onClick = onClick,
enabled = enabled,
modifier = modifier,
contentPadding = contentPadding,
colors = colors,
) {
ButtonText(text)
}
}

@Composable
fun HedvigContainedButton(
text: String,
Expand All @@ -73,28 +100,34 @@ fun HedvigContainedButton(
onClick()
}
},
enabled = enabled,
modifier = modifier,
contentPadding = contentPadding,
colors = colors,
) {
val loadingTransition = updateTransition(isLoading)
loadingTransition.AnimatedContent(
transitionSpec = {
fadeIn(tween(durationMillis = 220, delayMillis = 90)) togetherWith fadeOut(tween(90))
},
contentAlignment = Alignment.Center,
) { isLoading ->
if (isLoading) {
Box(
contentAlignment = Alignment.Center,
) {
// render the text too so that the same space is taken in all cases
ButtonText(text, Modifier.alpha(0f))
ThreeDotsLoading()
}
} else {
ButtonText(text)
LoadingButton(isLoading, text)
}
}

@Composable
private fun LoadingButton(isLoading: Boolean, text: String) {
val loadingTransition = updateTransition(isLoading, label = "loading transition")
loadingTransition.AnimatedContent(
transitionSpec = {
fadeIn(tween(durationMillis = 220, delayMillis = 90)) togetherWith fadeOut(tween(90))
},
contentAlignment = Alignment.Center,
) { isLoading ->
if (isLoading) {
Box(
contentAlignment = Alignment.Center,
) {
// render the text too so that the same space is taken in all cases
ButtonText(text, Modifier.alpha(0f))
ThreeDotsLoading()
}
} else {
ButtonText(text)
}
}
}
Expand Down Expand Up @@ -144,6 +177,16 @@ private fun PreviewHedvigContainedButton() {
}
}

@HedvigPreview
@Composable
private fun PreviewHedvigSecondaryContainedButton() {
HedvigTheme {
Surface(color = MaterialTheme.colorScheme.background) {
HedvigSecondaryContainedButton("Hello there", {}, Modifier.padding(24.dp))
}
}
}

@HedvigPreview
@Composable
private fun PreviewLoadingHedvigContainedButton() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.hedvig.android.core.designsystem.component.information

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.hedvig.android.core.designsystem.material3.squircleExtraSmall

@Composable
fun HedvigPill(text: String, color: Color, contentColor: Color = contentColorFor(color)) {
Surface(
shape = MaterialTheme.shapes.squircleExtraSmall,
color = color,
contentColor = contentColor,
modifier = Modifier.heightIn(min = 24.dp),
) {
Row(
Modifier.padding(
horizontal = 10.dp,
vertical = 4.dp,
),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = text,
style = MaterialTheme.typography.bodyMedium,
maxLines = 1,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ internal val LocalHedvigMaterial3ColorScheme = staticCompositionLocalOf<HedvigMa
class HedvigMaterial3ColorScheme(
val containedButtonContainer: Color,
val onContainedButtonContainer: Color,
val secondaryContainedButtonContainer: Color,
val onSecondaryContainedButtonContainer: Color,
val warningElement: Color,
val onWarningElement: Color,
val warningContainer: Color,
Expand Down Expand Up @@ -49,6 +51,16 @@ val ColorScheme.onContainedButtonContainer: Color
@Composable
get() = LocalHedvigMaterial3ColorScheme.current.onContainedButtonContainer

val ColorScheme.secondaryContainedButtonContainer: Color
@ReadOnlyComposable
@Composable
get() = LocalHedvigMaterial3ColorScheme.current.secondaryContainedButtonContainer

val ColorScheme.onSecondaryContainedButtonContainer: Color
@ReadOnlyComposable
@Composable
get() = LocalHedvigMaterial3ColorScheme.current.onSecondaryContainedButtonContainer

// region warning colors
val ColorScheme.warningElement: Color
@ReadOnlyComposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ internal fun lightColorScheme(hedvigTonalPalette: HedvigTonalPalette) = lightCol
inverseOnSurface = hedvigTonalPalette.greyscale50,
error = hedvigTonalPalette.red600,
onError = hedvigTonalPalette.greyscale25,
errorContainer = hedvigTonalPalette.greyscale50,
onErrorContainer = hedvigTonalPalette.greyscale1000,
errorContainer = hedvigTonalPalette.red100,
onErrorContainer = hedvigTonalPalette.red800,
// outline = no equivalent,
outlineVariant = hedvigTonalPalette.greyscale300,
// scrim = default is ok,
Expand Down Expand Up @@ -95,16 +95,18 @@ private fun darkColorScheme(hedvigTonalPalette: HedvigTonalPalette) = darkColorS
inverseOnSurface = hedvigTonalPalette.greyscale1000,
error = hedvigTonalPalette.red600,
onError = hedvigTonalPalette.greyscale25,
errorContainer = hedvigTonalPalette.greyscale900,
onErrorContainer = hedvigTonalPalette.greyscale25,
errorContainer = hedvigTonalPalette.red300,
onErrorContainer = hedvigTonalPalette.red900,
// outline = no equivalent,
outlineVariant = hedvigTonalPalette.greyscale700,
scrim = hedvigTonalPalette.greyscale25,
)

internal fun darkHedvigColorScheme(hedvigTonalPalette: HedvigTonalPalette) = HedvigMaterial3ColorScheme(
containedButtonContainer = hedvigTonalPalette.greyscale25,
onContainedButtonContainer = hedvigTonalPalette.greyscale1000,
onContainedButtonContainer = hedvigTonalPalette.greyscale100,
secondaryContainedButtonContainer = hedvigTonalPalette.greyscale800,
onSecondaryContainedButtonContainer = hedvigTonalPalette.greyscale100,
// In the comments are the light mode colors, showing the equivalent and how it was chosen
warningElement = hedvigTonalPalette.amber700,
onWarningElement = hedvigTonalPalette.greyscale25,
Expand All @@ -126,6 +128,8 @@ internal fun darkHedvigColorScheme(hedvigTonalPalette: HedvigTonalPalette) = Hed
internal fun lightHedvigColorScheme(hedvigTonalPalette: HedvigTonalPalette) = HedvigMaterial3ColorScheme(
containedButtonContainer = hedvigTonalPalette.greyscale25,
onContainedButtonContainer = hedvigTonalPalette.greyscale1000,
secondaryContainedButtonContainer = hedvigTonalPalette.greyscale100,
onSecondaryContainedButtonContainer = hedvigTonalPalette.greyscale1000,
warningElement = hedvigTonalPalette.amber600,
onWarningElement = hedvigTonalPalette.greyscale1000,
warningContainer = hedvigTonalPalette.amber100,
Expand Down
Loading

0 comments on commit ff73033

Please sign in to comment.