Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Help center feature split #2069

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ dependencies {
implementation(projects.featureEditCoinsured)
implementation(projects.featureFlagsPublic)
implementation(projects.featureForever)
implementation(projects.featureHelpCenter)
implementation(projects.featureHelpCenterData)
implementation(projects.featureHelpCenterUi)
implementation(projects.featureHome)
implementation(projects.featureInsurances)
implementation(projects.featureLogin)
Expand Down
7 changes: 4 additions & 3 deletions app/app/src/main/kotlin/com/hedvig/app/ApplicationModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.content.Context
import android.content.Context.MODE_PRIVATE
import android.content.SharedPreferences
import android.os.Build
import androidx.core.content.ContextCompat.startActivity
import androidx.work.WorkerParameters
import coil.ImageLoader
import coil.decode.GifDecoder
Expand Down Expand Up @@ -58,7 +57,8 @@ import com.hedvig.android.feature.connect.payment.trustly.di.connectPaymentTrust
import com.hedvig.android.feature.deleteaccount.di.deleteAccountModule
import com.hedvig.android.feature.editcoinsured.di.editCoInsuredModule
import com.hedvig.android.feature.forever.di.foreverModule
import com.hedvig.android.feature.help.center.di.helpCenterModule
import com.hedvig.android.feature.help.center.di.helpCenterDataModule
import com.hedvig.android.feature.help.center.di.helpCenterUiModule
import com.hedvig.android.feature.home.di.homeModule
import com.hedvig.android.feature.insurances.di.insurancesModule
import com.hedvig.android.feature.login.di.loginModule
Expand Down Expand Up @@ -355,7 +355,8 @@ val applicationModule = module {
fileUploadModule,
firebaseNotificationModule,
foreverModule,
helpCenterModule,
helpCenterDataModule,
helpCenterUiModule,
homeModule,
insurancesModule,
languageAuthListenersModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ internal class ClaimFlowRepositoryImpl(
// Same name for both due to this: https://hedviginsurance.slack.com/archives/C03RP2M458V/p1680004365854429
name = file.name,
filename = file.name,
body = file.asRequestBody("audio/aac".toMediaType()),
body = file.asRequestBody("audio/mp4".toMediaType()),
),
)
.onLeft {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.OffsetMapping
import androidx.compose.ui.text.input.TransformedText
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import com.hedvig.android.core.designsystem.component.button.HedvigContainedButton
import com.hedvig.android.core.designsystem.component.button.HedvigTextButton
Expand Down Expand Up @@ -186,18 +193,22 @@ private fun FetchFromSsnFields(
onContinue: () -> Unit,
) {
var ssnInput by remember { mutableStateOf("") }

val mask = stringResource(id = R.string.edit_coinsured_ssn_placeholder)
val maskColor = MaterialTheme.colorScheme.onSurfaceVariant
Column {
HedvigTextField(
value = ssnInput,
label = {
Text(stringResource(id = R.string.CONTRACT_PERSONAL_IDENTITY))
},
onValueChange = {
onSsnChanged(it)
ssnInput = it
if (it.length <= 12) {
onSsnChanged(it)
ssnInput = it
}
},
errorText = errorMessage,
visualTransformation = PersonalNumberVisualTransformation(mask, maskColor),
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Number,
imeAction = ImeAction.Done,
Expand Down Expand Up @@ -226,6 +237,45 @@ private fun FetchFromSsnFields(
}
}

private class PersonalNumberVisualTransformation(
private val mask: String,
private val maskColor: Color,
) : VisualTransformation {
override fun filter(text: AnnotatedString): TransformedText {
val trimmed = if (text.text.length >= 12) text.text.substring(0..11) else text.text

val annotatedString = buildAnnotatedString {
for (i in trimmed.indices) {
append(trimmed[i])
if (i == 7) {
append("-")
}
}
withStyle(SpanStyle(color = maskColor)) {
append(mask.takeLast(mask.length - length))
}
}

val personalNumberOffsetTranslator = object : OffsetMapping {
override fun originalToTransformed(offset: Int): Int {
return when {
offset < 8 -> offset
offset <= 12 -> offset + 1
else -> 13
}
}

override fun transformedToOriginal(offset: Int): Int {
return when {
offset <= 8 -> offset
else -> offset - 1
}.coerceAtMost(text.length)
}
}
return TransformedText(annotatedString, personalNumberOffsetTranslator)
}
}

@Composable
private fun ManualInputFields(
birthDate: LocalDate?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,14 @@ internal class EditCoInsuredPresenter(
}

is EditCoInsuredEvent.OnSsnChanged ->
addBottomSheetState = addBottomSheetState.copy(
ssn = event.ssn,
errorMessage = null,
firstName = null,
lastName = null,
)
if (event.ssn.length <= 12) {
addBottomSheetState = addBottomSheetState.copy(
ssn = event.ssn,
errorMessage = null,
firstName = null,
lastName = null,
)
}

is EditCoInsuredEvent.OnBirthDateChanged ->
addBottomSheetState =
Expand Down Expand Up @@ -406,7 +408,7 @@ internal sealed interface EditCoInsuredState {
fun canPickExistingCoInsured() = !selectableCoInsured.isNullOrEmpty()

fun canContinue() = (showManualInput && firstName != null && lastName != null && birthDate != null) ||
(!showManualInput && ssn != null) ||
(!showManualInput && ssn?.length == 12) ||
(selectedCoInsured != null)

fun shouldFetchInfo() = !showManualInput && ssn != null && firstName == null && lastName == null
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
plugins {
id("hedvig.android.ktlint")
id("hedvig.android.library")
alias(libs.plugins.apollo)
alias(libs.plugins.serialization)
alias(libs.plugins.squareSortDependencies)
}

dependencies {
apolloMetadata(projects.apolloOctopusPublic)

implementation(libs.androidx.annotation)
implementation(libs.apollo.normalizedCache)
implementation(libs.apollo.runtime)
implementation(libs.arrow.core)
implementation(libs.coroutines.core)
implementation(libs.koin.core)
implementation(libs.kotlinx.immutable.collections)
implementation(libs.kotlinx.serialization.core)
implementation(projects.apolloCore)
implementation(projects.apolloOctopusPublic)
implementation(projects.coreCommonPublic)
implementation(projects.coreResources)
implementation(projects.featureFlagsPublic)
implementation(projects.moleculePublic)
implementation(projects.uiEmergency)
implementation(projects.dataTravelCertificatePublic)
implementation(projects.dataTermination)
}

apollo {
service("octopus") {
packageName.set("octopus")
generateDataBuilders.set(true)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import com.hedvig.android.molecule.public.MoleculePresenterScope
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf

internal sealed interface HelpCenterEvent {
sealed interface HelpCenterEvent {
data class OnQuickActionSelected(val quickAction: QuickAction) : HelpCenterEvent

data object OnDismissQuickActionDialog : HelpCenterEvent
}

internal data class HelpCenterUiState(
data class HelpCenterUiState(
val topics: ImmutableList<Topic>,
val questions: ImmutableList<Question>,
val quickLinks: ImmutableList<QuickLinkType>,
Expand All @@ -38,7 +38,7 @@ internal data class HelpCenterUiState(
}
}

internal class HelpCenterPresenter(
class HelpCenterPresenter(
private val getCommonClaimsUseCase: GetCommonClaimsUseCase,
private val getQuickLinksUseCase: GetQuickLinksUseCase,
) : MoleculePresenter<HelpCenterEvent, HelpCenterUiState> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import hedvig.resources.R
import kotlinx.serialization.Serializable
import octopus.CommonClaimsQuery

internal sealed interface CommonClaim {
sealed interface CommonClaim {
val title: String
val hintTextRes: Int?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import octopus.CommonClaimsQuery
import octopus.CommonClaimsQuery.Data.CurrentMember.ActiveContract.CurrentAgreement.ProductVariant.CommonClaimDescription.Layout.Companion.asCommonClaimLayoutEmergency
import octopus.CommonClaimsQuery.Data.CurrentMember.ActiveContract.CurrentAgreement.ProductVariant.CommonClaimDescription.Layout.Companion.asCommonClaimLayoutTitleAndBulletPoints

internal class GetCommonClaimsUseCase(
class GetCommonClaimsUseCase(
private val apolloClient: ApolloClient,
) {
suspend fun invoke(): Either<ErrorMessage, PersistentList<CommonClaim>> = either {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.flow.first
import octopus.AvailableSelfServiceOnContractsQuery

internal class GetQuickLinksUseCase(
class GetQuickLinksUseCase(
private val apolloClient: ApolloClient,
private val featureManager: FeatureManager,
private val checkTravelCertificateDestinationAvailabilityUseCase:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package com.hedvig.android.feature.help.center.di

import com.hedvig.android.data.termination.data.GetTerminatableContractsUseCase
import com.hedvig.android.data.travelcertificate.CheckTravelCertificateDestinationAvailabilityUseCase
import com.hedvig.android.feature.help.center.HelpCenterViewModel
import com.hedvig.android.feature.help.center.data.GetCommonClaimsUseCase
import com.hedvig.android.feature.help.center.data.GetQuickLinksUseCase
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module

val helpCenterModule = module {
val helpCenterDataModule = module {
single<GetCommonClaimsUseCase> {
GetCommonClaimsUseCase(get())
}
Expand All @@ -20,10 +18,4 @@ val helpCenterModule = module {
get<GetTerminatableContractsUseCase>(),
)
}
viewModel<HelpCenterViewModel> {
HelpCenterViewModel(
getCommonClaimsUseCase = get<GetCommonClaimsUseCase>(),
getQuickLinksUseCase = get<GetQuickLinksUseCase>(),
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.hedvig.android.feature.help.center.model

enum class HelpCenterContext {
PAYMENT,
CLAIMS,
COVERAGE,
INSURANCE,
OTHER,
}
Loading
Loading