11import androidx.compose.foundation.background
2+ import androidx.compose.foundation.layout.Arrangement
23import androidx.compose.foundation.layout.Box
4+ import androidx.compose.foundation.layout.Column
35import androidx.compose.foundation.layout.fillMaxSize
6+ import androidx.compose.foundation.layout.fillMaxWidth
7+ import androidx.compose.foundation.layout.padding
48import androidx.compose.foundation.layout.size
9+ import androidx.compose.foundation.layout.widthIn
510import androidx.compose.runtime.Composable
611import androidx.compose.runtime.getValue
712import androidx.compose.runtime.mutableStateOf
@@ -13,41 +18,84 @@ import androidx.compose.ui.graphics.Brush
1318import androidx.compose.ui.graphics.Color
1419import androidx.compose.ui.unit.dp
1520import top.yukonga.miuix.kmp.basic.Button
21+ import top.yukonga.miuix.kmp.basic.ButtonDefaults
1622import top.yukonga.miuix.kmp.basic.Icon
23+ import top.yukonga.miuix.kmp.basic.Text
1724import top.yukonga.miuix.kmp.basic.TextButton
1825import top.yukonga.miuix.kmp.icon.MiuixIcons
1926import top.yukonga.miuix.kmp.icon.icons.useful.Like
27+ import top.yukonga.miuix.kmp.icon.icons.useful.Personal
28+ import top.yukonga.miuix.kmp.theme.MiuixTheme
2029
2130@Composable
2231fun ButtonDemo () {
2332 Box (
2433 modifier = Modifier
2534 .fillMaxSize()
26- .background(Brush .linearGradient(listOf (Color (0xFFFF6F61 ), Color (0xFFFF8A65 )))),
35+ .background(Brush .linearGradient(listOf (Color (0xfff77062 ), Color (0xfffe5196 )))),
2736 contentAlignment = Alignment .Center
2837 ) {
29- var buttonText by remember { mutableStateOf(" Click" ) }
30- var clickCount1 by remember { mutableStateOf(0 ) }
31- var clickCount2 by remember { mutableStateOf(0 ) }
32- Button (
33- onClick = {
34- clickCount1++
35- buttonText = " Click: $clickCount1 "
36- }
38+ Column (
39+ Modifier
40+ .padding(16 .dp)
41+ .widthIn(max = 600 .dp)
42+ .fillMaxWidth(),
43+ verticalArrangement = Arrangement .spacedBy(16 .dp),
44+ horizontalAlignment = Alignment .CenterHorizontally
3745 ) {
38- Icon (
39- imageVector = MiuixIcons .Useful .Like ,
40- contentDescription = null ,
41- tint = Color .Unspecified ,
42- modifier = Modifier .size(24 .dp)
46+ var buttonText1 by remember { mutableStateOf(" Button" ) }
47+ var buttonText2 by remember { mutableStateOf(" TextButton" ) }
48+ var clickCount1 by remember { mutableStateOf(0 ) }
49+ var clickCount2 by remember { mutableStateOf(0 ) }
50+ Button (
51+ onClick = {
52+ clickCount1++
53+ buttonText1 = " Button: $clickCount1 "
54+ }
55+ ) {
56+ Icon (
57+ imageVector = MiuixIcons .Useful .Like ,
58+ contentDescription = null ,
59+ tint = Color .Unspecified ,
60+ modifier = Modifier .size(24 .dp)
61+ )
62+ Text (
63+ text = buttonText1,
64+ style = MiuixTheme .textStyles.button,
65+ modifier = Modifier .padding(start = 8 .dp)
66+ )
67+ }
68+ TextButton (
69+ text = buttonText2,
70+ onClick = {
71+ clickCount2++
72+ buttonText2 = " TextButton: $clickCount2 "
73+ },
74+ colors = ButtonDefaults .textButtonColorsPrimary()
4375 )
44- }
45- TextButton (
46- text = buttonText,
47- onClick = {
48- clickCount2++
49- buttonText = " Click: $clickCount2 "
76+ Button (
77+ enabled = false ,
78+ onClick = {},
79+ colors = ButtonDefaults .buttonColorsPrimary()
80+ ) {
81+ Icon (
82+ imageVector = MiuixIcons .Useful .Personal ,
83+ contentDescription = null ,
84+ tint = MiuixTheme .colorScheme.disabledOnSecondaryVariant,
85+ modifier = Modifier .size(24 .dp)
86+ )
87+ Text (
88+ text = " Disabled Button" ,
89+ style = MiuixTheme .textStyles.button,
90+ color = MiuixTheme .colorScheme.disabledOnSecondaryVariant,
91+ modifier = Modifier .padding(start = 8 .dp)
92+ )
5093 }
51- )
94+ TextButton (
95+ text = " Disabled TextButton" ,
96+ enabled = false ,
97+ onClick = {}
98+ )
99+ }
52100 }
53101}
0 commit comments