Skip to content

Commit

Permalink
Merge pull request #1823 from HedvigInsurance/feature/inform-and-deflect
Browse files Browse the repository at this point in the history
Add steps for inform and deflect
  • Loading branch information
StylianosGakis authored Oct 20, 2023
2 parents 34dfa92 + 13ddd9a commit e8d89dc
Show file tree
Hide file tree
Showing 24 changed files with 1,327 additions and 108 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
# Only write to the cache for builds on the 'develop' branch
cache-read-only: ${{ github.ref != 'refs/heads/develop' }}
gradle-home-cache-cleanup: true
cache-disabled: true
- name: Prebuild
run: ./scripts/ci-prebuild.sh
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ fragment ClaimFlowStepFragment on Flow {
...FlowClaimFailedStepFragment
...FlowClaimSuccessStepFragment
...FlowClaimContractSelectStepFragment
...FlowClaimDeflectGlassDamageStepFragment
...FlowClaimConfirmEmergencyStepFragment
...FlowClaimDeflectEmergencyStepFragment
...FlowClaimDeflectPestsStepFragment
}
}

Expand Down Expand Up @@ -129,3 +133,41 @@ fragment FlowClaimContractSelectStepFragment on FlowClaimContractSelectStep {
displayName
}
}

fragment FlowClaimDeflectGlassDamageStepFragment on FlowClaimDeflectGlassDamageStep {
id
partners {
...FlowClaimDeflectPartnerFragment
}
}

fragment FlowClaimConfirmEmergencyStepFragment on FlowClaimConfirmEmergencyStep {
id
text
confirmEmergency
options {
displayName
displayValue: value
}
}

fragment FlowClaimDeflectEmergencyStepFragment on FlowClaimDeflectEmergencyStep {
id
partners {
...FlowClaimDeflectPartnerFragment
}
}

fragment FlowClaimDeflectPestsStepFragment on FlowClaimDeflectPestsStep {
id
partners {
...FlowClaimDeflectPartnerFragment
}
}

fragment FlowClaimDeflectPartnerFragment on FlowClaimDeflectPartner {
id
imageUrl
url
phoneNumber
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mutation FlowClaimConfirmEmergency($isUrgentEmergency: Boolean!, $context: FlowContext!) {
flowClaimConfirmEmergencyNext(input: { confirmEmergency: $isUrgentEmergency }, context: $context) {
id
context
...ClaimFlowStepFragment
}
}
2 changes: 1 addition & 1 deletion app/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ android {

signingConfigs {
named("debug") {
storeFile = file("../../debug.keystore").also { println("Stelios file : ${it.absolutePath}") }
storeFile = file("../../debug.keystore")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ internal fun HedvigNavHost(
navigator = navigator,
shouldShowRequestPermissionRationale = shouldShowRequestPermissionRationale,
activityNavigator = activityNavigator,
imageLoader = imageLoader,
)
},
navigator = navigator,
Expand Down Expand Up @@ -238,6 +239,7 @@ private fun NavGraphBuilder.nestedHomeGraphs(
navigator: Navigator,
shouldShowRequestPermissionRationale: (String) -> Boolean,
activityNavigator: ActivityNavigator,
imageLoader: ImageLoader,
) {
changeAddressGraph(
navController = hedvigAppState.navController,
Expand Down Expand Up @@ -281,6 +283,13 @@ private fun NavGraphBuilder.nestedHomeGraphs(
},
)
},
openUrl = { activityNavigator.openWebsite(context, Uri.parse(it)) },
openChat = { backStackEntry ->
with(navigator) {
backStackEntry.navigate(AppDestination.Chat)
}
},
imageLoader = imageLoader,
)
terminalClaimFlowStepDestinations(
navigator = navigator,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package com.hedvig.android.core.ui

import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.AnimationVector1D
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.PressInteraction
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
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.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.compositeOver
import androidx.compose.ui.graphics.graphicsLayer
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.material3.motion.MotionTokens
import com.hedvig.android.core.designsystem.material3.onTypeContainer
import com.hedvig.android.core.designsystem.material3.squircleMedium
import com.hedvig.android.core.designsystem.material3.typeContainer
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.filterIsInstance

@Composable
fun <T> HedvigChip(
item: T,
itemDisplayName: (T) -> String,
isSelected: Boolean,
onItemClick: (T) -> Unit,
modifier: Modifier = Modifier,
showChipAnimatable: Animatable<Float, AnimationVector1D>,
) {
Box(
// TODO replace with space on the flow row itself https://kotlinlang.slack.com/archives/CJLTWPH7S/p1687442185827989?thread_ts=1679515354.462029&cid=CJLTWPH7S
modifier = modifier
.padding(bottom = 8.dp)
.graphicsLayer {
scaleX = showChipAnimatable.value
scaleY = showChipAnimatable.value
},
contentAlignment = Alignment.Center,
) {
val surfaceColor by animateColorAsState(
if (isSelected) {
MaterialTheme.colorScheme.typeContainer.compositeOver(MaterialTheme.colorScheme.background)
} else {
MaterialTheme.colorScheme.surface
},
)
val contentColor by animateColorAsState(
if (isSelected) {
MaterialTheme.colorScheme.onTypeContainer.compositeOver(surfaceColor)
} else {
MaterialTheme.colorScheme.onSurface
},
)
val backgroundScale = remember { Animatable(1f) }
val interactionSource = remember { MutableInteractionSource() }
LaunchedEffect(interactionSource) {
interactionSource
.interactions
.filterIsInstance<PressInteraction.Release>()
.collectLatest {
backgroundScale.animateTo(
targetValue = 1.05f,
animationSpec = tween(
durationMillis = MotionTokens.DurationShort3.toInt(),
easing = MotionTokens.EasingStandardCubicBezier,
),
)
backgroundScale.animateTo(
targetValue = 1f,
animationSpec = tween(
durationMillis = MotionTokens.DurationShort3.toInt(),
easing = MotionTokens.EasingStandardCubicBezier,
),
)
}
}
Box(
modifier = Modifier
.matchParentSize()
.graphicsLayer {
scaleX = backgroundScale.value
scaleY = backgroundScale.value
}
.clip(MaterialTheme.shapes.squircleMedium)
.background(surfaceColor, MaterialTheme.shapes.squircleMedium)
.clickable(
interactionSource = interactionSource,
indication = null,
onClick = { onItemClick(item) },
),
)
CompositionLocalProvider(LocalContentColor provides contentColor) {
Text(
text = itemDisplayName(item),
style = MaterialTheme.typography.bodyLarge.copy(
fontSize = 18.sp,
),
maxLines = 1,
textAlign = TextAlign.Center,
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.hedvig.android.core.ui.infocard

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
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.CardColors
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp
import com.hedvig.android.core.designsystem.component.card.HedvigInfoCard
import com.hedvig.android.core.designsystem.material3.onWarningContainer
import com.hedvig.android.core.designsystem.material3.warningContainer
import com.hedvig.android.core.designsystem.material3.warningElement
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.WarningFilled

@Composable
fun VectorWarningCard(
text: String,
modifier: Modifier = Modifier,
icon: ImageVector = Icons.Hedvig.WarningFilled,
iconColor: Color = MaterialTheme.colorScheme.warningElement,
colors: CardColors = CardDefaults.outlinedCardColors(
containerColor = MaterialTheme.colorScheme.warningContainer,
contentColor = MaterialTheme.colorScheme.onWarningContainer,
),
) {
VectorWarningCard(
text = text,
modifier = modifier,
icon = icon,
iconColor = iconColor,
colors = colors,
underTextContent = null,
)
}

@Composable
fun VectorWarningCard(
text: String,
modifier: Modifier = Modifier,
icon: ImageVector = Icons.Hedvig.WarningFilled,
iconColor: Color = MaterialTheme.colorScheme.warningElement,
colors: CardColors = CardDefaults.outlinedCardColors(
containerColor = MaterialTheme.colorScheme.warningContainer,
contentColor = MaterialTheme.colorScheme.onWarningContainer,
),
underTextContent: @Composable (ColumnScope.() -> Unit)?,
) {
HedvigInfoCard(
modifier = modifier,
contentPadding = PaddingValues(
start = 12.dp,
top = 12.dp,
end = 16.dp,
bottom = 12.dp,
),
colors = colors,
) {
Icon(
imageVector = icon,
contentDescription = "info",
modifier = Modifier
.padding(top = 2.dp)
.size(16.dp),
tint = iconColor,
)
Spacer(Modifier.width(8.dp))
Column {
Text(
text = text,
style = MaterialTheme.typography.bodyMedium,
)
if (underTextContent != null) {
Spacer(Modifier.height(12.dp))
underTextContent()
Spacer(Modifier.height(4.dp))
}
}
}
}

@HedvigPreview
@Composable
private fun PreviewVectorInfoCard() {
HedvigTheme {
Surface(color = MaterialTheme.colorScheme.background) {
VectorInfoCard("Lorem ipsum")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,28 @@ sealed interface ClaimFlowDestination : Destination {
val selectedItemProblems: List<String>?,
) : ClaimFlowDestination

@Serializable
data class DeflectGlassDamage(
val partners: List<DeflectPartner>,
) : ClaimFlowDestination

@Serializable
data class ConfirmEmergency(
val text: String,
val confirmEmergency: Boolean?,
val options: List<EmergencyOption>,
) : ClaimFlowDestination

@Serializable
data class DeflectEmergency(
val partners: List<DeflectPartner>,
) : ClaimFlowDestination

@Serializable
data class DeflectPests(
val partners: List<DeflectPartner>,
) : ClaimFlowDestination

@Serializable
data class Summary(
val claimTypeTitle: String,
Expand Down Expand Up @@ -213,3 +235,14 @@ data class AudioContent(
*/
val audioUrl: AudioUrl,
)

@Serializable
data class DeflectPartner(
val id: String,
val imageUrl: String,
val phoneNumber: String?,
val url: String?,
)

@Serializable
data class EmergencyOption(val displayName: String, val value: Boolean)
Loading

0 comments on commit e8d89dc

Please sign in to comment.