diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index 9f28164..9f2bc94 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -16,7 +16,7 @@ plugins { val appName = "Miuix" val pkgName = "top.yukonga.miuix.uitest" -val verName = "1.0.0" +val verName = "1.0.1" val xcf = XCFramework(appName + "Framework") kotlin { @@ -86,7 +86,7 @@ android { applicationId = pkgName minSdk = libs.versions.android.minSdk.get().toInt() targetSdk = libs.versions.android.targetSdk.get().toInt() - versionCode = 11 + versionCode = 12 versionName = verName } val properties = Properties() diff --git a/composeApp/src/commonMain/kotlin/MainPage.kt b/composeApp/src/commonMain/kotlin/MainPage.kt index 602da61..8a993e0 100644 --- a/composeApp/src/commonMain/kotlin/MainPage.kt +++ b/composeApp/src/commonMain/kotlin/MainPage.kt @@ -1,7 +1,6 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.runtime.Composable import component.OtherComponent -import component.SecondComponent import component.TextComponent import top.yukonga.miuix.kmp.MiuixScrollBehavior import top.yukonga.miuix.kmp.basic.MiuixLazyColumn @@ -20,9 +19,6 @@ fun MainPage( item { TextComponent() } - item { - SecondComponent() - } item { OtherComponent(padding) } diff --git a/composeApp/src/commonMain/kotlin/UITest.kt b/composeApp/src/commonMain/kotlin/UITest.kt index c6914c6..8e68cc2 100644 --- a/composeApp/src/commonMain/kotlin/UITest.kt +++ b/composeApp/src/commonMain/kotlin/UITest.kt @@ -94,7 +94,7 @@ fun UITest( MiuixTopAppBar( navigationIcon = { IconButton( - modifier = Modifier.padding(start = 16.dp), + modifier = Modifier.padding(start = 12.dp), onClick = {} ) { Icon( @@ -106,7 +106,7 @@ fun UITest( }, actions = { IconButton( - modifier = Modifier.padding(end = 16.dp), + modifier = Modifier.padding(end = 12.dp), onClick = { uriHandler.openUri("https://github.com/miuix-kotlin-multiplatform/miuix") } diff --git a/composeApp/src/commonMain/kotlin/component/OtherComponent.kt b/composeApp/src/commonMain/kotlin/component/OtherComponent.kt index a6198fc..6f21efc 100644 --- a/composeApp/src/commonMain/kotlin/component/OtherComponent.kt +++ b/composeApp/src/commonMain/kotlin/component/OtherComponent.kt @@ -1,10 +1,13 @@ package component +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.runtime.Composable @@ -20,6 +23,7 @@ import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import top.yukonga.miuix.kmp.basic.MiuixButton import top.yukonga.miuix.kmp.basic.MiuixCard import top.yukonga.miuix.kmp.basic.MiuixSlider import top.yukonga.miuix.kmp.basic.MiuixText @@ -28,17 +32,71 @@ import top.yukonga.miuix.kmp.theme.MiuixTheme @Composable fun OtherComponent(padding: PaddingValues) { + + var buttonText by remember { mutableStateOf("Button") } + var submitButtonText by remember { mutableStateOf("Submit") } + var clickCount by remember { mutableStateOf(0) } + var submitClickCount by remember { mutableStateOf(0) } val focusManager = LocalFocusManager.current var text1 by remember { mutableStateOf("") } var text2 by remember { mutableStateOf("Text") } var progress by remember { mutableStateOf(0.5f) } val progressDisable by remember { mutableStateOf(0.5f) } + Row( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 24.dp, vertical = 20.dp), + horizontalArrangement = Arrangement.SpaceBetween + ) { + MiuixButton( + modifier = Modifier.weight(1f), + text = buttonText, + onClick = { + clickCount++ + buttonText = "Click: $clickCount" + } + ) + Spacer(Modifier.width(20.dp)) + MiuixButton( + modifier = Modifier.weight(1f), + text = submitButtonText, + submit = true, + onClick = { + submitClickCount++ + submitButtonText = "Click: $submitClickCount" + } + ) + } + + Row( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 24.dp), + horizontalArrangement = Arrangement.SpaceBetween + ) { + MiuixButton( + modifier = Modifier.weight(1f), + text = "Disabled", + submit = true, + enabled = false, + onClick = {} + ) + Spacer(Modifier.width(20.dp)) + MiuixButton( + modifier = Modifier.weight(1f), + text = "Disabled", + submit = false, + enabled = false, + onClick = {} + ) + } + MiuixTextField( value = text1, onValueChange = { text1 = it }, label = "Text Field", - modifier = Modifier.padding(horizontal = 28.dp, vertical = 20.dp), + modifier = Modifier.padding(horizontal = 24.dp, vertical = 20.dp), keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), ) @@ -48,7 +106,7 @@ fun OtherComponent(padding: PaddingValues) { onValueChange = { text2 = it }, backgroundColor = MiuixTheme.colorScheme.primaryContainer, label = "Text Field", - modifier = Modifier.padding(horizontal = 28.dp), + modifier = Modifier.padding(horizontal = 24.dp), keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), ) @@ -56,20 +114,20 @@ fun OtherComponent(padding: PaddingValues) { MiuixSlider( progress = progress, onProgressChange = { newProgress -> progress = newProgress }, - modifier = Modifier.padding(horizontal = 28.dp, vertical = 20.dp) + modifier = Modifier.padding(horizontal = 24.dp, vertical = 20.dp) ) MiuixSlider( progress = progressDisable, onProgressChange = {}, enabled = false, - modifier = Modifier.padding(horizontal = 28.dp) + modifier = Modifier.padding(horizontal = 24.dp) ) MiuixCard( modifier = Modifier .fillMaxWidth() - .padding(horizontal = 28.dp, vertical = 20.dp), + .padding(horizontal = 24.dp, vertical = 20.dp), insideMargin = DpSize(18.dp, 18.dp) ) { CardView() @@ -78,13 +136,14 @@ fun OtherComponent(padding: PaddingValues) { MiuixCard( modifier = Modifier .fillMaxWidth() - .padding(horizontal = 28.dp) + .padding(horizontal = 24.dp) .padding(bottom = 20.dp + padding.calculateBottomPadding()), color = MiuixTheme.colorScheme.primary, insideMargin = DpSize(18.dp, 18.dp) ) { CardView(color = Color.White) } + } @Composable diff --git a/composeApp/src/commonMain/kotlin/component/SecondComponent.kt b/composeApp/src/commonMain/kotlin/component/SecondComponent.kt deleted file mode 100644 index 3ff5841..0000000 --- a/composeApp/src/commonMain/kotlin/component/SecondComponent.kt +++ /dev/null @@ -1,167 +0,0 @@ -package component - -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import top.yukonga.miuix.kmp.MiuixSuperCheckbox -import top.yukonga.miuix.kmp.MiuixSuperSwitch -import top.yukonga.miuix.kmp.basic.MiuixButton -import top.yukonga.miuix.kmp.basic.MiuixCheckbox -import top.yukonga.miuix.kmp.basic.MiuixSwitch - -@Composable -fun SecondComponent() { - var checkbox by remember { mutableStateOf(false) } - var checkboxTrue by remember { mutableStateOf(true) } - var switch by remember { mutableStateOf(false) } - var switchTrue by remember { mutableStateOf(true) } - var buttonText by remember { mutableStateOf("Button") } - var submitButtonText by remember { mutableStateOf("Submit") } - var miuixSuperCheckbox by remember { mutableStateOf("State: false") } - var miuixSuperCheckboxState by remember { mutableStateOf(false) } - var miuixSuperSwitch by remember { mutableStateOf("State: false") } - var miuixSuperSwitchState by remember { mutableStateOf(false) } - var clickCount by remember { mutableStateOf(0) } - var submitClickCount by remember { mutableStateOf(0) } - - Row( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 28.dp, vertical = 20.dp), - horizontalArrangement = Arrangement.SpaceBetween - ) { - MiuixCheckbox( - modifier = Modifier, - checked = checkbox, - onCheckedChange = { checkbox = it } - - ) - MiuixCheckbox( - modifier = Modifier.padding(start = 8.dp), - checked = checkboxTrue, - onCheckedChange = { checkboxTrue = it } - ) - MiuixCheckbox( - modifier = Modifier.padding(start = 8.dp), - enabled = false, - checked = false, - onCheckedChange = { } - - ) - MiuixCheckbox( - modifier = Modifier.padding(start = 8.dp), - enabled = false, - checked = true, - onCheckedChange = { } - ) - } - - MiuixSuperCheckbox( - title = "Checkbox", - summary = miuixSuperCheckbox, - checked = miuixSuperCheckboxState, - onCheckedChange = { - miuixSuperCheckboxState = it - miuixSuperCheckbox = "State: $it" - }, - ) - - Row( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 28.dp, vertical = 20.dp), - horizontalArrangement = Arrangement.SpaceBetween - ) { - MiuixSwitch( - checked = switch, - onCheckedChange = { switch = it } - ) - MiuixSwitch( - modifier = Modifier.padding(start = 8.dp), - checked = switchTrue, - onCheckedChange = { switchTrue = it } - ) - MiuixSwitch( - modifier = Modifier.padding(start = 8.dp), - enabled = false, - checked = false, - onCheckedChange = { } - ) - MiuixSwitch( - modifier = Modifier.padding(start = 8.dp), - enabled = false, - checked = true, - onCheckedChange = { } - ) - } - - MiuixSuperSwitch( - title = "Switch", - summary = miuixSuperSwitch, - checked = miuixSuperSwitchState, - onCheckedChange = { - miuixSuperSwitchState = it - miuixSuperSwitch = "State: $it" - }, - ) - - Row( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 28.dp, vertical = 20.dp), - horizontalArrangement = Arrangement.SpaceBetween - ) { - MiuixButton( - modifier = Modifier.weight(1f), - text = buttonText, - onClick = { - clickCount++ - buttonText = "Click: $clickCount" - } - ) - Spacer(Modifier.width(20.dp)) - MiuixButton( - modifier = Modifier.weight(1f), - text = submitButtonText, - submit = true, - onClick = { - submitClickCount++ - submitButtonText = "Click: $submitClickCount" - } - ) - } - - Row( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 28.dp), - horizontalArrangement = Arrangement.SpaceBetween - ) { - MiuixButton( - modifier = Modifier.weight(1f), - text = "Disabled", - submit = true, - enabled = false, - onClick = {} - ) - Spacer(Modifier.width(20.dp)) - MiuixButton( - modifier = Modifier.weight(1f), - text = "Disabled", - submit = false, - enabled = false, - onClick = {} - ) - } - -} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/component/TextComponent.kt b/composeApp/src/commonMain/kotlin/component/TextComponent.kt index 775da50..5e7fcd4 100644 --- a/composeApp/src/commonMain/kotlin/component/TextComponent.kt +++ b/composeApp/src/commonMain/kotlin/component/TextComponent.kt @@ -11,19 +11,29 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Person import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState +import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import top.yukonga.miuix.kmp.CheckboxLocation import top.yukonga.miuix.kmp.MiuixSuperArrow +import top.yukonga.miuix.kmp.MiuixSuperCheckbox import top.yukonga.miuix.kmp.MiuixSuperDialog import top.yukonga.miuix.kmp.MiuixSuperDropdown +import top.yukonga.miuix.kmp.MiuixSuperSwitch import top.yukonga.miuix.kmp.basic.MiuixBasicComponent import top.yukonga.miuix.kmp.basic.MiuixButton +import top.yukonga.miuix.kmp.basic.MiuixCard +import top.yukonga.miuix.kmp.basic.MiuixCheckbox +import top.yukonga.miuix.kmp.basic.MiuixSmallTitle +import top.yukonga.miuix.kmp.basic.MiuixSwitch import top.yukonga.miuix.kmp.basic.MiuixText import top.yukonga.miuix.kmp.theme.MiuixTheme import top.yukonga.miuix.kmp.utils.MiuixPopupUtil.Companion.dismissDialog @@ -32,14 +42,24 @@ import top.yukonga.miuix.kmp.utils.MiuixPopupUtil.Companion.showDialog @Composable fun TextComponent() { val showDialog = remember { mutableStateOf(false) } + var checkbox by remember { mutableStateOf(false) } + var checkboxTrue by remember { mutableStateOf(true) } + var switch by remember { mutableStateOf(false) } + var switchTrue by remember { mutableStateOf(true) } val dropdownOptions = listOf("Option 1", "Option 2", "Option 3", "Option 4") val dropdownSelectedOption = remember { mutableStateOf(0) } val dropdownSelectedOptionRight = remember { mutableStateOf(1) } + var miuixSuperCheckbox by remember { mutableStateOf("State: false") } + var miuixSuperCheckboxState by remember { mutableStateOf(false) } + var miuixSuperRightCheckbox by remember { mutableStateOf("false") } + var miuixSuperRightCheckboxState by remember { mutableStateOf(false) } + var miuixSuperSwitch by remember { mutableStateOf("State: false") } + var miuixSuperSwitchState by remember { mutableStateOf(false) } Row( modifier = Modifier .fillMaxWidth() - .padding(horizontal = 28.dp, vertical = 15.dp), + .padding(horizontal = 24.dp, vertical = 15.dp), verticalAlignment = Alignment.CenterVertically ) { MiuixText( @@ -48,87 +68,203 @@ fun TextComponent() { ) MiuixText( text = "Text", - modifier = Modifier.padding(start = 24.dp) + modifier = Modifier.padding(start = 18.dp) ) MiuixText( text = "Text", fontSize = 15.sp, color = MiuixTheme.colorScheme.subTextBase, - modifier = Modifier.padding(start = 24.dp) + modifier = Modifier.padding(start = 18.dp) ) MiuixText( text = "Text", color = MiuixTheme.colorScheme.textFieldSub, - modifier = Modifier.padding(start = 24.dp) + modifier = Modifier.padding(start = 18.dp) ) MiuixText( text = "Text", style = MiuixTheme.textStyles.title, color = MiuixTheme.colorScheme.subDropdown, - modifier = Modifier.padding(start = 24.dp) + modifier = Modifier.padding(start = 18.dp) ) } - MiuixBasicComponent( - title = "Title", - summary = "Summary", - leftAction = { - MiuixText(text = "Left") - }, - rightActions = { - MiuixText(text = "Right1") - Spacer(Modifier.width(8.dp)) - MiuixText(text = "Right2") - }, - onClick = {} - ) - - MiuixSuperArrow( - title = "Arrow", - summary = "With an arrow on right", - onClick = {} - ) - - MiuixSuperArrow( - leftAction = { - Image( - colorFilter = ColorFilter.tint(MiuixTheme.colorScheme.onBackground), - imageVector = Icons.Default.Person, - contentDescription = "Person", - ) - }, - title = "Person", - summary = "An introduction", - onClick = {} - ) - - MiuixSuperArrow( - title = "Dialog", - summary = "Click to show Dialog", - onClick = { - showDialog.value = true - } - ) + Row( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 24.dp, vertical = 20.dp), + horizontalArrangement = Arrangement.SpaceBetween + ) { + MiuixCheckbox( + modifier = Modifier, + checked = checkbox, + onCheckedChange = { checkbox = it } - dialog(showDialog) + ) + MiuixCheckbox( + modifier = Modifier.padding(start = 8.dp), + checked = checkboxTrue, + onCheckedChange = { checkboxTrue = it } + ) + MiuixCheckbox( + modifier = Modifier.padding(start = 8.dp), + enabled = false, + checked = false, + onCheckedChange = { } + + ) + MiuixCheckbox( + modifier = Modifier.padding(start = 8.dp), + enabled = false, + checked = true, + onCheckedChange = { } + ) + } + + Row( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 24.dp, vertical = 20.dp), + horizontalArrangement = Arrangement.SpaceBetween + ) { + MiuixSwitch( + checked = switch, + onCheckedChange = { switch = it } + ) + MiuixSwitch( + modifier = Modifier.padding(start = 8.dp), + checked = switchTrue, + onCheckedChange = { switchTrue = it } + ) + MiuixSwitch( + modifier = Modifier.padding(start = 8.dp), + enabled = false, + checked = false, + onCheckedChange = { } + ) + MiuixSwitch( + modifier = Modifier.padding(start = 8.dp), + enabled = false, + checked = true, + onCheckedChange = { } + ) + } - MiuixSuperDropdown( - title = "Dropdown", - summary = "Popup near click", - items = dropdownOptions, - selectedIndex = dropdownSelectedOption.value, - onSelectedIndexChange = { newOption -> dropdownSelectedOption.value = newOption }, - ) - - MiuixSuperDropdown( - title = "Dropdown", - summary = "Popup always on right", - alwaysRight = true, - items = dropdownOptions, - selectedIndex = dropdownSelectedOptionRight.value, - onSelectedIndexChange = { newOption -> dropdownSelectedOptionRight.value = newOption }, - ) + MiuixSmallTitle("Title") + MiuixCard( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp) + ) { + + MiuixBasicComponent( + insideMargin = DpSize(16.dp, 16.dp), + title = "Title", + summary = "Summary", + leftAction = { + MiuixText(text = "Left") + }, + rightActions = { + MiuixText(text = "Right1") + Spacer(Modifier.width(8.dp)) + MiuixText(text = "Right2") + }, + onClick = {} + ) + + MiuixSuperArrow( + insideMargin = DpSize(18.dp, 18.dp), + title = "Arrow", + summary = "With an arrow on right", + onClick = {} + ) + + MiuixSuperArrow( + insideMargin = DpSize(18.dp, 18.dp), + leftAction = { + Image( + colorFilter = ColorFilter.tint(MiuixTheme.colorScheme.onBackground), + imageVector = Icons.Default.Person, + contentDescription = "Person", + ) + }, + title = "Person", + summary = "An introduction", + onClick = {} + ) + + MiuixSuperArrow( + insideMargin = DpSize(18.dp, 18.dp), + title = "Dialog", + summary = "Click to show Dialog", + onClick = { + showDialog.value = true + } + ) + + MiuixSuperDropdown( + insideMargin = DpSize(18.dp, 18.dp), + title = "Dropdown", + summary = "Popup near click", + items = dropdownOptions, + selectedIndex = dropdownSelectedOption.value, + onSelectedIndexChange = { newOption -> dropdownSelectedOption.value = newOption }, + ) + + MiuixSuperDropdown( + insideMargin = DpSize(18.dp, 18.dp), + title = "Dropdown", + summary = "Popup always on right", + alwaysRight = true, + items = dropdownOptions, + selectedIndex = dropdownSelectedOptionRight.value, + onSelectedIndexChange = { newOption -> dropdownSelectedOptionRight.value = newOption }, + ) + + MiuixSuperCheckbox( + insideMargin = DpSize(18.dp, 18.dp), + title = "Checkbox", + summary = miuixSuperCheckbox, + checked = miuixSuperCheckboxState, + onCheckedChange = { + miuixSuperCheckboxState = it + miuixSuperCheckbox = "State: $it" + }, + ) + + MiuixSuperCheckbox( + insideMargin = DpSize(18.dp, 18.dp), + checkboxLocation = CheckboxLocation.Right, + title = "Checkbox", + checked = miuixSuperRightCheckboxState, + rightActions = { + MiuixText( + modifier = Modifier.padding(end = 8.dp), + text = miuixSuperRightCheckbox, + color = MiuixTheme.colorScheme.subTextBase + ) + }, + onCheckedChange = { + miuixSuperRightCheckboxState = it + miuixSuperRightCheckbox = "$it" + }, + ) + + MiuixSuperSwitch( + insideMargin = DpSize(18.dp, 18.dp), + title = "Switch", + summary = miuixSuperSwitch, + checked = miuixSuperSwitchState, + onCheckedChange = { + miuixSuperSwitchState = it + miuixSuperSwitch = "State: $it" + }, + ) + + } + + dialog(showDialog) } @Composable diff --git a/iosApp/iosApp.xcodeproj/xcshareddata/xcschemes/iosApp.xcscheme b/iosApp/iosApp.xcodeproj/xcshareddata/xcschemes/iosApp.xcscheme index c4005a1..cfa2b7d 100644 --- a/iosApp/iosApp.xcodeproj/xcshareddata/xcschemes/iosApp.xcscheme +++ b/iosApp/iosApp.xcodeproj/xcshareddata/xcschemes/iosApp.xcscheme @@ -1,7 +1,7 @@ + version = "2.0"> + enableGPUValidationMode = "1" + allowLocationSimulation = "NO" + viewDebuggingEnabled = "No" + queueDebuggingEnabled = "No"> + + + + Unit)? = null, rightText: String? = null, onClick: (() -> Unit)? = null, - insideMargin: DpSize = DpSize(28.dp, 14.dp) + insideMargin: DpSize = DpSize(24.dp, 14.dp) ) { val updatedOnClick by rememberUpdatedState(onClick) MiuixBasicComponent( diff --git a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixSuperCheckbox.kt b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixSuperCheckbox.kt index 58811ff..07c456f 100644 --- a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixSuperCheckbox.kt +++ b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixSuperCheckbox.kt @@ -31,9 +31,10 @@ fun MiuixSuperCheckbox( summary: String? = null, rightActions: @Composable RowScope.() -> Unit = {}, checked: Boolean, + checkboxLocation: CheckboxLocation = CheckboxLocation.Left, onCheckedChange: ((Boolean) -> Unit)?, modifier: Modifier = Modifier, - insideMargin: DpSize = DpSize(28.dp, 14.dp), + insideMargin: DpSize = DpSize(24.dp, 14.dp), enabled: Boolean = true ) { var isChecked by remember { mutableStateOf(checked) } @@ -48,14 +49,25 @@ fun MiuixSuperCheckbox( insideMargin = insideMargin, title = title, summary = summary, - leftAction = { - MiuixCheckbox( - checked = isChecked, - onCheckedChange = updatedOnCheckedChange, - enabled = enabled - ) + leftAction = if (checkboxLocation == CheckboxLocation.Left) { + { + MiuixCheckbox( + checked = isChecked, + onCheckedChange = updatedOnCheckedChange, + enabled = enabled + ) + } + } else null, + rightActions = { + rightActions() + if (checkboxLocation == CheckboxLocation.Right) { + MiuixCheckbox( + checked = isChecked, + onCheckedChange = updatedOnCheckedChange, + enabled = enabled + ) + } }, - rightActions = rightActions, onClick = { if (enabled) { isChecked = !isChecked @@ -63,4 +75,9 @@ fun MiuixSuperCheckbox( } } ) +} + +enum class CheckboxLocation { + Left, + Right, } \ No newline at end of file diff --git a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixSuperDropdown.kt b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixSuperDropdown.kt index d8e876f..8cff319 100644 --- a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixSuperDropdown.kt +++ b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixSuperDropdown.kt @@ -87,7 +87,7 @@ fun MiuixSuperDropdown( modifier: Modifier = Modifier, items: List, alwaysRight: Boolean = false, - insideMargin: DpSize = DpSize(28.dp, 14.dp), + insideMargin: DpSize = DpSize(24.dp, 14.dp), selectedIndex: Int, onSelectedIndexChange: (Int) -> Unit ) { diff --git a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixSuperSwitch.kt b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixSuperSwitch.kt index 0838f55..f650a3b 100644 --- a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixSuperSwitch.kt +++ b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixSuperSwitch.kt @@ -32,7 +32,7 @@ fun MiuixSuperSwitch( checked: Boolean, onCheckedChange: ((Boolean) -> Unit)?, modifier: Modifier = Modifier, - insideMargin: DpSize = DpSize(28.dp, 14.dp), + insideMargin: DpSize = DpSize(24.dp, 14.dp), enabled: Boolean = true ) { var isChecked by remember { mutableStateOf(checked) } diff --git a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixTopAppBar.kt b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixTopAppBar.kt index 491d80c..bccfde5 100644 --- a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixTopAppBar.kt +++ b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/MiuixTopAppBar.kt @@ -459,7 +459,7 @@ private suspend fun settleAppBar( return Velocity.Zero } -private val TopAppBarHorizontalPadding = 28.dp +private val TopAppBarHorizontalPadding = 24.dp /** A functional interface for providing an app-bar scroll offset. */ private fun interface ScrolledOffset { diff --git a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/MiuixCheckbox.kt b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/MiuixCheckbox.kt index ba94c39..fd79a6d 100644 --- a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/MiuixCheckbox.kt +++ b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/MiuixCheckbox.kt @@ -5,6 +5,7 @@ import androidx.compose.animation.core.animateDpAsState import androidx.compose.animation.core.tween import androidx.compose.foundation.Canvas import androidx.compose.foundation.background +import androidx.compose.foundation.gestures.detectDragGestures import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.requiredSize @@ -97,6 +98,19 @@ fun MiuixCheckbox( } ) } + .pointerInput(Unit) { + detectDragGestures( + onDragEnd = { + isPressed = false + }, + onDragCancel = { + isPressed = false + }, + onDrag = { change, _ -> + change.consume() + } + ) + } ) { Canvas( modifier = Modifier.requiredSize(checkboxSize) diff --git a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/MiuixComponent.kt b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/MiuixComponent.kt index d12ae43..3846a06 100644 --- a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/MiuixComponent.kt +++ b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/MiuixComponent.kt @@ -13,6 +13,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clipToBounds import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp @@ -47,7 +48,7 @@ fun MiuixBasicComponent( ) { val interactionSource = interactionSource ?: remember { MutableInteractionSource() } val indication = indication ?: createRipple() - val insideMargin = remember { insideMargin } ?: remember { DpSize(28.dp, 14.dp) } + val insideMargin = remember { insideMargin } ?: remember { DpSize(24.dp, 14.dp) } val paddingModifier = remember(insideMargin) { Modifier.padding(horizontal = insideMargin.width, vertical = insideMargin.height) } diff --git a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/MiuixSmallTitle.kt b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/MiuixSmallTitle.kt new file mode 100644 index 0000000..c3d961a --- /dev/null +++ b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/MiuixSmallTitle.kt @@ -0,0 +1,36 @@ +package top.yukonga.miuix.kmp.basic + +import androidx.compose.foundation.layout.padding +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.DpSize +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import top.yukonga.miuix.kmp.theme.MiuixTheme + +/** + * A title component with Miuix style. + * + * @param text The text to be displayed in the title. + * @param modifier The modifier to be applied to the [MiuixSmallTitle]. + * @param insideMargin The margin inside the [MiuixSmallTitle]. + */ +@Composable +fun MiuixSmallTitle( + text: String, + modifier: Modifier = Modifier, + insideMargin: DpSize = DpSize(28.dp, 8.dp), +) { + val paddingModifier = remember(insideMargin) { + Modifier.padding(horizontal = insideMargin.width, vertical = insideMargin.height) + } + MiuixText( + modifier = modifier.then(paddingModifier), + text = text, + fontSize = 14.sp, + fontWeight = FontWeight.Medium, + color = MiuixTheme.colorScheme.smallTitle + ) +} \ No newline at end of file diff --git a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/MiuixSurface.kt b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/MiuixSurface.kt index 8ba7de3..95f0e85 100644 --- a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/MiuixSurface.kt +++ b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/MiuixSurface.kt @@ -5,6 +5,7 @@ import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.material3.Surface import androidx.compose.material3.minimumInteractiveComponentSize import androidx.compose.runtime.Composable import androidx.compose.runtime.NonRestartableComposable @@ -43,7 +44,8 @@ fun MiuixSurface( .border( border = border ?: BorderStroke(0.dp, Color.Transparent), shape = shape - ), + ) + .clip(shape), propagateMinConstraints = true ) { content() diff --git a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/theme/MiuixColor.kt b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/theme/MiuixColor.kt index 60bb07d..ff091e4 100644 --- a/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/theme/MiuixColor.kt +++ b/miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/theme/MiuixColor.kt @@ -25,6 +25,7 @@ import androidx.compose.ui.graphics.Color * @param submitDisabledBg The background color of the disabled submit button. * @param buttonDisableText The text color of the disabled button. * @param submitButtonDisabledText The text color of the disabled submit button. + * @param smallTitle The color of the small title. */ @Stable class MiuixColor( @@ -43,7 +44,8 @@ class MiuixColor( disabledBg: Color, submitDisabledBg: Color, buttonDisableText: Color, - submitButtonDisabledText: Color + submitButtonDisabledText: Color, + smallTitle: Color ) { val primary by mutableStateOf(primary, structuralEqualityPolicy()) val onPrimary by mutableStateOf(onPrimary, structuralEqualityPolicy()) @@ -61,6 +63,7 @@ class MiuixColor( val submitDisabledBg by mutableStateOf(disabledBg, structuralEqualityPolicy()) val buttonDisableText by mutableStateOf(buttonDisableText, structuralEqualityPolicy()) val submitButtonDisabledText by mutableStateOf(submitButtonDisabledText, structuralEqualityPolicy()) + val smallTitle by mutableStateOf(smallTitle, structuralEqualityPolicy()) } fun lightColorScheme() = MiuixColor( @@ -70,7 +73,6 @@ fun lightColorScheme() = MiuixColor( background = Color(0xFFF5F5F5), onBackground = Color.Black, subTextBase = Color(0xFF666666), - subDropdown = Color(0xFF999999), secondary = Color(0xFFE6E6E6), dropdownBackground = Color(0xFFFFFFFF), @@ -80,7 +82,8 @@ fun lightColorScheme() = MiuixColor( disabledBg = Color(0xFFC2D9FF), submitDisabledBg = Color(0xFFEEEEEC), buttonDisableText = Color.LightGray, - submitButtonDisabledText = Color(0xFFFFFFFF) + submitButtonDisabledText = Color(0xFFFFFFFF), + smallTitle = Color(0xCC000000) ) fun darkColorScheme() = MiuixColor( @@ -99,5 +102,6 @@ fun darkColorScheme() = MiuixColor( disabledBg = Color(0xFF253E64), submitDisabledBg = Color(0xFF222223), buttonDisableText = Color(0xFF666666), - submitButtonDisabledText = Color(0xFF677893) + submitButtonDisabledText = Color(0xFF677893), + smallTitle = Color(0xCCFFFFFF) ) \ No newline at end of file