diff --git a/app/app/src/main/kotlin/com/hedvig/app/feature/chat/data/ChatRepositoryNew.kt b/app/app/src/main/kotlin/com/hedvig/app/feature/chat/data/ChatRepositoryNew.kt index 480a2ed5f5..7e22ff9eed 100644 --- a/app/app/src/main/kotlin/com/hedvig/app/feature/chat/data/ChatRepositoryNew.kt +++ b/app/app/src/main/kotlin/com/hedvig/app/feature/chat/data/ChatRepositoryNew.kt @@ -51,7 +51,8 @@ class ChatRepositoryNewImpl( contentType: String, ) = either { val fileUpload = file.toUpload(contentType) - val input = ChatMessageFileInput(fileUpload) +// val input = ChatMessageFileInput(fileUpload) // todo here upload file directly through HTTP instead + val input = ChatMessageFileInput("") val mutation = ChatSendFileMutation(input) val result = apolloClientOctopus.mutation(mutation) diff --git a/app/core/core-design-system/src/main/kotlin/com/hedvig/android/core/designsystem/component/card/HedvigInfoCard.kt b/app/core/core-design-system/src/main/kotlin/com/hedvig/android/core/designsystem/component/card/HedvigInfoCard.kt index a42a3c3fb5..9ec69d9452 100644 --- a/app/core/core-design-system/src/main/kotlin/com/hedvig/android/core/designsystem/component/card/HedvigInfoCard.kt +++ b/app/core/core-design-system/src/main/kotlin/com/hedvig/android/core/designsystem/component/card/HedvigInfoCard.kt @@ -9,6 +9,7 @@ import androidx.compose.material3.CardDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Shape import androidx.compose.ui.unit.dp import com.hedvig.android.core.designsystem.material3.infoContainer import com.hedvig.android.core.designsystem.material3.onInfoContainer @@ -22,10 +23,11 @@ fun HedvigInfoCard( containerColor = MaterialTheme.colorScheme.infoContainer, contentColor = MaterialTheme.colorScheme.onInfoContainer, ), + shape: Shape = MaterialTheme.shapes.squircleMedium, content: @Composable RowScope.() -> Unit, ) { HedvigCard( - shape = MaterialTheme.shapes.squircleMedium, + shape = shape, colors = colors, modifier = modifier, ) { diff --git a/app/core/core-ui/src/main/kotlin/com/hedvig/android/core/ui/card/ExpandablePlusCard.kt b/app/core/core-ui/src/main/kotlin/com/hedvig/android/core/ui/card/ExpandablePlusCard.kt index 79f2a2b3ba..121e19fdc9 100644 --- a/app/core/core-ui/src/main/kotlin/com/hedvig/android/core/ui/card/ExpandablePlusCard.kt +++ b/app/core/core-ui/src/main/kotlin/com/hedvig/android/core/ui/card/ExpandablePlusCard.kt @@ -18,9 +18,7 @@ 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.CardDefaults import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment @@ -44,10 +42,6 @@ fun ExpandablePlusCard( ) { HedvigCard( onClick = onClick, - colors = CardDefaults.outlinedCardColors( - containerColor = MaterialTheme.colorScheme.surfaceVariant, - contentColor = MaterialTheme.colorScheme.onSurface, - ), modifier = modifier, ) { Column { diff --git a/app/feature/feature-changeaddress/build.gradle.kts b/app/feature/feature-changeaddress/build.gradle.kts index 3c5a82e751..23346966a0 100644 --- a/app/feature/feature-changeaddress/build.gradle.kts +++ b/app/feature/feature-changeaddress/build.gradle.kts @@ -28,6 +28,7 @@ dependencies { implementation(projects.apolloOctopusPublic) implementation(projects.coreCommonPublic) implementation(projects.coreDesignSystem) + implementation(projects.coreIcons) implementation(projects.coreResources) implementation(projects.coreUi) implementation(projects.coreUiData) diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ChangeAddressUiState.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ChangeAddressUiState.kt index 119fe72f45..ebee96818f 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ChangeAddressUiState.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ChangeAddressUiState.kt @@ -39,6 +39,18 @@ internal data class ChangeAddressUiState( val moveFromAddressId: AddressId? = null, val quotes: List = emptyList(), val successfulMoveResult: SuccessfulMove? = null, + + /** + * When we receive the moveIntentId, we want to navigate to the next step. We keep this signal here so that we can + * still go back to the previous screen and not introduce an infinite navigation loop + */ + val navigateToFirstStepAfterHavingReceivedMoveIntentId: Boolean = false, + + /** + * When we receive some quotes from submitting all the data, we want to navigate to the offer destination. We keep + * this signal so that we can go back to the previous screen and not introduce an infinite navigation loop. + */ + val navigateToOfferScreenAfterHavingReceivedQuotes: Boolean = false, ) { val isHousingTypeValid: Boolean @@ -132,24 +144,24 @@ internal data class ChangeAddressUiState( ) } - private fun isSquareMetersWithinBounds(squareMeters: Int?) = if (maxSquareMeters != null) { + private fun isSquareMetersWithinBounds(squareMeters: Int?): Boolean { + if (maxSquareMeters == null) { + return true + } if (squareMeters == null) { - false - } else { - squareMeters <= maxSquareMeters + return false } - } else { - true + return squareMeters <= maxSquareMeters } - private fun isNumberCoInsuredWithinBounds(numberCoInsured: Int?) = if (maxNumberCoInsured != null) { + private fun isNumberCoInsuredWithinBounds(numberCoInsured: Int?): Boolean { + if (maxNumberCoInsured == null) { + return true + } if (numberCoInsured == null) { - false - } else { - numberCoInsured <= maxNumberCoInsured + return false } - } else { - true + return numberCoInsured <= maxNumberCoInsured } } diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ChangeAddressViewModel.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ChangeAddressViewModel.kt index 52c78daef3..1a4c080d3a 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ChangeAddressViewModel.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ChangeAddressViewModel.kt @@ -65,10 +65,6 @@ internal class ChangeAddressViewModel( _uiState.update { it.copy(isSublet = ValidatedInput(isSublet)) } } - fun onQuotesCleared() { - _uiState.update { it.copy(quotes = emptyList()) } - } - fun validateAddressInput(): Boolean { _uiState.update { it.validateAddressInput() } return _uiState.value.isAddressInputValid @@ -79,6 +75,26 @@ internal class ChangeAddressViewModel( return _uiState.value.isHouseInputValid } + /** + * After we've received the MoveIntentId, `startMovingFlowAfterHavingReceivedMoveIntentId` is used to trigger the + * navigation to the next question. When this function is called, it means the navigation event has been handled. + */ + fun onNavigatedToFirstStepAfterHavingReceivedMoveIntentId() { + _uiState.update { + it.copy(navigateToFirstStepAfterHavingReceivedMoveIntentId = false) + } + } + + /** + * After we've received the offer quotes, `navigateToOfferScreenAfterHavingReceivedQuotes` is used to trigger the + * navigation to the offer page. When this function is called, it means the navigation event has been handled. + */ + fun onNavigatedToOfferScreenAfterHavingReceivedQuotes() { + _uiState.update { + it.copy(navigateToOfferScreenAfterHavingReceivedQuotes = false) + } + } + fun onSubmitNewAddress() { if (uiState.value.moveIntentId == null) { _uiState.update { @@ -102,6 +118,7 @@ internal class ChangeAddressViewModel( _uiState.update { it.copy( isLoading = false, + navigateToOfferScreenAfterHavingReceivedQuotes = true, quotes = quotes, ) } @@ -111,12 +128,11 @@ internal class ChangeAddressViewModel( } fun onExpandQuote(moveQuote: MoveQuote) { - _uiState.update { - it.copy( - quotes = it.quotes.replace( - newValue = moveQuote.copy(isExpanded = !moveQuote.isExpanded), - block = { it == moveQuote }, - ), + _uiState.update { uiState: ChangeAddressUiState -> + uiState.copy( + quotes = uiState.quotes.map { quote: MoveQuote -> + if (quote == moveQuote) moveQuote.copy(isExpanded = !moveQuote.isExpanded) else quote + }, ) } } @@ -167,7 +183,7 @@ internal class ChangeAddressViewModel( } fun onHousingTypeErrorDialogDismissed() { - _uiState.update { it.copy(housingType = ValidatedInput(it.housingType.input)) } + _uiState.update { it.copy(housingType = it.housingType.copy(errorMessageRes = null)) } } fun onHousingTypeSubmitted() { @@ -186,6 +202,7 @@ internal class ChangeAddressViewModel( _uiState.update { it.copy( moveIntentId = moveIntent.id, + navigateToFirstStepAfterHavingReceivedMoveIntentId = true, numberInsured = ValidatedInput(moveIntent.suggestedNumberInsured.toString()), moveFromAddressId = moveIntent.currentHomeAddresses.firstOrNull()?.id, extraBuildingTypes = moveIntent.extraBuildingTypes, @@ -229,10 +246,12 @@ internal class ChangeAddressViewModel( fun addExtraBuilding(extraBuilding: ExtraBuilding) { _uiState.update { val extraBuildings = it.extraBuildings.toMutableList() - extraBuildings.find { it.id == extraBuilding.id }?.let { - extraBuildings.replace(extraBuilding) { it.id == extraBuilding.id } - } ?: extraBuildings.add(extraBuilding) - it.copy(extraBuildings = extraBuildings) + val existingBuildingWithSameId = extraBuildings.find { it.id == extraBuilding.id } + if (existingBuildingWithSameId != null) { + extraBuildings.remove(existingBuildingWithSameId) + } + extraBuildings.add(extraBuilding) + it.copy(extraBuildings = extraBuildings.toList()) } } } @@ -275,9 +294,3 @@ private fun ChangeAddressUiState.toQuoteInput() = when (housingType.input) { null -> throw IllegalArgumentException("No housing type found when creating input") } - -fun List.replace(newValue: T, block: (T) -> Boolean): List { - return map { - if (block(it)) newValue else it - } -} diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/Address.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/Address.kt index 92bffe8b51..49b60a8fc7 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/Address.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/Address.kt @@ -4,10 +4,10 @@ import kotlinx.serialization.Serializable @JvmInline @Serializable -value class AddressId(val id: String) +internal value class AddressId(val id: String) @Serializable -data class Address( +internal data class Address( val id: AddressId, val apartmentNumber: String? = null, val bbrId: String? = null, diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/ChangeAddressRepository.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/ChangeAddressRepository.kt index 3eda02df10..06c4755239 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/ChangeAddressRepository.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/ChangeAddressRepository.kt @@ -2,12 +2,14 @@ package com.hedvig.android.feature.changeaddress.data import arrow.core.Either import arrow.core.raise.either +import arrow.core.raise.ensureNotNull import com.apollographql.apollo3.ApolloClient import com.hedvig.android.apollo.safeExecute import com.hedvig.android.apollo.toEither import com.hedvig.android.core.common.ErrorMessage import com.hedvig.android.core.ui.insurance.toProductVariant import com.hedvig.android.core.uidata.UiMoney +import com.hedvig.android.logger.logcat import kotlinx.collections.immutable.toImmutableList import octopus.MoveIntentCommitMutation import octopus.MoveIntentCreateMutation @@ -19,12 +21,13 @@ internal interface ChangeAddressRepository { suspend fun commitMove(id: MoveIntentId): Either } -data object SuccessfulMove +internal data object SuccessfulMove internal class NetworkChangeAddressRepository( private val apolloClient: ApolloClient, ) : ChangeAddressRepository { override suspend fun createMoveIntent(): Either { + logcat { "Moving Flow: createMoveIntent" } return either { val result = apolloClient .mutation(MoveIntentCreateMutation()) @@ -33,18 +36,20 @@ internal class NetworkChangeAddressRepository( .bind() .moveIntentCreate - val moveIntent = result.moveIntent val userError = result.userError - - when { - moveIntent != null -> moveIntent.toMoveIntent() - userError != null -> raise(ErrorMessage(userError.message)) - else -> raise(ErrorMessage("No data found in MoveIntent")) + if (userError != null) { + raise(ErrorMessage(userError.message)) } + val moveIntent = result.moveIntent + ensureNotNull(moveIntent) { + ErrorMessage("No data found in MoveIntent") + } + moveIntent.toMoveIntent() } } override suspend fun createQuotes(input: QuoteInput): Either> { + logcat { "Moving Flow: createQuotes with input:$input" } return either { val result = apolloClient .mutation(input.toMoveIntentRequestMutation()) @@ -53,18 +58,21 @@ internal class NetworkChangeAddressRepository( .bind() .moveIntentRequest - val moveIntent = result.moveIntent val userError = result.userError + if (userError != null) { + raise(ErrorMessage(userError.message)) + } - when { - userError != null -> raise(ErrorMessage(userError.message)) - moveIntent != null -> moveIntent.toMoveQuotes() - else -> raise(ErrorMessage("No data found in MoveIntent")) + val moveIntent = result.moveIntent + ensureNotNull(moveIntent) { + ErrorMessage("No data found in MoveIntent") } + moveIntent.toMoveQuotes() } } override suspend fun commitMove(id: MoveIntentId): Either { + logcat { "Moving Flow: commitMove with id:$id" } return either { val result = apolloClient .mutation(MoveIntentCommitMutation(id.id)) @@ -74,16 +82,15 @@ internal class NetworkChangeAddressRepository( .moveIntentCommit val userError = result.userError - - when { - userError != null -> raise(ErrorMessage(userError.message)) - else -> SuccessfulMove + if (userError != null) { + raise(ErrorMessage(userError.message)) } + SuccessfulMove } } } -private fun MoveIntentCreateMutation.Data.MoveIntentCreate.MoveIntent.toMoveIntent() = MoveIntent( +private fun MoveIntentCreateMutation.Data.MoveIntentCreate.MoveIntent.toMoveIntent(): MoveIntent = MoveIntent( id = MoveIntentId(id), currentHomeAddresses = currentHomeAddresses.map { currentHomeAddress -> Address( @@ -102,19 +109,21 @@ private fun MoveIntentCreateMutation.Data.MoveIntentCreate.MoveIntent.toMoveInte extraBuildingTypes = extraBuildingTypes.map { it.toExtraBuildingType() }, ) -private fun MoveIntentRequestMutation.Data.MoveIntentRequest.MoveIntent.toMoveQuotes() = quotes.map { quote -> - MoveQuote( - id = id, - insuranceName = quote.exposureName ?: quote.productVariant.displayName, - moveIntentId = MoveIntentId(id), - premium = UiMoney( - amount = quote.premium.amount, - currencyCode = quote.premium.currencyCode, - ), - startDate = quote.startDate, - productVariant = quote.productVariant.toProductVariant(), - displayItems = quote.displayItems - .map { it.displayTitle to it.displayValue } - .toImmutableList(), - ) +private fun MoveIntentRequestMutation.Data.MoveIntentRequest.MoveIntent.toMoveQuotes(): List { + return quotes.map { quote -> + MoveQuote( + id = id, + insuranceName = quote.exposureName ?: quote.productVariant.displayName, + moveIntentId = MoveIntentId(id), + premium = UiMoney( + amount = quote.premium.amount, + currencyCode = quote.premium.currencyCode, + ), + startDate = quote.startDate, + productVariant = quote.productVariant.toProductVariant(), + displayItems = quote.displayItems + .map { it.displayTitle to it.displayValue } + .toImmutableList(), + ) + } } diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/ExtraBuilding.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/ExtraBuilding.kt index 1e533eb0da..4808722c86 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/ExtraBuilding.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/ExtraBuilding.kt @@ -3,14 +3,14 @@ package com.hedvig.android.feature.changeaddress.data import octopus.type.MoveExtraBuildingType import java.util.UUID -data class ExtraBuilding( +internal data class ExtraBuilding( val id: String = UUID.randomUUID().toString(), val size: Int, val type: ExtraBuildingType, val hasWaterConnected: Boolean, ) -enum class ExtraBuildingType { +internal enum class ExtraBuildingType { GARAGE, CARPORT, SHED, @@ -28,7 +28,7 @@ enum class ExtraBuildingType { UNKNOWN, } -fun ExtraBuildingType.stringRes(): Int = when (this) { +internal fun ExtraBuildingType.stringRes(): Int = when (this) { ExtraBuildingType.GARAGE -> hedvig.resources.R.string.FIELD_EXTRA_BUIDLINGS_GARAGE_LABEL ExtraBuildingType.CARPORT -> hedvig.resources.R.string.FIELD_EXTRA_BUIDLINGS_CARPORT_LABEL ExtraBuildingType.SHED -> hedvig.resources.R.string.FIELD_EXTRA_BUIDLINGS_SHED_LABEL @@ -46,7 +46,7 @@ fun ExtraBuildingType.stringRes(): Int = when (this) { ExtraBuildingType.UNKNOWN -> hedvig.resources.R.string.FIELD_EXTRA_BUIDLINGS_OTHER_LABEL } -fun ExtraBuildingType.toMoveExtraBuildingType() = when (this) { +internal fun ExtraBuildingType.toMoveExtraBuildingType() = when (this) { ExtraBuildingType.GARAGE -> MoveExtraBuildingType.GARAGE ExtraBuildingType.CARPORT -> MoveExtraBuildingType.CARPORT ExtraBuildingType.SHED -> MoveExtraBuildingType.SHED @@ -64,7 +64,7 @@ fun ExtraBuildingType.toMoveExtraBuildingType() = when (this) { ExtraBuildingType.UNKNOWN -> MoveExtraBuildingType.UNKNOWN__ } -fun MoveExtraBuildingType.toExtraBuildingType() = when (this) { +internal fun MoveExtraBuildingType.toExtraBuildingType() = when (this) { MoveExtraBuildingType.GARAGE -> ExtraBuildingType.GARAGE MoveExtraBuildingType.CARPORT -> ExtraBuildingType.CARPORT MoveExtraBuildingType.SHED -> ExtraBuildingType.SHED diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/MoveIntent.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/MoveIntent.kt index 850b75210d..8b2046ff2c 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/MoveIntent.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/MoveIntent.kt @@ -1,13 +1,11 @@ package com.hedvig.android.feature.changeaddress.data import kotlinx.datetime.LocalDate -import kotlinx.serialization.Serializable @JvmInline -@Serializable -value class MoveIntentId(val id: String) +internal value class MoveIntentId(val id: String) -data class MoveIntent( +internal data class MoveIntent( val id: MoveIntentId, val currentHomeAddresses: List
, val movingDateRange: ClosedRange, diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/MoveQuote.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/MoveQuote.kt index 87e2f505b2..ccbbf2633f 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/MoveQuote.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/MoveQuote.kt @@ -9,7 +9,7 @@ import kotlinx.collections.immutable.persistentListOf import kotlinx.datetime.LocalDate import octopus.type.CurrencyCode -data class MoveQuote( +internal data class MoveQuote( val id: String, val insuranceName: String, val moveIntentId: MoveIntentId, diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/QuoteInput.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/QuoteInput.kt index f8bcefe31d..1267eb1c10 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/QuoteInput.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/data/QuoteInput.kt @@ -10,17 +10,17 @@ import octopus.type.MoveToAddressInput import octopus.type.MoveToApartmentInput import octopus.type.MoveToHouseInput -enum class HousingType { +internal enum class HousingType { APARTMENT_RENT, APARTMENT_OWN, VILLA } -fun HousingType.displayNameResource() = when (this) { +internal fun HousingType.displayNameResource() = when (this) { HousingType.APARTMENT_RENT -> hedvig.resources.R.string.CHANGE_ADDRESS_APARTMENT_RENT_LABEL HousingType.APARTMENT_OWN -> hedvig.resources.R.string.CHANGE_ADDRESS_APARTMENT_OWN_LABEL HousingType.VILLA -> hedvig.resources.R.string.CHANGE_ADDRESS_VILLA_LABEL } -sealed interface QuoteInput { +internal sealed interface QuoteInput { fun toMoveIntentRequestMutation(): MoveIntentRequestMutation data class ApartmentInput( @@ -33,7 +33,7 @@ sealed interface QuoteInput { val apartmentOwnerType: HousingType, val isStudent: Boolean, ) : QuoteInput { - override fun toMoveIntentRequestMutation() = MoveIntentRequestMutation( + override fun toMoveIntentRequestMutation(): MoveIntentRequestMutation = MoveIntentRequestMutation( intentId = moveIntentId.id, input = MoveIntentRequestInput( moveToAddress = MoveToAddressInput( @@ -74,7 +74,7 @@ sealed interface QuoteInput { val extraBuildings: List, val isStudent: Boolean, ) : QuoteInput { - override fun toMoveIntentRequestMutation() = MoveIntentRequestMutation( + override fun toMoveIntentRequestMutation(): MoveIntentRequestMutation = MoveIntentRequestMutation( intentId = moveIntentId.id, input = MoveIntentRequestInput( moveToAddress = MoveToAddressInput( diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressEnterNewAddressDestination.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressEnterNewAddressDestination.kt index 89e7e5d6df..b85adb8b2e 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressEnterNewAddressDestination.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressEnterNewAddressDestination.kt @@ -37,24 +37,25 @@ import hedvig.resources.R import kotlinx.datetime.LocalDate @Composable -internal fun ChangeAddressEnterNewDestination( +internal fun ChangeAddressEnterNewAddressDestination( viewModel: ChangeAddressViewModel, - onContinue: () -> Unit, - close: () -> Unit, - onQuotesReceived: () -> Unit, + onNavigateToVillaInformationDestination: () -> Unit, + navigateUp: () -> Unit, + onNavigateToOfferDestination: () -> Unit, ) { val uiState: ChangeAddressUiState by viewModel.uiState.collectAsStateWithLifecycle() - val quotes = uiState.quotes - LaunchedEffect(quotes) { - if (quotes.isNotEmpty()) { - onQuotesReceived() + val navigateToOfferScreenAfterHavingReceivedQuotes = uiState.navigateToOfferScreenAfterHavingReceivedQuotes + LaunchedEffect(navigateToOfferScreenAfterHavingReceivedQuotes) { + if (navigateToOfferScreenAfterHavingReceivedQuotes) { + viewModel.onNavigatedToOfferScreenAfterHavingReceivedQuotes() + onNavigateToOfferDestination() } } - ChangeAddressEnterNewScreen( + ChangeAddressEnterNewAddressScreen( uiState = uiState, - close = close, + navigateUp = navigateUp, onErrorDialogDismissed = viewModel::onErrorDialogDismissed, onStreetChanged = viewModel::onStreetChanged, onPostalCodeChanged = viewModel::onPostalCodeChanged, @@ -66,7 +67,7 @@ internal fun ChangeAddressEnterNewDestination( val isInputValid = viewModel.validateAddressInput() if (isInputValid) { if (uiState.housingType.input == HousingType.VILLA) { - onContinue() + onNavigateToVillaInformationDestination() } else { viewModel.onSubmitNewAddress() } @@ -76,9 +77,9 @@ internal fun ChangeAddressEnterNewDestination( } @Composable -private fun ChangeAddressEnterNewScreen( +private fun ChangeAddressEnterNewAddressScreen( uiState: ChangeAddressUiState, - close: () -> Unit, + navigateUp: () -> Unit, onErrorDialogDismissed: () -> Unit, onStreetChanged: (String) -> Unit, onPostalCodeChanged: (String) -> Unit, @@ -101,7 +102,7 @@ private fun ChangeAddressEnterNewScreen( } HedvigScaffold( - navigateUp = close, + navigateUp = navigateUp, modifier = Modifier.clearFocusOnTap(), topAppBarActionType = TopAppBarActionType.CLOSE, ) { @@ -195,10 +196,10 @@ private fun ChangeAddressEnterNewScreen( @HedvigPreview @Composable -private fun PreviewChangeAddressEnterNewScreen() { +private fun PreviewChangeAddressEnterNewAddressScreen() { HedvigTheme { Surface(color = MaterialTheme.colorScheme.background) { - ChangeAddressEnterNewScreen( + ChangeAddressEnterNewAddressScreen( ChangeAddressUiState(datePickerUiState = DatePickerUiState(null)), {}, {}, {}, {}, {}, {}, {}, {}, {}, ) diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressEnterNewVillaAddressDestination.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressEnterVillaInformationDestination.kt similarity index 91% rename from app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressEnterNewVillaAddressDestination.kt rename to app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressEnterVillaInformationDestination.kt index b771986f0b..52e2f0dd4a 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressEnterNewVillaAddressDestination.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressEnterVillaInformationDestination.kt @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text @@ -38,19 +37,19 @@ import com.hedvig.android.feature.changeaddress.ui.extrabuildings.ExtraBuildingB import com.hedvig.android.feature.changeaddress.ui.extrabuildings.ExtraBuildingContainer import hedvig.resources.R -@ExperimentalMaterial3Api @Composable -internal fun ChangeAddressEnterNewVillaAddressDestination( +internal fun ChangeAddressEnterVillaInformationDestination( viewModel: ChangeAddressViewModel, navigateUp: () -> Unit, - onQuotesReceived: () -> Unit, + onNavigateToOfferDestination: () -> Unit, ) { val uiState: ChangeAddressUiState by viewModel.uiState.collectAsStateWithLifecycle() - val quotes = uiState.quotes - LaunchedEffect(quotes) { - if (quotes.isNotEmpty()) { - onQuotesReceived() + val navigateToOfferScreenAfterHavingReceivedQuotes = uiState.navigateToOfferScreenAfterHavingReceivedQuotes + LaunchedEffect(navigateToOfferScreenAfterHavingReceivedQuotes) { + if (navigateToOfferScreenAfterHavingReceivedQuotes) { + viewModel.onNavigatedToOfferScreenAfterHavingReceivedQuotes() + onNavigateToOfferDestination() } } @@ -70,7 +69,7 @@ internal fun ChangeAddressEnterNewVillaAddressDestination( ) } - ChangeAddressEnterNewVillaAddressScreen( + ChangeAddressEnterVillaInformationScreen( uiState = uiState, navigateUp = navigateUp, onErrorDialogDismissed = viewModel::onErrorDialogDismissed, @@ -84,9 +83,6 @@ internal fun ChangeAddressEnterNewVillaAddressDestination( viewModel.onSubmitNewAddress() } }, - onExtraBuildingClicked = { - showExtraBuildingsBottomSheet = true - }, onAddExtraBuildingClicked = { showExtraBuildingsBottomSheet = true }, @@ -95,7 +91,7 @@ internal fun ChangeAddressEnterNewVillaAddressDestination( } @Composable -private fun ChangeAddressEnterNewVillaAddressScreen( +private fun ChangeAddressEnterVillaInformationScreen( uiState: ChangeAddressUiState, navigateUp: () -> Unit, onErrorDialogDismissed: () -> Unit, @@ -104,7 +100,6 @@ private fun ChangeAddressEnterNewVillaAddressScreen( onNumberOfBathroomsChanged: (String) -> Unit, onIsSubletSelected: (Boolean) -> Unit, onSaveNewAddress: () -> Unit, - onExtraBuildingClicked: (ExtraBuilding) -> Unit, onAddExtraBuildingClicked: () -> Unit, onRemoveExtraBuildingClicked: (ExtraBuilding) -> Unit, ) { @@ -173,7 +168,6 @@ private fun ChangeAddressEnterNewVillaAddressScreen( Spacer(modifier = Modifier.height(8.dp)) ExtraBuildingContainer( extraBuildings = uiState.extraBuildings, - onExtraBuildingItemClicked = onExtraBuildingClicked, onAddExtraBuildingClicked = onAddExtraBuildingClicked, onRemoveExtraBuildingClicked = onRemoveExtraBuildingClicked, modifier = Modifier @@ -198,10 +192,10 @@ private fun ChangeAddressEnterNewVillaAddressScreen( @HedvigPreview @Composable -private fun PreviewChangeAddressEnterNewVillaAddressDestination() { +private fun PreviewChangeAddressEnterVillaInformationScreen() { HedvigTheme { Surface(color = MaterialTheme.colorScheme.background) { - ChangeAddressEnterNewVillaAddressScreen( + ChangeAddressEnterVillaInformationScreen( ChangeAddressUiState(), {}, {}, @@ -212,7 +206,6 @@ private fun PreviewChangeAddressEnterNewVillaAddressDestination() { {}, {}, {}, - {}, ) } } diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressOfferDestination.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressOfferDestination.kt index 8604e70edd..b7ae865db3 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressOfferDestination.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressOfferDestination.kt @@ -19,13 +19,11 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.material3.Button import androidx.compose.material3.Divider 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.material3.TopAppBarDefaults import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableFloatStateOf @@ -34,7 +32,7 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.layout.onGloballyPositioned +import androidx.compose.ui.layout.onPlaced import androidx.compose.ui.layout.positionInParent import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource @@ -51,10 +49,10 @@ import com.hedvig.android.core.designsystem.component.button.HedvigContainedButt import com.hedvig.android.core.designsystem.component.button.HedvigTextButton import com.hedvig.android.core.designsystem.component.card.HedvigCard import com.hedvig.android.core.designsystem.component.card.HedvigInfoCard +import com.hedvig.android.core.designsystem.material3.squircleExtraSmall import com.hedvig.android.core.designsystem.material3.squircleMedium import com.hedvig.android.core.designsystem.theme.HedvigTheme import com.hedvig.android.core.ui.ValidatedInput -import com.hedvig.android.core.ui.appbar.m3.TopAppBarActionType import com.hedvig.android.core.ui.dialog.ErrorDialog import com.hedvig.android.core.ui.infocard.VectorInfoCard import com.hedvig.android.core.ui.scaffold.HedvigScaffold @@ -77,7 +75,7 @@ import kotlinx.datetime.toLocalDateTime internal fun ChangeAddressOfferDestination( viewModel: ChangeAddressViewModel, openChat: () -> Unit, - close: () -> Unit, + navigateUp: () -> Unit, onChangeAddressResult: (LocalDate?) -> Unit, openUrl: (String) -> Unit, ) { @@ -92,7 +90,7 @@ internal fun ChangeAddressOfferDestination( ChangeAddressOfferScreen( uiState = uiState, openChat = openChat, - close = close, + navigateUp = navigateUp, onErrorDialogDismissed = viewModel::onErrorDialogDismissed, onExpandQuote = viewModel::onExpandQuote, onConfirmMove = viewModel::onConfirmMove, @@ -104,7 +102,7 @@ internal fun ChangeAddressOfferDestination( private fun ChangeAddressOfferScreen( uiState: ChangeAddressUiState, openChat: () -> Unit, - close: () -> Unit, + navigateUp: () -> Unit, onErrorDialogDismissed: () -> Unit, onExpandQuote: (MoveQuote) -> Unit, onConfirmMove: (MoveIntentId) -> Unit, @@ -122,9 +120,8 @@ private fun ChangeAddressOfferScreen( val scrollState = rememberScrollState() HedvigScaffold( topAppBarText = stringResource(id = R.string.CHANGE_ADDRESS_SUMMARY_TITLE), - navigateUp = close, + navigateUp = navigateUp, topAppBarScrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(), - topAppBarActionType = TopAppBarActionType.CLOSE, scrollState = scrollState, ) { Spacer(Modifier.height(8.dp)) @@ -171,7 +168,7 @@ private fun ChangeAddressOfferScreen( }, modifier = Modifier .padding(horizontal = 16.dp) - .onGloballyPositioned { layoutCoordinates -> + .onPlaced { layoutCoordinates -> // Find the Y position where this button ends, to scroll right below it on click. whatsIncludedButtonPositionY = layoutCoordinates.positionInParent().y + layoutCoordinates.size.height @@ -210,7 +207,7 @@ private fun ChangeAddressOfferScreen( Spacer(Modifier.height(64.dp)) Text( text = stringResource(id = R.string.CHANGE_ADDRESS_NO_FIND), - fontSize = 18.sp, + style = MaterialTheme.typography.bodyLarge, textAlign = TextAlign.Center, modifier = Modifier .fillMaxWidth() @@ -227,7 +224,7 @@ private fun ChangeAddressOfferScreen( ) { Text( text = stringResource(R.string.open_chat), - fontSize = 18.sp, + style = MaterialTheme.typography.bodyLarge, ) } Spacer(Modifier.height(16.dp)) @@ -243,14 +240,14 @@ private fun QuotesPriceSum( startSlot = { Text( text = stringResource(id = R.string.CHANGE_ADDRESS_TOTAL), - fontSize = 18.sp, + style = MaterialTheme.typography.bodyLarge, ) }, endSlot = { val summedPrice = quotes.map(MoveQuote::premium).reduce(UiMoney::plus) Text( text = stringResource(R.string.CHANGE_ADDRESS_PRICE_PER_MONTH_LABEL, summedPrice.toString()), - fontSize = 18.sp, + style = MaterialTheme.typography.bodyLarge, textAlign = TextAlign.End, ) }, @@ -267,8 +264,12 @@ private fun QuoteDetailsAndPdfs( Column(modifier) { HedvigInfoCard( contentPadding = PaddingValues(horizontal = 8.dp, vertical = 4.dp), + shape = MaterialTheme.shapes.squircleExtraSmall, ) { - Text(quote.productVariant.displayName) + Text( + text = quote.productVariant.displayName, + style = MaterialTheme.typography.bodyMedium, + ) } Spacer(Modifier.height(32.dp)) InsurableLimits(quote) @@ -283,14 +284,20 @@ private fun ColumnScope.InsurableLimits(quote: MoveQuote) { quote.productVariant.insurableLimits.mapIndexed { index, highlight -> HorizontalItemsWithMaximumSpaceTaken( startSlot = { - Text(highlight.label, fontSize = 18.sp) + Text( + text = highlight.label, + style = MaterialTheme.typography.bodyLarge, + ) }, endSlot = { Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.End, ) { - Text(highlight.limit, fontSize = 18.sp) + Text( + text = highlight.limit, + style = MaterialTheme.typography.bodyLarge, + ) } }, spaceBetween = 18.dp, @@ -309,6 +316,9 @@ private fun Documents( openUrl: (String) -> Unit, ) { quote.productVariant.documents.mapIndexed { index, document -> + if (index > 0) { + Spacer(Modifier.height(8.dp)) + } HedvigCard( onClick = { openUrl(document.url) }, ) { @@ -331,11 +341,12 @@ private fun Documents( append(" PDF") } }, - fontSize = 18.sp, + style = MaterialTheme.typography.bodyLarge, + ) + Text( + text = document.displayName, + style = MaterialTheme.typography.bodyLarge.copy(color = MaterialTheme.colorScheme.onSurfaceVariant), ) - CompositionLocalProvider(LocalContentColor.provides(MaterialTheme.colorScheme.onSurfaceVariant)) { - Text(document.displayName, fontSize = 18.sp) - } } Spacer(Modifier.width(8.dp)) Icon( @@ -345,9 +356,6 @@ private fun Documents( ) } } - if (index != quote.productVariant.documents.lastIndex) { - Spacer(Modifier.height(8.dp)) - } } } diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressResultDestination.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressResultDestination.kt index 4fb4fdf9ea..d2c35f8944 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressResultDestination.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressResultDestination.kt @@ -46,7 +46,7 @@ internal fun ChangeAddressResultDestination( @HedvigPreview @Composable -internal fun PreviewChangeAddressResultDestination() { +private fun PreviewChangeAddressResultDestination() { HedvigTheme { Surface { ChangeAddressResultDestination(movingDate = LocalDate.fromEpochDays(3000)) {} diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressSelectHousingTypeDestination.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressSelectHousingTypeDestination.kt index 21cb2d3760..d190e8fc80 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressSelectHousingTypeDestination.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/destination/ChangeAddressSelectHousingTypeDestination.kt @@ -39,8 +39,9 @@ internal fun ChangeAddressSelectHousingTypeDestination( ) { val uiState: ChangeAddressUiState by viewModel.uiState.collectAsStateWithLifecycle() - LaunchedEffect(uiState.moveIntentId) { - if (uiState.moveIntentId != null) { + LaunchedEffect(uiState.navigateToFirstStepAfterHavingReceivedMoveIntentId) { + if (uiState.navigateToFirstStepAfterHavingReceivedMoveIntentId) { + viewModel.onNavigatedToFirstStepAfterHavingReceivedMoveIntentId() navigateToEnterNewAddressDestination() } } diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/navigation/ChangeAddressDestination.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/navigation/ChangeAddressDestination.kt index 6a478d3884..9cb0921020 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/navigation/ChangeAddressDestination.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/navigation/ChangeAddressDestination.kt @@ -6,16 +6,16 @@ import kotlinx.serialization.Serializable internal sealed interface ChangeAddressDestination : Destination { @Serializable - data object EnterNewAddress : ChangeAddressDestination + data object SelectHousingType : ChangeAddressDestination @Serializable - data object EnterNewVillaAddress : ChangeAddressDestination + data object EnterNewAddress : ChangeAddressDestination @Serializable - data object OfferDestination : ChangeAddressDestination + data object EnterVillaInformation : ChangeAddressDestination @Serializable - data object SelectHousingType : ChangeAddressDestination + data object Offer : ChangeAddressDestination @Serializable data class AddressResult( diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/navigation/ChangeAddressGraph.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/navigation/ChangeAddressGraph.kt index b8b15e04df..a09c6d485d 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/navigation/ChangeAddressGraph.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/navigation/ChangeAddressGraph.kt @@ -1,12 +1,11 @@ package com.hedvig.android.feature.changeaddress.navigation -import androidx.activity.compose.BackHandler import androidx.navigation.NavBackStackEntry import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder import com.hedvig.android.feature.changeaddress.ChangeAddressViewModel -import com.hedvig.android.feature.changeaddress.destination.ChangeAddressEnterNewDestination -import com.hedvig.android.feature.changeaddress.destination.ChangeAddressEnterNewVillaAddressDestination +import com.hedvig.android.feature.changeaddress.destination.ChangeAddressEnterNewAddressDestination +import com.hedvig.android.feature.changeaddress.destination.ChangeAddressEnterVillaInformationDestination import com.hedvig.android.feature.changeaddress.destination.ChangeAddressOfferDestination import com.hedvig.android.feature.changeaddress.destination.ChangeAddressResultDestination import com.hedvig.android.feature.changeaddress.destination.ChangeAddressSelectHousingTypeDestination @@ -16,7 +15,6 @@ import com.kiwi.navigationcompose.typed.composable import com.kiwi.navigationcompose.typed.createRoutePattern import com.kiwi.navigationcompose.typed.navigate import com.kiwi.navigationcompose.typed.navigation -import com.kiwi.navigationcompose.typed.popBackStack import com.kiwi.navigationcompose.typed.popUpTo fun NavGraphBuilder.changeAddressGraph( @@ -26,7 +24,6 @@ fun NavGraphBuilder.changeAddressGraph( ) { navigation( startDestination = createRoutePattern(), - deepLinks = listOf(), ) { composable { navBackStackEntry -> val viewModel: ChangeAddressViewModel = destinationScopedViewModel( @@ -45,49 +42,41 @@ fun NavGraphBuilder.changeAddressGraph( navController = navController, backStackEntry = navBackStackEntry, ) - BackHandler { - navController.popBackStack(inclusive = true) - } - ChangeAddressEnterNewDestination( + ChangeAddressEnterNewAddressDestination( viewModel = viewModel, - onContinue = { navController.navigate(ChangeAddressDestination.EnterNewVillaAddress) }, - close = { navController.popBackStack(inclusive = true) }, - onQuotesReceived = { - navController.navigate(ChangeAddressDestination.OfferDestination) + onNavigateToVillaInformationDestination = { + navController.navigate(ChangeAddressDestination.EnterVillaInformation) + }, + navigateUp = navController::navigateUp, + onNavigateToOfferDestination = { + navController.navigate(ChangeAddressDestination.Offer) }, ) } - composable { navBackStackEntry -> + composable { navBackStackEntry -> val viewModel: ChangeAddressViewModel = destinationScopedViewModel( navController = navController, backStackEntry = navBackStackEntry, ) - ChangeAddressEnterNewVillaAddressDestination( + ChangeAddressEnterVillaInformationDestination( viewModel = viewModel, navigateUp = navController::navigateUp, - onQuotesReceived = { - navController.navigate(ChangeAddressDestination.OfferDestination) + onNavigateToOfferDestination = { + navController.navigate(ChangeAddressDestination.Offer) }, ) } - composable { backStackEntry -> + composable { backStackEntry -> val viewModel: ChangeAddressViewModel = destinationScopedViewModel( navController = navController, backStackEntry = backStackEntry, ) - BackHandler { - viewModel.onQuotesCleared() - navController.popBackStack(inclusive = true) - } ChangeAddressOfferDestination( viewModel = viewModel, openChat = { openChat(backStackEntry) }, - close = { - viewModel.onQuotesCleared() - navController.popBackStack(inclusive = true) - }, + navigateUp = navController::navigateUp, onChangeAddressResult = { movingDate -> navController.navigate(ChangeAddressDestination.AddressResult(movingDate)) { popUpTo { diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/InputTextField.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/InputTextField.kt index 474a8f4276..4a94b20b81 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/InputTextField.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/InputTextField.kt @@ -9,7 +9,7 @@ import androidx.compose.ui.res.stringResource import com.hedvig.android.core.designsystem.component.textfield.HedvigTextField @Composable -fun InputTextField( +internal fun InputTextField( value: String?, errorMessageRes: Int?, onValueChange: (String) -> Unit, diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/Switch.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/Switch.kt index 6e080c8404..fdf0b05200 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/Switch.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/Switch.kt @@ -17,7 +17,7 @@ import com.hedvig.android.core.designsystem.component.card.HedvigCard import com.hedvig.android.core.designsystem.material3.squircleMedium @Composable -fun ChangeAddressSwitch( +internal fun ChangeAddressSwitch( label: String, checked: Boolean, onClick: () -> Unit, diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/extrabuildings/ExtraBuildingBottomSheet.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/extrabuildings/ExtraBuildingBottomSheet.kt index b647e7bca5..9bf1f38551 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/extrabuildings/ExtraBuildingBottomSheet.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/extrabuildings/ExtraBuildingBottomSheet.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ModalBottomSheet @@ -20,6 +21,7 @@ import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import com.hedvig.android.core.designsystem.component.button.HedvigContainedButton @@ -81,6 +83,9 @@ internal fun ExtraBuildingBottomSheet( sizeErrorText = null sizeInput = it }, + keyboardOptions = KeyboardOptions( + keyboardType = KeyboardType.Number, + ), modifier = Modifier .padding(horizontal = 16.dp) .fillMaxWidth(), @@ -98,7 +103,7 @@ internal fun ExtraBuildingBottomSheet( onClick = { if (isInputValid(sizeInput, selectedType)) { val newExtraBuilding = ExtraBuilding( - size = sizeInput?.toInt() ?: 0, + size = sizeInput?.toIntOrNull() ?: 0, type = selectedType ?: ExtraBuildingType.CARPORT, hasWaterConnected = hasWaterConnected, ) @@ -127,7 +132,7 @@ private fun isInputValid(sizeInput: String?, selectedType: ExtraBuildingType?): @HedvigPreview @Composable -internal fun PreviewExtraBuildingBottomSheet() { +private fun PreviewExtraBuildingBottomSheet() { HedvigTheme { Surface { ExtraBuildingBottomSheet( diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/extrabuildings/ExtraBuildingContainer.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/extrabuildings/ExtraBuildingContainer.kt index 2e548cf237..fe0558971e 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/extrabuildings/ExtraBuildingContainer.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/extrabuildings/ExtraBuildingContainer.kt @@ -1,40 +1,46 @@ package com.hedvig.android.feature.changeaddress.ui.extrabuildings -import androidx.compose.animation.AnimatedContent -import androidx.compose.foundation.Image +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.core.MutableTransitionState +import androidx.compose.animation.expandVertically +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut +import androidx.compose.animation.shrinkVertically import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Clear import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Icon import androidx.compose.material3.IconButton -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 import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.hedvig.android.core.designsystem.component.button.HedvigContainedSmallButton import com.hedvig.android.core.designsystem.component.card.HedvigCard +import com.hedvig.android.core.designsystem.material3.onTypeContainer 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.X import com.hedvig.android.feature.changeaddress.data.ExtraBuilding import com.hedvig.android.feature.changeaddress.data.ExtraBuildingType import com.hedvig.android.feature.changeaddress.data.stringRes import hedvig.resources.R @Composable -fun ExtraBuildingContainer( +internal fun ExtraBuildingContainer( extraBuildings: List, onAddExtraBuildingClicked: () -> Unit, - onExtraBuildingItemClicked: (ExtraBuilding) -> Unit, onRemoveExtraBuildingClicked: (ExtraBuilding) -> Unit, modifier: Modifier = Modifier, ) { @@ -46,12 +52,22 @@ fun ExtraBuildingContainer( style = MaterialTheme.typography.bodyMedium, modifier = Modifier.padding(vertical = 12.dp, horizontal = 16.dp), ) - AnimatedContent(targetState = extraBuildings, label = "extraBuildings") { - Column { - it.forEach { extraBuilding -> + Column { + extraBuildings.forEach { extraBuilding: ExtraBuilding -> + val visibleState = remember { + MutableTransitionState(false).apply { + targetState = true + } + } + AnimatedVisibility( + visibleState = visibleState, + enter = fadeIn() + expandVertically(expandFrom = Alignment.CenterVertically), + exit = fadeOut() + shrinkVertically(shrinkTowards = Alignment.CenterVertically), + label = "extraBuilding", + ) { Row( modifier = Modifier - // .clickable { onExtraBuildingItemClicked(extraBuilding) } // TODO +// .clickable { onExtraBuildingItemClicked(extraBuilding) } // TODO .padding(horizontal = 16.dp, vertical = 8.dp), verticalAlignment = Alignment.CenterVertically, ) { @@ -62,25 +78,23 @@ fun ExtraBuildingContainer( ) Text( text = stringResource(id = R.string.CHANGE_ADDRESS_EXTRA_BUILDINGS_SIZE_LABEL, extraBuilding.size), - color = MaterialTheme.colorScheme.secondary, + color = MaterialTheme.colorScheme.onSurfaceVariant, style = MaterialTheme.typography.bodyMedium, ) if (extraBuilding.hasWaterConnected) { Text( text = stringResource(id = R.string.CHANGE_ADDRESS_EXTRA_BUILDINGS_WATER_LABEL), - color = MaterialTheme.colorScheme.secondary, + color = MaterialTheme.colorScheme.onSurfaceVariant, style = MaterialTheme.typography.bodyMedium, ) } } - Spacer(modifier = Modifier.height(16.dp)) + Spacer(modifier = Modifier.width(16.dp)) Spacer(modifier = Modifier.weight(1f)) IconButton(onClick = { onRemoveExtraBuildingClicked(extraBuilding) }) { - Image( - imageVector = Icons.Filled.Clear, - contentDescription = stringResource( - R.string.login_text_input_email_address_icon_description_clear_all, - ), + Icon( + imageVector = Icons.Hedvig.X, + contentDescription = null, ) } } @@ -93,7 +107,7 @@ fun ExtraBuildingContainer( onClick = onAddExtraBuildingClicked, colors = ButtonDefaults.buttonColors( containerColor = MaterialTheme.colorScheme.typeContainer, - contentColor = LocalContentColor.current, + contentColor = MaterialTheme.colorScheme.onTypeContainer, ), modifier = Modifier.padding(vertical = 12.dp, horizontal = 16.dp), ) @@ -103,7 +117,7 @@ fun ExtraBuildingContainer( @HedvigPreview @Composable -fun PreviewExtraBuildingContainer() { +private fun PreviewExtraBuildingContainer() { HedvigTheme { Surface { ExtraBuildingContainer( @@ -119,7 +133,6 @@ fun PreviewExtraBuildingContainer() { hasWaterConnected = true, ), ), - onExtraBuildingItemClicked = {}, onAddExtraBuildingClicked = {}, onRemoveExtraBuildingClicked = {}, ) diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/extrabuildings/ExtraBuildingTypeContainer.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/extrabuildings/ExtraBuildingTypeContainer.kt index fb07f19f11..436c5f8686 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/extrabuildings/ExtraBuildingTypeContainer.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/extrabuildings/ExtraBuildingTypeContainer.kt @@ -65,7 +65,7 @@ internal fun ExtraBuildingTypeContainer( @HedvigPreview @Composable -fun PreviewExtraBuildingTypeContainer() { +private fun PreviewExtraBuildingTypeContainer() { HedvigTheme { Surface { ExtraBuildingTypeContainer( diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/offer/ContractTermsOverView.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/offer/ContractTermsOverview.kt similarity index 96% rename from app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/offer/ContractTermsOverView.kt rename to app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/offer/ContractTermsOverview.kt index 5e12444621..5b1a53a3d7 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/offer/ContractTermsOverView.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/offer/ContractTermsOverview.kt @@ -1,3 +1,4 @@ + package com.hedvig.android.feature.changeaddress.ui.offer import androidx.compose.foundation.background @@ -26,7 +27,7 @@ import com.hedvig.android.core.designsystem.material3.squircleMedium import com.hedvig.android.core.designsystem.theme.HedvigTheme @Composable -internal fun ContractTermsOverView( +private fun ContractTermsOverview( contractDisplayName: String, contractTerms: ContractTerms, ) { @@ -141,26 +142,26 @@ internal fun ContractTermsOverView( } } -data class ContractTerms( +private data class ContractTerms( val insurableLimits: List, val perils: List, val documents: List, ) -data class InsurableLimit( +private data class InsurableLimit( val label: String, val description: String, val limit: String, ) -data class Peril( +private data class Peril( val title: String, val description: String, val iconUrl: String, val isExpanded: Boolean = false, ) -data class Document( +private data class Document( val title: String, val description: String, val documentUrl: String, @@ -168,10 +169,10 @@ data class Document( @Preview @Composable -fun PreviewContractTermsOverView() { +private fun PreviewContractTermsOverview() { HedvigTheme { Surface { - ContractTermsOverView( + ContractTermsOverview( contractDisplayName = "Hemförsäkring", contractTerms = ContractTerms( insurableLimits = listOf( diff --git a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/offer/QuoteCard.kt b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/offer/QuoteCard.kt index 4e49336f5d..ec20214859 100644 --- a/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/offer/QuoteCard.kt +++ b/app/feature/feature-changeaddress/src/main/kotlin/com/hedvig/android/feature/changeaddress/ui/offer/QuoteCard.kt @@ -14,6 +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.Divider import androidx.compose.material3.Icon import androidx.compose.material3.LocalContentColor @@ -29,10 +30,11 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp 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.InfoFilled import com.hedvig.android.core.ui.getLocale import com.hedvig.android.core.ui.hedvigDateTimeFormatter import com.hedvig.android.core.ui.insurance.toPillow @@ -82,15 +84,14 @@ private fun PillAndBasicInfo(quote: MoveQuote, movingDate: LocalDate) { Row(verticalAlignment = Alignment.CenterVertically) { Image( painter = painterResource(id = quote.productVariant.contractType.toPillow()), - contentDescription = "pillow", + contentDescription = null, modifier = Modifier.size(48.dp), ) Spacer(modifier = Modifier.width(16.dp)) Column { Text( text = quote.insuranceName, - style = MaterialTheme.typography.titleMedium, - fontSize = 18.sp, + style = MaterialTheme.typography.bodyLarge, ) CompositionLocalProvider(LocalContentColor.provides(MaterialTheme.colorScheme.onSurfaceVariant)) { Row(verticalAlignment = Alignment.CenterVertically) { @@ -99,15 +100,13 @@ private fun PillAndBasicInfo(quote: MoveQuote, movingDate: LocalDate) { id = R.string.CHANGE_ADDRESS_ACTIVATION_DATE, movingDate.toJavaLocalDate().format(hedvigDateTimeFormatter(getLocale())), ), - fontSize = 18.sp, + style = MaterialTheme.typography.bodyLarge, ) Spacer(modifier = Modifier.width(4.dp)) Icon( - painter = painterResource(id = com.hedvig.android.core.design.system.R.drawable.ic_info), + imageVector = Icons.Hedvig.InfoFilled, contentDescription = null, - modifier = Modifier - .size(16.dp) - .padding(1.dp), + modifier = Modifier.size(16.dp), ) } } @@ -125,8 +124,7 @@ private fun QuoteDetailsAndPrice( Row(verticalAlignment = Alignment.CenterVertically) { Text( text = stringResource(id = R.string.CHANGE_ADDRESS_DETAILS_LABEL), - style = MaterialTheme.typography.titleMedium, - fontSize = 18.sp, + style = MaterialTheme.typography.bodyLarge, ) Spacer(Modifier.width(8.dp)) val angle = animateFloatAsState( @@ -140,7 +138,7 @@ private fun QuoteDetailsAndPrice( Icon( painter = painterResource(com.hedvig.android.core.design.system.R.drawable.ic_drop_down_indicator), contentDescription = null, - tint = MaterialTheme.colorScheme.outlineVariant, + tint = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier .size(16.dp) .graphicsLayer { @@ -155,8 +153,7 @@ private fun QuoteDetailsAndPrice( id = R.string.CHANGE_ADDRESS_PRICE_PER_MONTH_LABEL, quote.premium.toString(), ), - style = MaterialTheme.typography.titleMedium, - fontSize = 18.sp, + style = MaterialTheme.typography.bodyLarge, textAlign = TextAlign.End, ) }, @@ -180,7 +177,7 @@ private fun ExpandedInformation( @HedvigPreview @Composable -fun PreviewQuoteCard() { +private fun PreviewQuoteCard() { HedvigTheme { Surface(color = MaterialTheme.colorScheme.background) { QuoteCard( diff --git a/app/feature/feature-claim-triaging/src/main/kotlin/com/hedvig/android/feature/claimtriaging/OptionChipsFlowRow.kt b/app/feature/feature-claim-triaging/src/main/kotlin/com/hedvig/android/feature/claimtriaging/OptionChipsFlowRow.kt index e69aced1a7..26e1749bc6 100644 --- a/app/feature/feature-claim-triaging/src/main/kotlin/com/hedvig/android/feature/claimtriaging/OptionChipsFlowRow.kt +++ b/app/feature/feature-claim-triaging/src/main/kotlin/com/hedvig/android/feature/claimtriaging/OptionChipsFlowRow.kt @@ -14,12 +14,10 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.padding -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.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.key @@ -30,7 +28,6 @@ import androidx.compose.ui.graphics.compositeOver import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp import arrow.core.identity import com.hedvig.android.core.designsystem.material3.motion.MotionTokens import com.hedvig.android.core.designsystem.material3.onTypeContainer @@ -135,16 +132,12 @@ internal fun OptionChipsFlowRow( onClick = { onItemClick(item) }, ), ) - CompositionLocalProvider(LocalContentColor provides contentColor) { - Text( - text = itemDisplayName(item), - style = MaterialTheme.typography.bodyLarge.copy( - fontSize = 18.sp, - ), - maxLines = 1, - modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), - ) - } + Text( + text = itemDisplayName(item), + style = MaterialTheme.typography.bodyLarge.copy(color = contentColor), + maxLines = 1, + modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), + ) } } } diff --git a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurancedetail/documents/DocumentsTab.kt b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurancedetail/documents/DocumentsTab.kt index 0feba26447..f78da5cb00 100644 --- a/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurancedetail/documents/DocumentsTab.kt +++ b/app/feature/feature-insurances/src/main/kotlin/com/hedvig/android/feature/insurances/insurancedetail/documents/DocumentsTab.kt @@ -15,7 +15,6 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.material.icons.Icons -import androidx.compose.material3.CardDefaults import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface @@ -70,10 +69,6 @@ private fun DocumentCard( ) { HedvigCard( onClick = onClick, - colors = CardDefaults.outlinedCardColors( - containerColor = MaterialTheme.colorScheme.surfaceVariant, - contentColor = MaterialTheme.colorScheme.onSurface, - ), modifier = Modifier .padding(horizontal = 16.dp) .heightIn(min = 72.dp), diff --git a/app/hanalytics/hanalytics-feature-flags-public/src/main/kotlin/com/hedvig/android/hanalytics/featureflags/flags/HAnalyticsFeatureFlagProvider.kt b/app/hanalytics/hanalytics-feature-flags-public/src/main/kotlin/com/hedvig/android/hanalytics/featureflags/flags/HAnalyticsFeatureFlagProvider.kt index 131a5c8d6f..93f62704f5 100644 --- a/app/hanalytics/hanalytics-feature-flags-public/src/main/kotlin/com/hedvig/android/hanalytics/featureflags/flags/HAnalyticsFeatureFlagProvider.kt +++ b/app/hanalytics/hanalytics-feature-flags-public/src/main/kotlin/com/hedvig/android/hanalytics/featureflags/flags/HAnalyticsFeatureFlagProvider.kt @@ -20,7 +20,7 @@ internal class HAnalyticsFeatureFlagProvider( Feature.TERMINATION_FLOW -> hAnalytics.terminationFlow() Feature.UPDATE_NECESSARY -> hAnalytics.updateNecessary() Feature.USE_NATIVE_CLAIMS_FLOW -> hAnalytics.claimsFlow() - Feature.NEW_MOVING_FLOW -> false + Feature.NEW_MOVING_FLOW -> hAnalytics.movingFlowClient() Feature.CLAIMS_TRIAGING -> hAnalytics.claimsTriaging() Feature.TRAVEL_CERTIFICATE -> hAnalytics.travelInsurance() }