@momo-kits/native-kits 0.155.1-hello.1 → 0.155.1-hello.1-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore.backup +22 -0
- package/compose/compose.podspec +54 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +113 -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/Context.kt +95 -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 +305 -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 +121 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +405 -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 +85 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +343 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +353 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +98 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +138 -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 +78 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +151 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +190 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +119 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +447 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +175 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +244 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +233 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +233 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +257 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +240 -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 +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +44 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +95 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +43 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +355 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +106 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +72 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +17 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +99 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +99 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +95 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +132 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +217 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +180 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +208 -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 +239 -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 +189 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +285 -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/DeprecatedModifier.kt +15 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -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 +241 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +122 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +98 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +163 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +331 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +499 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +162 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +233 -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 +190 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +277 -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 +370 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +135 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +42 -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 +152 -0
- package/package.json +1 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
package vn.momo.kits.utils
|
|
2
|
+
|
|
3
|
+
import androidx.compose.runtime.Composable
|
|
4
|
+
import androidx.compose.runtime.LaunchedEffect
|
|
5
|
+
import androidx.compose.runtime.MutableState
|
|
6
|
+
import androidx.compose.runtime.getValue
|
|
7
|
+
import androidx.compose.runtime.mutableStateOf
|
|
8
|
+
import androidx.compose.runtime.remember
|
|
9
|
+
import org.jetbrains.compose.resources.DrawableResource
|
|
10
|
+
import org.jetbrains.compose.resources.InternalResourceApi
|
|
11
|
+
import org.jetbrains.compose.resources.ResourceItem
|
|
12
|
+
import org.jetbrains.compose.resources.readResourceBytes
|
|
13
|
+
|
|
14
|
+
@OptIn(InternalResourceApi::class)
|
|
15
|
+
@Composable
|
|
16
|
+
fun getResource(name: String): DrawableResource {
|
|
17
|
+
return DrawableResource(
|
|
18
|
+
"drawable:$name",
|
|
19
|
+
setOf(ResourceItem(setOf(), "drawable/$name", -1, -1))
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@OptIn(InternalResourceApi::class)
|
|
24
|
+
@Composable
|
|
25
|
+
fun readJson(name: String): String {
|
|
26
|
+
val path = name.plus(".json")
|
|
27
|
+
|
|
28
|
+
val jsonContent by rememberState(path, { "" }) {
|
|
29
|
+
val cached = resourceCache.getOrPut(path) {
|
|
30
|
+
val content = try {
|
|
31
|
+
readResourceBytes(path).decodeToString()
|
|
32
|
+
} catch (_: Exception) {
|
|
33
|
+
""
|
|
34
|
+
}
|
|
35
|
+
ResourceCache.JSON(content)
|
|
36
|
+
} as ResourceCache.JSON
|
|
37
|
+
|
|
38
|
+
cached.json
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return jsonContent
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
private val resourceCache = mutableMapOf<String, ResourceCache>()
|
|
46
|
+
|
|
47
|
+
private sealed interface ResourceCache {
|
|
48
|
+
class JSON(val json: String) : ResourceCache
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Composable
|
|
52
|
+
fun <T> rememberState(
|
|
53
|
+
key: Any,
|
|
54
|
+
getDefault: () -> T,
|
|
55
|
+
block: suspend () -> T
|
|
56
|
+
): MutableState<T> {
|
|
57
|
+
val state = remember(key) { mutableStateOf(getDefault()) }
|
|
58
|
+
LaunchedEffect(key) {
|
|
59
|
+
state.value = block()
|
|
60
|
+
}
|
|
61
|
+
return state
|
|
62
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
package vn.momo.kits.utils
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.layout.WindowInsets
|
|
4
|
+
import androidx.compose.foundation.layout.asPaddingValues
|
|
5
|
+
import androidx.compose.foundation.layout.systemBars
|
|
6
|
+
import androidx.compose.runtime.Composable
|
|
7
|
+
import androidx.compose.ui.Modifier
|
|
8
|
+
import androidx.compose.ui.composed
|
|
9
|
+
import androidx.compose.ui.draw.drawBehind
|
|
10
|
+
import androidx.compose.ui.geometry.Offset
|
|
11
|
+
import androidx.compose.ui.graphics.Color
|
|
12
|
+
import androidx.compose.ui.platform.LocalDensity
|
|
13
|
+
import androidx.compose.ui.unit.Dp
|
|
14
|
+
import androidx.compose.ui.unit.dp
|
|
15
|
+
import vn.momo.kits.const.AppStatusBar
|
|
16
|
+
import kotlin.math.abs
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
internal fun Modifier.bottomBorder(strokeWidth: Dp, color: Color) = composed(
|
|
20
|
+
factory = {
|
|
21
|
+
val density = LocalDensity.current
|
|
22
|
+
val strokeWidthPx = density.run { strokeWidth.toPx() }
|
|
23
|
+
if (strokeWidth > 0.dp) {
|
|
24
|
+
Modifier.drawBehind {
|
|
25
|
+
val width = size.width
|
|
26
|
+
val height = size.height - strokeWidthPx / 2
|
|
27
|
+
|
|
28
|
+
drawLine(
|
|
29
|
+
color = color,
|
|
30
|
+
start = Offset(x = 0f, y = height),
|
|
31
|
+
end = Offset(x = width, y = height),
|
|
32
|
+
strokeWidth = strokeWidthPx
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
Modifier
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
inline fun <T> Boolean.ifTrue(trueCase: T, falseCase: T): T = if (this) trueCase else falseCase
|
|
42
|
+
inline fun <T> String.ifNotNull(trueCase: T, falseCase: T): T =
|
|
43
|
+
if (this.isBlank()) falseCase else trueCase
|
|
44
|
+
|
|
45
|
+
fun formatNumberToMoney(number: Long, currency: String = "đ"): String {
|
|
46
|
+
if (number == 0L) {
|
|
47
|
+
return "0$currency"
|
|
48
|
+
}
|
|
49
|
+
val array = mutableListOf<Char>()
|
|
50
|
+
var result = ""
|
|
51
|
+
var isNegative = false
|
|
52
|
+
|
|
53
|
+
if (number < 0) {
|
|
54
|
+
isNegative = true
|
|
55
|
+
}
|
|
56
|
+
val numberString = abs(number).toString() // Convert to Int to avoid decimal places
|
|
57
|
+
if (numberString.length < 3) {
|
|
58
|
+
return numberString + currency
|
|
59
|
+
}
|
|
60
|
+
var count = 0
|
|
61
|
+
for (i in numberString.length - 1 downTo 0) {
|
|
62
|
+
count += 1
|
|
63
|
+
array.add(numberString[i])
|
|
64
|
+
if (count == 3 && i >= 1) {
|
|
65
|
+
array.add('.')
|
|
66
|
+
count = 0
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
for (i in array.size - 1 downTo 0) {
|
|
71
|
+
result += array[i]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (isNegative) {
|
|
75
|
+
result = "-$result"
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return result + currency
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@Composable
|
|
82
|
+
fun getAppStatusBarHeight(): Dp {
|
|
83
|
+
return if (AppStatusBar.current == 0.dp) {
|
|
84
|
+
WindowInsets.systemBars.asPaddingValues().calculateTopPadding()
|
|
85
|
+
} else {
|
|
86
|
+
AppStatusBar.current
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
package vn.momo.kits.platform
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.layout.Box
|
|
4
|
+
import androidx.compose.foundation.layout.WindowInsets
|
|
5
|
+
import androidx.compose.foundation.layout.asPaddingValues
|
|
6
|
+
import androidx.compose.foundation.layout.fillMaxSize
|
|
7
|
+
import androidx.compose.foundation.layout.systemBars
|
|
8
|
+
import androidx.compose.runtime.Composable
|
|
9
|
+
import androidx.compose.runtime.LaunchedEffect
|
|
10
|
+
import androidx.compose.runtime.getValue
|
|
11
|
+
import androidx.compose.runtime.mutableStateOf
|
|
12
|
+
import androidx.compose.runtime.remember
|
|
13
|
+
import androidx.compose.runtime.setValue
|
|
14
|
+
import androidx.compose.ui.Modifier
|
|
15
|
+
import androidx.compose.ui.draw.drawBehind
|
|
16
|
+
import androidx.compose.ui.graphics.Color
|
|
17
|
+
import androidx.compose.ui.graphics.NativePaint
|
|
18
|
+
import androidx.compose.ui.graphics.Paint
|
|
19
|
+
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
|
|
20
|
+
import androidx.compose.ui.graphics.toArgb
|
|
21
|
+
import androidx.compose.ui.interop.UIKitView
|
|
22
|
+
import androidx.compose.ui.unit.Dp
|
|
23
|
+
import androidx.compose.ui.unit.dp
|
|
24
|
+
import cocoapods.lottie_ios.CompatibleAnimation
|
|
25
|
+
import cocoapods.lottie_ios.CompatibleAnimationKeypath
|
|
26
|
+
import cocoapods.lottie_ios.CompatibleAnimationView
|
|
27
|
+
import kotlinx.cinterop.ExperimentalForeignApi
|
|
28
|
+
import kotlinx.cinterop.get
|
|
29
|
+
import kotlinx.cinterop.memScoped
|
|
30
|
+
import org.jetbrains.skia.FilterBlurMode
|
|
31
|
+
import org.jetbrains.skia.MaskFilter
|
|
32
|
+
import platform.Foundation.NSBundle
|
|
33
|
+
import platform.UIKit.UIColor
|
|
34
|
+
import platform.UIKit.UIScreen
|
|
35
|
+
|
|
36
|
+
actual fun getPlatformName(): String = "iOS"
|
|
37
|
+
|
|
38
|
+
@OptIn(ExperimentalForeignApi::class)
|
|
39
|
+
@Composable
|
|
40
|
+
actual fun getScreenDimensions(): ScreenDimension = memScoped {
|
|
41
|
+
val config = UIScreen.mainScreen.bounds.ptr[0]
|
|
42
|
+
return ScreenDimension(
|
|
43
|
+
config.size.width.toInt(),
|
|
44
|
+
config.size.height.toInt()
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
actual fun NativePaint.setMaskFilter(blurRadius: Float) {
|
|
49
|
+
this.maskFilter = MaskFilter.makeBlur(FilterBlurMode.NORMAL, blurRadius / 2, true)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Composable
|
|
53
|
+
actual fun getStatusBarHeight(): Dp {
|
|
54
|
+
return WindowInsets.systemBars.asPaddingValues().calculateTopPadding()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Composable
|
|
58
|
+
actual fun BackHandler(enabled: Boolean, onBack: () -> Unit) {
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@Composable
|
|
62
|
+
actual fun getScreenHeight(): Dp {
|
|
63
|
+
return getScreenDimensions().height.dp
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
actual fun getAndroidBuildVersion(): Int = 999
|
|
67
|
+
|
|
68
|
+
@OptIn(ExperimentalForeignApi::class)
|
|
69
|
+
@Composable
|
|
70
|
+
actual fun LottieAnimation(
|
|
71
|
+
path: String,
|
|
72
|
+
tintColor: Color?,
|
|
73
|
+
bgColor: Color?,
|
|
74
|
+
modifier: Modifier
|
|
75
|
+
) {
|
|
76
|
+
var animation by remember { mutableStateOf<CompatibleAnimation?>(null) }
|
|
77
|
+
|
|
78
|
+
LaunchedEffect(Unit) {
|
|
79
|
+
animation = CompatibleAnimation(name = "compose-resources/composeResources/vn.momo.compose.resources/".plus(path), subdirectory = null, NSBundle.mainBundle)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
when (val value = animation) {
|
|
83
|
+
null -> {
|
|
84
|
+
Box(modifier)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
else -> {
|
|
88
|
+
Box(modifier) {
|
|
89
|
+
UIKitView(
|
|
90
|
+
modifier = Modifier.fillMaxSize(),
|
|
91
|
+
factory = {
|
|
92
|
+
CompatibleAnimationView(value).apply {
|
|
93
|
+
translatesAutoresizingMaskIntoConstraints = true
|
|
94
|
+
|
|
95
|
+
setBackgroundColor(bgColor?.toUIColor() ?: UIColor.whiteColor)
|
|
96
|
+
|
|
97
|
+
setLoopAnimationCount(-1.0)
|
|
98
|
+
setAnimationSpeed(1.0)
|
|
99
|
+
|
|
100
|
+
if (tintColor != null) {
|
|
101
|
+
val uiColor = tintColor.toUIColor()
|
|
102
|
+
setColorValue(uiColor,
|
|
103
|
+
CompatibleAnimationKeypath("**.Fill 1.Color")
|
|
104
|
+
)
|
|
105
|
+
setColorValue(uiColor, CompatibleAnimationKeypath("**.Fill.Color"))
|
|
106
|
+
setColorValue(uiColor, CompatibleAnimationKeypath("**.Color"))
|
|
107
|
+
setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke 1.Color"))
|
|
108
|
+
setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke.Color"))
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
play()
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
update = { view ->
|
|
116
|
+
view.setBackgroundColor(bgColor?.toUIColor() ?: UIColor.whiteColor)
|
|
117
|
+
|
|
118
|
+
if (tintColor != null) {
|
|
119
|
+
val uiColor = tintColor.toUIColor()
|
|
120
|
+
|
|
121
|
+
view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Fill 1.Color"))
|
|
122
|
+
view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Fill.Color"))
|
|
123
|
+
view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Color"))
|
|
124
|
+
view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke 1.Color"))
|
|
125
|
+
view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke.Color"))
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
fun Color.toUIColor(): UIColor {
|
|
135
|
+
val argb = this.toArgb()
|
|
136
|
+
|
|
137
|
+
val a = ((argb shr 24) and 0xFF) / 255.0
|
|
138
|
+
val r = ((argb shr 16) and 0xFF) / 255.0
|
|
139
|
+
val g = ((argb shr 8) and 0xFF) / 255.0
|
|
140
|
+
val b = (argb and 0xFF) / 255.0
|
|
141
|
+
|
|
142
|
+
return UIColor(
|
|
143
|
+
red = r,
|
|
144
|
+
green = g,
|
|
145
|
+
blue = b,
|
|
146
|
+
alpha = a
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
actual fun NativePaint.setColor(color: Color){
|
|
151
|
+
this.color = color.toArgb()
|
|
152
|
+
}
|