@@ -16,18 +16,21 @@ import androidx.compose.material.icons.filled.Home
1616import androidx.compose.material3.Button
1717import androidx.compose.material3.CircularProgressIndicator
1818import androidx.compose.material3.Icon
19+ import androidx.compose.material3.MaterialTheme
1920import androidx.compose.material3.OutlinedButton
2021import androidx.compose.material3.Text
2122import androidx.compose.material3.TextButton
2223import androidx.compose.runtime.Composable
2324import androidx.compose.ui.Alignment
2425import androidx.compose.ui.Modifier
25- import androidx.compose.ui.draw.alpha
2626import androidx.compose.ui.graphics.Color
27+ import androidx.compose.ui.graphics.ColorFilter
28+ import androidx.compose.ui.graphics.graphicsLayer
2729import androidx.compose.ui.text.style.TextOverflow
2830import androidx.compose.ui.tooling.preview.Preview
2931import androidx.compose.ui.unit.Dp
3032import androidx.compose.ui.unit.dp
33+ import to.bitkit.ui.shared.util.primaryButtonStyle
3134import to.bitkit.ui.theme.AppButtonDefaults
3235import to.bitkit.ui.theme.AppThemeSurface
3336import to.bitkit.ui.theme.Colors
@@ -57,41 +60,68 @@ fun PrimaryButton(
5760 size : ButtonSize = ButtonSize .Large ,
5861 enabled : Boolean = true,
5962 fullWidth : Boolean = true,
60- color : Color = Colors . White16 ,
63+ color : Color ? = null ,
6164) {
6265 val contentPadding = PaddingValues (horizontal = size.horizontalPadding.takeIf { text != null } ? : 0 .dp)
66+ val buttonShape = MaterialTheme .shapes.large
67+
6368 Button (
6469 onClick = onClick,
6570 enabled = enabled && ! isLoading,
66- colors = AppButtonDefaults .primaryColors.copy(containerColor = color),
67- contentPadding = contentPadding,
71+ colors = AppButtonDefaults .primaryColors.copy(
72+ containerColor = Color .Transparent ,
73+ disabledContainerColor = Color .Transparent
74+ ),
75+ contentPadding = PaddingValues (0 .dp),
76+ shape = buttonShape,
6877 modifier = Modifier
6978 .then(if (fullWidth) Modifier .fillMaxWidth() else Modifier )
7079 .requiredHeight(size.height)
7180 .then(modifier)
7281 ) {
73- if (isLoading) {
74- CircularProgressIndicator (
75- color = Colors .White32 ,
76- strokeWidth = 2 .dp,
77- modifier = Modifier .size(size.height / 2 )
78- )
79- } else {
80- Row (
81- verticalAlignment = Alignment .CenterVertically ,
82- horizontalArrangement = Arrangement .spacedBy(8 .dp),
83- ) {
84- if (icon != null ) {
85- Box (modifier = if (enabled) Modifier else Modifier .alpha(0.5f )) {
86- icon()
82+ Box (
83+ contentAlignment = Alignment .Center ,
84+ modifier = Modifier
85+ .then(if (fullWidth) Modifier .fillMaxWidth() else Modifier )
86+ .requiredHeight(size.height)
87+ .primaryButtonStyle(
88+ isEnabled = enabled && ! isLoading,
89+ shape = buttonShape,
90+ primaryColor = color
91+ )
92+ .padding(contentPadding)
93+ ) {
94+ if (isLoading) {
95+ CircularProgressIndicator (
96+ color = Colors .White32 ,
97+ strokeWidth = 2 .dp,
98+ modifier = Modifier .size(size.height / 2 )
99+ )
100+ } else {
101+ Row (
102+ verticalAlignment = Alignment .CenterVertically ,
103+ horizontalArrangement = Arrangement .spacedBy(8 .dp),
104+ ) {
105+ if (icon != null ) {
106+ Box (
107+ modifier = if (enabled) {
108+ Modifier
109+ } else {
110+ Modifier .graphicsLayer {
111+ colorFilter = ColorFilter .tint(Colors .White32 )
112+ }
113+ }
114+ ) {
115+ icon()
116+ }
117+ }
118+ text?.let {
119+ Text (
120+ text = text,
121+ maxLines = 1 ,
122+ overflow = TextOverflow .Ellipsis ,
123+ )
87124 }
88- }
89- text?.let {
90- Text (
91- text = text,
92- maxLines = 1 ,
93- overflow = TextOverflow .Ellipsis ,
94- )
95125 }
96126 }
97127 }
@@ -110,7 +140,7 @@ fun SecondaryButton(
110140 fullWidth : Boolean = true,
111141) {
112142 val contentPadding = PaddingValues (horizontal = size.horizontalPadding.takeIf { text != null } ? : 0 .dp)
113- val border = BorderStroke (2 .dp, if (enabled) Colors .White16 else Color .Transparent )
143+ val border = BorderStroke (2 .dp, if (enabled) Colors .Gray4 else Color .Transparent )
114144 OutlinedButton (
115145 onClick = onClick,
116146 enabled = enabled && ! isLoading,
@@ -134,7 +164,15 @@ fun SecondaryButton(
134164 horizontalArrangement = Arrangement .spacedBy(8 .dp),
135165 ) {
136166 if (icon != null ) {
137- Box (modifier = if (enabled) Modifier else Modifier .alpha(0.5f )) {
167+ Box (
168+ modifier = if (enabled) {
169+ Modifier
170+ } else {
171+ Modifier .graphicsLayer {
172+ colorFilter = ColorFilter .tint(Colors .White32 )
173+ }
174+ }
175+ ) {
138176 icon()
139177 }
140178 }
@@ -179,17 +217,30 @@ fun TertiaryButton(
179217 modifier = Modifier .size(size.height / 2 )
180218 )
181219 } else {
182- if (icon != null ) {
183- Box (modifier = if (enabled) Modifier else Modifier .alpha(0.5f )) {
184- icon()
220+ Row (
221+ verticalAlignment = Alignment .CenterVertically ,
222+ horizontalArrangement = Arrangement .spacedBy(8 .dp),
223+ ) {
224+ if (icon != null ) {
225+ Box (
226+ modifier = if (enabled) {
227+ Modifier
228+ } else {
229+ Modifier .graphicsLayer {
230+ colorFilter = ColorFilter .tint(Colors .White32 )
231+ }
232+ }
233+ ) {
234+ icon()
235+ }
236+ }
237+ text?.let {
238+ Text (
239+ text = text,
240+ maxLines = 1 ,
241+ overflow = TextOverflow .Ellipsis ,
242+ )
185243 }
186- }
187- text?.let {
188- Text (
189- text = text,
190- maxLines = 1 ,
191- overflow = TextOverflow .Ellipsis ,
192- )
193244 }
194245 }
195246 }
@@ -237,6 +288,7 @@ private fun PrimaryButtonPreview() {
237288 )
238289 PrimaryButton (
239290 text = " Primary Small" ,
291+ fullWidth = false ,
240292 size = ButtonSize .Small ,
241293 onClick = {},
242294 )
@@ -339,6 +391,7 @@ private fun SecondaryButtonPreview() {
339391 SecondaryButton (
340392 text = " Secondary Small" ,
341393 size = ButtonSize .Small ,
394+ fullWidth = false ,
342395 onClick = {},
343396 )
344397 SecondaryButton (
@@ -421,11 +474,20 @@ private fun TertiaryButtonPreview() {
421474 TertiaryButton (
422475 text = " Tertiary Disabled" ,
423476 enabled = false ,
477+ icon = {
478+ Icon (
479+ imageVector = Icons .Filled .Favorite ,
480+ contentDescription = " " ,
481+ tint = Colors .Brand ,
482+ modifier = Modifier .size(16 .dp)
483+ )
484+ },
424485 onClick = {}
425486 )
426487 TertiaryButton (
427488 text = " Tertiary Small" ,
428489 size = ButtonSize .Small ,
490+ fullWidth = false ,
429491 onClick = {}
430492 )
431493 TertiaryButton (
0 commit comments