@@ -2,15 +2,17 @@ package to.bitkit.ui.components
22
33import androidx.annotation.DrawableRes
44import androidx.compose.foundation.BorderStroke
5- import androidx.compose.foundation.clickable
65import androidx.compose.foundation.layout.Arrangement
76import androidx.compose.foundation.layout.Column
87import androidx.compose.foundation.layout.PaddingValues
98import androidx.compose.foundation.layout.Row
109import androidx.compose.foundation.layout.padding
10+ import androidx.compose.foundation.layout.requiredHeight
1111import androidx.compose.foundation.layout.size
12+ import androidx.compose.foundation.shape.RoundedCornerShape
13+ import androidx.compose.material3.Button
1214import androidx.compose.material3.Icon
13- import androidx.compose.material3.Surface
15+ import androidx.compose.material3.OutlinedButton
1416import androidx.compose.runtime.Composable
1517import androidx.compose.ui.Alignment
1618import androidx.compose.ui.Modifier
@@ -19,7 +21,9 @@ import androidx.compose.ui.res.painterResource
1921import androidx.compose.ui.tooling.preview.Preview
2022import androidx.compose.ui.unit.dp
2123import to.bitkit.R
22- import to.bitkit.ui.theme.AppShapes
24+ import to.bitkit.ui.shared.modifiers.clickableAlpha
25+ import to.bitkit.ui.shared.util.primaryButtonStyle
26+ import to.bitkit.ui.theme.AppButtonDefaults
2327import to.bitkit.ui.theme.AppThemeSurface
2428import to.bitkit.ui.theme.Colors
2529
@@ -32,36 +36,74 @@ fun NumberPadActionButton(
3236 enabled : Boolean = true,
3337 @DrawableRes icon : Int? = null,
3438) {
35- val borderColor = if (enabled) Color .Transparent else color
36- val bgColor = if (enabled) Colors .White10 else Color .Transparent
39+ val contentPadding = PaddingValues (horizontal = 8 .dp, vertical = 5 .dp)
40+ val height = 28 .dp
41+ val buttonShape = RoundedCornerShape (8 .dp)
3742
38- Surface (
39- color = bgColor,
40- shape = AppShapes .small,
41- border = BorderStroke (1 .dp, borderColor),
42- modifier = modifier
43- .clickable(
44- enabled = enabled,
45- onClick = onClick,
46- )
47- ) {
48- Row (
49- verticalAlignment = Alignment .CenterVertically ,
50- horizontalArrangement = Arrangement .spacedBy(8 .dp),
51- modifier = Modifier .padding(PaddingValues (8 .dp, 5 .dp))
43+ if (enabled) {
44+ Button (
45+ onClick = {},
46+ colors = AppButtonDefaults .primaryColors.copy(
47+ containerColor = Color .Transparent ,
48+ disabledContainerColor = Color .Transparent
49+ ),
50+ contentPadding = contentPadding,
51+ shape = buttonShape,
52+ modifier = Modifier
53+ .requiredHeight(height)
54+ .primaryButtonStyle(
55+ isEnabled = true ,
56+ shape = buttonShape,
57+ )
58+ .clickableAlpha { onClick() }
59+ .then(modifier)
5260 ) {
53- if (icon != null ) {
54- Icon (
55- painter = painterResource(icon),
56- contentDescription = text,
57- tint = color,
58- modifier = Modifier .size(16 .dp)
61+ Row (
62+ verticalAlignment = Alignment .CenterVertically ,
63+ horizontalArrangement = Arrangement .spacedBy(8 .dp),
64+ ) {
65+ if (icon != null ) {
66+ Icon (
67+ painter = painterResource(icon),
68+ contentDescription = text,
69+ tint = color,
70+ modifier = Modifier .size(16 .dp)
71+ )
72+ }
73+ Caption13Up (
74+ text = text,
75+ color = color,
76+ )
77+ }
78+ }
79+ } else {
80+ OutlinedButton (
81+ onClick = onClick,
82+ shape = buttonShape,
83+ colors = AppButtonDefaults .secondaryColors,
84+ contentPadding = contentPadding,
85+ border = BorderStroke (width = 1 .dp, color = color),
86+ modifier = Modifier
87+ .requiredHeight(height)
88+ .then(modifier)
89+ ) {
90+ Row (
91+ verticalAlignment = Alignment .CenterVertically ,
92+ horizontalArrangement = Arrangement .spacedBy(8 .dp),
93+ ) {
94+ if (icon != null ) {
95+ Icon (
96+ painter = painterResource(icon),
97+ contentDescription = text,
98+ tint = color,
99+ modifier = Modifier .size(16 .dp)
100+ )
101+ }
102+ Caption13Up (
103+ text = text,
104+ color = color,
59105 )
60106 }
61- Caption13Up (
62- text = text,
63- color = color,
64- )
65107 }
66108 }
67109}
0 commit comments