Skip to content

Commit 3c005c8

Browse files
committed
refactor: extract selection color
1 parent e5716d3 commit 3c005c8

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

app/src/main/java/to/bitkit/ui/screens/wallets/receive/ReceiveQrScreen.kt

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,7 @@ fun ReceiveQrScreen(
200200
CustomTabRowWithSpacing(
201201
tabs = visibleTabs,
202202
currentTabIndex = currentTabIndex,
203-
selectedColor = when (selectedTab) {
204-
ReceiveTab.SAVINGS -> Colors.Brand
205-
ReceiveTab.AUTO -> Colors.White
206-
ReceiveTab.SPENDING -> Colors.Purple
207-
},
203+
selectedColor = selectedTab.accentColor,
208204
onTabChange = { tab ->
209205
haptic.performHapticFeedback(HapticFeedbackType.TextHandleMove)
210206
val newIndex = visibleTabs.indexOf(tab)
@@ -360,11 +356,7 @@ private fun ReceiveQrView(
360356
Icon(
361357
painter = painterResource(R.drawable.ic_pencil_simple),
362358
contentDescription = null,
363-
tint = when (tab) {
364-
ReceiveTab.SAVINGS -> Colors.Brand
365-
ReceiveTab.AUTO -> Colors.Brand
366-
ReceiveTab.SPENDING -> Colors.Purple
367-
},
359+
tint = tab.accentColor,
368360
modifier = Modifier.size(18.dp)
369361
)
370362
},
@@ -387,11 +379,7 @@ private fun ReceiveQrView(
387379
Icon(
388380
painter = painterResource(R.drawable.ic_copy),
389381
contentDescription = null,
390-
tint = when (tab) {
391-
ReceiveTab.SAVINGS -> Colors.Brand
392-
ReceiveTab.AUTO -> Colors.Brand
393-
ReceiveTab.SPENDING -> Colors.Purple
394-
},
382+
tint = tab.accentColor,
395383
modifier = Modifier.size(18.dp)
396384
)
397385
},
@@ -412,11 +400,7 @@ private fun ReceiveQrView(
412400
Icon(
413401
painter = painterResource(R.drawable.ic_share),
414402
contentDescription = null,
415-
tint = when (tab) {
416-
ReceiveTab.SAVINGS -> Colors.Brand
417-
ReceiveTab.AUTO -> Colors.Brand
418-
ReceiveTab.SPENDING -> Colors.Purple
419-
},
403+
tint = tab.accentColor,
420404
modifier = Modifier.size(18.dp)
421405
)
422406
},

app/src/main/java/to/bitkit/ui/screens/wallets/receive/ReceiveTab.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package to.bitkit.ui.screens.wallets.receive
22

33
import androidx.compose.runtime.Composable
4+
import androidx.compose.ui.graphics.Color
45
import androidx.compose.ui.res.stringResource
56
import to.bitkit.R
67
import to.bitkit.ui.screens.wallets.activity.components.TabItem
8+
import to.bitkit.ui.theme.Colors
79

810
enum class ReceiveTab : TabItem {
911
SAVINGS,
@@ -17,4 +19,11 @@ enum class ReceiveTab : TabItem {
1719
AUTO -> stringResource(R.string.wallet__receive_tab_auto)
1820
SPENDING -> stringResource(R.string.wallet__receive_tab_spending)
1921
}
22+
23+
val accentColor: Color
24+
get() = when (this) {
25+
SAVINGS -> Colors.Brand
26+
AUTO -> Colors.Brand
27+
SPENDING -> Colors.Purple
28+
}
2029
}

0 commit comments

Comments
 (0)