@momo-kits/native-kits 0.169.12-beta.3 → 0.169.12-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/build.gradle.kts +11 -0
- package/compose/build.gradle.kts +198 -0
- package/compose/compose.podspec +47 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +154 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +110 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +61 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1067 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +268 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +354 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +130 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +482 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +224 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +137 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +473 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +113 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +262 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +237 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +228 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +280 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +183 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +342 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +40 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +82 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +39 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +362 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +304 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +88 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +308 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +218 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +456 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +205 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +542 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +175 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +201 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +498 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +208 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +291 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -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 +315 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +54 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +397 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +153 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +118 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +206 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +421 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +750 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +152 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +242 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +398 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +103 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +93 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +208 -0
- 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 +167 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +446 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +105 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +400 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +197 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +114 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +21 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +117 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +65 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
- 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 +143 -0
- package/gradle/libs.versions.toml +67 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/gradle.properties +24 -0
- package/gradlew +252 -0
- package/gradlew.bat +94 -0
- package/ios/Navigation/BottomTab/BottomTabBar.swift +4 -14
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/README.md +120 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +3 -16
- package/package.json +1 -1
- package/settings.gradle.kts +64 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
package vn.momo.kits.navigation.component
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.layout.Box
|
|
4
|
+
import androidx.compose.foundation.layout.Column
|
|
5
|
+
import androidx.compose.foundation.layout.Row
|
|
6
|
+
import androidx.compose.foundation.layout.Spacer
|
|
7
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
8
|
+
import androidx.compose.foundation.layout.height
|
|
9
|
+
import androidx.compose.foundation.layout.width
|
|
10
|
+
import androidx.compose.foundation.layout.widthIn
|
|
11
|
+
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
12
|
+
import androidx.compose.runtime.Composable
|
|
13
|
+
import androidx.compose.ui.Alignment
|
|
14
|
+
import androidx.compose.ui.Modifier
|
|
15
|
+
import androidx.compose.ui.draw.clip
|
|
16
|
+
import androidx.compose.ui.graphics.Color
|
|
17
|
+
import androidx.compose.ui.text.style.TextOverflow
|
|
18
|
+
import androidx.compose.ui.unit.dp
|
|
19
|
+
import vn.momo.kits.components.Icon
|
|
20
|
+
import vn.momo.kits.components.Skeleton
|
|
21
|
+
import vn.momo.kits.components.Text
|
|
22
|
+
import vn.momo.kits.const.Spacing
|
|
23
|
+
import vn.momo.kits.const.Typography
|
|
24
|
+
import vn.momo.kits.modifier.activeOpacityClickable
|
|
25
|
+
|
|
26
|
+
@Composable
|
|
27
|
+
internal fun HeaderLocation(
|
|
28
|
+
data: HeaderTitle,
|
|
29
|
+
tintIconColor: Color,
|
|
30
|
+
) {
|
|
31
|
+
if (data !is HeaderTitle.Location) return
|
|
32
|
+
if (data.isLoading) return TitleLocationShimmer()
|
|
33
|
+
|
|
34
|
+
val maxWidth = headerTitleMaxWidth()
|
|
35
|
+
val tint = parseHeaderTint(data.tintColor) ?: tintIconColor
|
|
36
|
+
|
|
37
|
+
Column(
|
|
38
|
+
modifier = Modifier
|
|
39
|
+
.widthIn(max = maxWidth)
|
|
40
|
+
.activeOpacityClickable(enabled = data.onPress != null, onClick = { data.onPress?.invoke() }),
|
|
41
|
+
horizontalAlignment = Alignment.Start,
|
|
42
|
+
) {
|
|
43
|
+
if (!data.description.isNullOrEmpty()) {
|
|
44
|
+
Text(
|
|
45
|
+
text = data.description,
|
|
46
|
+
color = tint,
|
|
47
|
+
style = Typography.descriptionXsRegular,
|
|
48
|
+
maxLines = 1,
|
|
49
|
+
overflow = TextOverflow.Ellipsis,
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
53
|
+
Text(
|
|
54
|
+
text = data.location,
|
|
55
|
+
color = tint,
|
|
56
|
+
style = Typography.actionXsBold,
|
|
57
|
+
maxLines = 1,
|
|
58
|
+
overflow = TextOverflow.Ellipsis,
|
|
59
|
+
modifier = Modifier.weight(1f, fill = false),
|
|
60
|
+
)
|
|
61
|
+
Spacer(Modifier.width(Spacing.XS))
|
|
62
|
+
Icon(source = "16_arrow_chevron_down_small", size = 16.dp, color = tint)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@Composable
|
|
68
|
+
private fun TitleLocationShimmer() {
|
|
69
|
+
Column(modifier = Modifier.fillMaxWidth()) {
|
|
70
|
+
Box(modifier = Modifier.height(12.dp).width(120.dp).clip(RoundedCornerShape(8.dp))) { Skeleton() }
|
|
71
|
+
Spacer(Modifier.height(Spacing.XXS))
|
|
72
|
+
Box(modifier = Modifier.height(18.dp).width(120.dp).clip(RoundedCornerShape(8.dp))) { Skeleton() }
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
package vn.momo.kits.navigation.component
|
|
2
|
+
|
|
3
|
+
import vn.momo.kits.modifier.InternalApi
|
|
4
|
+
|
|
5
|
+
import androidx.compose.foundation.background
|
|
6
|
+
import androidx.compose.foundation.border
|
|
7
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
8
|
+
import androidx.compose.foundation.layout.Box
|
|
9
|
+
import androidx.compose.foundation.layout.Column
|
|
10
|
+
import androidx.compose.foundation.layout.Row
|
|
11
|
+
import androidx.compose.foundation.layout.RowScope
|
|
12
|
+
import androidx.compose.foundation.layout.fillMaxHeight
|
|
13
|
+
import androidx.compose.foundation.layout.height
|
|
14
|
+
import androidx.compose.foundation.layout.offset
|
|
15
|
+
import androidx.compose.foundation.layout.padding
|
|
16
|
+
import androidx.compose.foundation.layout.size
|
|
17
|
+
import androidx.compose.foundation.layout.width
|
|
18
|
+
import androidx.compose.foundation.shape.CircleShape
|
|
19
|
+
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
20
|
+
import androidx.compose.runtime.Composable
|
|
21
|
+
import androidx.compose.runtime.LaunchedEffect
|
|
22
|
+
import androidx.compose.runtime.derivedStateOf
|
|
23
|
+
import androidx.compose.runtime.getValue
|
|
24
|
+
import androidx.compose.runtime.mutableStateOf
|
|
25
|
+
import androidx.compose.runtime.remember
|
|
26
|
+
import androidx.compose.runtime.setValue
|
|
27
|
+
import androidx.compose.ui.Alignment
|
|
28
|
+
import androidx.compose.ui.Modifier
|
|
29
|
+
import androidx.compose.ui.draw.clip
|
|
30
|
+
import androidx.compose.ui.graphics.Color
|
|
31
|
+
import androidx.compose.ui.unit.Dp
|
|
32
|
+
import androidx.compose.ui.unit.dp
|
|
33
|
+
import vn.momo.kits.layout.DuoMetrics
|
|
34
|
+
import vn.momo.kits.layout.HEADER_BUTTON_SIZE
|
|
35
|
+
import vn.momo.kits.layout.HEADER_ICON_SIZE
|
|
36
|
+
import vn.momo.kits.layout.HEADER_PILL_WIDTH
|
|
37
|
+
import vn.momo.kits.application.LocalContext
|
|
38
|
+
import vn.momo.kits.application.MiniAppContext
|
|
39
|
+
import vn.momo.kits.components.BadgeDot
|
|
40
|
+
import vn.momo.kits.components.DotSize
|
|
41
|
+
import vn.momo.kits.components.Icon
|
|
42
|
+
import vn.momo.kits.const.Colors
|
|
43
|
+
import vn.momo.kits.const.Spacing
|
|
44
|
+
import vn.momo.kits.modifier.activeOpacityClickable
|
|
45
|
+
import vn.momo.kits.navigation.LocalMaxApi
|
|
46
|
+
|
|
47
|
+
@Composable
|
|
48
|
+
@InternalApi
|
|
49
|
+
fun HeaderRight(
|
|
50
|
+
headerRight: HeaderRight,
|
|
51
|
+
tintColor: Color? = null,
|
|
52
|
+
headerColor: HeaderColor
|
|
53
|
+
) {
|
|
54
|
+
when (headerRight) {
|
|
55
|
+
is HeaderRight.None -> {}
|
|
56
|
+
is HeaderRight.Custom -> {
|
|
57
|
+
headerRight.content()
|
|
58
|
+
}
|
|
59
|
+
is HeaderRight.OnBoarding -> {}
|
|
60
|
+
is HeaderRight.Toolkit -> {
|
|
61
|
+
Toolkit(
|
|
62
|
+
headerRight = headerRight,
|
|
63
|
+
tintColor = tintColor,
|
|
64
|
+
headerColor = headerColor
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private const val HELP_CENTER_APP_ID = "vn.momo.helpcenter"
|
|
71
|
+
|
|
72
|
+
private fun usesHelpCenter(context: MiniAppContext?): Boolean {
|
|
73
|
+
return context != null && context.appId != HELP_CENTER_APP_ID
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private fun showsShortcut(headerRight: HeaderRight.Toolkit, context: MiniAppContext?): Boolean {
|
|
77
|
+
return headerRight.useShortcut && !(headerRight.useMore && context == null)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Height of the vertical toolkit: the optional shortcut, then the help/home capsule.
|
|
81
|
+
@Composable
|
|
82
|
+
internal fun toolkitColumnHeight(headerRight: HeaderRight.Toolkit): Dp {
|
|
83
|
+
val context = LocalContext.current
|
|
84
|
+
val shortcut = if (showsShortcut(headerRight, context)) DuoMetrics.controlSize + Spacing.M else 0.dp
|
|
85
|
+
val groupCount = if (usesHelpCenter(context)) 2 else 1
|
|
86
|
+
return shortcut + if (groupCount > 1) DuoMetrics.itemPitch * groupCount else DuoMetrics.controlSize
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// SideBarColumn: the iPhone Duo side bar, 48pt controls; Bar: every header row, iPhone Duo status bar row included.
|
|
90
|
+
internal enum class ToolkitLayout { Bar, SideBarColumn }
|
|
91
|
+
|
|
92
|
+
@Composable
|
|
93
|
+
internal fun Toolkit(
|
|
94
|
+
headerRight: HeaderRight.Toolkit,
|
|
95
|
+
tintColor: Color? = null,
|
|
96
|
+
headerColor: HeaderColor,
|
|
97
|
+
layout: ToolkitLayout = ToolkitLayout.Bar,
|
|
98
|
+
) {
|
|
99
|
+
val api = LocalMaxApi.current
|
|
100
|
+
val context = LocalContext.current
|
|
101
|
+
|
|
102
|
+
var isFavorite by remember { mutableStateOf(false) }
|
|
103
|
+
val isLoading by remember { mutableStateOf(false) }
|
|
104
|
+
|
|
105
|
+
LaunchedEffect(context?.appCode) {
|
|
106
|
+
api?.isFavoriteApp(mapOf("code" to context?.appCode)) { callback ->
|
|
107
|
+
val response = callback?.get("response") as? Boolean
|
|
108
|
+
isFavorite = response == true
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
fun onPressShortcut() {
|
|
113
|
+
api?.onToolAction(mapOf("item" to mapOf("key" to "onFavorite"), "context" to MiniAppContext.toMap(context))) { callback ->
|
|
114
|
+
val response = callback?.get("response") as? Map<*, *>?
|
|
115
|
+
val success = response?.get("success") as? Boolean
|
|
116
|
+
if (success == true){
|
|
117
|
+
isFavorite = !isFavorite
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
fun onPressMore() {
|
|
123
|
+
api?.showTools(
|
|
124
|
+
mapOf(
|
|
125
|
+
"useSystemTools" to headerRight.useSystemTools,
|
|
126
|
+
"tools" to headerRight.tools.map { it.toMap() },
|
|
127
|
+
"context" to MiniAppContext.toMap(context)
|
|
128
|
+
)
|
|
129
|
+
) { callback ->
|
|
130
|
+
val response = callback?.get("response") as? String
|
|
131
|
+
if (response != null) {
|
|
132
|
+
headerRight.toolCallback?.invoke(response)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
fun onPressHelpCenter() {
|
|
138
|
+
if (context == null) return
|
|
139
|
+
api?.showHelpCenter(
|
|
140
|
+
mapOf(
|
|
141
|
+
"appId" to context.appId,
|
|
142
|
+
"code" to context.appCode,
|
|
143
|
+
"name" to context.appName,
|
|
144
|
+
"icon" to context.appIcon,
|
|
145
|
+
"description" to context.description
|
|
146
|
+
)
|
|
147
|
+
) {}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
fun onPressClose() {
|
|
151
|
+
if (headerRight.useCloseIcon) api?.dismiss { } else api?.dismissAll { }
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
val useHelpCenter = usesHelpCenter(context)
|
|
155
|
+
val closeIcon = if (headerRight.useCloseIcon) "16_navigation_close_circle" else "16_basic_home"
|
|
156
|
+
|
|
157
|
+
val navButtonConfig = getNavigationButtonConfig(
|
|
158
|
+
headerRight,
|
|
159
|
+
::onPressShortcut,
|
|
160
|
+
::onPressMore
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
val showBadge = headerRight.tools.any { group ->
|
|
164
|
+
group.items.any { it.showBadge }
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
val isShowShortcut = showsShortcut(headerRight, context)
|
|
168
|
+
|
|
169
|
+
val icon by remember(navButtonConfig.icon, isFavorite) {
|
|
170
|
+
derivedStateOf {
|
|
171
|
+
navButtonConfig.icon.takeUnless { it == "star" }
|
|
172
|
+
?: if (isFavorite) "pin_star_checked" else "pin_star"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (layout != ToolkitLayout.Bar) {
|
|
177
|
+
Column(verticalArrangement = Arrangement.spacedBy(Spacing.M)) {
|
|
178
|
+
if (isShowShortcut) {
|
|
179
|
+
SideBarButton(
|
|
180
|
+
icon = icon,
|
|
181
|
+
headerColor = headerColor,
|
|
182
|
+
enabled = !isLoading,
|
|
183
|
+
showBadge = showBadge,
|
|
184
|
+
onClick = navButtonConfig.onPress,
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
SideBarGroup(headerColor = headerColor, itemCount = if (useHelpCenter) 2 else 1) { item ->
|
|
188
|
+
if (useHelpCenter) {
|
|
189
|
+
SideBarGroupItem(
|
|
190
|
+
icon = "help_center",
|
|
191
|
+
headerColor = headerColor,
|
|
192
|
+
automationId = "btn_navigation_help_center",
|
|
193
|
+
onClick = ::onPressHelpCenter,
|
|
194
|
+
modifier = item,
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
SideBarGroupItem(
|
|
198
|
+
icon = closeIcon,
|
|
199
|
+
headerColor = headerColor,
|
|
200
|
+
automationId = "btn_navigation_close",
|
|
201
|
+
onClick = ::onPressClose,
|
|
202
|
+
modifier = item,
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
Row(
|
|
210
|
+
verticalAlignment = Alignment.CenterVertically
|
|
211
|
+
) {
|
|
212
|
+
if (isShowShortcut) {
|
|
213
|
+
NavigationButton(
|
|
214
|
+
disabled = isLoading,
|
|
215
|
+
icon = icon,
|
|
216
|
+
showBadge = showBadge,
|
|
217
|
+
onClick = navButtonConfig.onPress,
|
|
218
|
+
headerColor = headerColor
|
|
219
|
+
)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
Row(
|
|
223
|
+
verticalAlignment = Alignment.CenterVertically,
|
|
224
|
+
horizontalArrangement = Arrangement.Center,
|
|
225
|
+
modifier = Modifier
|
|
226
|
+
.padding(start = Spacing.S)
|
|
227
|
+
.border(0.2.dp, headerColor.borderColor, shape = PILL_SHAPE)
|
|
228
|
+
.height(HEADER_BUTTON_SIZE)
|
|
229
|
+
.width(if (useHelpCenter) HEADER_PILL_WIDTH else HEADER_BUTTON_SIZE)
|
|
230
|
+
.clip(shape = PILL_SHAPE)
|
|
231
|
+
.background(headerColor.backgroundButton)
|
|
232
|
+
) {
|
|
233
|
+
if (useHelpCenter) {
|
|
234
|
+
PillItem(icon = "help_center", headerColor = headerColor, onClick = ::onPressHelpCenter)
|
|
235
|
+
Box(
|
|
236
|
+
modifier = Modifier
|
|
237
|
+
.width(0.5.dp)
|
|
238
|
+
.height(12.dp)
|
|
239
|
+
.background(tintColor ?: Colors.black_20)
|
|
240
|
+
)
|
|
241
|
+
}
|
|
242
|
+
PillItem(icon = closeIcon, headerColor = headerColor, onClick = ::onPressClose)
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
private val PILL_SHAPE = RoundedCornerShape(percent = 50)
|
|
248
|
+
|
|
249
|
+
// One half of the help / home pill; each half takes an equal share of the pill width.
|
|
250
|
+
@Composable
|
|
251
|
+
private fun RowScope.PillItem(icon: String, headerColor: HeaderColor, onClick: () -> Unit) {
|
|
252
|
+
Box(
|
|
253
|
+
modifier = Modifier.weight(1f).fillMaxHeight().activeOpacityClickable(onClick = onClick),
|
|
254
|
+
contentAlignment = Alignment.Center,
|
|
255
|
+
) {
|
|
256
|
+
Icon(source = icon, size = HEADER_ICON_SIZE, color = headerColor.tintIconColor)
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Colors follow the enclosing header, so it fits a `HeaderRight.Custom` next to the toolkit.
|
|
261
|
+
@Composable
|
|
262
|
+
fun NavigationButton(
|
|
263
|
+
icon: String,
|
|
264
|
+
onClick: () -> Unit,
|
|
265
|
+
showBadge: Boolean = false,
|
|
266
|
+
disabled: Boolean = false,
|
|
267
|
+
modifier: Modifier = Modifier,
|
|
268
|
+
) {
|
|
269
|
+
NavigationButton(
|
|
270
|
+
disabled = disabled,
|
|
271
|
+
icon = icon,
|
|
272
|
+
showBadge = showBadge,
|
|
273
|
+
onClick = onClick,
|
|
274
|
+
headerColor = LocalHeaderColor.current ?: getHeaderColor(HeaderType.Default(), 1f, null, Colors.black_17),
|
|
275
|
+
modifier = modifier,
|
|
276
|
+
)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
@Composable
|
|
280
|
+
internal fun NavigationButton(
|
|
281
|
+
disabled: Boolean,
|
|
282
|
+
icon: String,
|
|
283
|
+
showBadge: Boolean? = false,
|
|
284
|
+
onClick: () -> Unit,
|
|
285
|
+
headerColor: HeaderColor,
|
|
286
|
+
modifier: Modifier = Modifier,
|
|
287
|
+
) {
|
|
288
|
+
Box(
|
|
289
|
+
modifier = modifier
|
|
290
|
+
.size(HEADER_BUTTON_SIZE)
|
|
291
|
+
.activeOpacityClickable(enabled = !disabled, onClick = onClick)
|
|
292
|
+
) {
|
|
293
|
+
Box(
|
|
294
|
+
modifier = Modifier
|
|
295
|
+
.matchParentSize()
|
|
296
|
+
.clip(CircleShape)
|
|
297
|
+
.background(headerColor.backgroundButton)
|
|
298
|
+
.border(0.2.dp, headerColor.borderColor, CircleShape)
|
|
299
|
+
)
|
|
300
|
+
Box(
|
|
301
|
+
modifier = Modifier.matchParentSize(),
|
|
302
|
+
contentAlignment = Alignment.Center
|
|
303
|
+
) {
|
|
304
|
+
Icon(
|
|
305
|
+
source = icon,
|
|
306
|
+
size = HEADER_ICON_SIZE,
|
|
307
|
+
color = headerColor.tintIconColor
|
|
308
|
+
)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (showBadge == true) {
|
|
312
|
+
BadgeDot(
|
|
313
|
+
size = DotSize.Small,
|
|
314
|
+
modifier = Modifier
|
|
315
|
+
.align(Alignment.TopEnd)
|
|
316
|
+
.offset(x = -Spacing.XXS, y = -Spacing.XXS)
|
|
317
|
+
)
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
private fun getNavigationButtonConfig(
|
|
323
|
+
headerRight: HeaderRight.Toolkit,
|
|
324
|
+
onPressShortcut: () -> Unit,
|
|
325
|
+
onPressMore: () -> Unit
|
|
326
|
+
): NavigationButtonConfig {
|
|
327
|
+
val totalTools = headerRight.tools.sumOf { it.items.size }
|
|
328
|
+
val config = NavigationButtonConfig(icon = "star", onPress = onPressShortcut)
|
|
329
|
+
return if (totalTools > 1 || headerRight.useMore == true) {
|
|
330
|
+
NavigationButtonConfig(
|
|
331
|
+
icon = "navigation_more_icon",
|
|
332
|
+
onPress = onPressMore
|
|
333
|
+
)
|
|
334
|
+
} else if (totalTools == 1 && headerRight.tools.isNotEmpty()) {
|
|
335
|
+
val singleTool = headerRight.tools.first().items.firstOrNull()
|
|
336
|
+
return if (singleTool != null){
|
|
337
|
+
NavigationButtonConfig(
|
|
338
|
+
icon = singleTool.icon,
|
|
339
|
+
onPress = {
|
|
340
|
+
headerRight.toolCallback?.invoke(singleTool.key)
|
|
341
|
+
}
|
|
342
|
+
)
|
|
343
|
+
} else {
|
|
344
|
+
config
|
|
345
|
+
}
|
|
346
|
+
} else {
|
|
347
|
+
config
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
sealed interface HeaderRight {
|
|
352
|
+
data object None : HeaderRight
|
|
353
|
+
data class Custom(
|
|
354
|
+
val content: @Composable () -> Unit
|
|
355
|
+
) : HeaderRight
|
|
356
|
+
data object OnBoarding : HeaderRight
|
|
357
|
+
data class Toolkit(
|
|
358
|
+
val useShortcut: Boolean = false,
|
|
359
|
+
val useMore: Boolean = false,
|
|
360
|
+
val useSystemTools: Boolean = true,
|
|
361
|
+
val tools: List<ToolGroup> = emptyList(),
|
|
362
|
+
val toolCallback: ((String) -> Unit)? = { _ -> },
|
|
363
|
+
// Close dismisses only this mini app instead of returning home.
|
|
364
|
+
val useCloseIcon: Boolean = false,
|
|
365
|
+
) : HeaderRight
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
data class ToolGroup(
|
|
369
|
+
val title: Map<String, String> = emptyMap(),
|
|
370
|
+
val items: List<Tool>
|
|
371
|
+
) {
|
|
372
|
+
fun toMap(): Map<String, Any> {
|
|
373
|
+
return mapOf(
|
|
374
|
+
"title" to title,
|
|
375
|
+
"items" to items.map { it.toMap() }
|
|
376
|
+
)
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
data class Tool(
|
|
380
|
+
val key: String,
|
|
381
|
+
val icon: String,
|
|
382
|
+
val showBadge: Boolean = false,
|
|
383
|
+
val name: Map<String, String> = emptyMap(),
|
|
384
|
+
val showRightIcon: Boolean = true,
|
|
385
|
+
) {
|
|
386
|
+
fun toMap(): Map<String, Any> {
|
|
387
|
+
return mapOf(
|
|
388
|
+
"key" to key,
|
|
389
|
+
"icon" to icon,
|
|
390
|
+
"showBadge" to showBadge,
|
|
391
|
+
"name" to name,
|
|
392
|
+
"showRightIcon" to showRightIcon
|
|
393
|
+
)
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
private data class NavigationButtonConfig(
|
|
398
|
+
val icon: String,
|
|
399
|
+
val onPress: () -> Unit
|
|
400
|
+
)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
package vn.momo.kits.navigation.component
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
4
|
+
import androidx.compose.runtime.Composable
|
|
5
|
+
import androidx.compose.ui.Modifier
|
|
6
|
+
import androidx.compose.ui.graphics.Color
|
|
7
|
+
import androidx.compose.ui.text.style.TextAlign
|
|
8
|
+
import androidx.compose.ui.text.style.TextOverflow
|
|
9
|
+
import androidx.compose.ui.unit.sp
|
|
10
|
+
import androidx.compose.ui.zIndex
|
|
11
|
+
import vn.momo.kits.application.DesignSystemKits
|
|
12
|
+
import vn.momo.kits.components.Text
|
|
13
|
+
import vn.momo.kits.const.Typography
|
|
14
|
+
import vn.momo.kits.modifier.setAutomationId
|
|
15
|
+
|
|
16
|
+
internal val headerFontFamily: String?
|
|
17
|
+
get() = if (DesignSystemKits.getConfigs().isWhiteList) "MoMoTrustDisplay" else null
|
|
18
|
+
|
|
19
|
+
@Composable
|
|
20
|
+
internal fun HeaderTitle(
|
|
21
|
+
title: String = "",
|
|
22
|
+
color: Color? = null,
|
|
23
|
+
modifier: Modifier = Modifier.fillMaxWidth(),
|
|
24
|
+
textAlign: TextAlign = TextAlign.Start,
|
|
25
|
+
) {
|
|
26
|
+
Text(
|
|
27
|
+
modifier = modifier.zIndex(1f).setAutomationId("title_navigation_header"),
|
|
28
|
+
text = title,
|
|
29
|
+
textAlign = textAlign,
|
|
30
|
+
style = Typography.actionSBold.copy(
|
|
31
|
+
fontSize = 15.sp,
|
|
32
|
+
lineHeight = 22.sp,
|
|
33
|
+
),
|
|
34
|
+
fontFamily = headerFontFamily,
|
|
35
|
+
color = color,
|
|
36
|
+
maxLines = 1,
|
|
37
|
+
overflow = TextOverflow.Ellipsis
|
|
38
|
+
)
|
|
39
|
+
}
|