@momo-kits/native-kits 0.169.6-debug → 0.169.7-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compose/build.gradle.kts +1 -1
- package/compose/compose.podspec +1 -1
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +2 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +13 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +13 -73
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +1 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +3 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +7 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +6 -30
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +2 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +6 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +1 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +4 -30
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +4 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +5 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +1 -1
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +1 -1
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +1 -2
- package/gradle/libs.versions.toml +0 -2
- package/gradle.properties +1 -1
- package/ios/Application/ApplicationEnvironment.swift +2 -3
- package/ios/Application/DesignSystemKits.swift +4 -20
- package/ios/Application/DesignSystemKitsPayload.swift +0 -8
- package/ios/Application/LanguageSource.swift +0 -8
- package/ios/Application/Localize.swift +7 -31
- package/ios/Application/LocalizeModifier.swift +0 -8
- package/ios/Application/MaxApi.swift +3 -11
- package/ios/Avatar/Avatar.swift +0 -1
- package/ios/Badge/Badge.swift +0 -1
- package/ios/Badge/BadgeRibbon.swift +2 -5
- package/ios/Button/Button.swift +2 -5
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +2 -2
- package/ios/Carousel/Carousel.swift +5 -17
- package/ios/Checkbox/Checkbox.swift +0 -2
- package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
- package/ios/DateTimePicker/DateTimePicker.swift +4 -10
- package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
- package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
- package/ios/DateTimePicker/WheelPicker.swift +2 -4
- package/ios/Extensions/SkeletonUICompat.swift +0 -8
- package/ios/Icon/Icon.swift +1 -3
- package/ios/IconButton/IconButton.swift +0 -2
- package/ios/Input/ErrorView.swift +0 -7
- package/ios/Input/Input.swift +6 -19
- package/ios/Input/InputPhoneNumber.swift +0 -11
- package/ios/Input/InputSearch.swift +0 -6
- package/ios/Input/InputTextArea.swift +1 -12
- package/ios/InputDropDown/InputDropDown.swift +1 -11
- package/ios/InputMoney/InputMoney.swift +9 -28
- package/ios/InputOTP/InputOTP.swift +2 -9
- package/ios/Layout/Item.swift +1 -2
- package/ios/Layout/ModalLayout.swift +7 -14
- package/ios/Layout/ScreenLayout.swift +2 -7
- package/ios/Loader/Loader.swift +3 -12
- package/ios/Lottie/LottieView.swift +0 -11
- package/ios/Navigation/BottomSheet.swift +14 -35
- package/ios/Navigation/BottomTab/BottomTab.swift +10 -19
- package/ios/Navigation/BottomTab/BottomTabBar.swift +4 -10
- package/ios/Navigation/BottomTab/CurvedContainer.swift +5 -11
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +6 -12
- package/ios/Navigation/BottomTab/DuoTabBar.swift +2 -7
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +3 -9
- package/ios/Navigation/Component/FloatingButton.swift +4 -11
- package/ios/Navigation/Component/Header.swift +4 -8
- package/ios/Navigation/Component/HeaderBackground.swift +2 -8
- package/ios/Navigation/Component/HeaderJourney.swift +2 -7
- package/ios/Navigation/Component/HeaderLocation.swift +2 -7
- package/ios/Navigation/Component/HeaderRight.swift +2 -7
- package/ios/Navigation/Component/HeaderTitle.swift +1 -6
- package/ios/Navigation/Component/HeaderUser.swift +2 -9
- package/ios/Navigation/Component/SideBar.swift +3 -8
- package/ios/Navigation/Component/SnackBar.swift +5 -13
- package/ios/Navigation/HostBackGestureBridge.swift +3 -9
- package/ios/Navigation/ModalScreen.swift +2 -8
- package/ios/Navigation/Navigation.swift +2 -15
- package/ios/Navigation/NavigationContainer.swift +3 -12
- package/ios/Navigation/Navigator.swift +15 -27
- package/ios/Navigation/StackScreen.swift +8 -28
- package/ios/Navigation/StackTransition.swift +3 -11
- package/ios/Navigation/SwipeBackHaptic.swift +2 -7
- package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
- package/ios/Pagination/PaginationDot.swift +0 -9
- package/ios/Pagination/PaginationNumber.swift +1 -9
- package/ios/Pagination/PaginationScroll.swift +2 -14
- package/ios/Pagination/PaginationWhiteDot.swift +1 -10
- package/ios/Popup/PopupDisplay.swift +3 -3
- package/ios/Popup/PopupInput.swift +1 -1
- package/ios/Popup/PopupLayout.swift +3 -3
- package/ios/PopupView/FullscreenPopup.swift +3 -4
- package/ios/PopupView/PopupView.swift +2 -2
- package/ios/PopupView/Utils++.swift +1 -2
- package/ios/ProgressInfo/ProgressInfo.swift +2 -13
- package/ios/Skeleton/Skeleton.swift +2 -10
- package/ios/Slider/Slider.swift +5 -12
- package/ios/StatusBarTap/StatusBarTap.h +2 -3
- package/ios/StatusBarTap/StatusBarTap.m +3 -16
- package/ios/Stepper/Stepper.swift +8 -27
- package/ios/Steps/Steps.swift +9 -11
- package/ios/Swipeable/SwipeCell.swift +2 -2
- package/ios/Swipeable/SwipeCellModel.swift +3 -6
- package/ios/TabView/TabView.swift +12 -25
- package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
- package/ios/Tooltip/Tooltip.swift +2 -7
- package/ios/Typography/FontScale.swift +3 -15
- package/ios/Typography/Text.swift +2 -7
- package/ios/Typography/Typography.swift +8 -10
- package/ios/Uploader/Uploader.swift +2 -17
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
- package/package.json +1 -1
package/compose/build.gradle.kts
CHANGED
package/compose/compose.podspec
CHANGED
|
@@ -12,8 +12,7 @@ internal actual fun hostFontFamily(fileName: String, weight: FontWeight): FontFa
|
|
|
12
12
|
val assets = LocalContext.current.applicationContext.assets
|
|
13
13
|
return remember(fileName, weight) {
|
|
14
14
|
val path = "fonts/$fileName"
|
|
15
|
-
//
|
|
16
|
-
// muộn lúc render nên phải kiểm tra tồn tại trước.
|
|
15
|
+
// Font(path, assetManager) only fails later at render time, so check the asset exists first.
|
|
17
16
|
val exists = runCatching { assets.open(path).close() }.isSuccess
|
|
18
17
|
if (exists) FontFamily(Font(path = path, assetManager = assets, weight = weight)) else null
|
|
19
18
|
}
|
|
@@ -150,7 +150,6 @@ fun LiteScreen(
|
|
|
150
150
|
verticalArrangement: Arrangement.Vertical = Arrangement.Top,
|
|
151
151
|
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
|
152
152
|
backgroundColor: Color = AppTheme.current.colors.background.default,
|
|
153
|
-
/* Begin of header props */
|
|
154
153
|
title: String? = null,
|
|
155
154
|
inputSearchProps: LiteInputSearchProps? = null,
|
|
156
155
|
goBack: (() -> Unit)? = null,
|
|
@@ -161,7 +160,6 @@ fun LiteScreen(
|
|
|
161
160
|
headerTintColor: Color? = null,
|
|
162
161
|
headerBackgroundColor: Color? = null,
|
|
163
162
|
headerSpaceBetween: Dp? = null,
|
|
164
|
-
/* End of header props */
|
|
165
163
|
|
|
166
164
|
screenContent: @Composable () -> Unit,
|
|
167
165
|
) {
|
|
@@ -678,9 +676,7 @@ private class LiteScreenLayoutPolicy(
|
|
|
678
676
|
)
|
|
679
677
|
)
|
|
680
678
|
|
|
681
|
-
|
|
682
|
-
* replicate logic from [vn.momo.kits.navigation.component.HeaderBackground]
|
|
683
|
-
* */
|
|
679
|
+
// Same height rule as navigation.component.HeaderBackground.
|
|
684
680
|
var defaultHeight = with(geometry) { headerHeight(screenLayout, statusBarPx, headerRowDefault) }
|
|
685
681
|
if (isHeaderExtend) {
|
|
686
682
|
defaultHeight = if (screenLayout.isIPhoneDuo) {
|
|
@@ -15,10 +15,8 @@ data class LocalizationObject(
|
|
|
15
15
|
)
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* switched at runtime via [changeLanguage]. Language is snapshot-backed, so a switch
|
|
21
|
-
* recomposes consumers of [translate]/[translateData].
|
|
18
|
+
* Port of RN `Application/Localize.ts`: kit defaults merged with host overrides. The language is
|
|
19
|
+
* snapshot state, so [changeLanguage] recomposes readers of [translate]/[translateData].
|
|
22
20
|
*/
|
|
23
21
|
@Stable
|
|
24
22
|
class Localize(translations: LocalizationObject = LocalizationObject()) {
|
|
@@ -17,19 +17,20 @@ import vn.momo.kits.application.IsShowBaseLineDebug
|
|
|
17
17
|
import vn.momo.kits.const.*
|
|
18
18
|
import vn.momo.kits.modifier.conditional
|
|
19
19
|
|
|
20
|
+
// RN accepts only the `_03` palette as a custom badge color.
|
|
20
21
|
private val badgePrimaryColors = listOf(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
Colors.black_03,
|
|
23
|
+
Colors.pink_03,
|
|
24
|
+
Colors.violet_03,
|
|
25
|
+
Colors.indigo_03,
|
|
26
|
+
Colors.blue_03,
|
|
27
|
+
Colors.mint_03,
|
|
28
|
+
Colors.green_03,
|
|
29
|
+
Colors.lime_03,
|
|
30
|
+
Colors.yellow_03,
|
|
31
|
+
Colors.gold_03,
|
|
32
|
+
Colors.orange_03,
|
|
33
|
+
Colors.red_03
|
|
33
34
|
)
|
|
34
35
|
|
|
35
36
|
private val badgeNumberRegex = "^\\d+$".toRegex()
|
|
@@ -218,8 +218,8 @@ fun RoundedBadgeRibbon(
|
|
|
218
218
|
val ribbonHeight = height - padding.toPx()
|
|
219
219
|
val cornerRadius = roundedRect.toPx()
|
|
220
220
|
|
|
221
|
-
val mainColor =
|
|
222
|
-
val tailColor =
|
|
221
|
+
val mainColor = Colors.orange_03
|
|
222
|
+
val tailColor = Colors.red_01
|
|
223
223
|
|
|
224
224
|
val headWidth = 4.dp.toPx()
|
|
225
225
|
val leftSectionWidth = width * (9f / 28f)
|
|
@@ -61,10 +61,7 @@ private enum class CupertinoSpringAnimationReason {
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
private data class CupertinoOverscrollAvailableDelta(
|
|
64
|
-
|
|
65
64
|
val availableDelta: Float,
|
|
66
|
-
|
|
67
|
-
|
|
68
65
|
val newOverscrollValue: Float
|
|
69
66
|
)
|
|
70
67
|
|
|
@@ -83,44 +80,21 @@ data class PullToRefreshCustomState(
|
|
|
83
80
|
}
|
|
84
81
|
|
|
85
82
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* @param density to be taken into consideration during computations;
|
|
89
|
-
* Cupertino formulas use DPs, and scroll machinery uses raw values.
|
|
90
|
-
*
|
|
91
|
-
* @param applyClip Some consumers of overscroll effect apply clip by themselves and some don't,
|
|
92
|
-
* thus this flag is needed to update our modifier chain and make the clipping correct in every case while avoiding redundancy
|
|
83
|
+
* iOS rubber-band overscroll (from JetBrains compose-multiplatform-core) with optional pull-to-refresh.
|
|
84
|
+
* The formulas run in dp, hence [density]; [applyClip] is for consumers that don't clip themselves.
|
|
93
85
|
*/
|
|
94
86
|
internal class CupertinoOverscrollEffect(
|
|
95
87
|
val pullRefreshState: PullToRefreshCustomState? = null,
|
|
96
88
|
private val density: Float,
|
|
97
89
|
val applyClip: Boolean
|
|
98
90
|
) : OverscrollEffect {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
* [applyToScroll] calls. Technically this effect supports both dimensions, but current API requires
|
|
102
|
-
* that different stages of animations spawned by this effect for both dimensions
|
|
103
|
-
* end at the same time, which is not the case:
|
|
104
|
-
* Spring->Fling->Spring, Fling->Spring, Spring->Fling effects can have different timing per dimension
|
|
105
|
-
* (see Notes of https://github.com/JetBrains/compose-multiplatform-core/pull/609),
|
|
106
|
-
* which is not possible to express without changing API. Hence, this effect will be fixed to latest
|
|
107
|
-
* received delta.
|
|
108
|
-
*/
|
|
91
|
+
// Follows the axis of the latest delta: the API can't end per-axis spring/fling stages at different
|
|
92
|
+
// times (Notes of https://github.com/JetBrains/compose-multiplatform-core/pull/609).
|
|
109
93
|
private var direction: CupertinoOverscrollDirection = CupertinoOverscrollDirection.UNKNOWN
|
|
110
94
|
|
|
111
|
-
/*
|
|
112
|
-
* Size of container is taking into consideration when computing rubber banding
|
|
113
|
-
*/
|
|
114
95
|
private var scrollSize: Size = Size.Zero
|
|
115
96
|
|
|
116
|
-
|
|
117
|
-
* Current offset in overscroll area
|
|
118
|
-
* Negative for bottom-right
|
|
119
|
-
* Positive for top-left
|
|
120
|
-
* Zero if within the scrollable range
|
|
121
|
-
* It will be mapped to the actual visible offset using the rubber banding rule inside
|
|
122
|
-
* [Modifier.offset] within [effectModifier]
|
|
123
|
-
*/
|
|
97
|
+
// Raw overscroll: positive top-left, negative bottom-right, zero in range; drawn rubber-banded.
|
|
124
98
|
private var overscrollOffsetState = mutableStateOf(Offset.Zero)
|
|
125
99
|
private var overscrollOffset: Offset
|
|
126
100
|
get() = overscrollOffsetState.value
|
|
@@ -135,10 +109,7 @@ internal class CupertinoOverscrollEffect(
|
|
|
135
109
|
get() = overscrollOffsetState.value.rubberBanded().round()
|
|
136
110
|
|
|
137
111
|
override val isInProgress: Boolean
|
|
138
|
-
get() =
|
|
139
|
-
// If visible overscroll offset has at least one pixel
|
|
140
|
-
// this effect is considered to be in progress
|
|
141
|
-
visibleOverscrollOffset.toOffset().getDistance() > 0.5f
|
|
112
|
+
get() = visibleOverscrollOffset.toOffset().getDistance() > 0.5f
|
|
142
113
|
|
|
143
114
|
@OptIn(ExperimentalMaterialApi::class)
|
|
144
115
|
private val overscrollNode = CupertinoOverscrollNode(
|
|
@@ -151,8 +122,7 @@ internal class CupertinoOverscrollEffect(
|
|
|
151
122
|
override val node: DelegatableNode get() = overscrollNode
|
|
152
123
|
|
|
153
124
|
private fun onDraw() {
|
|
154
|
-
//
|
|
155
|
-
// Reset the overscroll effect when no ongoing animation or interaction is applied.
|
|
125
|
+
// A cancelled scroll can leave the effect half-way: reset it once nothing animates or touches it.
|
|
156
126
|
if (!drawCallScheduledByOffsetChange && isInProgress && overscrollNode.pointersDown == 0) {
|
|
157
127
|
overscrollOffsetState.value = Offset.Zero
|
|
158
128
|
}
|
|
@@ -167,18 +137,12 @@ internal class CupertinoOverscrollEffect(
|
|
|
167
137
|
else -> null
|
|
168
138
|
}
|
|
169
139
|
|
|
170
|
-
/*
|
|
171
|
-
* Takes input scroll delta, current overscroll value, and scroll source, return [CupertinoOverscrollAvailableDelta]
|
|
172
|
-
*/
|
|
173
140
|
@Stable
|
|
174
141
|
private fun availableDelta(
|
|
175
142
|
delta: Float,
|
|
176
143
|
overscroll: Float,
|
|
177
144
|
source: CupertinoScrollSource
|
|
178
145
|
): CupertinoOverscrollAvailableDelta {
|
|
179
|
-
// if source is fling:
|
|
180
|
-
// 1. no delta will be consumed
|
|
181
|
-
// 2. overscroll will stay the same
|
|
182
146
|
if (source == CupertinoScrollSource.FLING) {
|
|
183
147
|
return CupertinoOverscrollAvailableDelta(delta, overscroll)
|
|
184
148
|
}
|
|
@@ -202,10 +166,7 @@ internal class CupertinoOverscrollEffect(
|
|
|
202
166
|
}
|
|
203
167
|
}
|
|
204
168
|
|
|
205
|
-
|
|
206
|
-
* Returns the amount of scroll delta available after user performed scroll inside overscroll area
|
|
207
|
-
* It will update [overscroll] resulting in visual change because of [Modifier.offset] depending on it
|
|
208
|
-
*/
|
|
169
|
+
// Delta left after the overscroll area takes its share; moves [overscrollOffset] as a side effect.
|
|
209
170
|
private fun availableDelta(delta: Offset, source: CupertinoScrollSource): Offset {
|
|
210
171
|
val (x, overscrollX) = availableDelta(delta.x, overscrollOffset.x, source)
|
|
211
172
|
val (y, overscrollY) = availableDelta(delta.y, overscrollOffset.y, source)
|
|
@@ -214,37 +175,25 @@ internal class CupertinoOverscrollEffect(
|
|
|
214
175
|
return Offset(x, y)
|
|
215
176
|
}
|
|
216
177
|
|
|
217
|
-
/*
|
|
218
|
-
* Semantics of this method match the [OverscrollEffect.applyToScroll] one,
|
|
219
|
-
* The only difference is NestedScrollSource being remapped to CupertinoScrollSource to narrow
|
|
220
|
-
* processed states invariant
|
|
221
|
-
*/
|
|
222
178
|
private fun applyToScroll(
|
|
223
179
|
delta: Offset,
|
|
224
180
|
source: CupertinoScrollSource,
|
|
225
181
|
performScroll: (Offset) -> Offset
|
|
226
182
|
): Offset {
|
|
227
|
-
// Calculate how much delta is available after being consumed by scrolling inside overscroll area
|
|
228
183
|
val deltaLeftForPerformScroll = availableDelta(delta, source)
|
|
229
|
-
|
|
230
|
-
// Then pass remaining delta to scroll closure
|
|
231
184
|
val deltaConsumedByPerformScroll = performScroll(deltaLeftForPerformScroll)
|
|
232
|
-
|
|
233
|
-
// Delta which is left after `performScroll` was invoked with availableDelta
|
|
234
185
|
val unconsumedDelta = deltaLeftForPerformScroll - deltaConsumedByPerformScroll
|
|
235
186
|
|
|
236
187
|
return when (source) {
|
|
237
188
|
CupertinoScrollSource.DRAG -> {
|
|
238
|
-
//
|
|
239
|
-
// overscroll->content->overscroll or content->overscroll scenario within single frame
|
|
189
|
+
// The rest goes back into overscroll: a drag can cross the content edge within one frame.
|
|
240
190
|
overscrollOffset += unconsumedDelta
|
|
241
191
|
lastFlingUnconsumedDelta = Offset.Zero
|
|
242
192
|
delta - unconsumedDelta
|
|
243
193
|
}
|
|
244
194
|
|
|
245
195
|
CupertinoScrollSource.FLING -> {
|
|
246
|
-
//
|
|
247
|
-
// start spring animation instead
|
|
196
|
+
// Non-zero cancels the fling and starts the spring animation instead.
|
|
248
197
|
lastFlingUnconsumedDelta = unconsumedDelta
|
|
249
198
|
delta - unconsumedDelta
|
|
250
199
|
}
|
|
@@ -302,11 +251,9 @@ internal class CupertinoOverscrollEffect(
|
|
|
302
251
|
if (hasXPart) {
|
|
303
252
|
CupertinoOverscrollDirection.HORIZONTAL
|
|
304
253
|
} else {
|
|
305
|
-
// hasYPart != hasXPart and hasXPart is false
|
|
306
254
|
CupertinoOverscrollDirection.VERTICAL
|
|
307
255
|
}
|
|
308
256
|
} else {
|
|
309
|
-
// hasXPart and hasYPart are equal
|
|
310
257
|
CupertinoOverscrollDirection.UNKNOWN
|
|
311
258
|
}
|
|
312
259
|
}
|
|
@@ -376,8 +323,7 @@ internal class CupertinoOverscrollEffect(
|
|
|
376
323
|
val initialSign = sign(initialValue)
|
|
377
324
|
var currentVelocity = initialVelocity
|
|
378
325
|
|
|
379
|
-
//
|
|
380
|
-
// they operated on DPs. Callback value is then scaled back to raw pixels.
|
|
326
|
+
// The spring runs in dp (inputs divided by density); the callback scales back to px.
|
|
381
327
|
val visibilityThreshold = 0.5f / density
|
|
382
328
|
|
|
383
329
|
val spec = when (reason) {
|
|
@@ -413,7 +359,7 @@ internal class CupertinoOverscrollEffect(
|
|
|
413
359
|
} ?: (value * density).toOffset()
|
|
414
360
|
currentVelocity = velocity * density
|
|
415
361
|
|
|
416
|
-
//
|
|
362
|
+
// Flung from overscroll: stop at the edge and hand the velocity back to the fling.
|
|
417
363
|
if (reason == CupertinoSpringAnimationReason.FLING_FROM_OVERSCROLL &&
|
|
418
364
|
initialSign != 0f &&
|
|
419
365
|
sign(value) != initialSign
|
|
@@ -425,8 +371,7 @@ internal class CupertinoOverscrollEffect(
|
|
|
425
371
|
}
|
|
426
372
|
|
|
427
373
|
if (currentCoroutineContext().isActive) {
|
|
428
|
-
//
|
|
429
|
-
// offset and velocity is of the opposite sign, it will end up with no animation
|
|
374
|
+
// Critically damped: a slightly offset spring-fling-spring with opposite velocity ends unanimated.
|
|
430
375
|
overscrollOffset = Offset.Zero
|
|
431
376
|
}
|
|
432
377
|
|
|
@@ -451,10 +396,6 @@ internal class CupertinoOverscrollEffect(
|
|
|
451
396
|
) * density
|
|
452
397
|
}
|
|
453
398
|
|
|
454
|
-
/*
|
|
455
|
-
* Maps raw delta offset [value] on an axis within scroll container with [dimension]
|
|
456
|
-
* to actual visible offset
|
|
457
|
-
*/
|
|
458
399
|
private fun rubberBandedValue(value: Float, dimension: Float) =
|
|
459
400
|
sign(value) * (1f - (1f / (abs(value) * RUBBER_BAND_COEFFICIENT / dimension + 1f))) * dimension
|
|
460
401
|
|
|
@@ -488,7 +429,6 @@ private class CupertinoOverscrollNode @OptIn(ExperimentalMaterialApi::class) con
|
|
|
488
429
|
pointersDown++
|
|
489
430
|
} else if (pointerEvent.type == PointerEventType.Release) {
|
|
490
431
|
pointersDown--
|
|
491
|
-
// assert(pointersDown >= 0) { "pointersDown cannot be negative" }
|
|
492
432
|
}
|
|
493
433
|
}
|
|
494
434
|
}
|
|
@@ -31,7 +31,6 @@ fun Icon(
|
|
|
31
31
|
color: Color? = AppTheme.current.colors.text.default,
|
|
32
32
|
modifier: Modifier = Modifier,
|
|
33
33
|
) {
|
|
34
|
-
// decode image without downscaling it
|
|
35
34
|
val context = LocalPlatformContext.current
|
|
36
35
|
|
|
37
36
|
val iconUrl = remember(source) {
|
|
@@ -72,6 +71,7 @@ fun Icon(
|
|
|
72
71
|
modifier = Modifier.matchParentSize(),
|
|
73
72
|
model = ImageRequest.Builder(context)
|
|
74
73
|
.data(iconUrl)
|
|
74
|
+
// Undefined size: decode at full resolution, not downscaled to the view.
|
|
75
75
|
.size(
|
|
76
76
|
coil3.size.Dimension.Undefined,
|
|
77
77
|
coil3.size.Dimension.Undefined
|
|
@@ -38,7 +38,7 @@ enum class ImageState {
|
|
|
38
38
|
Loading, Success, Error
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
//
|
|
41
|
+
// CDN hosts that serve a resized image for the `size` query param.
|
|
42
42
|
private val supportedDomains = setOf(
|
|
43
43
|
"static.momocdn.net",
|
|
44
44
|
"img.mservice.com.vn",
|
|
@@ -47,7 +47,6 @@ private val supportedDomains = setOf(
|
|
|
47
47
|
"image.momocdn.net"
|
|
48
48
|
)
|
|
49
49
|
|
|
50
|
-
// Pre-computed size chart for optimal image sizing
|
|
51
50
|
private val sizeChart = mapOf(
|
|
52
51
|
64 to "XXS",
|
|
53
52
|
128 to "XS",
|
|
@@ -58,7 +57,6 @@ private val sizeChart = mapOf(
|
|
|
58
57
|
2048 to "XXL"
|
|
59
58
|
)
|
|
60
59
|
|
|
61
|
-
// Optimized size selection using binary search approach
|
|
62
60
|
private fun closestSizeForWidth(width: Float): String {
|
|
63
61
|
val targetWidth = width.toInt()
|
|
64
62
|
return sizeChart.entries
|
|
@@ -66,7 +64,6 @@ private fun closestSizeForWidth(width: Float): String {
|
|
|
66
64
|
?.value ?: "M"
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
// Cached regex for better URL parsing performance
|
|
70
67
|
private val urlHostRegex = Regex("^(?:https?://)?([^:/\\s]+)")
|
|
71
68
|
|
|
72
69
|
private fun getHostFromUrl(url: String): String? {
|
|
@@ -90,7 +87,6 @@ private fun GifImageState.toImageState(): ImageState {
|
|
|
90
87
|
}
|
|
91
88
|
}
|
|
92
89
|
|
|
93
|
-
// Optimized query parameter appending
|
|
94
90
|
private fun appendSizeQueryParam(url: String, value: String): String {
|
|
95
91
|
val fragmentIndex = url.indexOf('#')
|
|
96
92
|
val (baseUrl, fragment) = if (fragmentIndex != -1) {
|
|
@@ -103,7 +99,6 @@ private fun appendSizeQueryParam(url: String, value: String): String {
|
|
|
103
99
|
return "${baseUrl}${separator}size=$value$fragment"
|
|
104
100
|
}
|
|
105
101
|
|
|
106
|
-
// Cache for processed URLs to avoid repeated calculations
|
|
107
102
|
private val urlCache = mutableMapOf<String, String>()
|
|
108
103
|
|
|
109
104
|
@Composable
|
|
@@ -130,7 +125,6 @@ fun Image(
|
|
|
130
125
|
val urlToLoad = remember(source, maxWidth, maxHeight, density) {
|
|
131
126
|
when (source) {
|
|
132
127
|
is String -> {
|
|
133
|
-
// Check cache first
|
|
134
128
|
val cacheKey = "$source|${maxWidth}|${density.density}"
|
|
135
129
|
urlCache[cacheKey] ?: run {
|
|
136
130
|
val processedUrl = processImageUrl(source, maxWidth, density)
|
|
@@ -182,7 +176,6 @@ fun Image(
|
|
|
182
176
|
}
|
|
183
177
|
}
|
|
184
178
|
|
|
185
|
-
// Extracted URL processing logic for better performance
|
|
186
179
|
private fun processImageUrl(url: String, maxWidth: androidx.compose.ui.unit.Dp, density: androidx.compose.ui.unit.Density): String {
|
|
187
180
|
val host = getHostFromUrl(url)
|
|
188
181
|
return if (!isGifUrl(url) && host != null && supportedDomains.contains(host)) {
|
|
@@ -210,10 +210,8 @@ fun Input(
|
|
|
210
210
|
modifier: Modifier = Modifier,
|
|
211
211
|
inputModifier: Modifier = Modifier,
|
|
212
212
|
) {
|
|
213
|
-
// Consolidated state management
|
|
214
213
|
var inputState by remember { mutableStateOf(InputState()) }
|
|
215
214
|
|
|
216
|
-
// Memoized color calculations
|
|
217
215
|
val theme = AppTheme.current
|
|
218
216
|
val colors = remember(disabled, theme, iconColor) {
|
|
219
217
|
if (disabled) {
|
|
@@ -221,9 +219,9 @@ fun Input(
|
|
|
221
219
|
Triple(disabledColor, disabledColor, disabledColor)
|
|
222
220
|
} else {
|
|
223
221
|
Triple(
|
|
224
|
-
theme.colors.text.default,
|
|
225
|
-
theme.colors.text.hint,
|
|
226
|
-
iconColor
|
|
222
|
+
theme.colors.text.default,
|
|
223
|
+
theme.colors.text.hint,
|
|
224
|
+
iconColor
|
|
227
225
|
)
|
|
228
226
|
}
|
|
229
227
|
}
|
|
@@ -310,7 +308,6 @@ fun Input(
|
|
|
310
308
|
onChangeText(limitedText)
|
|
311
309
|
},
|
|
312
310
|
decorationBox = { innerTextField ->
|
|
313
|
-
// Floating label
|
|
314
311
|
FloatingLabel(
|
|
315
312
|
floatingValue = floatingValue,
|
|
316
313
|
floatingIcon = floatingIcon,
|
|
@@ -339,7 +336,6 @@ fun Input(
|
|
|
339
336
|
modifier = Modifier.padding(horizontal = Spacing.M),
|
|
340
337
|
verticalAlignment = Alignment.CenterVertically
|
|
341
338
|
) {
|
|
342
|
-
// Leading icon
|
|
343
339
|
if (leadingIcon.isNotEmpty()) {
|
|
344
340
|
Icon(
|
|
345
341
|
source = leadingIcon,
|
|
@@ -404,7 +400,6 @@ fun Input(
|
|
|
404
400
|
},
|
|
405
401
|
)
|
|
406
402
|
|
|
407
|
-
// Error/hint display
|
|
408
403
|
ErrorView(error, errorSpacing, hintText)
|
|
409
404
|
}
|
|
410
405
|
}
|
|
@@ -190,7 +190,6 @@ fun InputMoney(
|
|
|
190
190
|
}
|
|
191
191
|
},
|
|
192
192
|
decorationBox = { innerTextField ->
|
|
193
|
-
// Floating Icon
|
|
194
193
|
FloatingLabel(
|
|
195
194
|
floatingValue = floatingValue,
|
|
196
195
|
floatingIcon = floatingIcon,
|
|
@@ -199,7 +198,7 @@ fun InputMoney(
|
|
|
199
198
|
offsetY = -size.values.height / 2,
|
|
200
199
|
required = required,
|
|
201
200
|
)
|
|
202
|
-
//
|
|
201
|
+
// Input container
|
|
203
202
|
Box(
|
|
204
203
|
modifier = Modifier.fillMaxWidth()
|
|
205
204
|
.border(
|
|
@@ -213,7 +212,6 @@ fun InputMoney(
|
|
|
213
212
|
modifier = Modifier.padding(horizontal = Spacing.M),
|
|
214
213
|
verticalAlignment = Alignment.CenterVertically
|
|
215
214
|
) {
|
|
216
|
-
//leading icon
|
|
217
215
|
if (leadingIcon.isNotEmpty()) {
|
|
218
216
|
Icon(
|
|
219
217
|
source = leadingIcon,
|
|
@@ -67,12 +67,8 @@ private fun getBorderColor(isFocused: Boolean, error: String): Color {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* @param onRightIconPressed Deprecated: use [onPressTrailing].
|
|
73
|
-
* @param trailing Icon key or URL; wins over [icon] when not empty.
|
|
74
|
-
* @param trailingColor Wins over [iconColor] when set.
|
|
75
|
-
* @param onPressTrailing Wins over [onRightIconPressed] when set.
|
|
70
|
+
* [icon], [iconColor] and [onRightIconPressed] are deprecated aliases of [trailing] (icon key or URL),
|
|
71
|
+
* [trailingColor] and [onPressTrailing]; the new param wins when set ([trailing] when not empty).
|
|
76
72
|
*/
|
|
77
73
|
@Composable
|
|
78
74
|
fun InputPhoneNumber(
|
|
@@ -95,17 +91,15 @@ fun InputPhoneNumber(
|
|
|
95
91
|
modifier: Modifier = Modifier,
|
|
96
92
|
inputModifier: Modifier = Modifier,
|
|
97
93
|
) {
|
|
98
|
-
// Consolidated state management
|
|
99
94
|
var inputState by remember { mutableStateOf(InputState()) }
|
|
100
95
|
|
|
101
|
-
// Memoized color calculations
|
|
102
96
|
val theme = AppTheme.current
|
|
103
97
|
val colors = remember(theme, iconColor, trailingColor) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
98
|
+
Triple(
|
|
99
|
+
theme.colors.text.default,
|
|
100
|
+
theme.colors.text.hint,
|
|
101
|
+
trailingColor ?: iconColor
|
|
102
|
+
)
|
|
109
103
|
}
|
|
110
104
|
|
|
111
105
|
val (textColor, placeholderColor, iconTintColor) = colors
|
|
@@ -164,7 +158,6 @@ fun InputPhoneNumber(
|
|
|
164
158
|
modifier = Modifier.padding(horizontal = Spacing.M),
|
|
165
159
|
verticalAlignment = Alignment.CenterVertically
|
|
166
160
|
) {
|
|
167
|
-
// Leading icon
|
|
168
161
|
Image(
|
|
169
162
|
source = "https://static.momocdn.net/app/img/icon/ic-qrcode-package/ic_vn_flag.png",
|
|
170
163
|
modifier = Modifier.size(24.dp).padding(end = Spacing.XS),
|
|
@@ -230,7 +223,6 @@ fun InputPhoneNumber(
|
|
|
230
223
|
}
|
|
231
224
|
},
|
|
232
225
|
)
|
|
233
|
-
// Error/hint display
|
|
234
226
|
ErrorView(error, errorSpacing, hintText)
|
|
235
227
|
}
|
|
236
228
|
}
|
|
@@ -95,7 +95,6 @@ fun InputTextArea(
|
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
97
|
decorationBox = { innerTextField ->
|
|
98
|
-
// Floating Icon
|
|
99
98
|
FloatingLabel(
|
|
100
99
|
floatingValue = floatingValue,
|
|
101
100
|
floatingIcon = floatingIcon,
|
|
@@ -104,7 +103,7 @@ fun InputTextArea(
|
|
|
104
103
|
offsetY = -scaleHeight / 2,
|
|
105
104
|
required = required,
|
|
106
105
|
)
|
|
107
|
-
//
|
|
106
|
+
// Input container
|
|
108
107
|
Box(
|
|
109
108
|
modifier = Modifier.fillMaxWidth()
|
|
110
109
|
.background(
|
|
@@ -179,7 +178,6 @@ fun InputTextArea(
|
|
|
179
178
|
}
|
|
180
179
|
},
|
|
181
180
|
)
|
|
182
|
-
// show error
|
|
183
181
|
ErrorView(error, errorSpacing, "")
|
|
184
182
|
}
|
|
185
183
|
}
|
|
@@ -8,7 +8,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
8
8
|
import androidx.compose.runtime.Composable
|
|
9
9
|
import androidx.compose.ui.Alignment
|
|
10
10
|
import androidx.compose.ui.Modifier
|
|
11
|
-
import androidx.compose.ui.graphics.Color
|
|
12
11
|
import androidx.compose.ui.unit.dp
|
|
13
12
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
14
13
|
import vn.momo.kits.const.Colors
|
|
@@ -23,7 +22,7 @@ fun PaginationNumber(
|
|
|
23
22
|
) {
|
|
24
23
|
BoxWithConstraints(
|
|
25
24
|
modifier = Modifier.background(
|
|
26
|
-
color =
|
|
25
|
+
color = Colors.opacity_black_20,
|
|
27
26
|
shape = RoundedCornerShape(Spacing.L)
|
|
28
27
|
)
|
|
29
28
|
.conditional(IsShowBaseLineDebug) {
|
|
@@ -38,14 +38,12 @@ fun PaginationScroll(
|
|
|
38
38
|
val scrollState = rememberScrollState()
|
|
39
39
|
val theme = AppTheme.current
|
|
40
40
|
|
|
41
|
-
// Use derivedStateOf to optimize scroll position calculations
|
|
42
41
|
val indicatorOffset by remember {
|
|
43
42
|
derivedStateOf {
|
|
44
43
|
calculateOffset(scrollState.value, scrollState.maxValue)
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
// Cache theme colors to avoid repeated access
|
|
49
47
|
val (progressBackground, indicatorColor) = remember(theme) {
|
|
50
48
|
theme.colors.background.pressed to theme.colors.primary
|
|
51
49
|
}
|
|
@@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.padding
|
|
|
7
7
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
8
8
|
import androidx.compose.runtime.Composable
|
|
9
9
|
import androidx.compose.ui.Modifier
|
|
10
|
-
import androidx.compose.ui.graphics.Color
|
|
11
10
|
import androidx.compose.ui.unit.dp
|
|
12
11
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
13
12
|
import vn.momo.kits.const.Colors
|
|
@@ -21,7 +20,7 @@ fun PaginationWhiteDot(
|
|
|
21
20
|
) {
|
|
22
21
|
Row(
|
|
23
22
|
modifier = Modifier.background(
|
|
24
|
-
color =
|
|
23
|
+
color = Colors.opacity_black_20,
|
|
25
24
|
shape = RoundedCornerShape(Spacing.S)
|
|
26
25
|
)
|
|
27
26
|
.conditional(IsShowBaseLineDebug) {
|
|
@@ -186,8 +186,7 @@ private fun ProgressInfoVertical(
|
|
|
186
186
|
steps.forEachIndexed { index, item ->
|
|
187
187
|
val isLast = index == steps.lastIndex
|
|
188
188
|
|
|
189
|
-
// Intrinsic height lets the connector fill the row in one pass
|
|
190
|
-
// feeding it back lagged a frame and never let the line shrink with its text.
|
|
189
|
+
// Intrinsic height lets the connector fill the row in one pass and shrink with its text.
|
|
191
190
|
Row(
|
|
192
191
|
modifier = Modifier
|
|
193
192
|
.fillMaxWidth()
|