@@ -72,56 +72,48 @@ fun PrimaryButton(
7272 containerColor = Color .Transparent ,
7373 disabledContainerColor = Color .Transparent
7474 ),
75- contentPadding = PaddingValues ( 0 .dp) ,
75+ contentPadding = contentPadding ,
7676 shape = buttonShape,
7777 modifier = Modifier
7878 .then(if (fullWidth) Modifier .fillMaxWidth() else Modifier )
7979 .requiredHeight(size.height)
80+ .primaryButtonStyle(
81+ isEnabled = enabled && ! isLoading,
82+ shape = buttonShape,
83+ primaryColor = color
84+ )
8085 .then(modifier)
8186 ) {
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- }
87+ if (isLoading) {
88+ CircularProgressIndicator (
89+ color = Colors .White32 ,
90+ strokeWidth = 2 .dp,
91+ modifier = Modifier .size(size.height / 2 )
92+ )
93+ } else {
94+ Row (
95+ verticalAlignment = Alignment .CenterVertically ,
96+ horizontalArrangement = Arrangement .spacedBy(8 .dp),
97+ ) {
98+ if (icon != null ) {
99+ Box (
100+ modifier = if (enabled) {
101+ Modifier
102+ } else {
103+ Modifier .graphicsLayer {
104+ colorFilter = ColorFilter .tint(Colors .White32 )
113105 }
114- ) {
115- icon()
116106 }
107+ ) {
108+ icon()
117109 }
118- text?. let {
119- Text (
120- text = text,
121- maxLines = 1 ,
122- overflow = TextOverflow . Ellipsis ,
123- )
124- }
110+ }
111+ text?. let {
112+ Text (
113+ text = text ,
114+ maxLines = 1 ,
115+ overflow = TextOverflow . Ellipsis ,
116+ )
125117 }
126118 }
127119 }
@@ -292,6 +284,25 @@ private fun PrimaryButtonPreview() {
292284 size = ButtonSize .Small ,
293285 onClick = {},
294286 )
287+ Row (
288+ modifier = Modifier .fillMaxWidth(),
289+ horizontalArrangement = Arrangement .spacedBy(8 .dp)
290+ ) {
291+ PrimaryButton (
292+ text = " Primary Small" ,
293+ fullWidth = false ,
294+ size = ButtonSize .Small ,
295+ modifier = Modifier .weight(1f ),
296+ onClick = {},
297+ )
298+ PrimaryButton (
299+ text = " Primary Small" ,
300+ fullWidth = false ,
301+ size = ButtonSize .Small ,
302+ modifier = Modifier .weight(1f ),
303+ onClick = {},
304+ )
305+ }
295306 PrimaryButton (
296307 text = " Primary Small Color Not Full" ,
297308 size = ButtonSize .Small ,
0 commit comments