Skip to content

Commit

Permalink
Merge branch 'feature/edit-co-insured' into feature/fetch-co-insured-…
Browse files Browse the repository at this point in the history
…on-ssn

# Conflicts:
#	app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/data/GetCoInsuredUseCase.kt
#	app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/di/GetCoInsuredUseCaseProvider.kt
#	app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/ui/EditCoInsuredDestination.kt
#	app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/ui/EditCoInsuredPresenter.kt
#	app/feature/feature-edit-coinsured/src/main/kotlin/com/hedvig/android/feature/editcoinsured/ui/EditCoInsuredViewModel.kt
  • Loading branch information
hugokallstrom committed Nov 23, 2023
2 parents aa60b2c + 618f30b commit 4e32fcd
Show file tree
Hide file tree
Showing 30 changed files with 607 additions and 114 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
query InsuranceContracts {
currentMember {
firstName
lastName
ssn
terminatedContracts {
...ContractFragment
}
Expand Down Expand Up @@ -28,6 +31,13 @@ fragment AgreementFragment on Agreement {
activeFrom
activeTo
certificateUrl
coInsured {
firstName
lastName
ssn
birthdate
hasMissingInfo
}
displayItems {
...AgreementDisplayItemFragment
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ 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
import com.hedvig.android.feature.insurances.navigation.InsurancesDestination
import com.hedvig.android.feature.odyssey.navigation.claimFlowGraph
import com.hedvig.android.feature.odyssey.navigation.navigateToClaimFlowDestination
import com.hedvig.android.feature.odyssey.navigation.terminalClaimFlowStepDestinations
Expand Down Expand Up @@ -126,6 +127,9 @@ internal fun HedvigNavHost(
with(navigator) { backStackEntry.navigate(ClaimDetailsDestination(claimId)) }
},
navigateToPayinScreen = navigateToConnectPayment,
navigateToContractDetail = { contractId ->
hedvigAppState.navController.navigate(InsurancesDestination.InsuranceContractDetail(contractId))
},
openAppSettings = { activityNavigator.openAppSettings(context) },
openUrl = ::openUrl,
imageLoader = imageLoader,
Expand Down Expand Up @@ -192,6 +196,9 @@ internal fun HedvigNavHost(
with(navigator) { backStackEntry.navigate(AppDestination.PaymentInfo) }
},
navigateToConnectPayment = navigateToConnectPayment,
navigateToContractDetail = { contractId ->
hedvigAppState.navController.navigate(InsurancesDestination.InsuranceContractDetail(contractId))
},
openAppSettings = { activityNavigator.openAppSettings(context) },
openUrl = ::openUrl,
)
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 @@ -11,13 +11,19 @@ internal data class CoInsured(
val ssn: String?,
val hasMissingInfo: Boolean,
) {
val displayName: String? = if (firstName != null && lastName != null) {
"$firstName $lastName"
} else {
null
val displayName: String = buildString {
if (firstName != null) {
append(firstName)
}
if (firstName != null && lastName != null) {
append(" ")
}
if (lastName != null) {
append(lastName)
}
}

fun details(dateTimeFormatter: DateTimeFormatter): String? =
fun identifier(dateTimeFormatter: DateTimeFormatter): String? =
ssn ?: birthDate?.toJavaLocalDate()?.format(dateTimeFormatter)

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.hedvig.android.feature.editcoinsured.data

data class Member(
internal data class Member(
val firstName: String,
val lastName: String,
val ssn: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package com.hedvig.android.feature.editcoinsured.navigation
import androidx.navigation.NavGraphBuilder
import com.hedvig.android.feature.editcoinsured.ui.EditCoInsuredDestination
import com.kiwi.navigationcompose.typed.composable
import org.koin.androidx.compose.koinViewModel
import org.koin.core.parameter.parametersOf

fun NavGraphBuilder.editCoInsuredGraph(navigateUp: () -> Unit) {
composable<EditCoInsuredDestination> { backStackEntry ->
EditCoInsuredDestination(
contractId,
koinViewModel { parametersOf(contractId) },
allowEdit,
navigateUp,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ import hedvig.resources.R
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.launch
import kotlinx.datetime.LocalDate
import org.koin.androidx.compose.koinViewModel
import org.koin.core.parameter.parametersOf

@Composable
internal fun EditCoInsuredDestination(contractId: String, allowEdit: Boolean, navigateUp: () -> Unit) {
val viewModel: EditCoInsuredViewModel = koinViewModel { parametersOf(contractId) }
internal fun EditCoInsuredDestination(
viewModel: EditCoInsuredViewModel,
allowEdit: Boolean,
navigateUp: () -> Unit,
) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()

EditCoInsuredScreen(
navigateUp = navigateUp,
allowEdit = allowEdit,
Expand Down Expand Up @@ -138,28 +138,29 @@ private fun CoInsuredList(uiState: EditCoInsuredState.Loaded.CoInsuredListState,
uiState.member?.let {
InsuredRow(
displayName = it.displayName,
details = it.ssn,
identifier = it.ssn ?: "",
hasMissingInfo = false,
allowEdit = false,
isMember = true,
onRemove = { },
onEdit = { },
)
}
Divider()
Divider(Modifier.padding(horizontal = 16.dp))
uiState.coInsured.forEachIndexed { index, coInsured ->
if (index != 0) {
Divider()
}

InsuredRow(
displayName = coInsured.displayName,
details = coInsured.details(dateTimeFormatter),
displayName = coInsured.displayName.ifBlank { stringResource(id = R.string.CONTRACT_COINSURED) },
identifier = coInsured.identifier(dateTimeFormatter) ?: stringResource(id = R.string.CONTRACT_NO_INFORMATION),
hasMissingInfo = coInsured.hasMissingInfo,
isMember = false,
allowEdit = allowEdit,
onRemove = { },
onEdit = { },
)
if (index < uiState.coInsured.size - 1) {
Divider()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import hedvig.resources.R

@Composable
internal fun InsuredRow(
displayName: String?,
details: String?,
displayName: String,
identifier: String,
hasMissingInfo: Boolean,
allowEdit: Boolean,
isMember: Boolean,
Expand All @@ -44,34 +44,19 @@ internal fun InsuredRow(
modifier = Modifier.padding(vertical = 16.dp),
) {
Column {
if (displayName != null) {
Text(
text = displayName,
color = if (isMember) {
MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.5f)
} else {
Color.Unspecified
},
)
} else {
Text(stringResource(id = R.string.CONTRACT_COINSURED))
}
Text(
text = displayName,
color = if (isMember) {
MaterialTheme.colorScheme.onSurfaceVariant
} else {
Color.Unspecified
},
)

if (details != null) {
Text(
text = details,
color = if (isMember) {
MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.5f)
} else {
MaterialTheme.colorScheme.onSurfaceVariant
},
)
} else {
Text(
text = stringResource(id = R.string.CONTRACT_NO_INFORMATION),
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
Text(
text = identifier,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
}
},
Expand All @@ -86,7 +71,7 @@ internal fun InsuredRow(
Icon(
imageVector = HedvigIcons.Lock,
contentDescription = "Locked",
tint = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.5f),
tint = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.size(16.dp),
)
}
Expand Down Expand Up @@ -135,7 +120,7 @@ private fun InsuredRowPreviewEditable() {
Surface {
InsuredRow(
displayName = "Test testersson",
details = "182312041933",
identifier = "182312041933",
hasMissingInfo = false,
isMember = false,
onRemove = {},
Expand All @@ -153,7 +138,7 @@ private fun InsuredRowPreviewMissingInfo() {
Surface {
InsuredRow(
displayName = "Test testersson",
details = "182312041933",
identifier = "182312041933",
hasMissingInfo = true,
isMember = false,
onRemove = {},
Expand All @@ -171,7 +156,7 @@ private fun InsuredRowPreviewMember() {
Surface {
InsuredRow(
displayName = "Test testersson",
details = "182312041933",
identifier = "182312041933",
hasMissingInfo = false,
isMember = true,
onRemove = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fun NavGraphBuilder.homeGraph(
onGenerateTravelCertificateClicked: () -> Unit,
navigateToClaimDetails: (NavBackStackEntry, claimId: String) -> Unit,
navigateToPayinScreen: () -> Unit,
navigateToContractDetail: (contractId: String) -> Unit,
openAppSettings: () -> Unit,
openUrl: (String) -> Unit,
imageLoader: ImageLoader,
Expand All @@ -51,6 +52,7 @@ fun NavGraphBuilder.homeGraph(
navigateToClaimDetails(backStackEntry, claimId)
},
navigateToConnectPayment = navigateToPayinScreen,
navigateToContractDetail = navigateToContractDetail,
onStartClaim = { onStartClaim(backStackEntry) },
onStartMovingFlow = { startMovingFlow(backStackEntry) },
onGenerateTravelCertificateClicked = onGenerateTravelCertificateClicked,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ internal fun HomeDestination(
onStartChat: () -> Unit,
onClaimDetailCardClicked: (String) -> Unit,
navigateToConnectPayment: () -> Unit,
navigateToContractDetail: (contractId: String) -> Unit,
onStartClaim: () -> Unit,
onStartMovingFlow: () -> Unit,
onGenerateTravelCertificateClicked: () -> Unit,
Expand All @@ -125,6 +126,7 @@ internal fun HomeDestination(
onStartChat = onStartChat,
onClaimDetailCardClicked = onClaimDetailCardClicked,
navigateToConnectPayment = navigateToConnectPayment,
navigateToContractDetail = navigateToContractDetail,
onStartClaim = onStartClaim,
onStartMovingFlow = onStartMovingFlow,
onGenerateTravelCertificateClicked = onGenerateTravelCertificateClicked,
Expand All @@ -142,6 +144,7 @@ private fun HomeScreen(
onStartChat: () -> Unit,
onClaimDetailCardClicked: (String) -> Unit,
navigateToConnectPayment: () -> Unit,
navigateToContractDetail: (contractId: String) -> Unit,
onStartClaim: () -> Unit,
onStartMovingFlow: () -> Unit,
onGenerateTravelCertificateClicked: () -> Unit,
Expand Down Expand Up @@ -191,6 +194,7 @@ private fun HomeScreen(
onStartMovingFlow = onStartMovingFlow,
onClaimDetailCardClicked = onClaimDetailCardClicked,
navigateToConnectPayment = navigateToConnectPayment,
navigateToContractDetail = navigateToContractDetail,
onEmergencyClaimClicked = { emergencyData ->
context.startActivity(
EmergencyActivity.newInstance(
Expand Down Expand Up @@ -259,6 +263,7 @@ private fun HomeScreenSuccess(
onStartMovingFlow: () -> Unit,
onClaimDetailCardClicked: (claimId: String) -> Unit,
navigateToConnectPayment: () -> Unit,
navigateToContractDetail: (contractId: String) -> Unit,
onEmergencyClaimClicked: (EmergencyData) -> Unit,
onGenerateTravelCertificateClicked: () -> Unit,
onOpenCommonClaim: (CommonClaimsData) -> Unit,
Expand Down Expand Up @@ -346,6 +351,7 @@ private fun HomeScreenSuccess(
MemberReminderCards(
memberReminders = memberReminders,
navigateToConnectPayment = navigateToConnectPayment,
navigateToContractDetail = navigateToContractDetail,
openUrl = openUrl,
modifier = Modifier
.fillMaxWidth()
Expand Down Expand Up @@ -482,6 +488,7 @@ private fun PreviewHomeScreen() {
onStartChat = {},
onClaimDetailCardClicked = {},
navigateToConnectPayment = {},
navigateToContractDetail = {},
onStartClaim = {},
onStartMovingFlow = {},
onGenerateTravelCertificateClicked = {},
Expand Down
Loading

0 comments on commit 4e32fcd

Please sign in to comment.