Skip to content

Commit e903d71

Browse files
committed
library: Opt SmoothRoundedCornerShape
* Switch to using androidx graphics-shapes * Remove the Box component, we didn't make any changes to it, just use this component from androidx foundation
1 parent 330efcd commit e903d71

File tree

25 files changed

+410
-508
lines changed

25 files changed

+410
-508
lines changed

composeApp/src/commonMain/kotlin/SecondPage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fun SecondPage(
2828
.padding(horizontal = 12.dp)
2929
.padding(top = 12.dp, bottom = 12.dp + padding.calculateBottomPadding())
3030
) {
31-
for (i in 0 until 20) {
31+
for (i in 0 until 50) {
3232
SuperDropdown(
3333
title = "Dropdown",
3434
items = dropdownOptions,

composeApp/src/commonMain/kotlin/component/TextComponent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.compose.animation.fadeIn
66
import androidx.compose.animation.fadeOut
77
import androidx.compose.animation.shrinkVertically
88
import androidx.compose.foundation.layout.Arrangement
9+
import androidx.compose.foundation.layout.Box
910
import androidx.compose.foundation.layout.Row
1011
import androidx.compose.foundation.layout.Spacer
1112
import androidx.compose.foundation.layout.fillMaxWidth
@@ -24,7 +25,6 @@ import androidx.compose.ui.graphics.painter.Painter
2425
import androidx.compose.ui.unit.Dp
2526
import androidx.compose.ui.unit.dp
2627
import top.yukonga.miuix.kmp.basic.BasicComponent
27-
import top.yukonga.miuix.kmp.basic.Box
2828
import top.yukonga.miuix.kmp.basic.ButtonDefaults
2929
import top.yukonga.miuix.kmp.basic.Card
3030
import top.yukonga.miuix.kmp.basic.Checkbox

gradle/libs.versions.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ kotlin = "2.1.0"
1212

1313
[libraries]
1414
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity-compose" }
15+
androidx-graphics-shapes = { group = "androidx.graphics", name = "graphics-shapes", version = "1.0.1" }
16+
androidx-graphics-shapes-web = { module = "org.jetbrains.androidx.graphics:graphics-shapes", version = "1.0.0-alpha01" }
1517
androidx-window = { group = "androidx.window", name = "window", version.ref = "androidx-window" }
18+
jetbrains-compose-collection = { module = "org.jetbrains.compose.collection-internal:collection", version.ref = "compose-plugin" }
1619
jetbrains-compose-window-size = { module = "org.jetbrains.compose.material3:material3-window-size-class", version.ref = "compose-plugin" }
1720

1821
[plugins]

miuix/build.gradle.kts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,33 @@ kotlin {
3939
}
4040

4141
sourceSets {
42+
val desktopMain by getting
43+
4244
androidMain.dependencies {
4345
implementation(libs.androidx.activity.compose)
46+
implementation(libs.androidx.graphics.shapes)
4447
implementation(libs.androidx.window)
4548
}
4649
commonMain.dependencies {
4750
implementation(compose.runtime)
4851
implementation(compose.foundation)
4952
implementation(compose.ui)
5053
implementation(compose.components.resources)
54+
implementation(libs.jetbrains.compose.collection)
5155
implementation(libs.jetbrains.compose.window.size)
5256
}
57+
nativeMain.dependencies {
58+
implementation(libs.androidx.graphics.shapes)
59+
}
60+
desktopMain.dependencies {
61+
implementation(libs.androidx.graphics.shapes)
62+
}
63+
jsMain.dependencies {
64+
implementation(libs.androidx.graphics.shapes.web)
65+
}
66+
wasmJsMain.dependencies {
67+
implementation(libs.androidx.graphics.shapes.web)
68+
}
5369
}
5470
}
5571

@@ -59,4 +75,4 @@ android {
5975
defaultConfig {
6076
minSdk = libs.versions.android.minSdk.get().toInt()
6177
}
62-
}
78+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package top.yukonga.miuix.kmp.utils
2+
3+
import androidx.compose.ui.geometry.Size
4+
import androidx.compose.ui.graphics.Path
5+
import androidx.compose.ui.graphics.asComposePath
6+
import androidx.graphics.shapes.CornerRounding
7+
import androidx.graphics.shapes.RoundedPolygon
8+
import androidx.graphics.shapes.toPath
9+
10+
actual fun Path.Companion.smoothRoundedRectangle(
11+
smoothing: Float,
12+
size: Size,
13+
topLeft: Float,
14+
topRight: Float,
15+
bottomLeft: Float,
16+
bottomRight: Float
17+
): Path =
18+
RoundedPolygon(
19+
vertices = floatArrayOf(
20+
0f, 0f,
21+
size.width, 0f,
22+
size.width, size.height,
23+
0f, size.height
24+
),
25+
perVertexRounding = listOf(
26+
CornerRounding(radius = topLeft, smoothing = smoothing),
27+
CornerRounding(radius = topRight, smoothing = smoothing),
28+
CornerRounding(radius = bottomRight, smoothing = smoothing),
29+
CornerRounding(radius = bottomLeft, smoothing = smoothing),
30+
)
31+
).toPath().asComposePath()

0 commit comments

Comments
 (0)