@momo-kits/native-kits 0.152.4-beta.6 → 0.152.4-maxapi
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/CODE_OF_CONDUCT.md +133 -0
- package/CONTRIBUTING.md +114 -0
- package/LICENSE +20 -0
- package/README.md +7 -0
- package/build.gradle.kts +32 -0
- package/compose/MoMoComposeKits.podspec +54 -0
- package/compose/build.gradle.kts +149 -0
- package/compose/src/androidMain/AndroidManifest.xml +2 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +105 -0
- package/compose/src/commonMain/composeResources/files/lottie_circle_loader.json +1 -0
- package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
- package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +57 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +201 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +222 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +48 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +306 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +715 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +214 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +236 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +77 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +27 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +334 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +345 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +90 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +131 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +543 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +58 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +143 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +179 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +111 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +384 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +160 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +234 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +223 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +232 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +236 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +228 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +364 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +50 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +34 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +85 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +33 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +338 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +95 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +64 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +91 -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 +84 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +208 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +172 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +199 -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 +237 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +191 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -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 +13 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +191 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +258 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +68 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +49 -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 +232 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +111 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +94 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +159 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +232 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScaleSizeScope.kt +17 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +459 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +169 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +216 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +180 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +251 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +80 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +306 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +31 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +385 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +38 -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 +62 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +88 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +144 -0
- package/gradle.properties +19 -0
- package/gradlew +240 -0
- package/gradlew.bat +91 -0
- package/ios/Application/ApplicationEnvironment.swift +50 -0
- package/ios/Application/Components.swift +263 -0
- package/ios/Application/ComposeApi.swift +22 -0
- package/ios/Application/FloatingButton.swift +172 -0
- package/ios/Application/HeaderRight.swift +271 -0
- package/ios/Application/Screen.swift +249 -0
- package/ios/Badge/BadgeDot.swift +31 -0
- package/ios/Button/Button.swift +211 -0
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +126 -0
- package/ios/Checkbox/Checkbox.swift +81 -0
- package/ios/Chip/Chip.swift +96 -0
- package/ios/Colors+Radius+Spacing/Colors.swift +172 -0
- package/ios/Colors+Radius+Spacing/Radius.swift +22 -0
- package/ios/Colors+Radius+Spacing/Spacing.swift +12 -0
- package/ios/Extensions/Color++.swift +25 -0
- package/ios/Icon/Icon.swift +51 -0
- package/ios/Image/Image.swift +70 -0
- package/ios/Input/Input.swift +207 -0
- package/ios/Input/InputPhoneNumber.swift +176 -0
- package/ios/Input/InputSearch.swift +238 -0
- package/ios/Input/InputTextArea.swift +242 -0
- package/ios/Lottie/LottieView.swift +86 -0
- package/ios/OTPKeyboard/KeyboardButton.swift +41 -0
- package/ios/OTPKeyboard/OTPKeyboard.swift +145 -0
- package/ios/Popup/PopupDisplay.swift +284 -0
- package/ios/Popup/PopupInput.swift +96 -0
- package/ios/Popup/PopupPromotion.swift +73 -0
- package/ios/PopupView/FullscreenPopup.swift +251 -0
- package/ios/PopupView/Modifiers.swift +158 -0
- package/ios/PopupView/PopupView.swift +289 -0
- package/ios/PopupView/Utils++.swift +281 -0
- package/ios/ScrollIndicator/ScrollIndicator.swift +110 -0
- package/ios/Swipeable/SwipeCell.swift +278 -0
- package/ios/Swipeable/SwipeCellModel.swift +86 -0
- package/ios/Switch/Switch.swift +44 -0
- package/ios/Template/Logo/Logo.swift +75 -0
- package/ios/Template/TrustBanner/TrustBanner.swift +120 -0
- package/ios/Theme.md +18 -0
- package/ios/Typography/Text.swift +140 -0
- package/ios/Typography/Typography.swift +95 -0
- package/ios/native-kits.podspec +18 -0
- package/package.json +6 -7
- package/settings.gradle.kts +25 -0
- package/shared/build.gradle.kts +0 -74
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
package vn.momo.kits.components
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.background
|
|
4
|
+
import androidx.compose.foundation.layout.Box
|
|
5
|
+
import androidx.compose.foundation.layout.Row
|
|
6
|
+
import androidx.compose.foundation.layout.height
|
|
7
|
+
import androidx.compose.foundation.layout.padding
|
|
8
|
+
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
9
|
+
import androidx.compose.runtime.Composable
|
|
10
|
+
import androidx.compose.ui.Alignment
|
|
11
|
+
import androidx.compose.ui.Modifier
|
|
12
|
+
import androidx.compose.ui.graphics.Color
|
|
13
|
+
import androidx.compose.ui.unit.dp
|
|
14
|
+
import vn.momo.kits.const.Colors
|
|
15
|
+
import vn.momo.kits.const.Radius
|
|
16
|
+
import vn.momo.kits.const.Spacing
|
|
17
|
+
import vn.momo.kits.const.Typography
|
|
18
|
+
import vn.momo.kits.const.scaleSize
|
|
19
|
+
|
|
20
|
+
enum class TagSize(val height: Float) {
|
|
21
|
+
Large(24.toFloat()),
|
|
22
|
+
Medium(18.toFloat())
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
enum class TagColor(val backgroundColor: Color, val textColor: Color) {
|
|
26
|
+
Default(Colors.black_04, Colors.black_17),
|
|
27
|
+
Orange(Colors.orange_08, Colors.orange_03),
|
|
28
|
+
Green(Colors.green_08, Colors.green_03),
|
|
29
|
+
Red(Colors.red_08, Colors.red_03),
|
|
30
|
+
Blue(Colors.blue_08, Colors.blue_03),
|
|
31
|
+
Grey(Colors.black_04, Colors.black_12),
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Composable
|
|
35
|
+
fun Tag(
|
|
36
|
+
label: String = "Label",
|
|
37
|
+
icon: String? = null,
|
|
38
|
+
color: TagColor = TagColor.Default,
|
|
39
|
+
size: TagSize = TagSize.Large,
|
|
40
|
+
customColor: Color? = null,
|
|
41
|
+
) {
|
|
42
|
+
val primaryColors = listOf(
|
|
43
|
+
Color(0xFFF0F0F0),
|
|
44
|
+
Color(0xFFEB2F96),
|
|
45
|
+
Color(0xFF962AF0),
|
|
46
|
+
Color(0xFF4E4BFF),
|
|
47
|
+
Color(0xFF007AFF),
|
|
48
|
+
Color(0xFF13C2C2),
|
|
49
|
+
Color(0xFF34C759),
|
|
50
|
+
Color(0xFFA0D911),
|
|
51
|
+
Color(0xFFFFCC00),
|
|
52
|
+
Color(0xFFFA8C16),
|
|
53
|
+
Color(0xFFFA541C),
|
|
54
|
+
Color(0xFFF5222D)
|
|
55
|
+
)
|
|
56
|
+
var tagColor = color.backgroundColor
|
|
57
|
+
var labelColor = color.textColor
|
|
58
|
+
|
|
59
|
+
if (primaryColors.contains(customColor)) {
|
|
60
|
+
tagColor = color.backgroundColor
|
|
61
|
+
labelColor = color.textColor
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
Box(
|
|
65
|
+
modifier = Modifier
|
|
66
|
+
.height(scaleSize(size.height).dp)
|
|
67
|
+
.background(tagColor, shape = RoundedCornerShape(Radius.S))
|
|
68
|
+
.padding(horizontal = Spacing.S),
|
|
69
|
+
contentAlignment = Alignment.Center
|
|
70
|
+
) {
|
|
71
|
+
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
72
|
+
if (icon != null) {
|
|
73
|
+
Icon(
|
|
74
|
+
source = icon,
|
|
75
|
+
size = 16.dp,
|
|
76
|
+
color = labelColor
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
Text(
|
|
80
|
+
text = label,
|
|
81
|
+
color = labelColor,
|
|
82
|
+
style = Typography.labelSMedium
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
package vn.momo.kits.components
|
|
2
|
+
|
|
3
|
+
import androidx.compose.runtime.Composable
|
|
4
|
+
import androidx.compose.runtime.remember
|
|
5
|
+
import androidx.compose.ui.Modifier
|
|
6
|
+
import androidx.compose.ui.graphics.Color
|
|
7
|
+
import androidx.compose.ui.text.TextLayoutResult
|
|
8
|
+
import androidx.compose.ui.text.TextStyle
|
|
9
|
+
import androidx.compose.ui.text.style.TextAlign
|
|
10
|
+
import androidx.compose.ui.text.style.TextDecoration
|
|
11
|
+
import androidx.compose.ui.text.style.TextOverflow
|
|
12
|
+
import androidx.compose.ui.unit.TextUnit
|
|
13
|
+
import androidx.compose.ui.unit.sp
|
|
14
|
+
import vn.momo.kits.const.AppTheme
|
|
15
|
+
import vn.momo.kits.const.Typography
|
|
16
|
+
import vn.momo.kits.const.getFontFamily
|
|
17
|
+
import vn.momo.kits.const.scaleSize
|
|
18
|
+
import vn.momo.kits.modifier.setAutomationId
|
|
19
|
+
|
|
20
|
+
@Composable
|
|
21
|
+
fun Text(
|
|
22
|
+
text: String,
|
|
23
|
+
color: Color? = null,
|
|
24
|
+
style: TextStyle = Typography.bodyDefaultRegular,
|
|
25
|
+
textAlign: TextAlign? = TextAlign.Start,
|
|
26
|
+
modifier: Modifier = Modifier,
|
|
27
|
+
maxLines: Int = Int.MAX_VALUE,
|
|
28
|
+
overflow: TextOverflow = TextOverflow.Clip,
|
|
29
|
+
textDecoration: TextDecoration? = null,
|
|
30
|
+
onTextLayout: ((TextLayoutResult) -> Unit)? = null,
|
|
31
|
+
fontFamily: String? = null,
|
|
32
|
+
minLines: Int = 1,
|
|
33
|
+
letterSpacing: TextUnit = TextUnit.Unspecified,
|
|
34
|
+
softWrap: Boolean = true,
|
|
35
|
+
accessibilityId: String? = null
|
|
36
|
+
) {
|
|
37
|
+
// Cache theme access to avoid repeated lookups
|
|
38
|
+
val theme = AppTheme.current
|
|
39
|
+
|
|
40
|
+
// Call @Composable functions directly in composable context
|
|
41
|
+
val scaledFontSize = scaleSize(style.fontSize.value).sp
|
|
42
|
+
val scaledLineHeight = scaleSize(style.lineHeight.value).sp
|
|
43
|
+
val fontFamilyResult = getFontFamily(fontFamily ?: theme.font, style.fontWeight)
|
|
44
|
+
|
|
45
|
+
// Now memoize the results
|
|
46
|
+
val fontSize = remember(scaledFontSize) { scaledFontSize }
|
|
47
|
+
val lineHeight = remember(scaledLineHeight) { scaledLineHeight }
|
|
48
|
+
val font = remember(fontFamilyResult) { fontFamilyResult }
|
|
49
|
+
|
|
50
|
+
// Memoize color calculation
|
|
51
|
+
val textColor = remember(color, theme) {
|
|
52
|
+
color ?: theme.colors.text.default
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Memoize style copy operation
|
|
56
|
+
val optimizedStyle = remember(style) {
|
|
57
|
+
style.copy(
|
|
58
|
+
fontWeight = null,
|
|
59
|
+
lineHeight = if (lineHeight.value.isFinite() && lineHeight.value > 0) lineHeight else style.lineHeight
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Memoize automation ID
|
|
64
|
+
val automationId = remember(accessibilityId, text) {
|
|
65
|
+
accessibilityId ?: text
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
androidx.compose.material3.Text(
|
|
69
|
+
modifier = modifier.setAutomationId(automationId, text),
|
|
70
|
+
text = text,
|
|
71
|
+
color = textColor,
|
|
72
|
+
style = optimizedStyle,
|
|
73
|
+
textAlign = textAlign,
|
|
74
|
+
fontSize = fontSize,
|
|
75
|
+
fontFamily = font,
|
|
76
|
+
maxLines = maxLines,
|
|
77
|
+
softWrap = softWrap,
|
|
78
|
+
letterSpacing = letterSpacing,
|
|
79
|
+
minLines = minLines,
|
|
80
|
+
textDecoration = textDecoration,
|
|
81
|
+
onTextLayout = onTextLayout,
|
|
82
|
+
overflow = overflow
|
|
83
|
+
)
|
|
84
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
package vn.momo.kits.components
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.background
|
|
4
|
+
import androidx.compose.foundation.clickable
|
|
5
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
6
|
+
import androidx.compose.foundation.layout.Box
|
|
7
|
+
import androidx.compose.foundation.layout.Column
|
|
8
|
+
import androidx.compose.foundation.layout.IntrinsicSize
|
|
9
|
+
import androidx.compose.foundation.layout.Row
|
|
10
|
+
import androidx.compose.foundation.layout.Spacer
|
|
11
|
+
import androidx.compose.foundation.layout.fillMaxHeight
|
|
12
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
13
|
+
import androidx.compose.foundation.layout.height
|
|
14
|
+
import androidx.compose.foundation.layout.padding
|
|
15
|
+
import androidx.compose.foundation.layout.size
|
|
16
|
+
import androidx.compose.foundation.layout.width
|
|
17
|
+
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
18
|
+
import androidx.compose.runtime.Composable
|
|
19
|
+
import androidx.compose.ui.Alignment
|
|
20
|
+
import androidx.compose.ui.Modifier
|
|
21
|
+
import androidx.compose.ui.graphics.Color
|
|
22
|
+
import androidx.compose.ui.text.TextStyle
|
|
23
|
+
import androidx.compose.ui.text.font.FontWeight
|
|
24
|
+
import androidx.compose.ui.unit.dp
|
|
25
|
+
import androidx.compose.ui.unit.sp
|
|
26
|
+
import vn.momo.kits.const.AppTheme
|
|
27
|
+
import vn.momo.kits.const.Colors
|
|
28
|
+
import vn.momo.kits.const.Spacing
|
|
29
|
+
import vn.momo.kits.const.Typography
|
|
30
|
+
|
|
31
|
+
enum class TitleType { Card, Section }
|
|
32
|
+
enum class TitleSize { Small, Medium, Large }
|
|
33
|
+
enum class IconAlign { Top, Center, Bottom }
|
|
34
|
+
enum class ButtonSize { Small, Large }
|
|
35
|
+
|
|
36
|
+
@Composable
|
|
37
|
+
fun Title(
|
|
38
|
+
title: String,
|
|
39
|
+
type: TitleType = TitleType.Section,
|
|
40
|
+
size: TitleSize = TitleSize.Medium,
|
|
41
|
+
icon: String? = null,
|
|
42
|
+
iconColor: Color? = null,
|
|
43
|
+
iconAlign: IconAlign = IconAlign.Top,
|
|
44
|
+
showRightAction: Boolean = false,
|
|
45
|
+
showTrailingAction: Boolean = false,
|
|
46
|
+
badgeLabel: String? = null,
|
|
47
|
+
buttonTitle: String? = null,
|
|
48
|
+
buttonSize: ButtonSize = ButtonSize.Small,
|
|
49
|
+
onPressRightAction: () -> Unit = {},
|
|
50
|
+
onPressTrailingAction: () -> Unit = {},
|
|
51
|
+
textOnly: Boolean = false,
|
|
52
|
+
description: String? = null,
|
|
53
|
+
modifier: Modifier = Modifier
|
|
54
|
+
) {
|
|
55
|
+
val theme = AppTheme.current
|
|
56
|
+
val textStyle: TextStyle = when (type) {
|
|
57
|
+
TitleType.Card -> when (size) {
|
|
58
|
+
TitleSize.Small -> TextStyle(fontSize = 14.sp, lineHeight = 20.sp)
|
|
59
|
+
TitleSize.Medium -> TextStyle(fontSize = 16.sp, lineHeight = 22.sp)
|
|
60
|
+
TitleSize.Large -> TextStyle(fontSize = 18.sp, lineHeight = 26.sp)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
TitleType.Section -> when (size) {
|
|
64
|
+
TitleSize.Small -> TextStyle(
|
|
65
|
+
fontSize = 16.sp,
|
|
66
|
+
lineHeight = 24.sp,
|
|
67
|
+
fontWeight = FontWeight.Bold
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
TitleSize.Medium -> TextStyle(
|
|
71
|
+
fontSize = 18.sp,
|
|
72
|
+
lineHeight = 26.sp,
|
|
73
|
+
fontWeight = FontWeight.Bold
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
TitleSize.Large -> TextStyle(
|
|
77
|
+
fontSize = 20.sp,
|
|
78
|
+
lineHeight = 28.sp,
|
|
79
|
+
fontWeight = FontWeight.Bold
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (textOnly) {
|
|
85
|
+
Text(
|
|
86
|
+
text = title,
|
|
87
|
+
style = textStyle,
|
|
88
|
+
modifier = modifier
|
|
89
|
+
)
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
Row(
|
|
94
|
+
modifier = modifier
|
|
95
|
+
.fillMaxWidth()
|
|
96
|
+
.height(IntrinsicSize.Min)
|
|
97
|
+
.padding(8.dp),
|
|
98
|
+
verticalAlignment = Alignment.CenterVertically
|
|
99
|
+
) {
|
|
100
|
+
icon?.let {
|
|
101
|
+
Column(
|
|
102
|
+
modifier = Modifier.fillMaxHeight().padding(end = Spacing.S),
|
|
103
|
+
verticalArrangement = when (iconAlign) {
|
|
104
|
+
IconAlign.Top -> Arrangement.Top
|
|
105
|
+
IconAlign.Center -> Arrangement.Center
|
|
106
|
+
IconAlign.Bottom -> Arrangement.Bottom
|
|
107
|
+
},
|
|
108
|
+
) {
|
|
109
|
+
// Icon
|
|
110
|
+
Icon(
|
|
111
|
+
source = it,
|
|
112
|
+
color = iconColor ?: theme.colors.text.default,
|
|
113
|
+
modifier = Modifier.size(24.dp)
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
Column(
|
|
119
|
+
modifier = Modifier.weight(1f)
|
|
120
|
+
) {
|
|
121
|
+
Row(
|
|
122
|
+
verticalAlignment = Alignment.CenterVertically
|
|
123
|
+
) {
|
|
124
|
+
Row(
|
|
125
|
+
verticalAlignment = Alignment.CenterVertically,
|
|
126
|
+
modifier = if (showTrailingAction) Modifier else Modifier.weight(1f),
|
|
127
|
+
) {
|
|
128
|
+
Text(
|
|
129
|
+
text = title,
|
|
130
|
+
style = textStyle,
|
|
131
|
+
maxLines = if (showTrailingAction || badgeLabel != null) 1 else 2,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
// Badge
|
|
135
|
+
badgeLabel?.let {
|
|
136
|
+
Spacer(modifier = Modifier.width(4.dp))
|
|
137
|
+
Badge(
|
|
138
|
+
label = it
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Trailing action (icon)
|
|
145
|
+
if (showTrailingAction && !showRightAction) {
|
|
146
|
+
Spacer(modifier = Modifier.width(8.dp))
|
|
147
|
+
Box(
|
|
148
|
+
modifier = Modifier
|
|
149
|
+
.size(24.dp)
|
|
150
|
+
.background(
|
|
151
|
+
color = if (type == TitleType.Section) Colors.black_06.copy(0.6f) else Colors.black_06.copy(
|
|
152
|
+
0.3f
|
|
153
|
+
),
|
|
154
|
+
shape = RoundedCornerShape(12.dp)
|
|
155
|
+
)
|
|
156
|
+
.clickable { onPressTrailingAction() },
|
|
157
|
+
contentAlignment = Alignment.Center
|
|
158
|
+
) {
|
|
159
|
+
Icon(
|
|
160
|
+
source = "arrow_chevron_right_small",
|
|
161
|
+
size = 18.dp
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Description
|
|
168
|
+
description?.let {
|
|
169
|
+
Spacer(modifier = Modifier.height(4.dp))
|
|
170
|
+
Text(
|
|
171
|
+
text = it,
|
|
172
|
+
style = Typography.descriptionDefaultRegular,
|
|
173
|
+
color = theme.colors.text.secondary
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Right action (button or icon)
|
|
179
|
+
if (showRightAction && !showTrailingAction) {
|
|
180
|
+
Spacer(modifier = Modifier.width(8.dp))
|
|
181
|
+
if (buttonTitle != null) {
|
|
182
|
+
Text(
|
|
183
|
+
text = buttonTitle,
|
|
184
|
+
style = if (buttonSize === ButtonSize.Small) Typography.actionXsBold else Typography.actionSBold,
|
|
185
|
+
color = theme.colors.primary,
|
|
186
|
+
modifier = Modifier.clickable { onPressRightAction() }
|
|
187
|
+
)
|
|
188
|
+
} else {
|
|
189
|
+
Box(
|
|
190
|
+
modifier = Modifier
|
|
191
|
+
.size(24.dp)
|
|
192
|
+
.background(
|
|
193
|
+
color = Colors.pink_03.copy(alpha = 0.1f),
|
|
194
|
+
shape = RoundedCornerShape(12.dp)
|
|
195
|
+
)
|
|
196
|
+
.clickable { onPressRightAction() },
|
|
197
|
+
contentAlignment = Alignment.Center
|
|
198
|
+
) {
|
|
199
|
+
Icon(
|
|
200
|
+
source = "arrow_chevron_right_small",
|
|
201
|
+
modifier = Modifier.size(22.dp),
|
|
202
|
+
color = theme.colors.primary
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
package vn.momo.kits.components
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.background
|
|
4
|
+
import androidx.compose.foundation.clickable
|
|
5
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
6
|
+
import androidx.compose.foundation.layout.Column
|
|
7
|
+
import androidx.compose.foundation.layout.Row
|
|
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.foundation.shape.RoundedCornerShape
|
|
13
|
+
import androidx.compose.runtime.Composable
|
|
14
|
+
import androidx.compose.ui.Alignment
|
|
15
|
+
import androidx.compose.ui.Modifier
|
|
16
|
+
import androidx.compose.ui.draw.clip
|
|
17
|
+
import androidx.compose.ui.graphics.Color
|
|
18
|
+
import androidx.compose.ui.layout.ContentScale
|
|
19
|
+
import androidx.compose.ui.unit.dp
|
|
20
|
+
import androidx.compose.ui.unit.sp
|
|
21
|
+
import vn.momo.kits.application.AppConfig
|
|
22
|
+
import vn.momo.kits.application.AppLanguage
|
|
23
|
+
import vn.momo.kits.modifier.noFeedbackClickable
|
|
24
|
+
import vn.momo.kits.components.Text
|
|
25
|
+
import vn.momo.kits.const.Typography
|
|
26
|
+
|
|
27
|
+
val defaultBanner = TrustBannerData(
|
|
28
|
+
content = mapOf(
|
|
29
|
+
"vi" to "An toàn tài sản & Bảo mật thông tin của bạn là ưu tiên hàng đầu của MoMo.",
|
|
30
|
+
"en" to "Ensuring financial security and data privacy is MoMo's highest priority."
|
|
31
|
+
),
|
|
32
|
+
subContent = mapOf(
|
|
33
|
+
"vi" to "Tìm hiểu thêm",
|
|
34
|
+
"en" to "Learn more"
|
|
35
|
+
),
|
|
36
|
+
pciImage = "https://static.momocdn.net/app/img/kits/trustBanner/pci_dss.png",
|
|
37
|
+
sslImage = "https://static.momocdn.net/app/img/kits/trustBanner/ssl.png",
|
|
38
|
+
urlConfig = "login_and_security",
|
|
39
|
+
icons = listOf(
|
|
40
|
+
"https://static.momocdn.net/app/img/kits/trustBanner/ic_viettinbank.png",
|
|
41
|
+
"https://static.momocdn.net/app/img/kits/trustBanner/ic_agribank.png",
|
|
42
|
+
"https://static.momocdn.net/app/img/kits/trustBanner/ic_vietcombank.png",
|
|
43
|
+
"https://static.momocdn.net/app/img/kits/trustBanner/ic_bidv.png"
|
|
44
|
+
),
|
|
45
|
+
momoImage = "https://static.momocdn.net/app/img/kits/trustBanner/ic_secu.png"
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
const val backgroundBlue = 0xFFF2F8FF
|
|
49
|
+
const val contentColor = 0xFF484848
|
|
50
|
+
const val subContentColor = 0xFFEB2F96
|
|
51
|
+
|
|
52
|
+
data class TrustBannerData(
|
|
53
|
+
val content: Map<String, String> = mapOf("vi" to "", "en" to ""),
|
|
54
|
+
val subContent: Map<String, String> = mapOf("vi" to "", "en" to ""),
|
|
55
|
+
val pciImage: String? = null,
|
|
56
|
+
val momoImage: String? = null,
|
|
57
|
+
val sslImage: String? = null,
|
|
58
|
+
val icons: List<String>? = null,
|
|
59
|
+
val urlConfig: String = ""
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
@Composable
|
|
63
|
+
fun TrustBanner(
|
|
64
|
+
serviceName: String = "",
|
|
65
|
+
screenName: String = "",
|
|
66
|
+
onPress: ((Map<String, String>) -> Unit)? = null,
|
|
67
|
+
trackEvent: ((String, Map<String, String>) -> Unit)? = null
|
|
68
|
+
) {
|
|
69
|
+
val appConfig = AppConfig.current
|
|
70
|
+
val language = AppLanguage.current ?: "vi"
|
|
71
|
+
val trustBanner = appConfig?.trustBanner ?: defaultBanner
|
|
72
|
+
val trackParams = mapOf(
|
|
73
|
+
"service_name" to serviceName,
|
|
74
|
+
"screen_name" to screenName,
|
|
75
|
+
"component_name" to "logo_trust",
|
|
76
|
+
"url_config" to trustBanner.urlConfig
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
Row(
|
|
80
|
+
modifier = Modifier
|
|
81
|
+
.clip(RoundedCornerShape(12.dp))
|
|
82
|
+
.background(color = Color(backgroundBlue))
|
|
83
|
+
.padding(12.dp)
|
|
84
|
+
.then(
|
|
85
|
+
if (onPress != null) {
|
|
86
|
+
Modifier.clickable {
|
|
87
|
+
trackEvent?.invoke(
|
|
88
|
+
"service_component_clicked", trackParams
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
onPress(
|
|
92
|
+
mapOf(
|
|
93
|
+
"service_name" to serviceName,
|
|
94
|
+
"screen_name" to screenName,
|
|
95
|
+
"url_config" to trustBanner.urlConfig,
|
|
96
|
+
)
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
Modifier.noFeedbackClickable {
|
|
102
|
+
trackEvent?.invoke(
|
|
103
|
+
"service_component_clicked", trackParams
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
) {
|
|
109
|
+
if (trustBanner.momoImage != null) {
|
|
110
|
+
Image(
|
|
111
|
+
source = trustBanner.momoImage,
|
|
112
|
+
modifier = Modifier
|
|
113
|
+
.width(64.dp)
|
|
114
|
+
.height(64.dp)
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
Column(
|
|
118
|
+
modifier = Modifier
|
|
119
|
+
.padding(start = 10.dp)
|
|
120
|
+
) {
|
|
121
|
+
Text(
|
|
122
|
+
text = trustBanner.content[language] ?: "",
|
|
123
|
+
modifier = Modifier.padding(bottom = 8.dp),
|
|
124
|
+
color = Color(contentColor),
|
|
125
|
+
style = Typography.descriptionDefaultRegular,
|
|
126
|
+
maxLines = 2
|
|
127
|
+
)
|
|
128
|
+
Row(
|
|
129
|
+
modifier = Modifier.fillMaxWidth(),
|
|
130
|
+
horizontalArrangement = Arrangement.SpaceBetween
|
|
131
|
+
) {
|
|
132
|
+
Row(
|
|
133
|
+
verticalAlignment = Alignment.CenterVertically,
|
|
134
|
+
) {
|
|
135
|
+
Text(
|
|
136
|
+
text = trustBanner.subContent[language] ?: "",
|
|
137
|
+
color = Color(subContentColor),
|
|
138
|
+
style = Typography.actionXsBold,
|
|
139
|
+
maxLines = 2
|
|
140
|
+
)
|
|
141
|
+
Icon(
|
|
142
|
+
source = "https://img.mservice.io/momo_app_v2/new_version/img/appx_icon/16_arrow_chevron_right_small.png",
|
|
143
|
+
color = Color(subContentColor),
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
Row {
|
|
147
|
+
if (trustBanner.pciImage != null) {
|
|
148
|
+
Image(
|
|
149
|
+
source = trustBanner.pciImage, modifier = Modifier
|
|
150
|
+
.padding(end = 4.dp)
|
|
151
|
+
.width(27.dp)
|
|
152
|
+
.height(20.dp), options = Options(
|
|
153
|
+
contentScale = ContentScale.Fit,
|
|
154
|
+
)
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
if (trustBanner.sslImage != null) {
|
|
158
|
+
Image(
|
|
159
|
+
source = trustBanner.sslImage, modifier = Modifier
|
|
160
|
+
.width(52.dp)
|
|
161
|
+
.height(20.dp),
|
|
162
|
+
options = Options(
|
|
163
|
+
contentScale = ContentScale.Fit,
|
|
164
|
+
)
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|