@momo-kits/native-kits 0.300.7-debug → 0.300.8-beta.1-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/CLAUDE.md +12 -8
- package/README.md +8 -7
- package/compose/build.gradle.kts +2 -4
- package/compose/build.gradle.kts.backup +1 -3
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +1 -2
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsBinding.kt +60 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsHost.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +20 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +5 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +7 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +18 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +15 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +4 -2
- 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/Information.kt +1 -53
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +3 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +12 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +17 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +20 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +3 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +7 -8
- 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 +83 -82
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +6 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +9 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +13 -35
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +2 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +5 -22
- 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 +55 -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 +3 -6
- 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 +22 -50
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +11 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +18 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +5 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +123 -64
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +24 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +16 -19
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +59 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +69 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +14 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +5 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +43 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +330 -149
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +87 -70
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +92 -261
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +31 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +46 -72
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +8 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +29 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +8 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +9 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +26 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +4 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +2 -3
- package/compose/src/commonTest/kotlin/vn/momo/kits/application/KitsHostTest.kt +44 -0
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +2 -7
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +9 -18
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +1 -1
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +3 -6
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +5 -6
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +12 -12
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +11 -6
- package/gradle/libs.versions.toml +1 -3
- package/gradle.properties +1 -3
- package/ios/Application/ApplicationEnvironment.swift +6 -4
- package/ios/Application/DesignSystemKits.swift +59 -13
- package/ios/Application/DesignSystemKitsPayload.swift +0 -8
- package/ios/Application/LanguageSource.swift +2 -11
- package/ios/Application/Localize.swift +8 -35
- package/ios/Application/LocalizeModifier.swift +2 -11
- package/ios/Application/MaxApi.swift +3 -11
- package/ios/Avatar/Avatar.swift +0 -1
- package/ios/Badge/Badge.swift +5 -8
- package/ios/Badge/BadgeRibbon.swift +2 -5
- package/ios/Button/Button.swift +4 -8
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +5 -7
- package/ios/Carousel/Carousel.swift +4 -17
- package/ios/Checkbox/Checkbox.swift +0 -2
- package/ios/Collapse/Collapse.swift +17 -11
- 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/ActiveOpacityButtonStyle.swift +2 -3
- package/ios/Extensions/Color++.swift +2 -4
- package/ios/Extensions/SkeletonUICompat.swift +0 -8
- package/ios/Icon/Icon.swift +3 -6
- package/ios/IconButton/IconButton.swift +2 -5
- package/ios/Input/ErrorView.swift +0 -7
- package/ios/Input/Input.swift +9 -20
- package/ios/Input/InputPhoneNumber.swift +37 -20
- package/ios/Input/InputSearch.swift +23 -12
- package/ios/Input/InputTextArea.swift +4 -13
- package/ios/InputDropDown/InputDropDown.swift +1 -11
- package/ios/InputMoney/InputMoney.swift +9 -28
- package/ios/InputOTP/InputOTP.swift +2 -9
- package/ios/Layout/HeaderLayout.swift +72 -0
- package/ios/Layout/Item.swift +1 -2
- package/ios/Layout/ModalLayout.swift +144 -0
- package/ios/Layout/ScreenLayout.swift +48 -31
- package/ios/Layout/Section.swift +2 -3
- package/ios/Loader/Loader.swift +3 -12
- package/ios/Lottie/LottieView.swift +0 -11
- package/ios/Navigation/BottomSheet.swift +73 -94
- package/ios/Navigation/BottomTab/BottomTab.swift +58 -73
- package/ios/Navigation/BottomTab/BottomTabBar.swift +286 -121
- package/ios/Navigation/BottomTab/CurvedContainer.swift +52 -54
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +5 -12
- package/ios/Navigation/BottomTab/DuoTabBar.swift +67 -202
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +97 -0
- package/ios/Navigation/Component/FloatingButton.swift +4 -11
- package/ios/Navigation/Component/Header.swift +35 -54
- package/ios/Navigation/Component/HeaderBackground.swift +2 -8
- package/ios/Navigation/Component/HeaderJourney.swift +4 -8
- package/ios/Navigation/Component/HeaderLocation.swift +4 -8
- package/ios/Navigation/Component/HeaderRight.swift +20 -22
- package/ios/Navigation/Component/HeaderTitle.swift +1 -6
- package/ios/Navigation/Component/HeaderUser.swift +4 -10
- package/ios/Navigation/Component/SideBar.swift +6 -21
- package/ios/Navigation/Component/SnackBar.swift +9 -13
- package/ios/Navigation/HostBackGestureBridge.swift +2 -9
- package/ios/Navigation/ModalScreen.swift +24 -13
- package/ios/Navigation/Navigation.swift +35 -19
- package/ios/Navigation/NavigationContainer.swift +4 -15
- package/ios/Navigation/Navigator.swift +21 -39
- package/ios/Navigation/StackScreen.swift +64 -51
- package/ios/Navigation/StackTransition.swift +7 -14
- 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 +7 -5
- package/ios/Popup/PopupInput.swift +6 -4
- package/ios/Popup/PopupLayout.swift +17 -9
- package/ios/Popup/PopupNotify.swift +32 -25
- 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 +5 -16
- 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 +29 -26
- package/ios/Swipeable/SwipeCell.swift +2 -2
- package/ios/Swipeable/SwipeCellModel.swift +3 -6
- package/ios/TabView/TabView.swift +14 -28
- package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
- package/ios/Title/Title.swift +1 -3
- package/ios/Tooltip/Tooltip.swift +4 -9
- package/ios/Typography/FontScale.swift +79 -24
- package/ios/Typography/Text.swift +6 -12
- package/ios/Typography/Typography.swift +8 -11
- package/ios/Uploader/Uploader.swift +2 -17
- package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
- package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +11 -2
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +296 -59
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +15 -4
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +114 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
- package/package.json +1 -1
- package/publish.sh +8 -2
- package/scripts/ci/build-swiftui.sh +22 -0
- package/scripts/ci/resolve-version.mjs +144 -0
- package/settings.gradle.kts +0 -1
|
@@ -244,8 +244,7 @@ fun getButtonBackgroundColor(
|
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
private fun Color.withLoading(loading: Boolean): Color =
|
|
248
|
-
this.copy(alpha = if (loading) 0.75f else 1f)
|
|
247
|
+
private fun Color.withLoading(loading: Boolean): Color = this.copy(alpha = if (loading) 0.75f else 1f)
|
|
249
248
|
|
|
250
249
|
@Composable
|
|
251
250
|
fun Button(
|
|
@@ -284,21 +283,20 @@ fun Button(
|
|
|
284
283
|
label = "buttonPressAlpha"
|
|
285
284
|
)
|
|
286
285
|
|
|
287
|
-
val clickableModifier =
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
286
|
+
val clickableModifier = if (isEnabled && !loading) {
|
|
287
|
+
modifier
|
|
288
|
+
.clip(RoundedCornerShape(radius))
|
|
289
|
+
.clickable(
|
|
290
|
+
enabled = isEnabled && !loading,
|
|
291
|
+
interactionSource = interactionSource,
|
|
292
|
+
indication = null,
|
|
293
|
+
onClick = onClick
|
|
294
|
+
)
|
|
295
|
+
.alpha(alpha)
|
|
296
|
+
} else {
|
|
297
|
+
modifier
|
|
298
|
+
.clip(RoundedCornerShape(radius))
|
|
299
|
+
}
|
|
302
300
|
|
|
303
301
|
val bgColor = getButtonBackgroundColor(loading, type)
|
|
304
302
|
val textColor = getTextColor(loading, type)
|
|
@@ -327,7 +325,6 @@ fun Button(
|
|
|
327
325
|
}
|
|
328
326
|
)
|
|
329
327
|
|
|
330
|
-
// Content
|
|
331
328
|
Row(
|
|
332
329
|
modifier = Modifier
|
|
333
330
|
.padding(horizontal = sizeSpecs.padding)
|
|
@@ -49,8 +49,10 @@ fun Chip(
|
|
|
49
49
|
ChipSize.LARGE -> ChipDefaults.Large
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
val
|
|
53
|
-
|
|
52
|
+
val height = scaleSize(dims.height)
|
|
53
|
+
val horizontal = scaleSize(dims.horizontal)
|
|
54
|
+
val iconSize = scaleSize(dims.iconSize)
|
|
55
|
+
val iconSpacing = scaleSize(dims.iconSpacing)
|
|
54
56
|
|
|
55
57
|
val radius = scaleSize(Radius.L)
|
|
56
58
|
|
|
@@ -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)) {
|
|
@@ -9,20 +9,13 @@ import androidx.compose.runtime.Composable
|
|
|
9
9
|
import androidx.compose.runtime.remember
|
|
10
10
|
import androidx.compose.ui.Modifier
|
|
11
11
|
import androidx.compose.ui.draw.clip
|
|
12
|
-
import androidx.compose.ui.text.AnnotatedString
|
|
13
|
-
import androidx.compose.ui.text.SpanStyle
|
|
14
|
-
import androidx.compose.ui.text.buildAnnotatedString
|
|
15
|
-
import androidx.compose.ui.text.font.FontSynthesis
|
|
16
12
|
import androidx.compose.ui.text.style.TextAlign
|
|
17
|
-
import androidx.compose.ui.text.withStyle
|
|
18
13
|
import androidx.compose.ui.unit.dp
|
|
19
14
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
20
|
-
import vn.momo.kits.const.AppTheme
|
|
21
15
|
import vn.momo.kits.const.Colors
|
|
22
16
|
import vn.momo.kits.const.Radius
|
|
23
17
|
import vn.momo.kits.const.Spacing
|
|
24
18
|
import vn.momo.kits.const.Typography
|
|
25
|
-
import vn.momo.kits.const.getFontFamily
|
|
26
19
|
import vn.momo.kits.modifier.conditional
|
|
27
20
|
import vn.momo.kits.modifier.setAutomationId
|
|
28
21
|
|
|
@@ -69,21 +62,7 @@ fun Information(
|
|
|
69
62
|
iconSource = "24_notifications_alert_octagon"
|
|
70
63
|
}
|
|
71
64
|
|
|
72
|
-
|
|
73
|
-
// faux-bolded again; fontWeight still applies when no host font is bundled and the system font is used.
|
|
74
|
-
val highlightWeight = Typography.headerXsSemibold.fontWeight
|
|
75
|
-
val highlightFontFamily = getFontFamily(AppTheme.current.font, highlightWeight)
|
|
76
|
-
val annotatedDescription = remember(description, highlightText, highlightFontFamily) {
|
|
77
|
-
highlightDescription(
|
|
78
|
-
description,
|
|
79
|
-
highlightText,
|
|
80
|
-
SpanStyle(
|
|
81
|
-
fontFamily = highlightFontFamily,
|
|
82
|
-
fontWeight = highlightWeight,
|
|
83
|
-
fontSynthesis = FontSynthesis.None,
|
|
84
|
-
),
|
|
85
|
-
)
|
|
86
|
-
}
|
|
65
|
+
val annotatedDescription = rememberHighlightedText(description, highlightText)
|
|
87
66
|
|
|
88
67
|
Column(
|
|
89
68
|
modifier = Modifier.border(
|
|
@@ -156,34 +135,3 @@ fun Information(
|
|
|
156
135
|
}
|
|
157
136
|
|
|
158
137
|
}
|
|
159
|
-
|
|
160
|
-
// Whole-word matches only; the longest keyword wins when keywords overlap (RN parity).
|
|
161
|
-
private fun highlightDescription(
|
|
162
|
-
description: String,
|
|
163
|
-
highlightText: List<String>,
|
|
164
|
-
style: SpanStyle,
|
|
165
|
-
): AnnotatedString {
|
|
166
|
-
val keywords = highlightText.filter { it.isNotEmpty() }
|
|
167
|
-
if (keywords.isEmpty()) return AnnotatedString(description)
|
|
168
|
-
val regex = Regex(keywords.sortedByDescending { it.length }.joinToString("|") { Regex.escape(it) })
|
|
169
|
-
fun isWordChar(index: Int) = description.getOrNull(index)?.let { it.isLetterOrDigit() || it == '_' } == true
|
|
170
|
-
|
|
171
|
-
return buildAnnotatedString {
|
|
172
|
-
var lastIndex = 0
|
|
173
|
-
var searchFrom = 0
|
|
174
|
-
while (true) {
|
|
175
|
-
val match = regex.find(description, searchFrom) ?: break
|
|
176
|
-
val start = match.range.first
|
|
177
|
-
val end = match.range.last + 1
|
|
178
|
-
if (isWordChar(start - 1) || isWordChar(end)) {
|
|
179
|
-
searchFrom = start + 1
|
|
180
|
-
continue
|
|
181
|
-
}
|
|
182
|
-
append(description.substring(lastIndex, start))
|
|
183
|
-
withStyle(style) { append(match.value) }
|
|
184
|
-
lastIndex = end
|
|
185
|
-
searchFrom = end
|
|
186
|
-
}
|
|
187
|
-
append(description.substring(lastIndex))
|
|
188
|
-
}
|
|
189
|
-
}
|
|
@@ -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
|
}
|
|
@@ -44,8 +44,8 @@ fun InputDropDown(
|
|
|
44
44
|
) {
|
|
45
45
|
val isFocused by remember { mutableStateOf(false) }
|
|
46
46
|
|
|
47
|
-
val (
|
|
48
|
-
|
|
47
|
+
val colors = getInputColors(disabled, iconColor, floatingValueColor, floatingIconColor)
|
|
48
|
+
val (textColor, placeholderColor, iconTintColor, floatingTitleColor, floatingIconTintColor) = colors
|
|
49
49
|
|
|
50
50
|
val testId = if (disabled) "input_${floatingValue}_disabled" else "input_$floatingValue"
|
|
51
51
|
|
|
@@ -83,7 +83,6 @@ fun InputDropDown(
|
|
|
83
83
|
modifier = Modifier.padding(horizontal = Spacing.M),
|
|
84
84
|
verticalAlignment = Alignment.CenterVertically
|
|
85
85
|
) {
|
|
86
|
-
//leading icon
|
|
87
86
|
if (leadingIcon.isNotEmpty()) {
|
|
88
87
|
Icon(
|
|
89
88
|
source = leadingIcon,
|
|
@@ -58,8 +58,10 @@ private fun normalizeDigits(text: String) = digitsOf(text).let { digits ->
|
|
|
58
58
|
digits.trimStart('0').ifEmpty { digits.take(1) }
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
private fun moneyDisplay(digits: String)
|
|
62
|
-
if (digits.isEmpty())
|
|
61
|
+
private fun moneyDisplay(digits: String): String {
|
|
62
|
+
if (digits.isEmpty()) return ""
|
|
63
|
+
return digits.reversed().chunked(3).joinToString(".").reversed() + MONEY_CURRENCY
|
|
64
|
+
}
|
|
63
65
|
|
|
64
66
|
// Caret position right after the `digitIndex`-th digit of `display`.
|
|
65
67
|
private fun caretFromDigitIndex(display: String, digitIndex: Int): Int {
|
|
@@ -78,19 +80,16 @@ private fun detectEdit(old: String, next: String, caret: Int): MoneyEdit {
|
|
|
78
80
|
while (prefix < minOf(caret, old.length - tail) && old[prefix] == next[prefix]) prefix++
|
|
79
81
|
return MoneyEdit(prefix, old.length - tail, next.substring(prefix, caret))
|
|
80
82
|
}
|
|
83
|
+
val minLength = minOf(old.length, next.length)
|
|
81
84
|
var prefix = 0
|
|
82
|
-
while (prefix <
|
|
85
|
+
while (prefix < minLength && old[prefix] == next[prefix]) prefix++
|
|
83
86
|
var suffix = 0
|
|
84
|
-
while (suffix <
|
|
85
|
-
old[old.length - 1 - suffix] == next[next.length - 1 - suffix]
|
|
86
|
-
) suffix++
|
|
87
|
+
while (suffix < minLength - prefix && old[old.length - 1 - suffix] == next[next.length - 1 - suffix]) suffix++
|
|
87
88
|
return MoneyEdit(prefix, old.length - suffix, next.substring(prefix, next.length - suffix))
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
// only the currency leaves the digits untouched.
|
|
93
|
-
// Returns the new digits and the caret as a digit index.
|
|
91
|
+
// Separators and currency are never deleted: removing a separator removes the digit before it, removing
|
|
92
|
+
// only the currency is a no-op. Returns the new digits and the caret as a digit index.
|
|
94
93
|
private fun applyEdit(display: String, edit: MoneyEdit): Pair<String, Int> {
|
|
95
94
|
val digits = digitsOf(display)
|
|
96
95
|
var left = digitsOf(display.substring(0, edit.start)).length
|
|
@@ -137,8 +136,8 @@ fun InputMoney(
|
|
|
137
136
|
val current = if (digitsOf(field.text) == digits) field else moneyDisplay(digits).let {
|
|
138
137
|
TextFieldValue(it, TextRange(caretFromDigitIndex(it, digits.length)))
|
|
139
138
|
}
|
|
140
|
-
val (
|
|
141
|
-
|
|
139
|
+
val colors = getInputColors(disabled, iconColor, floatingValueColor, floatingIconColor)
|
|
140
|
+
val (textColor, placeholderColor, iconTintColor, floatingTitleColor, floatingIconTintColor) = colors
|
|
142
141
|
|
|
143
142
|
val testId = if (disabled) "input_${floatingValue}_disabled" else "input_$floatingValue"
|
|
144
143
|
|
|
@@ -190,7 +189,6 @@ fun InputMoney(
|
|
|
190
189
|
}
|
|
191
190
|
},
|
|
192
191
|
decorationBox = { innerTextField ->
|
|
193
|
-
// Floating Icon
|
|
194
192
|
FloatingLabel(
|
|
195
193
|
floatingValue = floatingValue,
|
|
196
194
|
floatingIcon = floatingIcon,
|
|
@@ -199,7 +197,7 @@ fun InputMoney(
|
|
|
199
197
|
offsetY = -size.values.height / 2,
|
|
200
198
|
required = required,
|
|
201
199
|
)
|
|
202
|
-
//
|
|
200
|
+
// Input container
|
|
203
201
|
Box(
|
|
204
202
|
modifier = Modifier.fillMaxWidth()
|
|
205
203
|
.border(
|
|
@@ -213,7 +211,6 @@ fun InputMoney(
|
|
|
213
211
|
modifier = Modifier.padding(horizontal = Spacing.M),
|
|
214
212
|
verticalAlignment = Alignment.CenterVertically
|
|
215
213
|
) {
|
|
216
|
-
//leading icon
|
|
217
214
|
if (leadingIcon.isNotEmpty()) {
|
|
218
215
|
Icon(
|
|
219
216
|
source = leadingIcon,
|
|
@@ -103,10 +103,9 @@ fun InputOTP(
|
|
|
103
103
|
var isFocused by remember { mutableStateOf(false) }
|
|
104
104
|
|
|
105
105
|
val handleChangeText: (String) -> Unit = { text ->
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
) {
|
|
106
|
+
val fitsLength = text.length <= maxLength
|
|
107
|
+
val matchesType = dataType != "number" || text.all { it.isDigit() }
|
|
108
|
+
if (fitsLength && matchesType && text.length != value.length) {
|
|
110
109
|
onChangeText(text)
|
|
111
110
|
}
|
|
112
111
|
}
|
|
@@ -178,12 +177,15 @@ fun InputOTP(
|
|
|
178
177
|
if (isFocused && value.length == i) {
|
|
179
178
|
OTPCaret()
|
|
180
179
|
} else {
|
|
181
|
-
val
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
val digit = value.getOrNull(i)
|
|
181
|
+
var textColor = AppTheme.current.colors.text.hint
|
|
182
|
+
var typo = Typography.descriptionDefaultRegular
|
|
183
|
+
if (digit != null) {
|
|
184
|
+
textColor = AppTheme.current.colors.text.default
|
|
185
|
+
typo = Typography.headerDefaultBold
|
|
186
|
+
}
|
|
185
187
|
Text(
|
|
186
|
-
text =
|
|
188
|
+
text = digit?.toString() ?: "-",
|
|
187
189
|
color = textColor,
|
|
188
190
|
style = typo
|
|
189
191
|
)
|