Skip to content

Commit cc9e84a

Browse files
committed
library: Cleanup repo
1 parent 1074b84 commit cc9e84a

File tree

17 files changed

+82
-72
lines changed

17 files changed

+82
-72
lines changed

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/HorizontalPager.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ fun HorizontalPager(
3737
) {
3838
HorizontalPager(
3939
modifier =
40-
if (defaultWindowInsetsPadding) {
41-
modifier
42-
.windowInsetsPadding(WindowInsets.displayCutout.only(WindowInsetsSides.Horizontal))
43-
.windowInsetsPadding(WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal))
44-
} else {
45-
modifier
46-
},
40+
if (defaultWindowInsetsPadding) {
41+
modifier
42+
.windowInsetsPadding(WindowInsets.displayCutout.only(WindowInsetsSides.Horizontal))
43+
.windowInsetsPadding(WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal))
44+
} else {
45+
modifier
46+
},
4747
state = pagerState,
4848
beyondViewportPageCount = beyondViewportPageCount,
4949
verticalAlignment = Alignment.Top,

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/Icon.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import androidx.compose.ui.semantics.contentDescription
2121
import androidx.compose.ui.semantics.role
2222
import androidx.compose.ui.semantics.semantics
2323
import androidx.compose.ui.unit.dp
24+
import org.jetbrains.compose.resources.stringResource
2425
import top.yukonga.miuix.kmp.theme.MiuixTheme
2526

2627
/**

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/ListPopup.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ fun ListPopup(
162162
constraints.copy(
163163
minWidth = if (minWidth.roundToPx() <= windowSize.width) minWidth.roundToPx() else windowSize.width,
164164
minHeight = if (50.dp.roundToPx() <= windowSize.height) 50.dp.roundToPx() else windowSize.height,
165-
maxHeight = maxHeight?.roundToPx()?.coerceAtLeast(50.dp.roundToPx()) ?: (windowBounds.height - popupMargin.top - popupMargin.bottom).coerceAtLeast(50.dp.roundToPx()),
165+
maxHeight = maxHeight?.roundToPx()?.coerceAtLeast(50.dp.roundToPx())
166+
?: (windowBounds.height - popupMargin.top - popupMargin.bottom).coerceAtLeast(50.dp.roundToPx()),
166167
maxWidth = if (minWidth.roundToPx() <= windowSize.width) windowSize.width else minWidth.roundToPx()
167168
)
168169
)
@@ -332,7 +333,10 @@ object ListPopupDefaults {
332333
}
333334
return IntOffset(
334335
x = offsetX.coerceIn(windowBounds.left, (windowBounds.right - popupContentSize.width - popupMargin.right).coerceAtLeast(windowBounds.left)),
335-
y = offsetY.coerceIn((windowBounds.top + popupMargin.top).coerceAtMost(windowBounds.bottom - popupContentSize.height - popupMargin.bottom), windowBounds.bottom - popupContentSize.height - popupMargin.bottom)
336+
y = offsetY.coerceIn(
337+
(windowBounds.top + popupMargin.top).coerceAtMost(windowBounds.bottom - popupContentSize.height - popupMargin.bottom),
338+
windowBounds.bottom - popupContentSize.height - popupMargin.bottom
339+
)
336340
)
337341
}
338342

@@ -393,7 +397,10 @@ object ListPopupDefaults {
393397
}
394398
return IntOffset(
395399
x = offsetX.coerceIn(windowBounds.left, (windowBounds.right - popupContentSize.width - popupMargin.right).coerceAtLeast(windowBounds.left)),
396-
y = offsetY.coerceIn((windowBounds.top + popupMargin.top).coerceAtMost(windowBounds.bottom - popupContentSize.height - popupMargin.bottom), windowBounds.bottom - popupContentSize.height - popupMargin.bottom)
400+
y = offsetY.coerceIn(
401+
(windowBounds.top + popupMargin.top).coerceAtMost(windowBounds.bottom - popupContentSize.height - popupMargin.bottom),
402+
windowBounds.bottom - popupContentSize.height - popupMargin.bottom
403+
)
397404
)
398405
}
399406

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/PullToRefresh.kt

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package top.yukonga.miuix.kmp.basic
22

3-
// This component is modified from the example provided by @sd086. Thanks for his work.
4-
53
import androidx.compose.animation.AnimatedVisibility
64
import androidx.compose.animation.core.Animatable
75
import androidx.compose.animation.core.AnimationSpec
@@ -66,6 +64,7 @@ import kotlin.time.TimeSource
6664

6765
/**
6866
* A [PullToRefresh] component with Miuix style.
67+
* modified from the example provided by @sd086.
6968
*
7069
* @param modifier The modifier to be applied to the [PullToRefresh].
7170
* @param pullToRefreshState pullToRefreshState
@@ -75,7 +74,6 @@ import kotlin.time.TimeSource
7574
* @param refreshTextStyle The style of the refresh text.
7675
* @param onRefresh The callback to be called when the refresh is triggered.
7776
* @param content the content to be shown when the [PullToRefresh] is expanded.
78-
*
7977
*/
8078
@Composable
8179
fun PullToRefresh(
@@ -181,7 +179,6 @@ fun RefreshHeader(
181179
}
182180

183181
RefreshState.RefreshComplete -> {
184-
println(1f - refreshCompleteAnimProgress * 0.6f)
185182
1f - refreshCompleteAnimProgress * 1.2f
186183
}
187184

@@ -520,9 +517,9 @@ class PullToRefreshState(
520517
coroutineScope.launch {
521518
snapshotFlow { dragOffsetAnimatable.value }.collectLatest { offset ->
522519
internalRefreshState = when {
523-
offset >= refreshThresholdOffset && !isRefreshing -> RefreshState.ThresholdReached
524-
offset > 0 && !isRefreshing -> RefreshState.Pulling
525520
isRefreshing -> RefreshState.Refreshing
521+
offset >= refreshThresholdOffset -> RefreshState.ThresholdReached
522+
offset > 0 -> RefreshState.Pulling
526523
else -> RefreshState.Idle
527524
}
528525
}
@@ -687,12 +684,26 @@ internal const val thresholdRatio = 1 / 4f
687684
* The default values of the [PullToRefresh] component.
688685
*/
689686
object PullToRefreshDefaults {
687+
688+
/** The default color of the refresh indicator */
690689
val color: Color = Color.Gray
690+
691+
/** The default size of the refresh indicator circle */
691692
val circleSize: Dp = 20.dp
692-
val refreshTexts = listOf("Pull down to refresh", "Release to refresh", "Refreshing...", "Refreshed successfully")
693+
694+
/** The default texts to show when refreshing */
695+
val refreshTexts = listOf(
696+
"Pull down to refresh",
697+
"Release to refresh",
698+
"Refreshing...",
699+
"Refreshed successfully"
700+
)
701+
702+
/** The default style of the refresh text */
693703
val refreshTextStyle = TextStyle(
694704
fontSize = 14.sp,
695705
fontWeight = FontWeight.Bold,
696706
color = color
697707
)
708+
698709
}

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/Scaffold.kt

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ import androidx.compose.ui.util.fastForEach
2828
import androidx.compose.ui.util.fastMap
2929
import androidx.compose.ui.util.fastMapNotNull
3030
import androidx.compose.ui.util.fastMaxBy
31+
import top.yukonga.miuix.kmp.extra.SuperDialog
32+
import top.yukonga.miuix.kmp.extra.SuperDropdown
3133
import top.yukonga.miuix.kmp.theme.MiuixTheme
34+
import top.yukonga.miuix.kmp.utils.MiuixPopupUtil
3235
import top.yukonga.miuix.kmp.utils.MiuixPopupUtil.Companion.MiuixPopupHost
3336

3437
/**
@@ -235,23 +238,23 @@ private fun ScaffoldLayout(
235238
val innerPadding =
236239
PaddingValues(
237240
top =
238-
if (topBarPlaceables.isEmpty()) {
239-
insets.calculateTopPadding()
240-
} else {
241-
topBarHeight.toDp()
242-
},
241+
if (topBarPlaceables.isEmpty()) {
242+
insets.calculateTopPadding()
243+
} else {
244+
topBarHeight.toDp()
245+
},
243246
bottom =
244-
if (bottomBarPlaceables.isEmpty() || bottomBarHeight == null) {
245-
insets.calculateBottomPadding()
246-
} else {
247-
bottomBarHeight.toDp()
248-
},
247+
if (bottomBarPlaceables.isEmpty() || bottomBarHeight == null) {
248+
insets.calculateBottomPadding()
249+
} else {
250+
bottomBarHeight.toDp()
251+
},
249252
start =
250-
insets.calculateStartPadding(
251-
(this@SubcomposeLayout).layoutDirection
252-
),
253+
insets.calculateStartPadding(
254+
(this@SubcomposeLayout).layoutDirection
255+
),
253256
end =
254-
insets.calculateEndPadding((this@SubcomposeLayout).layoutDirection)
257+
insets.calculateEndPadding((this@SubcomposeLayout).layoutDirection)
255258
)
256259
content(innerPadding)
257260
}

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/TabRow.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import top.yukonga.miuix.kmp.utils.SmoothRoundedCornerShape
2929
import top.yukonga.miuix.kmp.utils.getWindowSize
3030
import top.yukonga.miuix.kmp.utils.overScrollHorizontal
3131

32-
3332
/**
3433
* A [TabRow] with Miuix style.
3534
*

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/Text.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,17 @@ fun Text(
169169
text = text,
170170
modifier = modifier.padding(vertical = 4.dp),
171171
style =
172-
style.merge(
173-
color = textColor,
174-
fontSize = fontSize,
175-
fontWeight = fontWeight,
176-
textAlign = textAlign ?: TextAlign.Unspecified,
177-
lineHeight = lineHeight,
178-
fontFamily = fontFamily,
179-
textDecoration = textDecoration,
180-
fontStyle = fontStyle,
181-
letterSpacing = letterSpacing
182-
),
172+
style.merge(
173+
color = textColor,
174+
fontSize = fontSize,
175+
fontWeight = fontWeight,
176+
textAlign = textAlign ?: TextAlign.Unspecified,
177+
lineHeight = lineHeight,
178+
fontFamily = fontFamily,
179+
textDecoration = textDecoration,
180+
fontStyle = fontStyle,
181+
letterSpacing = letterSpacing
182+
),
183183
onTextLayout = onTextLayout,
184184
overflow = overflow,
185185
softWrap = softWrap,

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/TextField.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ fun TextField(
103103
val isFocused by interactionSource.collectIsFocusedAsState()
104104
val borderWidth by animateDpAsState(if (isFocused) 2.dp else 0.dp)
105105
val borderColor by animateColorAsState(if (isFocused) MiuixTheme.colorScheme.primary else backgroundColor)
106-
val labelOffsetY by animateDpAsState(if (value.text.isNotEmpty() && useLabelAsPlaceholder == false) -(insideMargin.height / 2) else 0.dp)
107-
val innerTextOffsetY by animateDpAsState(if (value.text.isNotEmpty() && useLabelAsPlaceholder == false) (insideMargin.height / 2) else 0.dp)
108-
val labelFontSize by animateDpAsState(if (value.text.isNotEmpty() && useLabelAsPlaceholder == false) 10.dp else 16.dp)
106+
val labelOffsetY by animateDpAsState(if (value.text.isNotEmpty() && !useLabelAsPlaceholder) -(insideMargin.height / 2) else 0.dp)
107+
val innerTextOffsetY by animateDpAsState(if (value.text.isNotEmpty() && !useLabelAsPlaceholder) (insideMargin.height / 2) else 0.dp)
108+
val labelFontSize by animateDpAsState(if (value.text.isNotEmpty() && !useLabelAsPlaceholder) 10.dp else 16.dp)
109109
val border = Modifier.border(borderWidth, borderColor, RoundedCornerShape(cornerRadius))
110-
val labelOffset = if (label != "" && useLabelAsPlaceholder == false) Modifier.offset(y = labelOffsetY) else Modifier
111-
val innerTextOffset = if (label != "" && useLabelAsPlaceholder == false) Modifier.offset(y = innerTextOffsetY) else Modifier
110+
val labelOffset = if (label != "" && !useLabelAsPlaceholder) Modifier.offset(y = labelOffsetY) else Modifier
111+
val innerTextOffset = if (label != "" && !useLabelAsPlaceholder) Modifier.offset(y = innerTextOffsetY) else Modifier
112112

113113
BasicTextField(
114114
value = value,
@@ -246,12 +246,12 @@ fun TextField(
246246
val isFocused by interactionSource.collectIsFocusedAsState()
247247
val borderWidth by animateDpAsState(if (isFocused) 2.0.dp else 0.dp)
248248
val borderColor by animateColorAsState(if (isFocused) MiuixTheme.colorScheme.primary else backgroundColor)
249-
val labelOffsetY by animateDpAsState(if (value.isNotEmpty() && useLabelAsPlaceholder == false) -(insideMargin.height / 2) else 0.dp)
250-
val innerTextOffsetY by animateDpAsState(if (value.isNotEmpty() && useLabelAsPlaceholder == false) (insideMargin.height / 2) else 0.dp)
251-
val labelFontSize by animateDpAsState(if (value.isNotEmpty() && useLabelAsPlaceholder == false) 10.dp else 16.dp)
249+
val labelOffsetY by animateDpAsState(if (value.isNotEmpty() && !useLabelAsPlaceholder) -(insideMargin.height / 2) else 0.dp)
250+
val innerTextOffsetY by animateDpAsState(if (value.isNotEmpty() && !useLabelAsPlaceholder) (insideMargin.height / 2) else 0.dp)
251+
val labelFontSize by animateDpAsState(if (value.isNotEmpty() && !useLabelAsPlaceholder) 10.dp else 16.dp)
252252
val border = Modifier.border(borderWidth, borderColor, RoundedCornerShape(cornerRadius))
253-
val labelOffset = if (label != "" && useLabelAsPlaceholder == false) Modifier.offset(y = labelOffsetY) else Modifier
254-
val innerTextOffset = if (label != "" && useLabelAsPlaceholder == false) Modifier.offset(y = innerTextOffsetY) else Modifier
253+
val labelOffset = if (label != "" && !useLabelAsPlaceholder) Modifier.offset(y = labelOffsetY) else Modifier
254+
val innerTextOffset = if (label != "" && !useLabelAsPlaceholder) Modifier.offset(y = innerTextOffsetY) else Modifier
255255

256256
BasicTextField(
257257
value = value,

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/icon/icons/base/ArrowRight.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import androidx.compose.ui.graphics.vector.path
88
import androidx.compose.ui.unit.dp
99
import top.yukonga.miuix.kmp.icon.MiuixIcons
1010

11-
/**
12-
* ArrowRight icon with Miuix style.
13-
*/
1411
val MiuixIcons.Base.ArrowRight: ImageVector
1512
get() {
1613
if (_arrowRight != null) return _arrowRight!!

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/icon/icons/base/ArrowUpDown.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import androidx.compose.ui.graphics.vector.path
88
import androidx.compose.ui.unit.dp
99
import top.yukonga.miuix.kmp.icon.MiuixIcons
1010

11-
/**
12-
* ArrowUpDown icon with Miuix style.
13-
*/
1411
val MiuixIcons.Base.ArrowUpDown: ImageVector
1512
get() {
1613
if (_arrowUpDown != null) return _arrowUpDown!!

0 commit comments

Comments
 (0)