@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
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
package vn.momo.kits.navigation.bottomtab
|
|
2
|
+
|
|
3
|
+
import androidx.compose.animation.core.CubicBezierEasing
|
|
4
|
+
import androidx.compose.animation.core.tween
|
|
5
|
+
import androidx.compose.ui.graphics.Color
|
|
6
|
+
import androidx.compose.ui.graphics.shadow.Shadow
|
|
7
|
+
import androidx.compose.ui.unit.Dp
|
|
8
|
+
import androidx.compose.ui.unit.DpOffset
|
|
9
|
+
import androidx.compose.ui.unit.dp
|
|
10
|
+
import vn.momo.kits.const.Radius
|
|
11
|
+
import vn.momo.kits.const.Spacing
|
|
12
|
+
import vn.momo.kits.platform.getPlatformName
|
|
13
|
+
|
|
14
|
+
// Mirrored from RN BottomTab/metrics.ts (Figma "Specs Navigation"); `rail*` is the iPhone Duo vertical bar.
|
|
15
|
+
internal object TabBarMetrics {
|
|
16
|
+
val height = 60.dp
|
|
17
|
+
val margin = Spacing.S
|
|
18
|
+
val paddingVertical = Spacing.XS
|
|
19
|
+
val paddingHorizontal = Spacing.M
|
|
20
|
+
val itemGap = 1.dp
|
|
21
|
+
// gap between the icon slot and the label inside a tab (Figma: none)
|
|
22
|
+
val itemIconLabelGap = 0.dp
|
|
23
|
+
// Compose has no backdrop blur: Figma .Nav/Background Blur=Off spec (95%, no blur)
|
|
24
|
+
val backgroundOpacity = 0.95f
|
|
25
|
+
// white 60% hairline around the center action button (Figma Icon Button border)
|
|
26
|
+
val ctaBorderOpacity = 0.6f
|
|
27
|
+
val iconSize = 24.dp
|
|
28
|
+
val indicatorHeight = 32.dp
|
|
29
|
+
// label_s_medium / label_xs_medium line heights: the label slot keeps this height so a scaled
|
|
30
|
+
// label overflows downward instead of pushing the icon up
|
|
31
|
+
val labelHeight = 18.dp
|
|
32
|
+
val railLabelHeight = 14.dp
|
|
33
|
+
// font scale cap for the whole bar (RN ScaleSizeProvider around renderTabBar): its text follows the
|
|
34
|
+
// OS/host scale up to 1.2× so the fixed-height container and the notch stay aligned
|
|
35
|
+
const val LABEL_MAX_SCALE = 1.2f
|
|
36
|
+
// active indicator behind the icon: 24 icon + XS·M padding
|
|
37
|
+
val indicatorPaddingHorizontal = Spacing.M
|
|
38
|
+
val indicatorRadius = Radius.XL
|
|
39
|
+
// home indicator / gesture bar area under the container
|
|
40
|
+
val systemIndicatorHeight = 24.dp
|
|
41
|
+
// unfolded foldables (short side from 600, the smallest in the spec) use 65% of the short side,
|
|
42
|
+
// centered; phones and folded outer displays fill the window
|
|
43
|
+
val foldableMinShortSide = 600.dp
|
|
44
|
+
const val FOLDABLE_WIDTH_RATIO = 0.65f
|
|
45
|
+
// a 2-tab bar doesn't stretch to the full width: each item is this fixed width and the bar is sized
|
|
46
|
+
// to its content, centered (Figma Navigation · 2 Tab: item 100, bar ~225)
|
|
47
|
+
val twoTabItemWidth = 100.dp
|
|
48
|
+
val ctaSlotWidth = 92.dp
|
|
49
|
+
val ctaSize = 48.dp
|
|
50
|
+
// the icon sits 10 inside the 48 button (prototype .cta: 28 icon), 12 inside the 52 rail one
|
|
51
|
+
val ctaIconSize = 28.dp
|
|
52
|
+
// the button rises 22 above the container top edge
|
|
53
|
+
val ctaLift = 22.dp
|
|
54
|
+
val ctaLabelGap = Spacing.M
|
|
55
|
+
val ctaLabelHeight = 18.dp
|
|
56
|
+
val railContainerWidth = 56.dp
|
|
57
|
+
val railPaddingHorizontal = Spacing.XS
|
|
58
|
+
val railPaddingBottom = Spacing.S
|
|
59
|
+
val railItemWidth = 48.dp
|
|
60
|
+
val railItemHeight = 62.dp
|
|
61
|
+
val railIndicatorHeight = 40.dp
|
|
62
|
+
val railIndicatorRadius = 20.dp
|
|
63
|
+
val railCtaGap = Spacing.L
|
|
64
|
+
val railCtaSize = 52.dp
|
|
65
|
+
val railCtaLabelGap = Spacing.XS
|
|
66
|
+
val railCtaWidth = 68.dp
|
|
67
|
+
val railCtaHeight = 70.dp
|
|
68
|
+
val badgeMaxWidth = 58.dp
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Motion of the navigation bar (MoMo Navigation Prototype): one active indicator slides to the
|
|
72
|
+
// selected item overshooting a little, icon and label tint cross-fade, the center action shrinks while held.
|
|
73
|
+
internal object TabBarMotion {
|
|
74
|
+
val indicator = tween<Float>(durationMillis = 550, easing = CubicBezierEasing(0.34f, 1.4f, 0.5f, 1f))
|
|
75
|
+
const val TINT_MILLIS = 250
|
|
76
|
+
const val CTA_PRESS_MILLIS = 150
|
|
77
|
+
const val CTA_PRESSED_SCALE = 0.92f
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Figma Effect/Popover on the center action button.
|
|
81
|
+
internal val CtaShadows = listOf(
|
|
82
|
+
Shadow(radius = 24.dp, spread = (-12).dp, color = Color.Black, alpha = 0.08f, offset = DpOffset(0.dp, 8.dp)),
|
|
83
|
+
Shadow(radius = 32.dp, spread = (-16).dp, color = Color.Black, alpha = 0.04f, offset = DpOffset(0.dp, 12.dp)),
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
// Inner light and tint of the active indicator: white 12% from below, primary 12% from above.
|
|
87
|
+
internal fun indicatorInnerShadows(primary: Color) = listOf(
|
|
88
|
+
Shadow(radius = 2.dp, color = Color.White, alpha = 0.12f, offset = DpOffset(0.dp, (-2).dp)),
|
|
89
|
+
Shadow(radius = 2.dp, color = primary, alpha = 0.12f, offset = DpOffset(0.dp, 1.dp)),
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
// Center-action notch (Figma "Backgroud" path) from NOTCH_HALF_WIDTH left of center: cubic segments of
|
|
93
|
+
// (control1, control2, end), each point (dx from center, dy below the top edge) in dp.
|
|
94
|
+
internal const val NOTCH_HALF_WIDTH = 50.758f
|
|
95
|
+
internal val NOTCH_CURVES = listOf(
|
|
96
|
+
listOf(-39.749f to 0f, -31.231f to 9.765f, -24.563f to 18.526f),
|
|
97
|
+
listOf(-18.928f to 25.93f, -10.022f to 30.709f, 0f to 30.709f),
|
|
98
|
+
listOf(10.022f to 30.709f, 18.928f to 25.93f, 24.563f to 18.526f),
|
|
99
|
+
listOf(31.231f to 9.765f, 39.749f to 0f, NOTCH_HALF_WIDTH to 0f),
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
// Width of the horizontal bar: 65% of the short side on an unfolded foldable, otherwise the window minus
|
|
103
|
+
// the side safe areas and margins.
|
|
104
|
+
internal fun horizontalBarWidth(
|
|
105
|
+
width: Dp,
|
|
106
|
+
height: Dp,
|
|
107
|
+
insetLeft: Dp,
|
|
108
|
+
insetRight: Dp,
|
|
109
|
+
itemCount: Int,
|
|
110
|
+
hasCta: Boolean,
|
|
111
|
+
): Dp {
|
|
112
|
+
// 2 tabs (no center action) stay content-sized and centered instead of filling the window
|
|
113
|
+
if (itemCount == 2 && !hasCta) {
|
|
114
|
+
return TabBarMetrics.twoTabItemWidth * 2 + TabBarMetrics.paddingHorizontal * 2 + TabBarMetrics.itemGap
|
|
115
|
+
}
|
|
116
|
+
val shortSide = minOf(width, height)
|
|
117
|
+
if (shortSide >= TabBarMetrics.foldableMinShortSide) return shortSide * TabBarMetrics.FOLDABLE_WIDTH_RATIO
|
|
118
|
+
return width - insetLeft - insetRight - TabBarMetrics.margin * 2
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Gap under the container: the home indicator / gesture bar area.
|
|
122
|
+
internal fun tabBarBottomGap(navigationBar: Dp): Dp {
|
|
123
|
+
var gap = navigationBar
|
|
124
|
+
if (getPlatformName() == "iOS") {
|
|
125
|
+
gap = minOf(navigationBar, TabBarMetrics.systemIndicatorHeight)
|
|
126
|
+
}
|
|
127
|
+
return gap.coerceAtLeast(Spacing.S)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// The center action needs a tab on each side: Special type takes 2 or 4 tabs.
|
|
131
|
+
internal fun hasCenterAction(floatingButton: BottomTabFloatingButton?, tabCount: Int): Boolean {
|
|
132
|
+
return floatingButton != null && tabCount % 2 == 0
|
|
133
|
+
}
|
|
@@ -75,14 +75,12 @@ internal fun FloatingButton(
|
|
|
75
75
|
|
|
76
76
|
val coroutineScope = rememberCoroutineScope()
|
|
77
77
|
|
|
78
|
-
// Animations
|
|
79
78
|
val baseSize = if (size == FABSize.SMALL) FabSmallSize else FabDefaultSize
|
|
80
79
|
val width by animateDpAsState(
|
|
81
80
|
targetValue = if (isExpanded && text != null) FabExpandedWidth else baseSize,
|
|
82
81
|
animationSpec = tween(100, easing = CubicBezierEasing(0.2f, 0.2f, 0.2f, 0.2f))
|
|
83
82
|
)
|
|
84
83
|
|
|
85
|
-
// Scroll listener
|
|
86
84
|
LaunchedEffect(text) {
|
|
87
85
|
if (text != null) {
|
|
88
86
|
coroutineScope.launch {
|
|
@@ -42,8 +42,12 @@ import vn.momo.kits.const.Colors
|
|
|
42
42
|
import vn.momo.kits.components.PopupNotifyProps
|
|
43
43
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
44
44
|
import vn.momo.kits.const.Spacing
|
|
45
|
-
import vn.momo.kits.layout.
|
|
45
|
+
import vn.momo.kits.layout.HEADER_BUTTON_SIZE
|
|
46
|
+
import vn.momo.kits.layout.HEADER_CLUSTER_WIDTH
|
|
47
|
+
import vn.momo.kits.layout.HEADER_ICON_SIZE
|
|
48
|
+
import vn.momo.kits.layout.HEADER_TITLE_GAP
|
|
46
49
|
import vn.momo.kits.layout.getScreenLayout
|
|
50
|
+
import vn.momo.kits.layout.rememberHeaderLayout
|
|
47
51
|
import vn.momo.kits.modifier.activeOpacityClickable
|
|
48
52
|
import vn.momo.kits.modifier.conditional
|
|
49
53
|
import vn.momo.kits.modifier.setAutomationId
|
|
@@ -60,10 +64,8 @@ const val HEADER_HEIGHT = 52
|
|
|
60
64
|
internal enum class InputSearchType { None, Header, Animated }
|
|
61
65
|
enum class TitlePosition { LEFT, CENTER }
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
// Extra width the 48pt back and toolkit take on the iPhone Duo status bar row.
|
|
66
|
-
private val STATUS_BAR_ROW_ACTIONS_EXTRA = 55.dp
|
|
67
|
+
// back, the gaps around the title and the right cluster
|
|
68
|
+
private val HEADER_ACTIONS_WIDTH = HEADER_BUTTON_SIZE + HEADER_TITLE_GAP * 2 + HEADER_CLUSTER_WIDTH
|
|
67
69
|
|
|
68
70
|
@Suppress("FrequentlyChangingValue")
|
|
69
71
|
@Composable
|
|
@@ -91,7 +93,7 @@ internal fun headerTitleMaxWidth(): Dp {
|
|
|
91
93
|
val clearance = layout.statusBarClearance
|
|
92
94
|
val clearanceWidth = clearance?.let { it.left + it.right } ?: 0.dp
|
|
93
95
|
if (layout.sideBar != null) return layout.contentWidth - Spacing.M * 2 - clearanceWidth
|
|
94
|
-
return
|
|
96
|
+
return rememberHeaderLayout(LocalOptions.current.contentLayout).frameWidth - HEADER_ACTIONS_WIDTH - clearanceWidth
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
// Scroll distance over which the Duo glass bar fades in.
|
|
@@ -124,10 +126,10 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
124
126
|
val headerRightWidthPx = LocalHeaderRightWidthPx.current
|
|
125
127
|
val inputSearchType = getInputSearchType(options)
|
|
126
128
|
val layout = getScreenLayout()
|
|
129
|
+
val headerLayout = rememberHeaderLayout(options.contentLayout)
|
|
127
130
|
val useSideBar = layout.sideBar != null
|
|
128
|
-
// iPhone Duo inner portrait: the row sits on the status bar, between its clusters
|
|
131
|
+
// iPhone Duo inner portrait: the row sits on the status bar, between its clusters, with phone-size controls
|
|
129
132
|
val clearance = layout.statusBarClearance
|
|
130
|
-
val statusBarRow = clearance != null && !useSideBar
|
|
131
133
|
val opacity = headerOpacity()
|
|
132
134
|
|
|
133
135
|
val headerColor = getHeaderColor(options.headerType, opacity, options.tintColor, Colors.black_17)
|
|
@@ -186,31 +188,22 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
186
188
|
.fillMaxWidth()
|
|
187
189
|
.horizontalSafeAreaPadding()
|
|
188
190
|
.padding(
|
|
189
|
-
start =
|
|
190
|
-
end =
|
|
191
|
+
start = headerLayout.frameInset + (clearance?.left ?: 0.dp),
|
|
192
|
+
end = headerLayout.frameInset + (clearance?.right ?: 0.dp),
|
|
191
193
|
),
|
|
192
194
|
verticalAlignment = Alignment.CenterVertically,
|
|
193
195
|
horizontalArrangement = Arrangement.SpaceBetween
|
|
194
196
|
) {
|
|
195
197
|
if (!options.hiddenBack && !useSideBar) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
borderColor = headerColor.borderColor,
|
|
206
|
-
backgroundButton = headerColor.backgroundButton,
|
|
207
|
-
tintIconColor = headerColor.tintIconColor,
|
|
208
|
-
onBackHandler = {
|
|
209
|
-
navigator.onBackSafe { }
|
|
210
|
-
}
|
|
211
|
-
)
|
|
212
|
-
}
|
|
213
|
-
Spacer(Modifier.width(Spacing.S))
|
|
198
|
+
BackButton(
|
|
199
|
+
borderColor = headerColor.borderColor,
|
|
200
|
+
backgroundButton = headerColor.backgroundButton,
|
|
201
|
+
tintIconColor = headerColor.tintIconColor,
|
|
202
|
+
onBackHandler = {
|
|
203
|
+
navigator.onBackSafe { }
|
|
204
|
+
}
|
|
205
|
+
)
|
|
206
|
+
Spacer(Modifier.width(HEADER_TITLE_GAP))
|
|
214
207
|
}
|
|
215
208
|
|
|
216
209
|
if (centerTitle) {
|
|
@@ -228,13 +221,8 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
228
221
|
}){
|
|
229
222
|
val headerRight = options.headerRight
|
|
230
223
|
when {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
headerRight = headerRight,
|
|
234
|
-
tintColor = options.tintColor,
|
|
235
|
-
headerColor = headerColor,
|
|
236
|
-
layout = ToolkitLayout.SideBarRow,
|
|
237
|
-
)
|
|
224
|
+
// on Duo the side bar column holds the header right (toolkit or custom), not this row
|
|
225
|
+
useSideBar -> Unit
|
|
238
226
|
else -> CompositionLocalProvider(LocalHeaderColor provides headerColor) {
|
|
239
227
|
HeaderRight(headerRight, options.tintColor, headerColor)
|
|
240
228
|
}
|
|
@@ -244,7 +232,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
244
232
|
if (centerTitle) {
|
|
245
233
|
// on the status bar row the clusters are lopsided, so both sides keep the wider one's room
|
|
246
234
|
val centerInset = if (clearance != null) {
|
|
247
|
-
val back = if (options.hiddenBack || useSideBar) 0.dp else
|
|
235
|
+
val back = if (options.hiddenBack || useSideBar) 0.dp else HEADER_BUTTON_SIZE + HEADER_TITLE_GAP
|
|
248
236
|
val right = with(LocalDensity.current) { headerRightWidthPx.intValue.toDp() }
|
|
249
237
|
maxOf(clearance.left + back, clearance.right + right) + Spacing.S
|
|
250
238
|
} else {
|
|
@@ -254,7 +242,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
254
242
|
modifier = Modifier.height(layout.headerBarHeight)
|
|
255
243
|
.fillMaxWidth()
|
|
256
244
|
.horizontalSafeAreaPadding()
|
|
257
|
-
.padding(horizontal =
|
|
245
|
+
.padding(horizontal = headerLayout.frameInset + centerInset),
|
|
258
246
|
contentAlignment = Alignment.Center
|
|
259
247
|
) {
|
|
260
248
|
HeaderContent(
|
|
@@ -274,7 +262,7 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
274
262
|
private fun BackButton(borderColor: Color, backgroundButton: Color, tintIconColor: Color, onBackHandler: () -> Unit){
|
|
275
263
|
Box(
|
|
276
264
|
modifier = Modifier
|
|
277
|
-
.size(
|
|
265
|
+
.size(HEADER_BUTTON_SIZE)
|
|
278
266
|
.background(backgroundButton, RoundedCornerShape(100))
|
|
279
267
|
.border(width = 0.2.dp, color = borderColor, shape = RoundedCornerShape(100))
|
|
280
268
|
.activeOpacityClickable(onClick = onBackHandler)
|
|
@@ -285,7 +273,7 @@ private fun BackButton(borderColor: Color, backgroundButton: Color, tintIconColo
|
|
|
285
273
|
Icon(
|
|
286
274
|
source = "arrow-back",
|
|
287
275
|
color = tintIconColor,
|
|
288
|
-
size =
|
|
276
|
+
size = HEADER_ICON_SIZE,
|
|
289
277
|
)
|
|
290
278
|
}
|
|
291
279
|
}
|
|
@@ -405,7 +393,10 @@ sealed class HeaderType {
|
|
|
405
393
|
val isSurface: Boolean = true,
|
|
406
394
|
val layoutOffSet: Dp = 56.dp,
|
|
407
395
|
val height: Dp? = null,
|
|
408
|
-
|
|
396
|
+
// Wide windows: fills the sides of the phone-sized banner, fading out downward.
|
|
397
|
+
val bannerBackgroundColor: Color? = null,
|
|
398
|
+
// Last so callers can keep passing it as a trailing lambda.
|
|
399
|
+
val composable: @Composable (scrollState: Int) -> Unit = {},
|
|
409
400
|
) : HeaderType()
|
|
410
401
|
|
|
411
402
|
data class Transparent(
|
|
@@ -90,7 +90,9 @@ internal fun HeaderBackground() {
|
|
|
90
90
|
.fillMaxWidth()
|
|
91
91
|
.then(if (fillsBox && !theme.isHeaderImage()) Modifier.fillMaxHeight() else Modifier.height(maxHeight))
|
|
92
92
|
.conditional(!theme.isHeaderImage()) {
|
|
93
|
-
|
|
93
|
+
// RN spans the gradient over 375:154 and clips it, so a default header shows only its top
|
|
94
|
+
val endY = if (fillsBox) Float.POSITIVE_INFINITY else with(density) { maxHeight.toPx() }
|
|
95
|
+
background(Brush.verticalGradient(colors = listOf(color, backgroundColor), endY = endY))
|
|
94
96
|
}
|
|
95
97
|
){
|
|
96
98
|
if (!theme.isHeaderImage()) return@Box
|
|
@@ -8,6 +8,8 @@ import androidx.compose.foundation.layout.Arrangement
|
|
|
8
8
|
import androidx.compose.foundation.layout.Box
|
|
9
9
|
import androidx.compose.foundation.layout.Column
|
|
10
10
|
import androidx.compose.foundation.layout.Row
|
|
11
|
+
import androidx.compose.foundation.layout.RowScope
|
|
12
|
+
import androidx.compose.foundation.layout.fillMaxHeight
|
|
11
13
|
import androidx.compose.foundation.layout.height
|
|
12
14
|
import androidx.compose.foundation.layout.offset
|
|
13
15
|
import androidx.compose.foundation.layout.padding
|
|
@@ -17,17 +19,7 @@ import androidx.compose.foundation.shape.CircleShape
|
|
|
17
19
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
18
20
|
import androidx.compose.runtime.Composable
|
|
19
21
|
import androidx.compose.runtime.LaunchedEffect
|
|
20
|
-
// AI-GENERATED START: dispose toolkit requests with their UI owner
|
|
21
22
|
import androidx.compose.runtime.DisposableEffect
|
|
22
|
-
import kotlinx.serialization.json.booleanOrNull
|
|
23
|
-
import kotlinx.serialization.json.jsonPrimitive
|
|
24
|
-
import vn.momo.maxapi.contract.navigation.model.DismissTarget
|
|
25
|
-
import vn.momo.maxapi.contract.toolkit.model.ToolAction
|
|
26
|
-
import vn.momo.maxapi.contract.toolkit.model.ToolkitOptions
|
|
27
|
-
import vn.momo.maxapi.contract.toolkit.model.ToolkitToolGroup
|
|
28
|
-
import vn.momo.maxapi.contract.toolkit.model.ToolkitTool
|
|
29
|
-
import vn.momo.maxapi.runtime.ApiResult
|
|
30
|
-
// AI-GENERATED END: dispose toolkit requests with their UI owner
|
|
31
23
|
import androidx.compose.runtime.derivedStateOf
|
|
32
24
|
import androidx.compose.runtime.getValue
|
|
33
25
|
import androidx.compose.runtime.mutableStateOf
|
|
@@ -40,6 +32,10 @@ import androidx.compose.ui.graphics.Color
|
|
|
40
32
|
import androidx.compose.ui.unit.Dp
|
|
41
33
|
import androidx.compose.ui.unit.dp
|
|
42
34
|
import vn.momo.kits.layout.DuoMetrics
|
|
35
|
+
import vn.momo.kits.layout.HEADER_BUTTON_SIZE
|
|
36
|
+
import vn.momo.kits.layout.HEADER_ICON_SIZE
|
|
37
|
+
import vn.momo.kits.layout.HEADER_PILL_WIDTH
|
|
38
|
+
import vn.momo.kits.application.KitsDismissTarget
|
|
43
39
|
import vn.momo.kits.application.LocalContext
|
|
44
40
|
import vn.momo.kits.application.MiniAppContext
|
|
45
41
|
import vn.momo.kits.components.BadgeDot
|
|
@@ -48,7 +44,7 @@ import vn.momo.kits.components.Icon
|
|
|
48
44
|
import vn.momo.kits.const.Colors
|
|
49
45
|
import vn.momo.kits.const.Spacing
|
|
50
46
|
import vn.momo.kits.modifier.activeOpacityClickable
|
|
51
|
-
import vn.momo.kits.navigation.
|
|
47
|
+
import vn.momo.kits.navigation.LocalKitsBinding
|
|
52
48
|
|
|
53
49
|
@Composable
|
|
54
50
|
@InternalApi
|
|
@@ -75,11 +71,13 @@ fun HeaderRight(
|
|
|
75
71
|
|
|
76
72
|
private const val HELP_CENTER_APP_ID = "vn.momo.helpcenter"
|
|
77
73
|
|
|
78
|
-
private fun usesHelpCenter(context: MiniAppContext?): Boolean
|
|
79
|
-
context != null && context.appId != HELP_CENTER_APP_ID
|
|
74
|
+
private fun usesHelpCenter(context: MiniAppContext?): Boolean {
|
|
75
|
+
return context != null && context.appId != HELP_CENTER_APP_ID
|
|
76
|
+
}
|
|
80
77
|
|
|
81
|
-
private fun showsShortcut(headerRight: HeaderRight.Toolkit, context: MiniAppContext?): Boolean
|
|
82
|
-
headerRight.useShortcut && !(headerRight.useMore && context == null)
|
|
78
|
+
private fun showsShortcut(headerRight: HeaderRight.Toolkit, context: MiniAppContext?): Boolean {
|
|
79
|
+
return headerRight.useShortcut && !(headerRight.useMore && context == null)
|
|
80
|
+
}
|
|
83
81
|
|
|
84
82
|
// Height of the vertical toolkit: the optional shortcut, then the help/home capsule.
|
|
85
83
|
@Composable
|
|
@@ -90,8 +88,8 @@ internal fun toolkitColumnHeight(headerRight: HeaderRight.Toolkit): Dp {
|
|
|
90
88
|
return shortcut + if (groupCount > 1) DuoMetrics.itemPitch * groupCount else DuoMetrics.controlSize
|
|
91
89
|
}
|
|
92
90
|
|
|
93
|
-
// SideBarColumn: the iPhone Duo side bar;
|
|
94
|
-
internal enum class ToolkitLayout { Bar, SideBarColumn
|
|
91
|
+
// SideBarColumn: the iPhone Duo side bar, 48pt controls; Bar: every header row, iPhone Duo status bar row included.
|
|
92
|
+
internal enum class ToolkitLayout { Bar, SideBarColumn }
|
|
95
93
|
|
|
96
94
|
@Composable
|
|
97
95
|
internal fun Toolkit(
|
|
@@ -100,62 +98,44 @@ internal fun Toolkit(
|
|
|
100
98
|
headerColor: HeaderColor,
|
|
101
99
|
layout: ToolkitLayout = ToolkitLayout.Bar,
|
|
102
100
|
) {
|
|
103
|
-
val api =
|
|
101
|
+
val api = LocalKitsBinding.current
|
|
104
102
|
val context = LocalContext.current
|
|
105
103
|
|
|
106
104
|
var isFavorite by remember { mutableStateOf(false) }
|
|
107
105
|
val isLoading by remember { mutableStateOf(false) }
|
|
108
106
|
|
|
109
|
-
// AI-GENERATED START: retain custom tool data and typed callback outcomes
|
|
110
107
|
val requests = remember(api, context?.appCode) { ToolkitRequests() }
|
|
111
108
|
DisposableEffect(requests) { onDispose { requests.close() } }
|
|
112
109
|
|
|
113
110
|
LaunchedEffect(requests) {
|
|
114
111
|
val client = api ?: return@LaunchedEffect
|
|
115
|
-
requests.launch<Boolean>({ callback -> client.checkFavorite(context?.appCode, callback) }) {
|
|
116
|
-
|
|
112
|
+
requests.launch<Boolean>({ callback -> client.checkFavorite(context?.appCode, callback) }) {
|
|
113
|
+
isFavorite = it
|
|
117
114
|
}
|
|
118
115
|
}
|
|
119
116
|
|
|
120
117
|
fun onPressShortcut() {
|
|
121
118
|
val client = api ?: return
|
|
122
|
-
requests.launch({ callback ->
|
|
123
|
-
|
|
124
|
-
}) { result ->
|
|
125
|
-
if (result is ApiResult.Success) {
|
|
126
|
-
result.value.jsonPrimitive.booleanOrNull?.let { isFavorite = it }
|
|
127
|
-
}
|
|
119
|
+
requests.launch<Boolean>({ callback -> client.toggleFavorite(context?.appCode, callback) }) {
|
|
120
|
+
isFavorite = it
|
|
128
121
|
}
|
|
129
122
|
}
|
|
130
123
|
|
|
131
124
|
fun onPressMore() {
|
|
132
125
|
val client = api ?: return
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
ToolkitTool(tool.key, tool.icon, tool.showBadge, tool.name, tool.showRightIcon)
|
|
137
|
-
})
|
|
138
|
-
},
|
|
139
|
-
useSystemTools = headerRight.useSystemTools,
|
|
140
|
-
)
|
|
141
|
-
requests.launch({ callback -> client.showToolkit(options, callback) }) { result ->
|
|
142
|
-
if (result is ApiResult.Success) headerRight.toolCallback?.invoke(result.value.actionKey)
|
|
143
|
-
}
|
|
126
|
+
requests.launch<String>({ callback ->
|
|
127
|
+
client.showToolkit(headerRight.tools, headerRight.useSystemTools, callback)
|
|
128
|
+
}) { actionKey -> headerRight.toolCallback?.invoke(actionKey) }
|
|
144
129
|
}
|
|
145
|
-
// AI-GENERATED END: retain custom tool data and typed callback outcomes
|
|
146
130
|
|
|
147
131
|
fun onPressHelpCenter() {
|
|
148
132
|
if (context == null) return
|
|
149
|
-
// AI-GENERATED START: preserve Help Center context and own its event subscription
|
|
150
133
|
val client = api ?: return
|
|
151
|
-
requests.observe
|
|
152
|
-
// AI-GENERATED END: preserve Help Center context and own its event subscription
|
|
134
|
+
requests.observe { client.showHelpCenter(context.helpCenterRequest()) }
|
|
153
135
|
}
|
|
154
136
|
|
|
155
137
|
fun onPressClose() {
|
|
156
|
-
|
|
157
|
-
api?.dismiss(if (headerRight.useCloseIcon) DismissTarget.Current() else DismissTarget.All) {}
|
|
158
|
-
// AI-GENERATED END: preserve current-container and whole-stack dismissal
|
|
138
|
+
api?.dismiss(if (headerRight.useCloseIcon) KitsDismissTarget.Current else KitsDismissTarget.All)
|
|
159
139
|
}
|
|
160
140
|
|
|
161
141
|
val useHelpCenter = usesHelpCenter(context)
|
|
@@ -181,8 +161,7 @@ internal fun Toolkit(
|
|
|
181
161
|
}
|
|
182
162
|
|
|
183
163
|
if (layout != ToolkitLayout.Bar) {
|
|
184
|
-
|
|
185
|
-
val controls = @Composable {
|
|
164
|
+
Column(verticalArrangement = Arrangement.spacedBy(Spacing.M)) {
|
|
186
165
|
if (isShowShortcut) {
|
|
187
166
|
SideBarButton(
|
|
188
167
|
icon = icon,
|
|
@@ -192,7 +171,7 @@ internal fun Toolkit(
|
|
|
192
171
|
onClick = navButtonConfig.onPress,
|
|
193
172
|
)
|
|
194
173
|
}
|
|
195
|
-
SideBarGroup(headerColor = headerColor, itemCount = if (useHelpCenter) 2 else 1
|
|
174
|
+
SideBarGroup(headerColor = headerColor, itemCount = if (useHelpCenter) 2 else 1) { item ->
|
|
196
175
|
if (useHelpCenter) {
|
|
197
176
|
SideBarGroupItem(
|
|
198
177
|
icon = "help_center",
|
|
@@ -211,13 +190,6 @@ internal fun Toolkit(
|
|
|
211
190
|
)
|
|
212
191
|
}
|
|
213
192
|
}
|
|
214
|
-
if (horizontal) {
|
|
215
|
-
Row(horizontalArrangement = Arrangement.spacedBy(Spacing.M), verticalAlignment = Alignment.CenterVertically) {
|
|
216
|
-
controls()
|
|
217
|
-
}
|
|
218
|
-
} else {
|
|
219
|
-
Column(verticalArrangement = Arrangement.spacedBy(Spacing.M)) { controls() }
|
|
220
|
-
}
|
|
221
193
|
return
|
|
222
194
|
}
|
|
223
195
|
|
|
@@ -239,18 +211,14 @@ internal fun Toolkit(
|
|
|
239
211
|
horizontalArrangement = Arrangement.Center,
|
|
240
212
|
modifier = Modifier
|
|
241
213
|
.padding(start = Spacing.S)
|
|
242
|
-
.border(0.2.dp, headerColor.borderColor, shape =
|
|
243
|
-
.height(
|
|
244
|
-
.
|
|
214
|
+
.border(0.2.dp, headerColor.borderColor, shape = PILL_SHAPE)
|
|
215
|
+
.height(HEADER_BUTTON_SIZE)
|
|
216
|
+
.width(if (useHelpCenter) HEADER_PILL_WIDTH else HEADER_BUTTON_SIZE)
|
|
217
|
+
.clip(shape = PILL_SHAPE)
|
|
245
218
|
.background(headerColor.backgroundButton)
|
|
246
219
|
) {
|
|
247
220
|
if (useHelpCenter) {
|
|
248
|
-
|
|
249
|
-
source = "help_center",
|
|
250
|
-
size = 20.dp,
|
|
251
|
-
color = headerColor.tintIconColor,
|
|
252
|
-
modifier = Modifier.padding(4.dp).activeOpacityClickable(onClick = ::onPressHelpCenter)
|
|
253
|
-
)
|
|
221
|
+
PillItem(icon = "help_center", headerColor = headerColor, onClick = ::onPressHelpCenter)
|
|
254
222
|
Box(
|
|
255
223
|
modifier = Modifier
|
|
256
224
|
.width(0.5.dp)
|
|
@@ -258,17 +226,23 @@ internal fun Toolkit(
|
|
|
258
226
|
.background(tintColor ?: Colors.black_20)
|
|
259
227
|
)
|
|
260
228
|
}
|
|
261
|
-
|
|
262
|
-
source = closeIcon,
|
|
263
|
-
size = 20.dp,
|
|
264
|
-
color = headerColor.tintIconColor,
|
|
265
|
-
modifier = Modifier.padding(4.dp).activeOpacityClickable(onClick = ::onPressClose)
|
|
266
|
-
)
|
|
229
|
+
PillItem(icon = closeIcon, headerColor = headerColor, onClick = ::onPressClose)
|
|
267
230
|
}
|
|
268
231
|
}
|
|
269
232
|
}
|
|
270
233
|
|
|
234
|
+
private val PILL_SHAPE = RoundedCornerShape(percent = 50)
|
|
271
235
|
|
|
236
|
+
// One half of the help / home pill; each half takes an equal share of the pill width.
|
|
237
|
+
@Composable
|
|
238
|
+
private fun RowScope.PillItem(icon: String, headerColor: HeaderColor, onClick: () -> Unit) {
|
|
239
|
+
Box(
|
|
240
|
+
modifier = Modifier.weight(1f).fillMaxHeight().activeOpacityClickable(onClick = onClick),
|
|
241
|
+
contentAlignment = Alignment.Center,
|
|
242
|
+
) {
|
|
243
|
+
Icon(source = icon, size = HEADER_ICON_SIZE, color = headerColor.tintIconColor)
|
|
244
|
+
}
|
|
245
|
+
}
|
|
272
246
|
|
|
273
247
|
// Colors follow the enclosing header, so it fits a `HeaderRight.Custom` next to the toolkit.
|
|
274
248
|
@Composable
|
|
@@ -300,7 +274,7 @@ internal fun NavigationButton(
|
|
|
300
274
|
) {
|
|
301
275
|
Box(
|
|
302
276
|
modifier = modifier
|
|
303
|
-
.size(
|
|
277
|
+
.size(HEADER_BUTTON_SIZE)
|
|
304
278
|
.activeOpacityClickable(enabled = !disabled, onClick = onClick)
|
|
305
279
|
) {
|
|
306
280
|
Box(
|
|
@@ -316,7 +290,7 @@ internal fun NavigationButton(
|
|
|
316
290
|
) {
|
|
317
291
|
Icon(
|
|
318
292
|
source = icon,
|
|
319
|
-
size =
|
|
293
|
+
size = HEADER_ICON_SIZE,
|
|
320
294
|
color = headerColor.tintIconColor
|
|
321
295
|
)
|
|
322
296
|
}
|
package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// File: HelpCenterRequest.kt
|
|
2
2
|
// Created At: 2026-10-19 +07:00
|
|
3
3
|
// Created By: AI | AI Agent: Codex | Model: GPT-6
|
|
4
|
-
// AI-GENERATED START: preserve the toolkit Help Center payload in the typed request
|
|
5
4
|
package vn.momo.kits.navigation.component
|
|
6
5
|
|
|
7
6
|
import kotlinx.serialization.json.JsonArray
|
|
@@ -9,18 +8,16 @@ import kotlinx.serialization.json.JsonElement
|
|
|
9
8
|
import kotlinx.serialization.json.JsonNull
|
|
10
9
|
import kotlinx.serialization.json.JsonObject
|
|
11
10
|
import kotlinx.serialization.json.JsonPrimitive
|
|
11
|
+
import vn.momo.kits.application.KitsHelpCenterRequest
|
|
12
12
|
import vn.momo.kits.application.MiniAppContext
|
|
13
|
-
import vn.momo.maxapi.contract.navigation.model.BottomSheetRequest
|
|
14
|
-
import vn.momo.maxapi.contract.navigation.model.HelpCenterContext
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
),
|
|
14
|
+
// Keeps the localized name/description maps as JSON so the host Help Center gets the toolkit payload intact.
|
|
15
|
+
internal fun MiniAppContext.helpCenterRequest() = KitsHelpCenterRequest(
|
|
16
|
+
appId = appId,
|
|
17
|
+
code = appCode,
|
|
18
|
+
name = appName?.helpCenterJson(),
|
|
19
|
+
icon = appIcon,
|
|
20
|
+
description = description?.helpCenterJson(),
|
|
24
21
|
)
|
|
25
22
|
|
|
26
23
|
private fun Any?.helpCenterJson(): JsonElement = when (this) {
|
|
@@ -34,4 +31,3 @@ private fun Any?.helpCenterJson(): JsonElement = when (this) {
|
|
|
34
31
|
is Array<*> -> JsonArray(map { it.helpCenterJson() })
|
|
35
32
|
else -> JsonPrimitive(toString())
|
|
36
33
|
}
|
|
37
|
-
// AI-GENERATED END: preserve the toolkit Help Center payload in the typed request
|