@momo-kits/native-kits 0.151.2-chip.1 → 0.151.2-test.10
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 +2 -0
- package/compose/src/commonMain/composeResources/files/lottie_circle_loader.json +1 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +1 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +2 -14
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +1 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +1 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +1 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +1 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +2 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +7 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +1 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +36 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +4 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +4 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +23 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +4 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +132 -119
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +21 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +14 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +5 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +14 -0
- package/ios/Button/Button.swift +25 -4
- package/ios/Lottie/LottieView.swift +86 -0
- package/ios/native-kits.podspec +1 -0
- package/package.json +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Localize.kt +0 -35
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//
|
|
2
|
+
// LottieView.swift
|
|
3
|
+
// MoMoPlatform
|
|
4
|
+
//
|
|
5
|
+
// Created by thanhdat on 16/01/2023.
|
|
6
|
+
// Copyright © 2023 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import SwiftUI
|
|
10
|
+
import Lottie
|
|
11
|
+
|
|
12
|
+
struct LottieView: UIViewRepresentable {
|
|
13
|
+
var name: String = ""
|
|
14
|
+
var url: String?
|
|
15
|
+
var loopMode: LottieLoopMode = .playOnce
|
|
16
|
+
var contentMode : UIView.ContentMode = .scaleAspectFit
|
|
17
|
+
var onDone: (() -> Void)?
|
|
18
|
+
|
|
19
|
+
// Add static cache for animations
|
|
20
|
+
private static var animationCache = NSCache<NSString, LottieAnimation>()
|
|
21
|
+
|
|
22
|
+
func makeUIView(context: UIViewRepresentableContext<LottieView>) -> UIView {
|
|
23
|
+
let view = UIView(frame: .zero)
|
|
24
|
+
|
|
25
|
+
// Configure Lottie with optimized settings
|
|
26
|
+
let configuration = LottieConfiguration(
|
|
27
|
+
renderingEngine: .coreAnimation,
|
|
28
|
+
decodingStrategy: .dictionaryBased
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
let animationView = LottieAnimationView(configuration: configuration)
|
|
32
|
+
|
|
33
|
+
if let url = url {
|
|
34
|
+
// Use cached animation if available
|
|
35
|
+
if let cachedAnimation = Self.animationCache.object(forKey: url as NSString) {
|
|
36
|
+
animationView.animation = cachedAnimation
|
|
37
|
+
setupAnimationView(animationView, view)
|
|
38
|
+
} else {
|
|
39
|
+
LottieAnimation.loadedFrom(url: URL(string: url)!, closure: { animation in
|
|
40
|
+
if let animation = animation {
|
|
41
|
+
Self.animationCache.setObject(animation, forKey: url as NSString)
|
|
42
|
+
animationView.animation = animation
|
|
43
|
+
setupAnimationView(animationView, view)
|
|
44
|
+
}
|
|
45
|
+
}, animationCache: nil)
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
// Use cached animation if available
|
|
49
|
+
if let cachedAnimation = Self.animationCache.object(forKey: name as NSString) {
|
|
50
|
+
animationView.animation = cachedAnimation
|
|
51
|
+
setupAnimationView(animationView, view)
|
|
52
|
+
} else if let animation = LottieAnimation.named(name) {
|
|
53
|
+
Self.animationCache.setObject(animation, forKey: name as NSString)
|
|
54
|
+
animationView.animation = animation
|
|
55
|
+
setupAnimationView(animationView, view)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return view
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private func setupAnimationView(_ animationView: LottieAnimationView, _ containerView: UIView) {
|
|
63
|
+
animationView.contentMode = contentMode
|
|
64
|
+
animationView.loopMode = loopMode
|
|
65
|
+
animationView.backgroundBehavior = loopMode == .loop ? .pauseAndRestore : .pause
|
|
66
|
+
|
|
67
|
+
// Optimize rendering
|
|
68
|
+
animationView.shouldRasterizeWhenIdle = true
|
|
69
|
+
|
|
70
|
+
animationView.translatesAutoresizingMaskIntoConstraints = false
|
|
71
|
+
containerView.addSubview(animationView)
|
|
72
|
+
|
|
73
|
+
NSLayoutConstraint.activate([
|
|
74
|
+
animationView.widthAnchor.constraint(equalTo: containerView.widthAnchor),
|
|
75
|
+
animationView.heightAnchor.constraint(equalTo: containerView.heightAnchor)
|
|
76
|
+
])
|
|
77
|
+
|
|
78
|
+
animationView.play { finished in
|
|
79
|
+
if finished {
|
|
80
|
+
onDone?()
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<LottieView>) {}
|
|
86
|
+
}
|
package/ios/native-kits.podspec
CHANGED
package/package.json
CHANGED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
package vn.momo.kits.utils
|
|
2
|
-
|
|
3
|
-
import vn.momo.kits.application.ComposeApi
|
|
4
|
-
import vn.momo.maxapi.IMaxApi
|
|
5
|
-
|
|
6
|
-
object Localize {
|
|
7
|
-
val vi = mapOf(
|
|
8
|
-
"enterPhoneNumber" to "Vui lòng nhập số điện thoại",
|
|
9
|
-
"invalidPhoneNumber" to "Số điện thoại không đúng"
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
val en = mapOf(
|
|
13
|
-
"enterPhoneNumber" to "Please enter your phone number",
|
|
14
|
-
"invalidPhoneNumber" to "Invalid phone number"
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
fun getLocalized(composeApi: ComposeApi?, maxApi: IMaxApi?, key: String): String {
|
|
21
|
-
return when {
|
|
22
|
-
composeApi != null -> getLocalized(composeApi, key)
|
|
23
|
-
maxApi != null -> getLocalized(maxApi, key)
|
|
24
|
-
else -> ""
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
private fun getLocalized(api: ComposeApi?, key: String): String {
|
|
29
|
-
return if (api?.request("getLanguage"){} == "vi") vi[key] ?: key else en[key] ?: key
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
private fun getLocalized(api: IMaxApi?, key: String): String {
|
|
33
|
-
return if (api?.getLanguage{} == "vi") vi[key] ?: key else en[key] ?: key
|
|
34
|
-
}
|
|
35
|
-
}
|