@momo-kits/native-kits 0.160.7-debug → 0.161.1-beta.15-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/compose/build.gradle.kts +1 -1
- package/compose/compose.podspec +1 -1
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +14 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +3 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +14 -19
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +12 -27
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +28 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +1 -14
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +7 -11
- package/example/ios/Example.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +5 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/Pods-Example.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImage.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SkeletonUI.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +46 -0
- package/gradle/libs.versions.toml +1 -1
- package/gradle.properties +1 -1
- package/ios/Application/ApplicationEnvironment.swift +6 -2
- package/ios/Input/Input.swift +21 -50
- package/ios/Input/InputPhoneNumber.swift +17 -17
- package/ios/Typography/Text.swift +14 -19
- package/ios/Typography/Typography.swift +1 -22
- package/local.properties +8 -0
- package/package.json +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -17
package/compose/build.gradle.kts
CHANGED
package/compose/compose.podspec
CHANGED
|
@@ -70,14 +70,13 @@ actual fun getScreenHeight(): Dp {
|
|
|
70
70
|
return getScreenDimensions().height.dp + if (getOSVersion() >= 35) 0.dp else AppStatusBar.current + AppNavigationBar.current
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
actual fun getOSVersion():
|
|
73
|
+
actual fun getOSVersion(): Int = Build.VERSION.SDK_INT
|
|
74
74
|
|
|
75
75
|
@Composable
|
|
76
76
|
actual fun LottieAnimation(
|
|
77
77
|
path: String,
|
|
78
78
|
tintColor: Color?,
|
|
79
79
|
bgColor: Color?,
|
|
80
|
-
placedAsOverlay: Boolean,
|
|
81
80
|
modifier: Modifier
|
|
82
81
|
) {
|
|
83
82
|
val json = readJson(path)
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
package vn.momo.kits.application
|
|
2
2
|
|
|
3
3
|
import androidx.compose.runtime.Immutable
|
|
4
|
+
import androidx.compose.runtime.mutableStateOf
|
|
4
5
|
import androidx.compose.runtime.staticCompositionLocalOf
|
|
5
6
|
import vn.momo.kits.components.TrustBannerData
|
|
6
7
|
|
|
7
8
|
@Immutable
|
|
8
9
|
data class FeatureFlags(
|
|
9
|
-
val
|
|
10
|
+
val isBaselineEnabled: Boolean? = false,
|
|
11
|
+
val isWhiteList: Boolean? = false,
|
|
12
|
+
val allowFontScale: Boolean? = true,
|
|
10
13
|
)
|
|
11
14
|
|
|
12
15
|
@Immutable
|
|
@@ -28,7 +31,6 @@ data class MiniAppContext(
|
|
|
28
31
|
val providerId: String = "",
|
|
29
32
|
val permissions: List<Map<String, Any>>? = emptyList(),
|
|
30
33
|
val features: FeatureFlags? = null,
|
|
31
|
-
val scaleSizeMaxRate: Float? = null,
|
|
32
34
|
) {
|
|
33
35
|
companion object {
|
|
34
36
|
|
|
@@ -60,7 +62,6 @@ data class MiniAppContext(
|
|
|
60
62
|
providerId = parent.providerId.ifBlank { child.providerId },
|
|
61
63
|
permissions = if (!parent.permissions.isNullOrEmpty()) parent.permissions else child.permissions,
|
|
62
64
|
features = mergeFeatureFlags(parent.features, child.features),
|
|
63
|
-
scaleSizeMaxRate = parent.scaleSizeMaxRate ?: child.scaleSizeMaxRate,
|
|
64
65
|
)
|
|
65
66
|
}
|
|
66
67
|
|
|
@@ -74,7 +75,7 @@ data class MiniAppContext(
|
|
|
74
75
|
if (child == null) return parent
|
|
75
76
|
|
|
76
77
|
return FeatureFlags(
|
|
77
|
-
|
|
78
|
+
isBaselineEnabled = parent.isBaselineEnabled ?: child.isBaselineEnabled
|
|
78
79
|
)
|
|
79
80
|
}
|
|
80
81
|
}
|
|
@@ -88,12 +89,19 @@ data class ComponentInformation(
|
|
|
88
89
|
val action: String? = null
|
|
89
90
|
)
|
|
90
91
|
|
|
91
|
-
var IsShowBaseLineDebug = false
|
|
92
|
-
|
|
93
92
|
val ApplicationContext = staticCompositionLocalOf<MiniAppContext?> {
|
|
94
93
|
null
|
|
95
94
|
}
|
|
96
95
|
|
|
96
|
+
var IsShowBaseLineDebug = false
|
|
97
|
+
|
|
98
|
+
private val UseFontScaleSystemState = mutableStateOf(true)
|
|
99
|
+
var UseFontScaleSystem: Boolean
|
|
100
|
+
get() = UseFontScaleSystemState.value
|
|
101
|
+
set(value) {
|
|
102
|
+
UseFontScaleSystemState.value = value
|
|
103
|
+
}
|
|
104
|
+
|
|
97
105
|
val AppConfig = staticCompositionLocalOf<KitConfig?> {
|
|
98
106
|
null
|
|
99
107
|
}
|
|
@@ -105,5 +113,3 @@ val AppLanguage = staticCompositionLocalOf<String?> {
|
|
|
105
113
|
val LocalComponentInformation = staticCompositionLocalOf<ComponentInformation?> {
|
|
106
114
|
null
|
|
107
115
|
}
|
|
108
|
-
|
|
109
|
-
val ScaleSizeMaxRate = staticCompositionLocalOf<Float?> { null }
|
|
@@ -59,9 +59,8 @@ import vn.momo.kits.modifier.DeprecatedModifier
|
|
|
59
59
|
import vn.momo.kits.modifier.conditional
|
|
60
60
|
import vn.momo.kits.modifier.shadow
|
|
61
61
|
import vn.momo.kits.navigation.component.SnackBar
|
|
62
|
-
import vn.momo.kits.platform.
|
|
62
|
+
import vn.momo.kits.platform.getOSVersion
|
|
63
63
|
import vn.momo.kits.utils.getAppStatusBarHeight
|
|
64
|
-
import vn.momo.kits.utils.getNavigationBarHeight
|
|
65
64
|
|
|
66
65
|
enum class HeaderType {
|
|
67
66
|
DEFAULT,
|
|
@@ -103,7 +102,7 @@ fun Screen(
|
|
|
103
102
|
val keyboardController = LocalSoftwareKeyboardController.current
|
|
104
103
|
|
|
105
104
|
val isKeyboardVisible = isKeyboardVisible()
|
|
106
|
-
val indicator =
|
|
105
|
+
val indicator = getAppStatusBarHeight()
|
|
107
106
|
val bottomPadding = if (isKeyboardVisible) 0.dp else indicator
|
|
108
107
|
|
|
109
108
|
val headerHeight = if (animatedHeader !== null)
|
|
@@ -135,7 +134,7 @@ fun Screen(
|
|
|
135
134
|
Box(
|
|
136
135
|
Modifier.fillMaxSize()
|
|
137
136
|
.background(backgroundColor ?: AppTheme.current.colors.background.default)
|
|
138
|
-
.conditional(useAvoidKeyboard &&
|
|
137
|
+
.conditional(useAvoidKeyboard && getOSVersion() > 29) {
|
|
139
138
|
imePadding()
|
|
140
139
|
}.then(DeprecatedModifier())
|
|
141
140
|
) {
|
|
@@ -21,10 +21,6 @@ import androidx.compose.ui.graphics.Color
|
|
|
21
21
|
import androidx.compose.ui.graphics.PathEffect
|
|
22
22
|
import androidx.compose.ui.graphics.StrokeCap
|
|
23
23
|
import androidx.compose.ui.unit.dp
|
|
24
|
-
import io.ktor.util.Platform
|
|
25
|
-
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
26
|
-
import vn.momo.kits.const.Colors
|
|
27
|
-
import vn.momo.kits.modifier.conditional
|
|
28
24
|
import vn.momo.kits.platform.getPlatformName
|
|
29
25
|
import vn.momo.kits.platform.getStatusBarHeight
|
|
30
26
|
|
|
@@ -221,7 +221,6 @@ fun Input(
|
|
|
221
221
|
onBlur: () -> Unit = {},
|
|
222
222
|
loading: Boolean = false,
|
|
223
223
|
required: Boolean = false,
|
|
224
|
-
maxLength: Int? = null,
|
|
225
224
|
fontWeight: InputFontWeight = InputFontWeight.REGULAR,
|
|
226
225
|
keyboardType: KeyboardType = KeyboardType.Text,
|
|
227
226
|
modifier: Modifier = Modifier,
|
|
@@ -320,10 +319,7 @@ fun Input(
|
|
|
320
319
|
onBlur()
|
|
321
320
|
}
|
|
322
321
|
},
|
|
323
|
-
onValueChange =
|
|
324
|
-
val limitedText = maxLength?.let { newText.take(it) } ?: newText
|
|
325
|
-
onChangeText(limitedText)
|
|
326
|
-
},
|
|
322
|
+
onValueChange = onChangeText,
|
|
327
323
|
decorationBox = { innerTextField ->
|
|
328
324
|
// Floating label
|
|
329
325
|
if (floatingValue.isNotEmpty() || floatingIcon.isNotEmpty()) {
|
|
@@ -8,7 +8,6 @@ import androidx.compose.animation.core.rememberInfiniteTransition
|
|
|
8
8
|
import androidx.compose.animation.core.tween
|
|
9
9
|
import androidx.compose.foundation.background
|
|
10
10
|
import androidx.compose.foundation.border
|
|
11
|
-
import androidx.compose.ui.draw.alpha
|
|
12
11
|
import androidx.compose.foundation.clickable
|
|
13
12
|
import androidx.compose.foundation.layout.Arrangement
|
|
14
13
|
import androidx.compose.foundation.layout.Box
|
|
@@ -130,11 +129,8 @@ fun InputOTP(
|
|
|
130
129
|
if (!it.isFocused && isBlurred) onBlur()
|
|
131
130
|
if (it.isFocused && !isBlurred) isBlurred = true
|
|
132
131
|
},
|
|
133
|
-
decorationBox = {
|
|
132
|
+
decorationBox = { _ ->
|
|
134
133
|
Box {
|
|
135
|
-
Box(
|
|
136
|
-
modifier = Modifier.fillMaxWidth().height(56.dp).alpha(0f)
|
|
137
|
-
) { innerTextField() }
|
|
138
134
|
if (floatingValue.isNotEmpty()) {
|
|
139
135
|
Box(
|
|
140
136
|
modifier = Modifier.wrapContentSize()
|
|
@@ -105,8 +105,6 @@ data class InputSearchProps(
|
|
|
105
105
|
val iconModifier: Modifier = Modifier,
|
|
106
106
|
val onClearPress: () -> Unit = {},
|
|
107
107
|
val leftPosition: Dp? = null,
|
|
108
|
-
val placeholderCustomRender: (@Composable () -> Unit)? = null,
|
|
109
|
-
val searchIcon: (@Composable () -> Unit)? = null
|
|
110
108
|
)
|
|
111
109
|
|
|
112
110
|
@Composable
|
|
@@ -147,13 +145,12 @@ fun InputSearch(
|
|
|
147
145
|
)
|
|
148
146
|
}
|
|
149
147
|
|
|
150
|
-
Row(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
.
|
|
155
|
-
|
|
156
|
-
}
|
|
148
|
+
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier
|
|
149
|
+
.fillMaxWidth()
|
|
150
|
+
.height(36.dp)
|
|
151
|
+
.conditional(IsShowBaseLineDebug) {
|
|
152
|
+
border(1.dp, Colors.blue_03)
|
|
153
|
+
}
|
|
157
154
|
) {
|
|
158
155
|
BasicTextField(
|
|
159
156
|
enabled = !inputSearchProps.disabled,
|
|
@@ -187,14 +184,13 @@ fun InputSearch(
|
|
|
187
184
|
horizontalArrangement = Arrangement.Start,
|
|
188
185
|
verticalAlignment = Alignment.CenterVertically
|
|
189
186
|
) {
|
|
190
|
-
|
|
191
187
|
Row(
|
|
192
188
|
modifier = Modifier.padding(
|
|
193
189
|
horizontal = Spacing.M
|
|
194
190
|
),
|
|
195
191
|
verticalAlignment = Alignment.CenterVertically
|
|
196
192
|
) {
|
|
197
|
-
|
|
193
|
+
Icon(
|
|
198
194
|
source = "navigation_search",
|
|
199
195
|
modifier = Modifier.padding(end = Spacing.XS),
|
|
200
196
|
size = 24.dp,
|
|
@@ -202,14 +198,13 @@ fun InputSearch(
|
|
|
202
198
|
)
|
|
203
199
|
Box(Modifier.weight(1f)) {
|
|
204
200
|
if (inputSearchProps.text.value.isEmpty()) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
)
|
|
201
|
+
Text(
|
|
202
|
+
text = inputSearchProps.placeholder,
|
|
203
|
+
style = placeHolderStyle,
|
|
204
|
+
maxLines = 1,
|
|
205
|
+
color = placeholderColor,
|
|
206
|
+
overflow = TextOverflow.Ellipsis
|
|
207
|
+
)
|
|
213
208
|
}
|
|
214
209
|
innerTextField()
|
|
215
210
|
}
|
|
@@ -7,15 +7,11 @@ import androidx.compose.ui.text.TextStyle
|
|
|
7
7
|
import androidx.compose.ui.text.font.FontFamily
|
|
8
8
|
import androidx.compose.ui.text.font.FontWeight
|
|
9
9
|
import androidx.compose.ui.text.style.TextDecoration
|
|
10
|
-
import androidx.compose.ui.unit
|
|
11
|
-
import androidx.compose.ui.unit.TextUnit
|
|
12
|
-
import androidx.compose.ui.unit.TextUnitType
|
|
13
|
-
import androidx.compose.ui.unit.dp
|
|
14
|
-
import androidx.compose.ui.unit.sp
|
|
10
|
+
import androidx.compose.ui.unit.*
|
|
15
11
|
import org.jetbrains.compose.resources.Font
|
|
16
12
|
import org.jetbrains.compose.resources.FontResource
|
|
17
13
|
import org.jetbrains.compose.resources.InternalResourceApi
|
|
18
|
-
import vn.momo.kits.application.
|
|
14
|
+
import vn.momo.kits.application.UseFontScaleSystem
|
|
19
15
|
import vn.momo.kits.platform.getScreenDimensions
|
|
20
16
|
import vn.momo.uikits.resources.Res
|
|
21
17
|
import vn.momo.uikits.resources.momosignature
|
|
@@ -33,34 +29,23 @@ import kotlin.math.max
|
|
|
33
29
|
import kotlin.math.min
|
|
34
30
|
|
|
35
31
|
const val DEFAULT_SCREEN_SIZE = 375f
|
|
36
|
-
const val MAX_FONT_SCALE = 1.
|
|
37
|
-
const val MAX_DEVICE_SCALE = 5
|
|
32
|
+
const val MAX_FONT_SCALE = 1.2f
|
|
38
33
|
|
|
39
34
|
@Composable
|
|
40
35
|
fun scaleSize(size: Float): Float {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
if (UseFontScaleSystem) {
|
|
37
|
+
val deviceWidth = getScreenDimensions().width
|
|
38
|
+
val deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE
|
|
39
|
+
val fontScale = LocalDensity.current.fontScale
|
|
44
40
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var fontSizeScaleDevice = size
|
|
49
|
-
var fontSizeScaleOS = size
|
|
41
|
+
val maxSize = size * MAX_FONT_SCALE
|
|
42
|
+
val fontSizeScaleDevice = if (deviceScale > 1) deviceScale * size else size
|
|
43
|
+
val fontSizeScaleOS = if (fontScale > 1) fontScale * size else size
|
|
50
44
|
|
|
51
|
-
|
|
52
|
-
fontSizeScaleDevice =
|
|
53
|
-
min(deviceScale * fontSizeScaleDevice, fontSizeScaleDevice + MAX_DEVICE_SCALE)
|
|
45
|
+
return min(max(fontSizeScaleDevice, fontSizeScaleOS), maxSize)
|
|
54
46
|
}
|
|
55
47
|
|
|
56
|
-
|
|
57
|
-
fontSizeScaleOS = min(fontScale * fontSizeScaleOS, fontSizeScaleOS * scaleSizeMaxRate)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return max(
|
|
61
|
-
fontSizeScaleDevice,
|
|
62
|
-
fontSizeScaleOS
|
|
63
|
-
)
|
|
48
|
+
return size
|
|
64
49
|
}
|
|
65
50
|
|
|
66
51
|
@Composable
|
|
@@ -8,6 +8,9 @@ import androidx.navigation.compose.NavHost
|
|
|
8
8
|
import androidx.navigation.compose.composable
|
|
9
9
|
import androidx.navigation.compose.rememberNavController
|
|
10
10
|
import androidx.navigation.toRoute
|
|
11
|
+
import kotlinx.coroutines.flow.catch
|
|
12
|
+
import kotlinx.coroutines.flow.distinctUntilChanged
|
|
13
|
+
import kotlinx.coroutines.flow.map
|
|
11
14
|
import vn.momo.kits.application.*
|
|
12
15
|
import vn.momo.kits.const.*
|
|
13
16
|
import vn.momo.kits.platform.ProvideNavigationEventDispatcherOwner
|
|
@@ -49,6 +52,19 @@ fun NavigationContainer(
|
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
|
|
55
|
+
LaunchedEffect(maxApi) {
|
|
56
|
+
val api = maxApi ?: return@LaunchedEffect
|
|
57
|
+
runCatching {
|
|
58
|
+
api.observer("use_font_scale")
|
|
59
|
+
.map { parseUseFontScale(it) }
|
|
60
|
+
.distinctUntilChanged()
|
|
61
|
+
.catch { /* ignore observer errors, keep current value */ }
|
|
62
|
+
.collect { enabled ->
|
|
63
|
+
UseFontScaleSystem = enabled
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
52
68
|
val startDestination = DynamicScreenRegistry.register(initialScreenName, initialScreen, options)
|
|
53
69
|
|
|
54
70
|
ProvideNavigationEventDispatcherOwner {
|
|
@@ -61,7 +77,6 @@ fun NavigationContainer(
|
|
|
61
77
|
ApplicationContext provides mergedContext,
|
|
62
78
|
AppConfig provides config,
|
|
63
79
|
AppLanguage provides language,
|
|
64
|
-
ScaleSizeMaxRate provides mergedContext?.scaleSizeMaxRate,
|
|
65
80
|
) {
|
|
66
81
|
LaunchedEffect(Unit) {
|
|
67
82
|
setNavigator?.invoke(navigator)
|
|
@@ -139,3 +154,15 @@ fun NavigationContainer(
|
|
|
139
154
|
val LocalMaxApi = staticCompositionLocalOf<IMaxApi?> {
|
|
140
155
|
error("No MaxApi provided")
|
|
141
156
|
}
|
|
157
|
+
|
|
158
|
+
private fun parseUseFontScale(raw: Any?): Boolean = when (raw) {
|
|
159
|
+
null -> true
|
|
160
|
+
is Boolean -> raw
|
|
161
|
+
is String -> raw.isBlank() || !raw.equals("false", ignoreCase = true)
|
|
162
|
+
is Number -> raw.toInt() != 0
|
|
163
|
+
is Map<*, *> -> {
|
|
164
|
+
val nested = raw["response"] ?: raw["value"] ?: raw["data"]
|
|
165
|
+
if (nested === raw) true else parseUseFontScale(nested)
|
|
166
|
+
}
|
|
167
|
+
else -> true
|
|
168
|
+
}
|
|
@@ -62,7 +62,7 @@ import vn.momo.kits.navigation.component.HeaderRight
|
|
|
62
62
|
import vn.momo.kits.navigation.component.HeaderType
|
|
63
63
|
import vn.momo.kits.navigation.component.InputSearchType
|
|
64
64
|
import vn.momo.kits.platform.BackHandler
|
|
65
|
-
import vn.momo.kits.platform.
|
|
65
|
+
import vn.momo.kits.platform.getOSVersion
|
|
66
66
|
import vn.momo.kits.navigation.tracking.ScreenTracker
|
|
67
67
|
import vn.momo.kits.navigation.tracking.ScreenTrackingState
|
|
68
68
|
import kotlinx.coroutines.delay
|
|
@@ -166,7 +166,7 @@ internal fun StackScreen(
|
|
|
166
166
|
.conditional(options.keyboardOptions.keyboardShouldPersistTaps) {
|
|
167
167
|
hideKeyboardOnTap()
|
|
168
168
|
}
|
|
169
|
-
.conditional(options.keyboardOptions.useAvoidKeyboard &&
|
|
169
|
+
.conditional(options.keyboardOptions.useAvoidKeyboard && getOSVersion() > 29) {
|
|
170
170
|
imePadding()
|
|
171
171
|
}
|
|
172
172
|
) {
|
|
@@ -30,26 +30,13 @@ expect fun ProvideNavigationEventDispatcherOwner(content: @Composable () -> Unit
|
|
|
30
30
|
@Composable
|
|
31
31
|
expect fun getScreenHeight(): Dp
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
val value: Int
|
|
35
|
-
data class Android(val sdk: Int) : OSVersion { override val value: Int get() = sdk }
|
|
36
|
-
data class IOS(val major: Int) : OSVersion { override val value: Int get() = major }
|
|
37
|
-
|
|
38
|
-
operator fun compareTo(other: Int): Int = value.compareTo(other)
|
|
39
|
-
}
|
|
40
|
-
expect fun getOSVersion(): OSVersion
|
|
41
|
-
|
|
42
|
-
fun supportsImePadding(): Boolean = when (val v = getOSVersion()) {
|
|
43
|
-
is OSVersion.Android -> v.sdk > 29
|
|
44
|
-
is OSVersion.IOS -> true
|
|
45
|
-
}
|
|
33
|
+
expect fun getOSVersion(): Int
|
|
46
34
|
|
|
47
35
|
@Composable
|
|
48
36
|
expect fun LottieAnimation(
|
|
49
37
|
path: String,
|
|
50
38
|
tintColor: Color? = null,
|
|
51
39
|
bgColor: Color? = null,
|
|
52
|
-
placedAsOverlay: Boolean = false,
|
|
53
40
|
modifier: Modifier = Modifier
|
|
54
41
|
)
|
|
55
42
|
|
|
@@ -12,19 +12,17 @@ import androidx.compose.runtime.getValue
|
|
|
12
12
|
import androidx.compose.runtime.mutableStateOf
|
|
13
13
|
import androidx.compose.runtime.remember
|
|
14
14
|
import androidx.compose.runtime.setValue
|
|
15
|
-
import androidx.compose.ui.ExperimentalComposeUiApi
|
|
16
15
|
import androidx.compose.ui.InternalComposeUiApi
|
|
17
16
|
import androidx.compose.ui.Modifier
|
|
18
17
|
import androidx.compose.ui.backhandler.LocalCompatNavigationEventDispatcherOwner
|
|
19
18
|
import androidx.compose.ui.graphics.Color
|
|
20
19
|
import androidx.compose.ui.graphics.NativePaint
|
|
21
20
|
import androidx.compose.ui.graphics.toArgb
|
|
21
|
+
import androidx.compose.ui.interop.UIKitView
|
|
22
22
|
import androidx.compose.ui.semantics.SemanticsPropertyKey
|
|
23
23
|
import androidx.compose.ui.semantics.semantics
|
|
24
24
|
import androidx.compose.ui.unit.Dp
|
|
25
25
|
import androidx.compose.ui.unit.dp
|
|
26
|
-
import androidx.compose.ui.viewinterop.UIKitInteropProperties
|
|
27
|
-
import androidx.compose.ui.viewinterop.UIKitView
|
|
28
26
|
import cocoapods.lottie_ios.CompatibleAnimation
|
|
29
27
|
import cocoapods.lottie_ios.CompatibleAnimationKeypath
|
|
30
28
|
import cocoapods.lottie_ios.CompatibleAnimationView
|
|
@@ -87,17 +85,16 @@ actual fun getScreenHeight(): Dp {
|
|
|
87
85
|
return getScreenDimensions().height.dp
|
|
88
86
|
}
|
|
89
87
|
|
|
90
|
-
actual fun getOSVersion():
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
actual fun getOSVersion(): Int {
|
|
89
|
+
return UIDevice.currentDevice.systemVersion.substringBefore(".").toIntOrNull() ?: 0
|
|
90
|
+
}
|
|
93
91
|
|
|
94
|
-
@OptIn(ExperimentalForeignApi::class
|
|
92
|
+
@OptIn(ExperimentalForeignApi::class)
|
|
95
93
|
@Composable
|
|
96
94
|
actual fun LottieAnimation(
|
|
97
95
|
path: String,
|
|
98
96
|
tintColor: Color?,
|
|
99
97
|
bgColor: Color?,
|
|
100
|
-
placedAsOverlay: Boolean,
|
|
101
98
|
modifier: Modifier
|
|
102
99
|
) {
|
|
103
100
|
var animation by remember { mutableStateOf<CompatibleAnimation?>(null) }
|
|
@@ -115,12 +112,11 @@ actual fun LottieAnimation(
|
|
|
115
112
|
Box(modifier) {
|
|
116
113
|
UIKitView(
|
|
117
114
|
modifier = Modifier.fillMaxSize(),
|
|
118
|
-
properties = UIKitInteropProperties(placedAsOverlay = placedAsOverlay),
|
|
119
115
|
factory = {
|
|
120
116
|
CompatibleAnimationView(value).apply {
|
|
121
117
|
translatesAutoresizingMaskIntoConstraints = true
|
|
122
118
|
|
|
123
|
-
setBackgroundColor(bgColor?.toUIColor() ?: UIColor.
|
|
119
|
+
setBackgroundColor(bgColor?.toUIColor() ?: UIColor.whiteColor)
|
|
124
120
|
|
|
125
121
|
setLoopAnimationCount(-1.0)
|
|
126
122
|
setAnimationSpeed(1.0)
|
|
@@ -141,7 +137,7 @@ actual fun LottieAnimation(
|
|
|
141
137
|
},
|
|
142
138
|
|
|
143
139
|
update = { view ->
|
|
144
|
-
view.setBackgroundColor(bgColor?.toUIColor() ?: UIColor.
|
|
140
|
+
view.setBackgroundColor(bgColor?.toUIColor() ?: UIColor.whiteColor)
|
|
145
141
|
|
|
146
142
|
if (tintColor != null) {
|
|
147
143
|
val uiColor = tintColor.toUIColor()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>SchemeUserState</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>Example.xcscheme_^#shared#^_</key>
|
|
8
|
+
<dict>
|
|
9
|
+
<key>orderHint</key>
|
|
10
|
+
<integer>0</integer>
|
|
11
|
+
</dict>
|
|
12
|
+
</dict>
|
|
13
|
+
</dict>
|
|
14
|
+
</plist>
|
|
Binary file
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Scheme
|
|
3
|
+
LastUpgradeVersion = "1600"
|
|
4
|
+
version = "1.3">
|
|
5
|
+
<BuildAction
|
|
6
|
+
parallelizeBuildables = "YES"
|
|
7
|
+
buildImplicitDependencies = "YES">
|
|
8
|
+
<BuildActionEntries>
|
|
9
|
+
<BuildActionEntry
|
|
10
|
+
buildForTesting = "YES"
|
|
11
|
+
buildForRunning = "YES"
|
|
12
|
+
buildForProfiling = "YES"
|
|
13
|
+
buildForArchiving = "YES"
|
|
14
|
+
buildForAnalyzing = "YES">
|
|
15
|
+
<BuildableReference
|
|
16
|
+
BuildableIdentifier = "primary"
|
|
17
|
+
BlueprintIdentifier = "3B6FB503A75BF5BC1FA6F30BC06B9D28"
|
|
18
|
+
BuildableName = "MoMoUIKits.framework"
|
|
19
|
+
BlueprintName = "MoMoUIKits"
|
|
20
|
+
ReferencedContainer = "container:Pods.xcodeproj">
|
|
21
|
+
</BuildableReference>
|
|
22
|
+
</BuildActionEntry>
|
|
23
|
+
</BuildActionEntries>
|
|
24
|
+
</BuildAction>
|
|
25
|
+
<TestAction
|
|
26
|
+
buildConfiguration = "Debug"
|
|
27
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
28
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
29
|
+
shouldUseLaunchSchemeArgsEnv = "YES">
|
|
30
|
+
<Testables>
|
|
31
|
+
</Testables>
|
|
32
|
+
</TestAction>
|
|
33
|
+
<LaunchAction
|
|
34
|
+
buildConfiguration = "Debug"
|
|
35
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
36
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
37
|
+
launchStyle = "0"
|
|
38
|
+
useCustomWorkingDirectory = "NO"
|
|
39
|
+
ignoresPersistentStateOnLaunch = "NO"
|
|
40
|
+
debugDocumentVersioning = "YES"
|
|
41
|
+
debugServiceExtension = "internal"
|
|
42
|
+
allowLocationSimulation = "YES">
|
|
43
|
+
</LaunchAction>
|
|
44
|
+
<ProfileAction
|
|
45
|
+
buildConfiguration = "Release"
|
|
46
|
+
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
47
|
+
savedToolIdentifier = ""
|
|
48
|
+
useCustomWorkingDirectory = "NO"
|
|
49
|
+
debugDocumentVersioning = "YES">
|
|
50
|
+
</ProfileAction>
|
|
51
|
+
<AnalyzeAction
|
|
52
|
+
buildConfiguration = "Debug">
|
|
53
|
+
</AnalyzeAction>
|
|
54
|
+
<ArchiveAction
|
|
55
|
+
buildConfiguration = "Release"
|
|
56
|
+
revealArchiveInOrganizer = "YES">
|
|
57
|
+
</ArchiveAction>
|
|
58
|
+
</Scheme>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Scheme
|
|
3
|
+
LastUpgradeVersion = "1600"
|
|
4
|
+
version = "1.3">
|
|
5
|
+
<BuildAction
|
|
6
|
+
parallelizeBuildables = "YES"
|
|
7
|
+
buildImplicitDependencies = "YES">
|
|
8
|
+
<BuildActionEntries>
|
|
9
|
+
<BuildActionEntry
|
|
10
|
+
buildForTesting = "YES"
|
|
11
|
+
buildForRunning = "YES"
|
|
12
|
+
buildForProfiling = "YES"
|
|
13
|
+
buildForArchiving = "YES"
|
|
14
|
+
buildForAnalyzing = "YES">
|
|
15
|
+
<BuildableReference
|
|
16
|
+
BuildableIdentifier = "primary"
|
|
17
|
+
BlueprintIdentifier = "0AEE99A309977BD12A049FF48AF9BA4B"
|
|
18
|
+
BuildableName = "Pods_Example.framework"
|
|
19
|
+
BlueprintName = "Pods-Example"
|
|
20
|
+
ReferencedContainer = "container:Pods.xcodeproj">
|
|
21
|
+
</BuildableReference>
|
|
22
|
+
</BuildActionEntry>
|
|
23
|
+
</BuildActionEntries>
|
|
24
|
+
</BuildAction>
|
|
25
|
+
<TestAction
|
|
26
|
+
buildConfiguration = "Debug"
|
|
27
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
28
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
29
|
+
shouldUseLaunchSchemeArgsEnv = "YES">
|
|
30
|
+
<Testables>
|
|
31
|
+
</Testables>
|
|
32
|
+
</TestAction>
|
|
33
|
+
<LaunchAction
|
|
34
|
+
buildConfiguration = "Debug"
|
|
35
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
36
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
37
|
+
launchStyle = "0"
|
|
38
|
+
useCustomWorkingDirectory = "NO"
|
|
39
|
+
ignoresPersistentStateOnLaunch = "NO"
|
|
40
|
+
debugDocumentVersioning = "YES"
|
|
41
|
+
debugServiceExtension = "internal"
|
|
42
|
+
allowLocationSimulation = "YES">
|
|
43
|
+
</LaunchAction>
|
|
44
|
+
<ProfileAction
|
|
45
|
+
buildConfiguration = "Release"
|
|
46
|
+
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
47
|
+
savedToolIdentifier = ""
|
|
48
|
+
useCustomWorkingDirectory = "NO"
|
|
49
|
+
debugDocumentVersioning = "YES">
|
|
50
|
+
</ProfileAction>
|
|
51
|
+
<AnalyzeAction
|
|
52
|
+
buildConfiguration = "Debug">
|
|
53
|
+
</AnalyzeAction>
|
|
54
|
+
<ArchiveAction
|
|
55
|
+
buildConfiguration = "Release"
|
|
56
|
+
revealArchiveInOrganizer = "YES">
|
|
57
|
+
</ArchiveAction>
|
|
58
|
+
</Scheme>
|