@momo-kits/native-kits 0.120.0-rc.8 → 0.120.0-test.20
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/compose/build.gradle.kts +9 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +3 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +1 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +2 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +3 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +2 -66
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +31 -34
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +25 -37
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +19 -30
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +21 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +27 -5
- package/ios/Application/Components.swift +2 -2
- package/ios/Application/Screen.swift +1 -4
- package/ios/Button/Button.swift +7 -7
- package/ios/Checkbox/Checkbox.swift +1 -2
- package/ios/Input/Input.swift +61 -64
- package/ios/Popup/PopupDisplay.swift +20 -25
- package/ios/Popup/PopupPromotion.swift +22 -28
- package/ios/Typography/Text.swift +42 -15
- package/ios/Typography/Typography.swift +22 -1
- package/local.properties +8 -0
- package/package.json +1 -1
- package/publish.sh +16 -15
- package/.fleet/run.json +0 -14
- package/.gitattributes +0 -3
- package/.gitlab-ci.yml +0 -15
- package/.run/momo-native-kits_compose [publish].run.xml +0 -24
- package/example/ios/Example/Assets.xcassets/AccentColor.colorset/Contents.json +0 -11
- package/example/ios/Example/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -63
- package/example/ios/Example/Assets.xcassets/Background.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Border.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Card.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Contents.json +0 -6
- package/example/ios/Example/Assets.xcassets/Error.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Icon.appiconset/icon.json +0 -4052
- package/example/ios/Example/Assets.xcassets/Primary.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/PrimaryDark.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/PrimaryLight.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Secondary.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Success.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Text.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/TextSecondary.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Warning.colorset/Contents.json +0 -38
- package/example/ios/Example/BaselineView.swift +0 -331
- package/example/ios/Example/ButtonDemo.swift +0 -72
- package/example/ios/Example/CheckboxDemo.swift +0 -63
- package/example/ios/Example/ContentView.swift +0 -71
- package/example/ios/Example/Example.entitlements +0 -10
- package/example/ios/Example/Home.swift +0 -134
- package/example/ios/Example/ImageDemo.swift +0 -78
- package/example/ios/Example/InputDemo.swift +0 -90
- package/example/ios/Example/InputSearchDemo.swift +0 -32
- package/example/ios/Example/InputTextAreaDemo.swift +0 -57
- package/example/ios/Example/Main.swift +0 -31
- package/example/ios/Example/Preview Content/Preview Assets.xcassets/Contents.json +0 -6
- package/example/ios/Example/SwitchDemo.swift +0 -33
- package/example/ios/Example/TypographyDemo.swift +0 -87
- package/example/ios/Example/icon.json +0 -4052
- package/example/ios/Example.xcodeproj/project.pbxproj +0 -478
- package/example/ios/Example.xcworkspace/contents.xcworkspacedata +0 -10
- package/example/ios/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/example/ios/Podfile +0 -10
- package/example/ios/Podfile.lock +0 -35
- package/gradle/libs.versions.toml +0 -42
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +0 -6
- package/sample/androidApp/build.gradle.kts +0 -45
- package/sample/androidApp/src/androidMain/AndroidManifest.xml +0 -26
- package/sample/androidApp/src/androidMain/kotlin/com/myapplication/MainActivity.kt +0 -22
- package/sample/androidApp/src/androidMain/res/drawable/ic_launcher_background.xml +0 -170
- package/sample/androidApp/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml +0 -30
- package/sample/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml +0 -5
- package/sample/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml +0 -5
- package/sample/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/sample/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/sample/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/sample/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/sample/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/sample/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/sample/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/sample/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/sample/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/sample/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/sample/androidApp/src/androidMain/res/values/strings.xml +0 -3
- package/sample/iosApp/Configuration/Config.xcconfig +0 -3
- package/sample/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json +0 -11
- package/sample/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -14
- package/sample/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png +0 -0
- package/sample/iosApp/iosApp/Assets.xcassets/Contents.json +0 -6
- package/sample/iosApp/iosApp/Info.plist +0 -50
- package/sample/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json +0 -6
- package/sample/iosApp/iosApp/iosApp.swift +0 -28
- package/sample/iosApp/iosApp.xcodeproj/project.pbxproj +0 -392
- package/sample/shared/build.gradle.kts +0 -66
- package/sample/shared/src/androidMain/AndroidManifest.xml +0 -2
- package/sample/shared/src/androidMain/kotlin/main.android.kt +0 -12
- package/sample/shared/src/commonMain/composeResources/font/momosignature.otf +0 -0
- package/sample/shared/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
- package/sample/shared/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
- package/sample/shared/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
- package/sample/shared/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
- package/sample/shared/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
- package/sample/shared/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
- package/sample/shared/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
- package/sample/shared/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
- package/sample/shared/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
- package/sample/shared/src/commonMain/kotlin/App.kt +0 -11
- package/sample/shared/src/commonMain/kotlin/Home.kt +0 -284
- package/sample/shared/src/commonMain/kotlin/screens/AnimatedHeaderUsage.kt +0 -62
- package/sample/shared/src/commonMain/kotlin/screens/BadgeUsage.kt +0 -32
- package/sample/shared/src/commonMain/kotlin/screens/ButtonUsage.kt +0 -227
- package/sample/shared/src/commonMain/kotlin/screens/CheckBoxUsage.kt +0 -110
- package/sample/shared/src/commonMain/kotlin/screens/DemoScreen.kt +0 -80
- package/sample/shared/src/commonMain/kotlin/screens/DividerUsage.kt +0 -29
- package/sample/shared/src/commonMain/kotlin/screens/IconButtonUsage.kt +0 -115
- package/sample/shared/src/commonMain/kotlin/screens/IconUsage.kt +0 -64
- package/sample/shared/src/commonMain/kotlin/screens/ImageUsage.kt +0 -94
- package/sample/shared/src/commonMain/kotlin/screens/InfomationUsage.kt +0 -53
- package/sample/shared/src/commonMain/kotlin/screens/InputDropDownUsage.kt +0 -318
- package/sample/shared/src/commonMain/kotlin/screens/InputMoneyUsage.kt +0 -277
- package/sample/shared/src/commonMain/kotlin/screens/InputOTPUsage.kt +0 -238
- package/sample/shared/src/commonMain/kotlin/screens/InputSearchUsage.kt +0 -103
- package/sample/shared/src/commonMain/kotlin/screens/InputTextAreaUsage.kt +0 -173
- package/sample/shared/src/commonMain/kotlin/screens/InputUsage.kt +0 -376
- package/sample/shared/src/commonMain/kotlin/screens/PaginationUsage.kt +0 -118
- package/sample/shared/src/commonMain/kotlin/screens/PopupNotify.kt +0 -49
- package/sample/shared/src/commonMain/kotlin/screens/PromotionPopupUsage.kt +0 -30
- package/sample/shared/src/commonMain/kotlin/screens/RadioUsage.kt +0 -79
- package/sample/shared/src/commonMain/kotlin/screens/ScreenUsage.kt +0 -122
- package/sample/shared/src/commonMain/kotlin/screens/SkeletonUsage.kt +0 -28
- package/sample/shared/src/commonMain/kotlin/screens/SwitchUsage.kt +0 -74
- package/sample/shared/src/commonMain/kotlin/screens/TagUsage.kt +0 -38
- package/sample/shared/src/commonMain/kotlin/screens/TextUsage.kt +0 -46
- package/sample/shared/src/commonMain/kotlin/screens/TitleUsage.kt +0 -76
- package/sample/shared/src/commonMain/kotlin/screens/TrustBannerUsage.kt +0 -30
- package/sample/shared/src/iosMain/kotlin/main.ios.kt +0 -10
package/compose/build.gradle.kts
CHANGED
|
@@ -15,10 +15,11 @@ kotlin {
|
|
|
15
15
|
publishLibraryVariants("release")
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
listOf(
|
|
19
|
+
iosX64(),
|
|
20
|
+
iosArm64(),
|
|
21
|
+
iosSimulatorArm64(),
|
|
22
|
+
).forEach { iosTarget ->
|
|
22
23
|
iosTarget.binaries.framework {
|
|
23
24
|
baseName = "lib"
|
|
24
25
|
isStatic = true
|
|
@@ -49,13 +50,10 @@ kotlin {
|
|
|
49
50
|
implementation(libs.jetbrains.coroutines.android)
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
val iosArm64Main by getting
|
|
57
|
-
}
|
|
58
|
-
|
|
53
|
+
val iosX64Main by getting
|
|
54
|
+
val iosArm64Main by getting
|
|
55
|
+
val iosSimulatorArm64Main by getting
|
|
56
|
+
|
|
59
57
|
iosMain.dependencies {
|
|
60
58
|
implementation(libs.ktor.client.darwin)
|
|
61
59
|
}
|
|
@@ -27,7 +27,6 @@ import androidx.compose.ui.graphics.Color
|
|
|
27
27
|
import androidx.compose.ui.graphics.graphicsLayer
|
|
28
28
|
import androidx.compose.ui.semantics.semantics
|
|
29
29
|
import androidx.compose.ui.semantics.testTag
|
|
30
|
-
import androidx.compose.ui.text.style.TextAlign
|
|
31
30
|
import androidx.compose.ui.unit.Dp
|
|
32
31
|
import androidx.compose.ui.unit.dp
|
|
33
32
|
import androidx.compose.ui.zIndex
|
|
@@ -168,11 +167,9 @@ fun Header(
|
|
|
168
167
|
HeaderTitle(
|
|
169
168
|
title = title,
|
|
170
169
|
color = tintIconColor,
|
|
171
|
-
modifier = Modifier
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
,
|
|
175
|
-
textAlign = if(titlePosition == TitlePosition.LEFT) TextAlign.Start else TextAlign.Center
|
|
170
|
+
modifier = Modifier.semantics {
|
|
171
|
+
testTag = "title_navigation_header"
|
|
172
|
+
}
|
|
176
173
|
)
|
|
177
174
|
}
|
|
178
175
|
}
|
|
@@ -4,7 +4,6 @@ import androidx.compose.runtime.Composable
|
|
|
4
4
|
import androidx.compose.ui.Modifier
|
|
5
5
|
import androidx.compose.ui.graphics.Color
|
|
6
6
|
import androidx.compose.ui.text.style.TextAlign
|
|
7
|
-
import androidx.compose.ui.text.style.TextOverflow
|
|
8
7
|
import androidx.compose.ui.unit.sp
|
|
9
8
|
import androidx.compose.ui.zIndex
|
|
10
9
|
import vn.momo.kits.components.Text
|
|
@@ -26,7 +25,6 @@ fun HeaderTitle(
|
|
|
26
25
|
lineHeight = 22.sp,
|
|
27
26
|
),
|
|
28
27
|
color = color,
|
|
29
|
-
maxLines = 1
|
|
30
|
-
overflow = TextOverflow.Ellipsis
|
|
28
|
+
maxLines = 1
|
|
31
29
|
)
|
|
32
30
|
}
|
|
@@ -96,7 +96,8 @@ val AppLanguage = staticCompositionLocalOf<String?> {
|
|
|
96
96
|
data class KitConfig(
|
|
97
97
|
val trustBanner: TrustBannerData? = null,
|
|
98
98
|
val headerBar: String? = null,
|
|
99
|
-
val headerGradient: String? = null
|
|
99
|
+
val headerGradient: String? = null,
|
|
100
|
+
val isWhiteList: Boolean = false
|
|
100
101
|
)
|
|
101
102
|
|
|
102
103
|
@Composable
|
|
@@ -200,8 +200,9 @@ fun Footer(footer: @Composable (() -> Unit)? = null, keyboardSize: Dp = 0.dp, bo
|
|
|
200
200
|
Box(
|
|
201
201
|
Modifier
|
|
202
202
|
.offset(y = -keyboardSize)
|
|
203
|
+
.padding(bottom = bottom)
|
|
203
204
|
.shadow(
|
|
204
|
-
Colors.black_20.copy(alpha = 0.
|
|
205
|
+
Colors.black_20.copy(alpha = 0.1f),
|
|
205
206
|
borderRadius = 0.dp,
|
|
206
207
|
10f,
|
|
207
208
|
offsetX = 0.dp,
|
|
@@ -211,9 +212,7 @@ fun Footer(footer: @Composable (() -> Unit)? = null, keyboardSize: Dp = 0.dp, bo
|
|
|
211
212
|
.background(AppTheme.current.colors.background.surface)
|
|
212
213
|
) {
|
|
213
214
|
Box(
|
|
214
|
-
Modifier.fillMaxWidth()
|
|
215
|
-
.padding(bottom = bottom)
|
|
216
|
-
.padding(vertical = Spacing.S, horizontal = Spacing.M)
|
|
215
|
+
Modifier.fillMaxWidth().padding(vertical = Spacing.S, horizontal = Spacing.M)
|
|
217
216
|
) {
|
|
218
217
|
footer?.invoke()
|
|
219
218
|
}
|
|
@@ -14,8 +14,6 @@ import androidx.compose.ui.graphics.painter.Painter
|
|
|
14
14
|
import androidx.compose.ui.layout.ContentScale
|
|
15
15
|
import androidx.compose.ui.semantics.contentDescription
|
|
16
16
|
import androidx.compose.ui.semantics.semantics
|
|
17
|
-
import androidx.compose.ui.platform.LocalDensity
|
|
18
|
-
import androidx.compose.ui.layout.onSizeChanged
|
|
19
17
|
import coil3.compose.AsyncImage
|
|
20
18
|
import vn.momo.kits.const.AppTheme
|
|
21
19
|
|
|
@@ -30,47 +28,6 @@ enum class ImageState {
|
|
|
30
28
|
Loading, Success, Error
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
private val supportedDomains = setOf(
|
|
34
|
-
"static.momocdn.net",
|
|
35
|
-
"img.mservice.com.vn",
|
|
36
|
-
"cdn.mservice.com.vn",
|
|
37
|
-
"img.mservice.io",
|
|
38
|
-
"image.momocdn.net"
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
private val sizeChart = mapOf(
|
|
42
|
-
"XXS" to 64,
|
|
43
|
-
"XS" to 128,
|
|
44
|
-
"S" to 256,
|
|
45
|
-
"M" to 512,
|
|
46
|
-
"L" to 768,
|
|
47
|
-
"XL" to 1024,
|
|
48
|
-
"XXL" to 2048
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
private fun closestSizeForWidth(width: Float): String {
|
|
52
|
-
return sizeChart.minByOrNull { (_, value) ->
|
|
53
|
-
kotlin.math.abs(value - width)
|
|
54
|
-
}?.key ?: "M"
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private fun getHostFromUrl(url: String): String? {
|
|
58
|
-
return try {
|
|
59
|
-
val noProtocol = url.substringAfter("//")
|
|
60
|
-
noProtocol.substringBefore("/").substringBefore(":")
|
|
61
|
-
} catch (_: Exception) {
|
|
62
|
-
null
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private fun appendQueryParam(url: String, key: String, value: String): String {
|
|
67
|
-
val parts = url.split("#", limit = 2)
|
|
68
|
-
val base = parts[0]
|
|
69
|
-
val fragment = if (parts.size > 1) "#" + parts[1] else ""
|
|
70
|
-
val sep = if (base.contains("?")) "&" else "?"
|
|
71
|
-
return "$base$sep$key=$value$fragment"
|
|
72
|
-
}
|
|
73
|
-
|
|
74
31
|
@Composable
|
|
75
32
|
fun Image(
|
|
76
33
|
source: Any,
|
|
@@ -80,8 +37,6 @@ fun Image(
|
|
|
80
37
|
) {
|
|
81
38
|
var imageOptions = Options()
|
|
82
39
|
var imageState by remember { mutableStateOf(ImageState.Loading) }
|
|
83
|
-
var urlToLoad by remember(source) { mutableStateOf(source) }
|
|
84
|
-
val density = LocalDensity.current
|
|
85
40
|
|
|
86
41
|
options?.let {
|
|
87
42
|
imageOptions = Options(
|
|
@@ -92,29 +47,10 @@ fun Image(
|
|
|
92
47
|
)
|
|
93
48
|
}
|
|
94
49
|
|
|
95
|
-
Box(
|
|
96
|
-
modifier = modifier
|
|
97
|
-
.semantics { contentDescription = "img|$source" }
|
|
98
|
-
.onSizeChanged { size ->
|
|
99
|
-
if (source is String) {
|
|
100
|
-
val host = getHostFromUrl(source)
|
|
101
|
-
if (host != null && supportedDomains.contains(host)) {
|
|
102
|
-
val widthPx = size.width.toFloat()
|
|
103
|
-
val pixelRatio = density.density
|
|
104
|
-
val pixelFitForWidth = widthPx * pixelRatio
|
|
105
|
-
val sizeKey = closestSizeForWidth(pixelFitForWidth)
|
|
106
|
-
urlToLoad = appendQueryParam(source, "size", sizeKey)
|
|
107
|
-
} else {
|
|
108
|
-
urlToLoad = source
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
urlToLoad = source
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
) {
|
|
50
|
+
Box(modifier = modifier.semantics { contentDescription = "img|$source" }) {
|
|
115
51
|
AsyncImage(
|
|
116
52
|
modifier = Modifier.matchParentSize(),
|
|
117
|
-
model =
|
|
53
|
+
model = source,
|
|
118
54
|
contentDescription = null,
|
|
119
55
|
contentScale = imageOptions.contentScale,
|
|
120
56
|
alignment = imageOptions.alignment,
|
|
@@ -36,7 +36,6 @@ import androidx.compose.ui.text.input.KeyboardType
|
|
|
36
36
|
import androidx.compose.ui.unit.dp
|
|
37
37
|
import androidx.compose.ui.zIndex
|
|
38
38
|
import vn.momo.kits.const.AppTheme
|
|
39
|
-
import vn.momo.kits.const.Colors
|
|
40
39
|
import vn.momo.kits.const.Radius
|
|
41
40
|
import vn.momo.kits.const.Spacing
|
|
42
41
|
import vn.momo.kits.const.Typography
|
|
@@ -57,7 +57,6 @@ fun PopupNotify(
|
|
|
57
57
|
secondary: PopupAction? = null,
|
|
58
58
|
buttonDirection: PopupActionDirection = PopupActionDirection.ROW,
|
|
59
59
|
onIconClose: () -> Unit,
|
|
60
|
-
isShowCloseIcon: Boolean = true,
|
|
61
60
|
) {
|
|
62
61
|
var isScroll by remember { mutableStateOf(false) }
|
|
63
62
|
val layoutResult = remember { mutableStateOf<TextLayoutResult?>(null) }
|
|
@@ -108,13 +107,13 @@ fun PopupNotify(
|
|
|
108
107
|
RoundedCornerShape(Radius.L)
|
|
109
108
|
)
|
|
110
109
|
) {
|
|
111
|
-
|
|
110
|
+
image.ifNotNull(
|
|
112
111
|
Image(
|
|
113
112
|
source = image,
|
|
114
113
|
modifier = Modifier.fillMaxWidth().aspectRatio(1.777f),
|
|
115
|
-
options = Options(alignment =
|
|
116
|
-
)
|
|
117
|
-
|
|
114
|
+
options = Options(alignment = Alignment.Center)
|
|
115
|
+
), null
|
|
116
|
+
)
|
|
118
117
|
|
|
119
118
|
Column(modifier = Modifier.padding(Spacing.XL)) {
|
|
120
119
|
Text(
|
|
@@ -126,7 +125,7 @@ fun PopupNotify(
|
|
|
126
125
|
content(Modifier.padding(top = Spacing.S))
|
|
127
126
|
if (error.isNotEmpty()) {
|
|
128
127
|
Text(
|
|
129
|
-
text =
|
|
128
|
+
text = error,
|
|
130
129
|
style = Typography.descriptionXsRegular,
|
|
131
130
|
color = AppTheme.current.colors.text.hint,
|
|
132
131
|
maxLines = 1,
|
|
@@ -145,36 +144,34 @@ fun PopupNotify(
|
|
|
145
144
|
}
|
|
146
145
|
}
|
|
147
146
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
.
|
|
159
|
-
width = 2.dp,
|
|
160
|
-
color = AppTheme.current.colors.background.surface,
|
|
161
|
-
shape = RoundedCornerShape(Radius.M)
|
|
162
|
-
)
|
|
163
|
-
.clip(RoundedCornerShape(100))
|
|
164
|
-
.clickable(
|
|
165
|
-
interactionSource = remember { MutableInteractionSource() },
|
|
166
|
-
indication = null,
|
|
167
|
-
onClick = { onClose { onIconClose() } }
|
|
168
|
-
),
|
|
169
|
-
contentAlignment = Alignment.Center
|
|
170
|
-
) {
|
|
171
|
-
Icon(
|
|
172
|
-
source = "navigation_close",
|
|
147
|
+
Box(
|
|
148
|
+
Modifier
|
|
149
|
+
.width(22.dp)
|
|
150
|
+
.height(22.dp)
|
|
151
|
+
.offset(x = -(1).dp, y = (-11).dp)
|
|
152
|
+
.background(
|
|
153
|
+
color = AppTheme.current.colors.text.default,
|
|
154
|
+
shape = RoundedCornerShape(Radius.M)
|
|
155
|
+
)
|
|
156
|
+
.border(
|
|
157
|
+
width = 2.dp,
|
|
173
158
|
color = AppTheme.current.colors.background.surface,
|
|
174
|
-
|
|
175
|
-
modifier = Modifier.setAutomationId("ic_popup_close")
|
|
159
|
+
shape = RoundedCornerShape(Radius.M)
|
|
176
160
|
)
|
|
177
|
-
|
|
161
|
+
.clip(RoundedCornerShape(100))
|
|
162
|
+
.clickable(
|
|
163
|
+
interactionSource = remember { MutableInteractionSource() },
|
|
164
|
+
indication = null,
|
|
165
|
+
onClick = { onClose { onIconClose() } }
|
|
166
|
+
),
|
|
167
|
+
contentAlignment = Alignment.Center
|
|
168
|
+
) {
|
|
169
|
+
Icon(
|
|
170
|
+
source = "navigation_close",
|
|
171
|
+
color = AppTheme.current.colors.background.surface,
|
|
172
|
+
size = 16.dp,
|
|
173
|
+
modifier = Modifier.setAutomationId("ic_popup_close")
|
|
174
|
+
)
|
|
178
175
|
}
|
|
179
176
|
}
|
|
180
177
|
}
|
|
@@ -22,11 +22,8 @@ import androidx.compose.ui.semantics.semantics
|
|
|
22
22
|
import androidx.compose.ui.semantics.testTag
|
|
23
23
|
import androidx.compose.ui.unit.dp
|
|
24
24
|
import vn.momo.kits.const.AppTheme
|
|
25
|
-
import vn.momo.kits.const.Colors
|
|
26
25
|
import vn.momo.kits.const.Radius
|
|
27
26
|
import vn.momo.kits.const.Spacing
|
|
28
|
-
import vn.momo.kits.modifier.setAutomationId
|
|
29
|
-
import vn.momo.kits.utils.ifNotNull
|
|
30
27
|
|
|
31
28
|
@Composable
|
|
32
29
|
fun PopupPromotion(
|
|
@@ -35,7 +32,7 @@ fun PopupPromotion(
|
|
|
35
32
|
onClose: (() -> Unit) = {},
|
|
36
33
|
) {
|
|
37
34
|
Column(Modifier.semantics { testTag = "popup_notify" }) {
|
|
38
|
-
source.
|
|
35
|
+
if (source.isNotEmpty()) {
|
|
39
36
|
Image(
|
|
40
37
|
source = source,
|
|
41
38
|
modifier = Modifier.fillMaxWidth()
|
|
@@ -46,20 +43,28 @@ fun PopupPromotion(
|
|
|
46
43
|
onClick = onPress
|
|
47
44
|
),
|
|
48
45
|
options = Options(alignment = Alignment.Center, contentScale = ContentScale.Crop)
|
|
49
|
-
)
|
|
50
|
-
|
|
46
|
+
)
|
|
47
|
+
}
|
|
51
48
|
Box(
|
|
52
49
|
modifier = Modifier
|
|
53
50
|
.padding(top = Spacing.S)
|
|
54
|
-
.fillMaxWidth()
|
|
55
|
-
.width(40.dp)
|
|
56
|
-
.height(40.dp),
|
|
51
|
+
.fillMaxWidth(),
|
|
57
52
|
contentAlignment = Alignment.Center
|
|
58
53
|
) {
|
|
59
54
|
Box(
|
|
60
|
-
|
|
61
|
-
.width(
|
|
62
|
-
.height(
|
|
55
|
+
Modifier
|
|
56
|
+
.width(20.dp)
|
|
57
|
+
.height(20.dp)
|
|
58
|
+
.background(
|
|
59
|
+
color = AppTheme.current.colors.text.default,
|
|
60
|
+
shape = RoundedCornerShape(Radius.M)
|
|
61
|
+
)
|
|
62
|
+
.border(
|
|
63
|
+
width = 2.dp,
|
|
64
|
+
color = AppTheme.current.colors.background.surface,
|
|
65
|
+
shape = RoundedCornerShape(Radius.M)
|
|
66
|
+
)
|
|
67
|
+
.clip(RoundedCornerShape(100))
|
|
63
68
|
.clickable(
|
|
64
69
|
interactionSource = remember { MutableInteractionSource() },
|
|
65
70
|
indication = null,
|
|
@@ -67,32 +72,15 @@ fun PopupPromotion(
|
|
|
67
72
|
),
|
|
68
73
|
contentAlignment = Alignment.Center
|
|
69
74
|
) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
.border(
|
|
79
|
-
width = 2.dp,
|
|
80
|
-
color = AppTheme.current.colors.background.surface,
|
|
81
|
-
shape = RoundedCornerShape(Radius.M)
|
|
82
|
-
)
|
|
83
|
-
.clip(RoundedCornerShape(100))
|
|
84
|
-
,
|
|
85
|
-
contentAlignment = Alignment.Center
|
|
86
|
-
) {
|
|
87
|
-
Icon(
|
|
88
|
-
source = "navigation_close",
|
|
89
|
-
color = AppTheme.current.colors.background.surface,
|
|
90
|
-
size = 16.dp,
|
|
91
|
-
modifier = Modifier.setAutomationId("ic_popup_close")
|
|
92
|
-
)
|
|
93
|
-
}
|
|
75
|
+
Icon(
|
|
76
|
+
source = "navigation_close",
|
|
77
|
+
color = AppTheme.current.colors.background.surface,
|
|
78
|
+
size = 14.dp,
|
|
79
|
+
modifier = Modifier.semantics {
|
|
80
|
+
testTag = "ic_popup_close"
|
|
81
|
+
}
|
|
82
|
+
)
|
|
94
83
|
}
|
|
95
|
-
|
|
96
84
|
}
|
|
97
85
|
}
|
|
98
86
|
}
|
|
@@ -17,7 +17,6 @@ import androidx.compose.ui.graphics.Color
|
|
|
17
17
|
import androidx.compose.ui.unit.dp
|
|
18
18
|
import vn.momo.kits.const.Colors
|
|
19
19
|
import vn.momo.kits.const.Spacing
|
|
20
|
-
import vn.momo.kits.modifier.setAutomationId
|
|
21
20
|
import vn.momo.kits.utils.ifTrue
|
|
22
21
|
|
|
23
22
|
@Composable
|
|
@@ -25,8 +24,6 @@ fun Switch(
|
|
|
25
24
|
value: Boolean = false,
|
|
26
25
|
onChange: (Boolean) -> Unit = {},
|
|
27
26
|
disabled: Boolean = false,
|
|
28
|
-
title: String? = "",
|
|
29
|
-
accessibilityId: String? = ""
|
|
30
27
|
) {
|
|
31
28
|
val circleBackgroundColor = value.ifTrue(Colors.black_01, Colors.black_03)
|
|
32
29
|
var backgroundColor = value.ifTrue(Colors.green_03, Colors.black_07)
|
|
@@ -35,35 +32,27 @@ fun Switch(
|
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
Box(
|
|
38
|
-
modifier = Modifier.
|
|
35
|
+
modifier = Modifier.then(
|
|
36
|
+
Modifier.width(38.dp).height(20.dp).border(
|
|
37
|
+
0.dp, Color.Unspecified,
|
|
38
|
+
RoundedCornerShape(20.dp)
|
|
39
|
+
).background(backgroundColor, RoundedCornerShape(20.dp)).clip(RoundedCornerShape(20.dp))
|
|
40
|
+
.clickable(
|
|
41
|
+
enabled = !disabled,
|
|
42
|
+
onClick = { onChange(!value) }
|
|
43
|
+
)
|
|
44
|
+
.padding(horizontal = Spacing.XS)
|
|
45
|
+
),
|
|
46
|
+
contentAlignment = value.ifTrue(Alignment.CenterEnd, Alignment.CenterStart)
|
|
39
47
|
) {
|
|
40
48
|
Box(
|
|
41
|
-
modifier = Modifier.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
enabled = !disabled,
|
|
49
|
-
onClick = { onChange(!value) }
|
|
50
|
-
)
|
|
51
|
-
.padding(horizontal = Spacing.XS)
|
|
52
|
-
),
|
|
53
|
-
contentAlignment = value.ifTrue(Alignment.CenterEnd, Alignment.CenterStart)
|
|
54
|
-
) {
|
|
55
|
-
Box(
|
|
56
|
-
modifier = Modifier.size(14.dp)
|
|
57
|
-
.border(0.dp, Color.Unspecified, RoundedCornerShape(percent = 100))
|
|
58
|
-
.background(circleBackgroundColor, RoundedCornerShape(percent = 100)),
|
|
59
|
-
contentAlignment = Alignment.Center
|
|
60
|
-
)
|
|
61
|
-
{
|
|
62
|
-
Box(
|
|
63
|
-
Modifier.size(6.dp)
|
|
64
|
-
.background(backgroundColor, RoundedCornerShape(percent = 100))
|
|
65
|
-
)
|
|
66
|
-
}
|
|
49
|
+
modifier = Modifier.size(14.dp)
|
|
50
|
+
.border(0.dp, Color.Unspecified, RoundedCornerShape(percent = 100))
|
|
51
|
+
.background(circleBackgroundColor, RoundedCornerShape(percent = 100)),
|
|
52
|
+
contentAlignment = Alignment.Center
|
|
53
|
+
)
|
|
54
|
+
{
|
|
55
|
+
Box(Modifier.size(6.dp).background(backgroundColor, RoundedCornerShape(percent = 100)))
|
|
67
56
|
}
|
|
68
57
|
}
|
|
69
58
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package vn.momo.kits.components
|
|
2
2
|
|
|
3
|
+
import androidx.compose.foundation.border
|
|
4
|
+
import androidx.compose.foundation.layout.Box
|
|
3
5
|
import androidx.compose.runtime.Composable
|
|
4
6
|
import androidx.compose.ui.Modifier
|
|
5
7
|
import androidx.compose.ui.graphics.Color
|
|
@@ -8,9 +10,10 @@ import androidx.compose.ui.text.TextStyle
|
|
|
8
10
|
import androidx.compose.ui.text.style.TextAlign
|
|
9
11
|
import androidx.compose.ui.text.style.TextDecoration
|
|
10
12
|
import androidx.compose.ui.text.style.TextOverflow
|
|
11
|
-
import androidx.compose.ui.unit.
|
|
13
|
+
import androidx.compose.ui.unit.dp
|
|
12
14
|
import androidx.compose.ui.unit.sp
|
|
13
15
|
import vn.momo.kits.const.AppTheme
|
|
16
|
+
import vn.momo.kits.const.Colors
|
|
14
17
|
import vn.momo.kits.const.Typography
|
|
15
18
|
import vn.momo.kits.const.getFontFamily
|
|
16
19
|
import vn.momo.kits.const.scaleSize
|
|
@@ -28,28 +31,25 @@ fun Text(
|
|
|
28
31
|
textDecoration: TextDecoration? = null,
|
|
29
32
|
onTextLayout: ((TextLayoutResult) -> Unit)? = null,
|
|
30
33
|
fontFamily: String = "SFProText",
|
|
31
|
-
minLines: Int = 1,
|
|
32
|
-
letterSpacing: TextUnit = TextUnit.Unspecified,
|
|
33
|
-
softWrap: Boolean = true,
|
|
34
34
|
accessibilityId: String? = null
|
|
35
35
|
) {
|
|
36
36
|
val fontSize = scaleSize(style.fontSize.value).sp
|
|
37
37
|
val font = getFontFamily(fontFamily, style.fontWeight)
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
39
|
+
Box(modifier = Modifier.border(0.5.dp, Colors.green_06)) {
|
|
40
|
+
androidx.compose.material3.Text(
|
|
41
|
+
modifier = modifier.setAutomationId(accessibilityId ?: text, text),
|
|
42
|
+
text = text,
|
|
43
|
+
color = color ?: AppTheme.current.colors.text.default,
|
|
44
|
+
style = style.copy(fontWeight = null),
|
|
45
|
+
textAlign = textAlign,
|
|
46
|
+
fontSize = fontSize,
|
|
47
|
+
fontFamily = font,
|
|
48
|
+
maxLines = maxLines,
|
|
49
|
+
textDecoration = textDecoration,
|
|
50
|
+
onTextLayout = onTextLayout,
|
|
51
|
+
overflow = overflow
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
@@ -2,6 +2,7 @@ package vn.momo.kits.const
|
|
|
2
2
|
|
|
3
3
|
import androidx.compose.runtime.Composable
|
|
4
4
|
import androidx.compose.runtime.Immutable
|
|
5
|
+
import androidx.compose.ui.platform.LocalDensity
|
|
5
6
|
import androidx.compose.ui.text.TextStyle
|
|
6
7
|
import androidx.compose.ui.text.font.FontFamily
|
|
7
8
|
import androidx.compose.ui.text.font.FontWeight
|
|
@@ -11,18 +12,39 @@ import org.jetbrains.compose.resources.Font
|
|
|
11
12
|
import org.jetbrains.compose.resources.FontResource
|
|
12
13
|
import org.jetbrains.compose.resources.InternalResourceApi
|
|
13
14
|
import org.jetbrains.compose.resources.ResourceItem
|
|
15
|
+
import vn.momo.kits.application.AppConfig
|
|
16
|
+
import vn.momo.kits.application.KitConfig
|
|
14
17
|
import vn.momo.kits.platform.getScreenDimensions
|
|
18
|
+
import kotlin.math.max
|
|
19
|
+
import kotlin.math.min
|
|
15
20
|
|
|
16
21
|
const val DEFAULT_SCREEN_SIZE = 375f
|
|
22
|
+
const val MAX_FONT_SCALE = 1.5f
|
|
23
|
+
const val MAX_DEVICE_SCALE = 5
|
|
17
24
|
|
|
18
25
|
@Composable
|
|
19
|
-
fun scaleSize(size: Float): Float {
|
|
26
|
+
fun scaleSize(size: Float, config: KitConfig? = AppConfig.current): Float {
|
|
27
|
+
val isWhiteList = config?.isWhiteList ?: false
|
|
20
28
|
val deviceWidth = getScreenDimensions().width
|
|
21
|
-
val
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
val deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE
|
|
30
|
+
|
|
31
|
+
val density = LocalDensity.current
|
|
32
|
+
val fontScale = density.fontScale
|
|
33
|
+
|
|
34
|
+
val defaultFontSize = size / fontScale //To ignore OS scale
|
|
35
|
+
var fontSizeScaleDevice = defaultFontSize
|
|
36
|
+
var fontSizeScaleOS = defaultFontSize
|
|
37
|
+
|
|
38
|
+
if (deviceScale > 1) {
|
|
39
|
+
fontSizeScaleDevice =
|
|
40
|
+
min(deviceScale * fontSizeScaleDevice, fontSizeScaleDevice + MAX_DEVICE_SCALE)
|
|
24
41
|
}
|
|
25
|
-
|
|
42
|
+
|
|
43
|
+
if (fontScale > 1) {
|
|
44
|
+
fontSizeScaleOS = min(fontScale * fontSizeScaleOS, fontSizeScaleOS * MAX_FONT_SCALE)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return if (isWhiteList) max(fontSizeScaleDevice, fontSizeScaleOS) else fontSizeScaleDevice
|
|
26
48
|
}
|
|
27
49
|
|
|
28
50
|
@OptIn(InternalResourceApi::class)
|
|
@@ -214,8 +214,8 @@ public struct Header: View {
|
|
|
214
214
|
}
|
|
215
215
|
} else {
|
|
216
216
|
Text(title)
|
|
217
|
-
.font(Font.system(size: 17).weight(.bold))
|
|
218
|
-
.lineSpacing(22)
|
|
217
|
+
.font(Font.system(size: scaleSize(17)).weight(.bold))
|
|
218
|
+
.lineSpacing(scaleSize(22))
|
|
219
219
|
.foregroundColor(tintColor)
|
|
220
220
|
.frame(maxWidth: titlePosition == .center ? UIScreen.main.bounds.width - 252 : nil)
|
|
221
221
|
.frame(maxWidth: titlePosition == .center ? .infinity : UIScreen.main.bounds.width - 172, alignment: titlePosition == .center ? .center : .leading)
|
|
@@ -88,8 +88,7 @@ public struct Screen<Content: View>: View {
|
|
|
88
88
|
let screenHeight = height + topInset + bottomInset
|
|
89
89
|
|
|
90
90
|
ZStack {
|
|
91
|
-
(backgroundColor ?? Color.white)
|
|
92
|
-
.edgesIgnoringSafeArea(.top)
|
|
91
|
+
(backgroundColor ?? Color.white).edgesIgnoringSafeArea(.all)
|
|
93
92
|
|
|
94
93
|
VStack(spacing: 0) {
|
|
95
94
|
ZStack(alignment: .top) {
|
|
@@ -185,8 +184,6 @@ struct Footer: View {
|
|
|
185
184
|
VStack {
|
|
186
185
|
footerView
|
|
187
186
|
}
|
|
188
|
-
.padding(.vertical, Spacing.S)
|
|
189
|
-
.padding(.horizontal, Spacing.M)
|
|
190
187
|
.padding(.bottom, keyboardSize)
|
|
191
188
|
.background(Colors.black01)
|
|
192
189
|
}
|