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

GEN-2537 New design/coinsured #2327

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.hedvig.android.design.system.hedvig.tokens.MediumSizeButtonTokens
import com.hedvig.android.design.system.hedvig.tokens.MiniSizeButtonTokens
import com.hedvig.android.design.system.hedvig.tokens.PrimaryAltStyleButtonTokens
import com.hedvig.android.design.system.hedvig.tokens.PrimaryStyleButtonTokens
import com.hedvig.android.design.system.hedvig.tokens.RedStyleButtonTokens
import com.hedvig.android.design.system.hedvig.tokens.SecondaryAltStyleButtonTokens
import com.hedvig.android.design.system.hedvig.tokens.SecondaryStyleButtonTokens
import com.hedvig.android.design.system.hedvig.tokens.SmallSizeButtonTokens
Expand Down Expand Up @@ -181,6 +182,7 @@ object ButtonDefaults {
Secondary,
SecondaryAlt,
Ghost,
Red,
}

enum class ButtonSize {
Expand All @@ -198,6 +200,7 @@ private val ButtonDefaults.ButtonStyle.style: Style
ButtonDefaults.ButtonStyle.Secondary -> Style.Secondary
ButtonDefaults.ButtonStyle.SecondaryAlt -> Style.SecondaryAlt
ButtonDefaults.ButtonStyle.Ghost -> Style.Ghost
ButtonDefaults.ButtonStyle.Red -> Style.Red
}

private val ButtonDefaults.ButtonSize.size: Size
Expand Down Expand Up @@ -427,4 +430,24 @@ private sealed interface Style {
}
}
}

data object Red : Style {
override val buttonColors: ButtonColors
@Composable
get() = with(HedvigTheme.colorScheme) {
remember(this) {
ButtonColors(
containerColor = fromToken(RedStyleButtonTokens.ContainerColor),
contentColor = fromToken(RedStyleButtonTokens.ContentColor),
disabledContainerColor = fromToken(RedStyleButtonTokens.DisabledContainerColor),
disabledContentColor = fromToken(RedStyleButtonTokens.DisabledContentColor),
hoverContainerColor = fromToken(RedStyleButtonTokens.HoverContainerColor),
hoverContentColor = fromToken(RedStyleButtonTokens.HoverContentColor),
activeLoadingIndicatorColor = fromToken(RedStyleButtonTokens.ActiveLoadingIndicatorColor),
inactiveLoadingIndicatorColor = fromToken(RedStyleButtonTokens.InactiveLoadingIndicatorColor),
redTextColor = fromToken(RedStyleButtonTokens.RedContentColor),
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ fun ErrorDialog(
text = title,
description = message,
iconStyle = ERROR,
modifier = Modifier.fillMaxWidth(),
buttonStyle = EmptyStateButtonStyle.Button(
buttonText = buttonText,
onButtonClick = onButtonClick ?: onDismiss,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale
Expand All @@ -46,11 +47,12 @@ fun HedvigCard(
onClick: (() -> Unit)? = null,
interactionSource: MutableInteractionSource? = null,
indication: Indication? = null,
shape: Shape = HedvigTheme.shapes.cornerXLarge,
content: @Composable () -> Unit,
) {
if (onClick != null) {
Surface(
shape = HedvigTheme.shapes.cornerXLarge,
shape = shape,
onClick = onClick,
interactionSource = interactionSource,
indication = indication,
Expand All @@ -60,7 +62,7 @@ fun HedvigCard(
}
} else {
Surface(
shape = HedvigTheme.shapes.cornerXLarge,
shape = shape,
modifier = modifier,
) {
content()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ internal object GhostStyleButtonTokens {
val InactiveLoadingIndicatorColor = ColorSchemeKeyTokens.SurfaceSecondaryTransparent
}

internal object RedStyleButtonTokens {
val ContainerColor = ColorSchemeKeyTokens.SignalRedElement
val ContentColor = ColorSchemeKeyTokens.TextWhite
val HoverContainerColor = ColorSchemeKeyTokens.ButtonPrimaryHover
val HoverContentColor = ColorSchemeKeyTokens.TextWhite
val DisabledContainerColor = ColorSchemeKeyTokens.ButtonPrimaryDisabled
val DisabledContentColor = ColorSchemeKeyTokens.TextTertiary
val ActiveLoadingIndicatorColor = ColorSchemeKeyTokens.TextWhite
val InactiveLoadingIndicatorColor = ColorSchemeKeyTokens.SignalRedText
val RedContentColor = ColorSchemeKeyTokens.SignalRedElement // should not be used ever
}

internal object LargeSizeButtonTokens {
val HorizontalPadding = 32.dp
val TopPadding = 15.dp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameter
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.halilibo.richtext.commonmark.Markdown
import com.hedvig.android.design.system.hedvig.ButtonDefaults
import com.hedvig.android.design.system.hedvig.HedvigButton
import com.hedvig.android.design.system.hedvig.HedvigErrorSection
import com.hedvig.android.design.system.hedvig.HedvigFullScreenCenterAlignedProgress
import com.hedvig.android.design.system.hedvig.HedvigPreview
import com.hedvig.android.design.system.hedvig.HedvigRedTextButton
import com.hedvig.android.design.system.hedvig.HedvigScaffold
import com.hedvig.android.design.system.hedvig.HedvigText
import com.hedvig.android.design.system.hedvig.HedvigTheme
Expand Down Expand Up @@ -124,26 +124,21 @@ private fun DeleteScreenContents(
Spacer(Modifier.height(16.dp))
Spacer(Modifier.weight(1f))
Spacer(Modifier.height(8.dp))
if (isButtonRed) {
HedvigRedTextButton(
text = buttonText,
onClick = onButtonClick,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
val buttonStyle = if (isButtonRed) {
ButtonDefaults.ButtonStyle.Red
} else {
HedvigButton(
text = buttonText,
onClick = onButtonClick,
enabled = true,
isLoading = isButtonLoading,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
ButtonDefaults.ButtonStyle.Primary
}

HedvigButton(
text = buttonText,
onClick = onButtonClick,
enabled = true,
buttonStyle = buttonStyle,
isLoading = isButtonLoading,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
Spacer(Modifier.height(16.dp))
}
}
Expand Down
6 changes: 1 addition & 5 deletions app/feature/feature-edit-coinsured/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ android {

dependencies {
api(libs.androidx.navigation.common)

implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.foundation)
implementation(libs.androidx.lifecycle.compose)
implementation(libs.androidx.navigation.compose)
implementation(libs.arrow.core)
Expand All @@ -31,10 +30,7 @@ dependencies {
implementation(projects.coreAppReview)
implementation(projects.coreCommonPublic)
implementation(projects.coreDemoMode)
implementation(projects.coreDesignSystem)
implementation(projects.coreIcons)
implementation(projects.coreResources)
implementation(projects.coreUi)
implementation(projects.coreUiData)
implementation(projects.designSystemHedvig)
implementation(projects.moleculeAndroid)
Expand Down
Loading
Loading