@momo-kits/native-kits 0.162.0-debug → 0.162.1-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/settings.local.json +32 -0
- package/compose/build.gradle.kts +66 -63
- package/compose/build.gradle.kts.backup +66 -63
- package/compose/compose.podspec +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +2 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +6 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +4 -19
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +1 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +5 -16
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +6 -101
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +4 -16
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +9 -34
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +1 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +27 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +3 -26
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +27 -30
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +3 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +3 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +3 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +11 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +3 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +84 -59
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +13 -71
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +10 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +6 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +4 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +15 -76
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +5 -26
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +3 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +15 -36
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -28
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +2 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +4 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +3 -28
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +8 -47
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +4 -25
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +2 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +1 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +1 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +50 -111
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +1 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +4 -96
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +2 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +9 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +9 -14
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +8 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +3 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +5 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +6 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +55 -55
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +3 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +12 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +6 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +55 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +2 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +6 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +5 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +3 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +3 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +1 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Deprecated.kt +107 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +3 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +3 -3
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +2 -3
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -2
- package/gradle.properties +1 -1
- package/local.properties +2 -2
- package/package.json +1 -1
- package/publish.sh +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -14
- package/example/ios/Example.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -5
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/Pods-Example.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImage.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SkeletonUI.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -46
|
@@ -5,28 +5,9 @@ import androidx.compose.foundation.background
|
|
|
5
5
|
import androidx.compose.foundation.border
|
|
6
6
|
import androidx.compose.foundation.clickable
|
|
7
7
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
8
|
-
import androidx.compose.foundation.layout
|
|
9
|
-
import androidx.compose.foundation.layout.Box
|
|
10
|
-
import androidx.compose.foundation.layout.Column
|
|
11
|
-
import androidx.compose.foundation.layout.IntrinsicSize
|
|
12
|
-
import androidx.compose.foundation.layout.Row
|
|
13
|
-
import androidx.compose.foundation.layout.Spacer
|
|
14
|
-
import androidx.compose.foundation.layout.fillMaxWidth
|
|
15
|
-
import androidx.compose.foundation.layout.height
|
|
16
|
-
import androidx.compose.foundation.layout.offset
|
|
17
|
-
import androidx.compose.foundation.layout.padding
|
|
18
|
-
import androidx.compose.foundation.layout.size
|
|
19
|
-
import androidx.compose.foundation.layout.width
|
|
20
|
-
import androidx.compose.foundation.layout.widthIn
|
|
21
|
-
import androidx.compose.foundation.layout.wrapContentSize
|
|
8
|
+
import androidx.compose.foundation.layout.*
|
|
22
9
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
23
|
-
import androidx.compose.runtime
|
|
24
|
-
import androidx.compose.runtime.LaunchedEffect
|
|
25
|
-
import androidx.compose.runtime.Stable
|
|
26
|
-
import androidx.compose.runtime.getValue
|
|
27
|
-
import androidx.compose.runtime.mutableStateOf
|
|
28
|
-
import androidx.compose.runtime.remember
|
|
29
|
-
import androidx.compose.runtime.setValue
|
|
10
|
+
import androidx.compose.runtime.*
|
|
30
11
|
import androidx.compose.ui.Alignment
|
|
31
12
|
import androidx.compose.ui.Modifier
|
|
32
13
|
import androidx.compose.ui.draw.clip
|
|
@@ -36,63 +17,32 @@ import androidx.compose.ui.graphics.PathEffect
|
|
|
36
17
|
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
|
|
37
18
|
import androidx.compose.ui.platform.LocalDensity
|
|
38
19
|
import androidx.compose.ui.text.style.TextOverflow
|
|
39
|
-
import androidx.compose.ui.unit
|
|
40
|
-
import androidx.compose.ui.unit.IntRect
|
|
41
|
-
import androidx.compose.ui.unit.IntSize
|
|
42
|
-
import androidx.compose.ui.unit.LayoutDirection
|
|
43
|
-
import androidx.compose.ui.unit.dp
|
|
20
|
+
import androidx.compose.ui.unit.*
|
|
44
21
|
import androidx.compose.ui.window.Popup
|
|
45
22
|
import androidx.compose.ui.window.PopupPositionProvider
|
|
46
23
|
import androidx.compose.ui.window.PopupProperties
|
|
47
24
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
48
|
-
import vn.momo.kits.const
|
|
49
|
-
import vn.momo.kits.const.Radius
|
|
50
|
-
import vn.momo.kits.const.Spacing
|
|
51
|
-
import vn.momo.kits.const.Typography
|
|
52
|
-
import vn.momo.kits.const.scaleSize
|
|
25
|
+
import vn.momo.kits.const.*
|
|
53
26
|
import vn.momo.kits.modifier.activeOpacityClickable
|
|
54
27
|
import vn.momo.kits.modifier.conditional
|
|
55
28
|
|
|
56
29
|
|
|
57
|
-
// region Types
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Tooltip placement relative to the anchor element.
|
|
61
|
-
*/
|
|
62
30
|
enum class TooltipPlacement {
|
|
63
31
|
TOP,
|
|
64
32
|
BOTTOM,
|
|
65
33
|
LEFT,
|
|
66
34
|
RIGHT,
|
|
67
35
|
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Cross-axis alignment of the tooltip relative to the anchor.
|
|
71
|
-
*/
|
|
72
36
|
enum class TooltipAlign {
|
|
73
37
|
START,
|
|
74
38
|
CENTER,
|
|
75
39
|
END,
|
|
76
40
|
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Describes a single action button displayed in the tooltip.
|
|
80
|
-
*
|
|
81
|
-
* @param title Text label for the button (used for text buttons).
|
|
82
|
-
* @param icon Icon source for the button (used for icon buttons).
|
|
83
|
-
* @param onPress Callback invoked when the button is pressed.
|
|
84
|
-
*/
|
|
85
41
|
data class TooltipButton(
|
|
86
42
|
val title: String? = null,
|
|
87
43
|
val icon: String? = null,
|
|
88
44
|
val onPress: (() -> Unit)? = null,
|
|
89
45
|
)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* State holder for controlling tooltip visibility imperatively.
|
|
94
|
-
* Equivalent to the React Native `useImperativeHandle` ref pattern.
|
|
95
|
-
*/
|
|
96
46
|
@Stable
|
|
97
47
|
class TooltipState {
|
|
98
48
|
var isVisible by mutableStateOf(false)
|
|
@@ -113,30 +63,12 @@ class TooltipState {
|
|
|
113
63
|
isVisible = !isVisible
|
|
114
64
|
}
|
|
115
65
|
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Creates and remembers a [TooltipState].
|
|
119
|
-
*/
|
|
120
66
|
@Composable
|
|
121
67
|
fun rememberTooltipState(): TooltipState {
|
|
122
68
|
return remember { TooltipState() }
|
|
123
69
|
}
|
|
124
70
|
private val TOOLTIP_OFFSET = Spacing.S
|
|
125
71
|
private val ARROW_SIZE = 6.dp
|
|
126
|
-
/**
|
|
127
|
-
* Custom [PopupPositionProvider] that positions the tooltip relative to the anchor.
|
|
128
|
-
*
|
|
129
|
-
* Mirrors the React Native `placementStyle` calculation:
|
|
130
|
-
* - TOP: tooltip bottom edge sits at `anchorTop - TOOLTIP_OFFSET`
|
|
131
|
-
* - BOTTOM: tooltip top edge sits at `anchorBottom + TOOLTIP_OFFSET`
|
|
132
|
-
* - LEFT: tooltip right edge sits at `anchorLeft - TOOLTIP_OFFSET`
|
|
133
|
-
* - RIGHT: tooltip left edge sits at `anchorRight + TOOLTIP_OFFSET`
|
|
134
|
-
*
|
|
135
|
-
* Cross-axis alignment:
|
|
136
|
-
* - start: tooltip aligns to anchor start edge
|
|
137
|
-
* - center: tooltip centers on anchor
|
|
138
|
-
* - end: tooltip aligns to anchor end edge
|
|
139
|
-
*/
|
|
140
72
|
private class TooltipPositionProvider(
|
|
141
73
|
private val placement: TooltipPlacement,
|
|
142
74
|
private val align: TooltipAlign,
|
|
@@ -199,27 +131,6 @@ private class TooltipPositionProvider(
|
|
|
199
131
|
}
|
|
200
132
|
}
|
|
201
133
|
|
|
202
|
-
// endregion
|
|
203
|
-
|
|
204
|
-
// region Tooltip Composable
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* A tooltip component that wraps [content] (the anchor) and shows a positioned
|
|
208
|
-
* tooltip popup with title, description, close button, and action buttons.
|
|
209
|
-
*
|
|
210
|
-
* Port of the React Native `Tooltip` component.
|
|
211
|
-
*
|
|
212
|
-
* @param state Controls visibility (use [rememberTooltipState]).
|
|
213
|
-
* @param title Title text displayed in the tooltip header.
|
|
214
|
-
* @param description Description text shown under the title.
|
|
215
|
-
* @param buttons Action buttons rendered at the bottom.
|
|
216
|
-
* @param placement Tooltip position relative to the anchor (default TOP).
|
|
217
|
-
* @param align Cross-axis alignment (default CENTER).
|
|
218
|
-
* @param onVisibleChange Callback when visibility changes.
|
|
219
|
-
* @param onPressClose Callback when the close button (X) is pressed.
|
|
220
|
-
* @param modifier Modifier for the anchor wrapper.
|
|
221
|
-
* @param content The anchor element that the tooltip is attached to.
|
|
222
|
-
*/
|
|
223
134
|
@Composable
|
|
224
135
|
fun Tooltip(
|
|
225
136
|
state: TooltipState,
|
|
@@ -525,9 +436,6 @@ private fun TooltipSingleButton(btn: TooltipButton) {
|
|
|
525
436
|
)
|
|
526
437
|
}
|
|
527
438
|
}
|
|
528
|
-
|
|
529
|
-
private const val MAX_BUTTON_LENGTH = 16
|
|
530
|
-
|
|
531
439
|
private fun String.limitWithEllipsis(max: Int = 16): String {
|
|
532
440
|
return if (length > max) take(max) + "…" else this
|
|
533
441
|
}
|
|
@@ -3,13 +3,7 @@ package vn.momo.kits.components
|
|
|
3
3
|
import androidx.compose.foundation.background
|
|
4
4
|
import androidx.compose.foundation.border
|
|
5
5
|
import androidx.compose.foundation.horizontalScroll
|
|
6
|
-
import androidx.compose.foundation.layout
|
|
7
|
-
import androidx.compose.foundation.layout.Box
|
|
8
|
-
import androidx.compose.foundation.layout.Column
|
|
9
|
-
import androidx.compose.foundation.layout.Row
|
|
10
|
-
import androidx.compose.foundation.layout.fillMaxSize
|
|
11
|
-
import androidx.compose.foundation.layout.padding
|
|
12
|
-
import androidx.compose.foundation.layout.size
|
|
6
|
+
import androidx.compose.foundation.layout.*
|
|
13
7
|
import androidx.compose.foundation.rememberScrollState
|
|
14
8
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
15
9
|
import androidx.compose.runtime.Composable
|
|
@@ -25,11 +19,7 @@ import androidx.compose.ui.graphics.drawscope.Stroke
|
|
|
25
19
|
import androidx.compose.ui.unit.Dp
|
|
26
20
|
import androidx.compose.ui.unit.dp
|
|
27
21
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
28
|
-
import vn.momo.kits.const
|
|
29
|
-
import vn.momo.kits.const.Colors
|
|
30
|
-
import vn.momo.kits.const.Radius
|
|
31
|
-
import vn.momo.kits.const.Spacing
|
|
32
|
-
import vn.momo.kits.const.Typography
|
|
22
|
+
import vn.momo.kits.const.*
|
|
33
23
|
import vn.momo.kits.modifier.activeOpacityClickable
|
|
34
24
|
import vn.momo.kits.modifier.conditional
|
|
35
25
|
|
package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt
CHANGED
|
@@ -2,20 +2,8 @@ package vn.momo.kits.components.datetimepicker
|
|
|
2
2
|
|
|
3
3
|
import androidx.compose.foundation.background
|
|
4
4
|
import androidx.compose.foundation.border
|
|
5
|
-
import androidx.compose.foundation.layout
|
|
6
|
-
import androidx.compose.
|
|
7
|
-
import androidx.compose.foundation.layout.Spacer
|
|
8
|
-
import androidx.compose.foundation.layout.fillMaxWidth
|
|
9
|
-
import androidx.compose.foundation.layout.height
|
|
10
|
-
import androidx.compose.foundation.layout.padding
|
|
11
|
-
import androidx.compose.foundation.layout.width
|
|
12
|
-
import androidx.compose.runtime.Composable
|
|
13
|
-
import androidx.compose.runtime.LaunchedEffect
|
|
14
|
-
import androidx.compose.runtime.getValue
|
|
15
|
-
import androidx.compose.runtime.mutableStateOf
|
|
16
|
-
import androidx.compose.runtime.remember
|
|
17
|
-
import androidx.compose.runtime.setValue
|
|
18
|
-
import androidx.compose.runtime.snapshotFlow
|
|
5
|
+
import androidx.compose.foundation.layout.*
|
|
6
|
+
import androidx.compose.runtime.*
|
|
19
7
|
import androidx.compose.ui.Alignment
|
|
20
8
|
import androidx.compose.ui.Modifier
|
|
21
9
|
import androidx.compose.ui.unit.dp
|
|
@@ -74,7 +62,7 @@ fun DateTimePicker(
|
|
|
74
62
|
var currentDate by remember(initialValue) {
|
|
75
63
|
mutableStateOf(
|
|
76
64
|
PickerData(
|
|
77
|
-
day = initialValue.
|
|
65
|
+
day = initialValue.day,
|
|
78
66
|
month = initialValue.month.number,
|
|
79
67
|
year = initialValue.year,
|
|
80
68
|
hour = initialValue.hour,
|
|
@@ -95,10 +83,10 @@ fun DateTimePicker(
|
|
|
95
83
|
month = when (year) {
|
|
96
84
|
effectiveMaxDate.year -> month.coerceIn(
|
|
97
85
|
1,
|
|
98
|
-
effectiveMaxDate.
|
|
86
|
+
effectiveMaxDate.month.number
|
|
99
87
|
)
|
|
100
88
|
effectiveMinDate.year -> month.coerceIn(
|
|
101
|
-
effectiveMinDate.
|
|
89
|
+
effectiveMinDate.month.number,
|
|
102
90
|
12,
|
|
103
91
|
)
|
|
104
92
|
else -> month
|
|
@@ -112,11 +100,11 @@ fun DateTimePicker(
|
|
|
112
100
|
}
|
|
113
101
|
|
|
114
102
|
day = when {
|
|
115
|
-
year == effectiveMaxDate.year && month == effectiveMaxDate.
|
|
116
|
-
day.coerceIn(1, effectiveMaxDate.
|
|
103
|
+
year == effectiveMaxDate.year && month == effectiveMaxDate.month.number ->
|
|
104
|
+
day.coerceIn(1, effectiveMaxDate.day)
|
|
117
105
|
|
|
118
|
-
year == effectiveMinDate.year && month == effectiveMinDate.
|
|
119
|
-
day.coerceIn(effectiveMinDate.
|
|
106
|
+
year == effectiveMinDate.year && month == effectiveMinDate.month.number ->
|
|
107
|
+
day.coerceIn(effectiveMinDate.day, maxDayOfMonth)
|
|
120
108
|
|
|
121
109
|
day > maxDayOfMonth -> maxDayOfMonth
|
|
122
110
|
else -> day
|
package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt
CHANGED
|
@@ -2,15 +2,10 @@ package vn.momo.kits.components.datetimepicker
|
|
|
2
2
|
|
|
3
3
|
import androidx.compose.runtime.Composable
|
|
4
4
|
import androidx.compose.runtime.remember
|
|
5
|
+
import kotlinx.datetime.*
|
|
6
|
+
import kotlinx.datetime.number
|
|
5
7
|
import kotlin.time.Clock
|
|
6
8
|
import kotlin.time.ExperimentalTime
|
|
7
|
-
import kotlinx.datetime.DatePeriod
|
|
8
|
-
import kotlinx.datetime.LocalDateTime
|
|
9
|
-
import kotlinx.datetime.TimeZone
|
|
10
|
-
import kotlinx.datetime.minus
|
|
11
|
-
import kotlinx.datetime.number
|
|
12
|
-
import kotlinx.datetime.plus
|
|
13
|
-
import kotlinx.datetime.toLocalDateTime
|
|
14
9
|
|
|
15
10
|
/**
|
|
16
11
|
* Format a LocalDateTime object into a string
|
|
@@ -19,13 +14,13 @@ fun formatLocalDateTime(dateTime: LocalDateTime, format: String = "yyyy-MM-dd HH
|
|
|
19
14
|
return when (format) {
|
|
20
15
|
"yyyy-MM-dd HH:mm" -> "${dateTime.year}-${paddingNum(dateTime.month.number)}-${
|
|
21
16
|
paddingNum(
|
|
22
|
-
dateTime.
|
|
17
|
+
dateTime.day
|
|
23
18
|
)
|
|
24
19
|
} ${paddingNum(dateTime.hour)}:${paddingNum(dateTime.minute)}"
|
|
25
20
|
|
|
26
|
-
"dd-MM-yyyy" -> "${paddingNum(dateTime.
|
|
21
|
+
"dd-MM-yyyy" -> "${paddingNum(dateTime.day)}-${paddingNum(dateTime.month.number)}-${dateTime.year}"
|
|
27
22
|
"HH:mm" -> "${paddingNum(dateTime.hour)}:${paddingNum(dateTime.minute)}"
|
|
28
|
-
else -> "${dateTime.year}-${paddingNum(dateTime.month.number)}-${paddingNum(dateTime.
|
|
23
|
+
else -> "${dateTime.year}-${paddingNum(dateTime.month.number)}-${paddingNum(dateTime.day)} ${
|
|
29
24
|
paddingNum(
|
|
30
25
|
dateTime.hour
|
|
31
26
|
)
|
|
@@ -60,11 +55,11 @@ fun getDaysInMonth(
|
|
|
60
55
|
var endDay = daysInMonth
|
|
61
56
|
|
|
62
57
|
if (year == minDate.year && month == minDate.month.number) {
|
|
63
|
-
startDay = minDate.
|
|
58
|
+
startDay = minDate.day
|
|
64
59
|
}
|
|
65
60
|
|
|
66
61
|
if (year == maxDate.year && month == maxDate.month.number) {
|
|
67
|
-
endDay = maxDate.
|
|
62
|
+
endDay = maxDate.day
|
|
68
63
|
}
|
|
69
64
|
|
|
70
65
|
val days = mutableListOf<String>()
|
|
@@ -170,8 +165,8 @@ fun createRelativeDate(years: Int): LocalDateTime {
|
|
|
170
165
|
|
|
171
166
|
return LocalDateTime(
|
|
172
167
|
adjustedDate.year,
|
|
173
|
-
adjustedDate.
|
|
174
|
-
adjustedDate.
|
|
168
|
+
adjustedDate.month.number,
|
|
169
|
+
adjustedDate.day,
|
|
175
170
|
currentDateTime.hour,
|
|
176
171
|
currentDateTime.minute
|
|
177
172
|
)
|
|
@@ -10,13 +10,7 @@ import androidx.compose.foundation.lazy.LazyColumn
|
|
|
10
10
|
import androidx.compose.foundation.lazy.LazyListState
|
|
11
11
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
|
12
12
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
13
|
-
import androidx.compose.runtime
|
|
14
|
-
import androidx.compose.runtime.LaunchedEffect
|
|
15
|
-
import androidx.compose.runtime.getValue
|
|
16
|
-
import androidx.compose.runtime.mutableStateOf
|
|
17
|
-
import androidx.compose.runtime.remember
|
|
18
|
-
import androidx.compose.runtime.setValue
|
|
19
|
-
import androidx.compose.runtime.snapshotFlow
|
|
13
|
+
import androidx.compose.runtime.*
|
|
20
14
|
import androidx.compose.ui.Alignment
|
|
21
15
|
import androidx.compose.ui.Modifier
|
|
22
16
|
import androidx.compose.ui.draw.alpha
|
|
@@ -25,6 +19,7 @@ import androidx.compose.ui.platform.LocalDensity
|
|
|
25
19
|
import androidx.compose.ui.unit.Dp
|
|
26
20
|
import androidx.compose.ui.unit.dp
|
|
27
21
|
import androidx.compose.ui.zIndex
|
|
22
|
+
import kotlinx.coroutines.FlowPreview
|
|
28
23
|
import kotlinx.coroutines.delay
|
|
29
24
|
import kotlinx.coroutines.flow.collect
|
|
30
25
|
import kotlinx.coroutines.flow.debounce
|
|
@@ -36,12 +31,14 @@ import vn.momo.kits.const.Colors
|
|
|
36
31
|
import vn.momo.kits.const.Radius
|
|
37
32
|
import vn.momo.kits.const.Typography
|
|
38
33
|
import kotlin.math.abs
|
|
34
|
+
import kotlin.time.Duration.Companion.milliseconds
|
|
39
35
|
|
|
40
36
|
private val wheelItemHeight = 42.dp
|
|
41
37
|
private val wheelPickerBorderWidth = 1.dp
|
|
42
38
|
|
|
39
|
+
@OptIn(FlowPreview::class)
|
|
43
40
|
@Composable
|
|
44
|
-
fun WheelPicker(
|
|
41
|
+
internal fun WheelPicker(
|
|
45
42
|
name: String,
|
|
46
43
|
data: List<String>,
|
|
47
44
|
selectedData: String,
|
|
@@ -68,7 +65,7 @@ fun WheelPicker(
|
|
|
68
65
|
LaunchedEffect(paddedData) {
|
|
69
66
|
snapshotFlow { selectedIndex }
|
|
70
67
|
.distinctUntilChanged()
|
|
71
|
-
.debounce(50)
|
|
68
|
+
.debounce(50.milliseconds)
|
|
72
69
|
.onEach {
|
|
73
70
|
val value = paddedData.getOrNull(it)
|
|
74
71
|
if (!value.isNullOrEmpty()) {
|
|
@@ -95,7 +92,7 @@ fun WheelPicker(
|
|
|
95
92
|
} else {
|
|
96
93
|
-abs(firstItemOffset)
|
|
97
94
|
}
|
|
98
|
-
delay(50)
|
|
95
|
+
delay(50.milliseconds)
|
|
99
96
|
listState.animateScrollBy(offset.toFloat())
|
|
100
97
|
val centeredIndex = firstItemIdx + (if (isScrollUp) 1 else 0) + 2
|
|
101
98
|
if (centeredIndex in 2 until paddedData.size - 2) {
|
|
@@ -145,7 +142,7 @@ fun WheelPicker(
|
|
|
145
142
|
}
|
|
146
143
|
|
|
147
144
|
@Composable
|
|
148
|
-
fun WheelPickerItem(
|
|
145
|
+
internal fun WheelPickerItem(
|
|
149
146
|
text: String,
|
|
150
147
|
isSelected: Boolean,
|
|
151
148
|
index: Int,
|
|
@@ -7,28 +7,13 @@ import androidx.compose.ui.text.TextStyle
|
|
|
7
7
|
import androidx.compose.ui.text.font.FontFamily
|
|
8
8
|
import androidx.compose.ui.text.font.FontWeight
|
|
9
9
|
import androidx.compose.ui.text.style.TextDecoration
|
|
10
|
-
import androidx.compose.ui.unit
|
|
11
|
-
import androidx.compose.ui.unit.TextUnit
|
|
12
|
-
import androidx.compose.ui.unit.TextUnitType
|
|
13
|
-
import androidx.compose.ui.unit.dp
|
|
14
|
-
import androidx.compose.ui.unit.sp
|
|
10
|
+
import androidx.compose.ui.unit.*
|
|
15
11
|
import org.jetbrains.compose.resources.Font
|
|
16
12
|
import org.jetbrains.compose.resources.FontResource
|
|
17
13
|
import org.jetbrains.compose.resources.InternalResourceApi
|
|
18
14
|
import vn.momo.kits.application.ScaleSizeMaxRate
|
|
19
15
|
import vn.momo.kits.platform.getScreenDimensions
|
|
20
|
-
import vn.momo.uikits.resources
|
|
21
|
-
import vn.momo.uikits.resources.momosignature
|
|
22
|
-
import vn.momo.uikits.resources.momotrustdisplay
|
|
23
|
-
import vn.momo.uikits.resources.sfprotext_black
|
|
24
|
-
import vn.momo.uikits.resources.sfprotext_bold
|
|
25
|
-
import vn.momo.uikits.resources.sfprotext_heavy
|
|
26
|
-
import vn.momo.uikits.resources.sfprotext_light
|
|
27
|
-
import vn.momo.uikits.resources.sfprotext_medium
|
|
28
|
-
import vn.momo.uikits.resources.sfprotext_regular
|
|
29
|
-
import vn.momo.uikits.resources.sfprotext_semibold
|
|
30
|
-
import vn.momo.uikits.resources.sfprotext_thin
|
|
31
|
-
import vn.momo.uikits.resources.sfprotext_ultralight
|
|
16
|
+
import vn.momo.uikits.resources.*
|
|
32
17
|
import kotlin.math.max
|
|
33
18
|
import kotlin.math.min
|
|
34
19
|
|
|
@@ -98,7 +83,7 @@ fun scaleSize(textStyle: TextStyle): TextStyle {
|
|
|
98
83
|
|
|
99
84
|
@OptIn(InternalResourceApi::class)
|
|
100
85
|
@Composable
|
|
101
|
-
fun getFont(font: FontResource): FontFamily {
|
|
86
|
+
internal fun getFont(font: FontResource): FontFamily {
|
|
102
87
|
return FontFamily(Font(font))
|
|
103
88
|
}
|
|
104
89
|
|
|
@@ -20,11 +20,6 @@ fun Modifier.setAutomationId(accessibilityId: String, mergeDescendants: Boolean
|
|
|
20
20
|
}
|
|
21
21
|
}}
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
* Alternative for [setAutomationId]
|
|
25
|
-
*
|
|
26
|
-
* reason: [link](https://developer.android.com/develop/ui/compose/custom-modifiers#composable_function_modifiers_are_never_skipped)
|
|
27
|
-
* */
|
|
28
23
|
fun Modifier.kitsAutomationId(accessibilityId: String, label: String? = null) =
|
|
29
24
|
this then KitsAutomationIdElement(accessibilityId, label)
|
|
30
25
|
|
|
@@ -10,11 +10,7 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
|
10
10
|
import androidx.compose.foundation.layout.Box
|
|
11
11
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
12
12
|
import androidx.compose.foundation.layout.wrapContentSize
|
|
13
|
-
import androidx.compose.runtime
|
|
14
|
-
import androidx.compose.runtime.DisposableEffect
|
|
15
|
-
import androidx.compose.runtime.LaunchedEffect
|
|
16
|
-
import androidx.compose.runtime.remember
|
|
17
|
-
import androidx.compose.runtime.rememberCoroutineScope
|
|
13
|
+
import androidx.compose.runtime.*
|
|
18
14
|
import androidx.compose.ui.Alignment
|
|
19
15
|
import androidx.compose.ui.Modifier
|
|
20
16
|
import androidx.compose.ui.draw.alpha
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
package vn.momo.kits.navigation
|
|
2
2
|
|
|
3
3
|
import androidx.compose.foundation.gestures.ScrollableState
|
|
4
|
-
import androidx.compose.runtime
|
|
5
|
-
import androidx.compose.runtime.Stable
|
|
6
|
-
import androidx.compose.runtime.State
|
|
7
|
-
import androidx.compose.runtime.mutableStateOf
|
|
8
|
-
import androidx.compose.runtime.staticCompositionLocalOf
|
|
4
|
+
import androidx.compose.runtime.*
|
|
9
5
|
import androidx.compose.ui.graphics.Color
|
|
10
6
|
import vn.momo.kits.navigation.bottomtab.setBottomTabOption
|
|
11
|
-
import vn.momo.kits.navigation.component
|
|
12
|
-
import vn.momo.kits.navigation.component.HeaderBackProps
|
|
13
|
-
import vn.momo.kits.navigation.component.HeaderRight
|
|
14
|
-
import vn.momo.kits.navigation.component.HeaderTitle
|
|
15
|
-
import vn.momo.kits.navigation.component.HeaderType
|
|
7
|
+
import vn.momo.kits.navigation.component.*
|
|
16
8
|
|
|
17
9
|
class Navigation(
|
|
18
10
|
val id: Int = -1,
|
|
@@ -28,6 +20,7 @@ class Navigation(
|
|
|
28
20
|
hiddenBack: Boolean? = null,
|
|
29
21
|
headerBackProps: HeaderBackProps? = null,
|
|
30
22
|
headerTitle: HeaderTitle? = null,
|
|
23
|
+
titlePosition: TitlePosition? = null,
|
|
31
24
|
headerRight: HeaderRight? = null,
|
|
32
25
|
headerType: HeaderType? = null,
|
|
33
26
|
scrollData: ScrollData? = null,
|
|
@@ -43,6 +36,7 @@ class Navigation(
|
|
|
43
36
|
hiddenBack = hiddenBack ?: options.hiddenBack,
|
|
44
37
|
headerBackProps = headerBackProps ?: options.headerBackProps,
|
|
45
38
|
headerTitle = headerTitle ?: options.headerTitle,
|
|
39
|
+
titlePosition = titlePosition ?: options.titlePosition,
|
|
46
40
|
headerRight = headerRight ?: options.headerRight,
|
|
47
41
|
headerType = headerType ?: options.headerType,
|
|
48
42
|
scrollData = scrollData ?: options.scrollData,
|
|
@@ -77,6 +71,7 @@ data class NavigationOptions(
|
|
|
77
71
|
val hiddenBack: Boolean = false,
|
|
78
72
|
val headerBackProps: HeaderBackProps = HeaderBackProps(),
|
|
79
73
|
val headerTitle: HeaderTitle = HeaderTitle.Default("Stack"),
|
|
74
|
+
val titlePosition: TitlePosition = TitlePosition.LEFT,
|
|
80
75
|
val headerRight: HeaderRight = HeaderRight.Toolkit(),
|
|
81
76
|
val headerType: HeaderType = HeaderType.Default(),
|
|
82
77
|
val scrollData: ScrollData = ScrollData(),
|
|
@@ -91,8 +86,6 @@ data class KeyboardOptions(
|
|
|
91
86
|
val keyboardShouldPersistTaps: Boolean = false,
|
|
92
87
|
val useAvoidKeyboard: Boolean = true
|
|
93
88
|
)
|
|
94
|
-
|
|
95
|
-
|
|
96
89
|
data class ScrollData(
|
|
97
90
|
val scrollable: Boolean = true,
|
|
98
91
|
val scrollState: ScrollableState? = null,
|
|
@@ -21,6 +21,7 @@ import vn.momo.kits.components.PopupNotify
|
|
|
21
21
|
import vn.momo.kits.navigation.BottomHeader.*
|
|
22
22
|
import vn.momo.kits.navigation.component.SnackBar
|
|
23
23
|
import vn.momo.maxapi.IMaxApi
|
|
24
|
+
import kotlin.time.Duration.Companion.milliseconds
|
|
24
25
|
|
|
25
26
|
class Navigator(
|
|
26
27
|
private val navController: NavController,
|
|
@@ -87,14 +88,14 @@ class Navigator(
|
|
|
87
88
|
}
|
|
88
89
|
private suspend fun dismissOverplay(isDelay: Boolean = true) {
|
|
89
90
|
OverplayComponentRegistry.clear()
|
|
90
|
-
if (isDelay) delay(300L)
|
|
91
|
+
if (isDelay) delay(300L.milliseconds)
|
|
91
92
|
OverplayComponentRegistry.hardClearAfterDismiss()
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
private suspend fun dismissScreen() {
|
|
95
96
|
if (navController.previousBackStackEntry != null){
|
|
96
97
|
navController.popBackStack()
|
|
97
|
-
delay(300L)
|
|
98
|
+
delay(300L.milliseconds)
|
|
98
99
|
DynamicScreenRegistry.getLatestScreen()?.let { it1 ->
|
|
99
100
|
DynamicScreenRegistry.unregisterScreen(it1.id)
|
|
100
101
|
}
|
|
@@ -154,7 +155,7 @@ class Navigator(
|
|
|
154
155
|
fun hideSnackBar() {
|
|
155
156
|
scope.launch {
|
|
156
157
|
OverplayComponentRegistry.clear()
|
|
157
|
-
delay(250L)
|
|
158
|
+
delay(250L.milliseconds)
|
|
158
159
|
OverplayComponentRegistry.hardClearAfterDismiss()
|
|
159
160
|
}
|
|
160
161
|
}
|
|
@@ -244,7 +245,7 @@ sealed class OverplayComponentParams {
|
|
|
244
245
|
val bottomSheetHeader: BottomHeader? = null,
|
|
245
246
|
) : OverplayComponentParams()
|
|
246
247
|
|
|
247
|
-
class SnackBar
|
|
248
|
+
class SnackBar : OverplayComponentParams()
|
|
248
249
|
}
|
|
249
250
|
|
|
250
251
|
data class OverplayComponent(
|
|
@@ -308,7 +309,7 @@ object OverplayComponentRegistry {
|
|
|
308
309
|
}
|
|
309
310
|
|
|
310
311
|
@Composable
|
|
311
|
-
fun OverlayComponent(){
|
|
312
|
+
internal fun OverlayComponent(){
|
|
312
313
|
val overplay = currentOverlayComponent.value ?: return
|
|
313
314
|
|
|
314
315
|
when (val params = overplay.params) {
|