Skip to content

Commit 65367c8

Browse files
authored
Merge pull request #513 from code-payments/chore/update-share-action-for-tip-card
feat: update share action for tip cards
2 parents 50a33bd + e645db7 commit 65367c8

6 files changed

Lines changed: 35 additions & 21 deletions

File tree

app/src/main/java/com/getcode/models/BillState.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ data class BillState(
4747

4848
sealed interface Action {
4949

50-
val label: String
50+
val label: String?
5151
@Composable get
5252
val asset: Painter
5353
@Composable get
@@ -63,7 +63,7 @@ data class BillState(
6363

6464
data class Share(override val action: () -> Unit): Action {
6565
override val label: String
66-
@Composable get() = stringResource(R.string.action_share)
66+
@Composable get() = stringResource(R.string.action_shareAsURL)
6767

6868
override val asset: Painter
6969
@Composable get() = painterResource(id = R.drawable.ic_remote_send)

app/src/main/java/com/getcode/ui/components/Pill.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fun Pill(
5151
fun Pill(
5252
modifier: Modifier = Modifier,
5353
backgroundColor: Color = Black50,
54-
contentColor: Color = Color.White,
54+
contentColor: Color = CodeTheme.colors.onAction,
5555
shape: CornerBasedShape = CircleShape,
5656
contentPadding: PaddingValues = PaddingValues(
5757
horizontal = CodeTheme.dimens.grid.x2,

app/src/main/java/com/getcode/view/main/home/HomeViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ class HomeViewModel @Inject constructor(
748748
val billState = it.billState.copy(
749749
bill = Bill.Tip(code),
750750
primaryAction = BillState.Action.Share { onRemoteSend() },
751-
secondaryAction = BillState.Action.Done(::cancelSend)
751+
secondaryAction = BillState.Action.Cancel(::cancelSend)
752752
)
753753

754754
it.copy(

app/src/main/java/com/getcode/view/main/home/components/BillManagementOptions.kt

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import com.getcode.theme.Gray50
2121
import com.getcode.theme.White
2222
import com.getcode.ui.components.CodeCircularProgressIndicator
2323
import com.getcode.ui.components.Pill
24+
import com.getcode.ui.utils.addIf
2425
import com.getcode.ui.utils.rememberedClickable
2526

2627
@Composable
@@ -45,10 +46,9 @@ internal fun BillManagementOptions(
4546
if (primaryAction != null) {
4647
Pill(
4748
modifier = Modifier
48-
.rememberedClickable(enabled = !isSending) { primaryAction.action() }
49-
.padding(vertical = 15.dp, horizontal = 20.dp),
50-
contentPadding = PaddingValues(),
51-
backgroundColor = Gray50,
49+
.rememberedClickable(enabled = !isSending) { primaryAction.action() },
50+
contentPadding = PaddingValues(15.dp),
51+
backgroundColor = CodeTheme.colors.action,
5252
) {
5353
Box {
5454
Row(
@@ -59,10 +59,12 @@ internal fun BillManagementOptions(
5959
contentDescription = "",
6060
modifier = Modifier.width(22.dp)
6161
)
62-
Text(
63-
modifier = Modifier.padding(start = 10.dp),
64-
text = primaryAction.label
65-
)
62+
primaryAction.label?.let { label ->
63+
Text(
64+
modifier = Modifier.padding(start = 10.dp),
65+
text = label
66+
)
67+
}
6668
}
6769

6870
if (isSending) {
@@ -80,20 +82,21 @@ internal fun BillManagementOptions(
8082
if (secondaryAction != null) {
8183
Pill(
8284
modifier = Modifier
83-
.rememberedClickable(enabled = isInteractable) { secondaryAction.action() }
84-
.padding(vertical = 15.dp, horizontal = 20.dp),
85-
contentPadding = PaddingValues(),
86-
backgroundColor = Gray50,
85+
.rememberedClickable(enabled = isInteractable) { secondaryAction.action() },
86+
contentPadding = PaddingValues(15.dp),
87+
backgroundColor = CodeTheme.colors.action,
8788
) {
8889
Image(
8990
painter = secondaryAction.asset,
9091
contentDescription = "",
9192
modifier = Modifier.size(18.dp)
9293
)
93-
Text(
94-
modifier = Modifier.padding(start = 10.dp),
95-
text = secondaryAction.label
96-
)
94+
secondaryAction.label?.let { label ->
95+
Text(
96+
modifier = Modifier.padding(start = 10.dp),
97+
text = label
98+
)
99+
}
97100
}
98101
}
99102
}

common/theme/src/main/kotlin/com/getcode/theme/Color.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ val BrandLight = Color(0xFF7379A0)
88
val BrandSubtle = Color(0xFF565C86)
99
val BrandMuted = Color(0xFF45464E)
1010
val BrandDark = Color(0xFF1F1A34)
11-
val BrandOverlay = Color(0xBF1E1E1E)
11+
val BrandAction = Color(0xFF212121)
1212

1313
val Brand01 = Color(0xFF130F27)
1414
val White = Color(0xffffffff)

common/theme/src/main/kotlin/com/getcode/theme/Theme.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ private val DarkColorPalette = CodeColors(
2323
brandLight = BrandLight,
2424
brandSubtle = BrandSubtle,
2525
brandMuted = BrandMuted,
26+
action = Gray50,
27+
onAction = White,
2628
background = Brand,
2729
onBackground = White,
2830
surface = Brand,
@@ -82,6 +84,8 @@ class CodeColors(
8284
brandLight: Color,
8385
brandSubtle: Color,
8486
brandMuted: Color,
87+
action: Color,
88+
onAction: Color,
8589
background: Color,
8690
onBackground: Color,
8791
surface: Color,
@@ -99,6 +103,10 @@ class CodeColors(
99103
private set
100104
var brandMuted by mutableStateOf(brandMuted)
101105
private set
106+
var action by mutableStateOf(action)
107+
private set
108+
var onAction by mutableStateOf(onAction)
109+
private set
102110
var background by mutableStateOf(background)
103111
private set
104112
var onBackground by mutableStateOf(onBackground)
@@ -121,6 +129,7 @@ class CodeColors(
121129
brandLight = other.brandLight
122130
brandSubtle = other.brandSubtle
123131
brandMuted = other.brandMuted
132+
action = other.action
124133
background = other.background
125134
onBackground = other.onBackground
126135
surface = other.surface
@@ -136,6 +145,8 @@ class CodeColors(
136145
brandLight = brandLight,
137146
brandSubtle = brandSubtle,
138147
brandMuted = brandMuted,
148+
action = action,
149+
onAction = onAction,
139150
background = background,
140151
onBackground = onBackground,
141152
surface = surface,

0 commit comments

Comments
 (0)