@thelacanians/vue-native-cli 0.4.11 → 0.4.13
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/dist/cli.js +1 -1
- package/native/android/.editorconfig +25 -0
- package/native/android/VueNativeCore/build.gradle.kts +25 -1
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/JSPolyfills.kt +17 -10
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/JSRuntime.kt +5 -5
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/NativeBridge.kt +13 -13
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/ComponentRegistry.kt +27 -27
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VActionSheetFactory.kt +6 -4
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VActivityIndicatorFactory.kt +1 -1
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VAlertDialogFactory.kt +24 -12
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VButtonFactory.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VImageFactory.kt +7 -7
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VInputFactory.kt +12 -12
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VKeyboardAvoidingFactory.kt +0 -1
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VListFactory.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VModalFactory.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VPickerFactory.kt +3 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VPressableFactory.kt +5 -3
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VRootFactory.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VScrollViewFactory.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VSectionListFactory.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VSegmentedControlFactory.kt +3 -3
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VStatusBarFactory.kt +3 -3
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VSwitchFactory.kt +0 -1
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VViewFactory.kt +9 -3
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VWebViewFactory.kt +7 -5
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/NativeComponentFactory.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Helpers/GestureHelper.kt +4 -1
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/AnimationModule.kt +77 -21
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/AsyncStorageModule.kt +20 -5
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/BackgroundTaskModule.kt +12 -3
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/BiometryModule.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/BluetoothModule.kt +88 -23
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/CalendarModule.kt +24 -11
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/ClipboardModule.kt +7 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/ContactsModule.kt +24 -12
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/DeviceInfoModule.kt +14 -11
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/FileSystemModule.kt +79 -24
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/GeolocationModule.kt +10 -7
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/HapticsModule.kt +5 -5
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/HttpModule.kt +17 -8
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/IAPModule.kt +20 -5
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/KeyboardModule.kt +4 -1
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/LinkingModule.kt +12 -3
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/NetworkModule.kt +4 -1
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/NotificationsModule.kt +24 -6
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/OTAModule.kt +13 -5
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/PerformanceModule.kt +8 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/PermissionsModule.kt +17 -8
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/SecureStorageModule.kt +20 -5
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/SensorsModule.kt +16 -4
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/ShareModule.kt +6 -3
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/SocialAuthModule.kt +4 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/WebSocketModule.kt +26 -8
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Styling/StyleEngine.kt +127 -84
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Tags.kt +26 -26
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/VueNativeActivity.kt +1 -1
- package/native/android/VueNativeCore/src/test/kotlin/com/vuenative/core/ComponentRegistryTest.kt +173 -0
- package/native/android/VueNativeCore/src/test/kotlin/com/vuenative/core/NativeBridgeTest.kt +436 -0
- package/native/android/VueNativeCore/src/test/kotlin/com/vuenative/core/NativeModuleRegistryTest.kt +251 -0
- package/native/android/VueNativeCore/src/test/kotlin/com/vuenative/core/StyleEngineTest.kt +482 -0
- package/native/android/build.gradle.kts +1 -0
- package/native/ios/.swiftlint.yml +62 -0
- package/native/ios/VueNativeCore/Sources/VueNativeCore/Bridge/NativeBridge.swift +4 -1
- package/native/ios/VueNativeCore/Tests/VueNativeCoreTests/ComponentRegistryTests.swift +237 -0
- package/native/ios/VueNativeCore/Tests/VueNativeCoreTests/NativeBridgeOperationTests.swift +398 -0
- package/native/ios/VueNativeCore/Tests/VueNativeCoreTests/NativeModuleRegistryTests.swift +203 -0
- package/native/ios/VueNativeCore/Tests/VueNativeCoreTests/StyleEngineTests.swift +381 -0
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ import org.json.JSONArray
|
|
|
9
9
|
|
|
10
10
|
class VSegmentedControlFactory : NativeComponentFactory {
|
|
11
11
|
private val changeHandlers = mutableMapOf<RadioGroup, (Any?) -> Unit>()
|
|
12
|
-
private val segmentValues
|
|
12
|
+
private val segmentValues = mutableMapOf<RadioGroup, List<String>>()
|
|
13
13
|
|
|
14
14
|
override fun createView(context: Context): View {
|
|
15
15
|
return RadioGroup(context).apply {
|
|
@@ -27,8 +27,8 @@ class VSegmentedControlFactory : NativeComponentFactory {
|
|
|
27
27
|
"values" -> {
|
|
28
28
|
val labels = when (value) {
|
|
29
29
|
is JSONArray -> (0 until value.length()).map { value.getString(it) }
|
|
30
|
-
is List<*>
|
|
31
|
-
else
|
|
30
|
+
is List<*> -> value.map { it?.toString() ?: "" }
|
|
31
|
+
else -> emptyList()
|
|
32
32
|
}
|
|
33
33
|
segmentValues[rg] = labels
|
|
34
34
|
rg.removeAllViews()
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
package com.vuenative.core
|
|
2
2
|
|
|
3
|
+
import android.content.Context
|
|
3
4
|
import android.os.Build
|
|
4
5
|
import android.view.View
|
|
5
6
|
import android.view.ViewGroup
|
|
6
7
|
import android.view.WindowInsetsController
|
|
7
|
-
import android.content.Context
|
|
8
8
|
|
|
9
9
|
class VStatusBarFactory : NativeComponentFactory {
|
|
10
10
|
override fun createView(context: Context): View = View(context).apply {
|
|
@@ -21,13 +21,13 @@ class VStatusBarFactory : NativeComponentFactory {
|
|
|
21
21
|
val controller = window.insetsController
|
|
22
22
|
when (value) {
|
|
23
23
|
"light-content" -> controller?.setSystemBarsAppearance(0, WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS)
|
|
24
|
-
"dark-content"
|
|
24
|
+
"dark-content" -> controller?.setSystemBarsAppearance(WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS, WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS)
|
|
25
25
|
}
|
|
26
26
|
} else {
|
|
27
27
|
@Suppress("DEPRECATION")
|
|
28
28
|
val flags = window.decorView.systemUiVisibility
|
|
29
29
|
window.decorView.systemUiVisibility = when (value) {
|
|
30
|
-
"dark-content"
|
|
30
|
+
"dark-content" -> flags or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
|
31
31
|
"light-content" -> flags and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv()
|
|
32
32
|
else -> flags
|
|
33
33
|
}
|
|
@@ -24,7 +24,10 @@ class VViewFactory : NativeComponentFactory {
|
|
|
24
24
|
override fun addEventListener(view: View, event: String, handler: (Any?) -> Unit) {
|
|
25
25
|
when (event) {
|
|
26
26
|
"press" -> view.setOnClickListener { handler(null) }
|
|
27
|
-
"longPress" -> view.setOnLongClickListener {
|
|
27
|
+
"longPress" -> view.setOnLongClickListener {
|
|
28
|
+
handler(null)
|
|
29
|
+
true
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
|
|
@@ -38,8 +41,11 @@ class VViewFactory : NativeComponentFactory {
|
|
|
38
41
|
override fun insertChild(parent: View, child: View, index: Int) {
|
|
39
42
|
val flex = parent as? FlexboxLayout ?: return
|
|
40
43
|
val lp = StyleEngine.buildFlexLayoutParams(child)
|
|
41
|
-
if (index >= flex.childCount)
|
|
42
|
-
|
|
44
|
+
if (index >= flex.childCount) {
|
|
45
|
+
flex.addView(child, lp)
|
|
46
|
+
} else {
|
|
47
|
+
flex.addView(child, index, lp)
|
|
48
|
+
}
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
override fun removeChild(parent: View, child: View) {
|
|
@@ -12,8 +12,8 @@ import android.webkit.WebViewClient
|
|
|
12
12
|
import org.json.JSONObject
|
|
13
13
|
|
|
14
14
|
class VWebViewFactory : NativeComponentFactory {
|
|
15
|
-
private val loadHandlers
|
|
16
|
-
private val errorHandlers
|
|
15
|
+
private val loadHandlers = mutableMapOf<WebView, (Any?) -> Unit>()
|
|
16
|
+
private val errorHandlers = mutableMapOf<WebView, (Any?) -> Unit>()
|
|
17
17
|
private val messageHandlers = mutableMapOf<WebView, (Any?) -> Unit>()
|
|
18
18
|
|
|
19
19
|
override fun createView(context: Context): View {
|
|
@@ -77,14 +77,16 @@ class VWebViewFactory : NativeComponentFactory {
|
|
|
77
77
|
override fun addEventListener(view: View, event: String, handler: (Any?) -> Unit) {
|
|
78
78
|
val wv = view as? WebView ?: return
|
|
79
79
|
when (event) {
|
|
80
|
-
"load"
|
|
81
|
-
"error"
|
|
80
|
+
"load" -> loadHandlers[wv] = handler
|
|
81
|
+
"error" -> errorHandlers[wv] = handler
|
|
82
82
|
"message" -> messageHandlers[wv] = handler
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
override fun removeEventListener(view: View, event: String) {
|
|
87
87
|
val wv = view as? WebView ?: return
|
|
88
|
-
loadHandlers.remove(wv)
|
|
88
|
+
loadHandlers.remove(wv)
|
|
89
|
+
errorHandlers.remove(wv)
|
|
90
|
+
messageHandlers.remove(wv)
|
|
89
91
|
}
|
|
90
92
|
}
|
|
@@ -20,8 +20,11 @@ interface NativeComponentFactory {
|
|
|
20
20
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
|
21
21
|
ViewGroup.LayoutParams.WRAP_CONTENT
|
|
22
22
|
)
|
|
23
|
-
if (index >= vg.childCount)
|
|
24
|
-
|
|
23
|
+
if (index >= vg.childCount) {
|
|
24
|
+
vg.addView(child, lp)
|
|
25
|
+
} else {
|
|
26
|
+
vg.addView(child, index, lp)
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/AnimationModule.kt
CHANGED
|
@@ -22,7 +22,8 @@ class AnimationModule : NativeModule {
|
|
|
22
22
|
private val mainHandler = Handler(Looper.getMainLooper())
|
|
23
23
|
|
|
24
24
|
override fun initialize(context: Context, bridge: NativeBridge) {
|
|
25
|
-
this.context = context
|
|
25
|
+
this.context = context
|
|
26
|
+
this.bridge = bridge
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
override fun invoke(method: String, args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
@@ -34,15 +35,22 @@ class AnimationModule : NativeModule {
|
|
|
34
35
|
"parallel" -> handleParallel(args, bridge, callback)
|
|
35
36
|
"fadeIn" -> {
|
|
36
37
|
val nodeId = StyleEngine.toInt(args.getOrNull(0), -1)
|
|
37
|
-
val view = bridge.nodeViews[nodeId] ?: run {
|
|
38
|
+
val view = bridge.nodeViews[nodeId] ?: run {
|
|
39
|
+
callback(null, null)
|
|
40
|
+
return
|
|
41
|
+
}
|
|
38
42
|
mainHandler.post {
|
|
39
|
-
view.alpha = 0f
|
|
43
|
+
view.alpha = 0f
|
|
44
|
+
view.visibility = View.VISIBLE
|
|
40
45
|
view.animate().alpha(1f).setDuration(300).withEndAction { callback(null, null) }.start()
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
"fadeOut" -> {
|
|
44
49
|
val nodeId = StyleEngine.toInt(args.getOrNull(0), -1)
|
|
45
|
-
val view = bridge.nodeViews[nodeId] ?: run {
|
|
50
|
+
val view = bridge.nodeViews[nodeId] ?: run {
|
|
51
|
+
callback(null, null)
|
|
52
|
+
return
|
|
53
|
+
}
|
|
46
54
|
mainHandler.post {
|
|
47
55
|
view.animate().alpha(0f).setDuration(300).withEndAction {
|
|
48
56
|
view.visibility = View.INVISIBLE
|
|
@@ -68,11 +76,17 @@ class AnimationModule : NativeModule {
|
|
|
68
76
|
val delay = StyleEngine.toInt(options["delay"], 0).toLong()
|
|
69
77
|
val easing = options["easing"]?.toString() ?: "easeInOut"
|
|
70
78
|
|
|
71
|
-
val view = bridge.nodeViews[nodeId] ?: run {
|
|
79
|
+
val view = bridge.nodeViews[nodeId] ?: run {
|
|
80
|
+
callback(null, "timing: view $nodeId not found")
|
|
81
|
+
return
|
|
82
|
+
}
|
|
72
83
|
|
|
73
84
|
mainHandler.post {
|
|
74
85
|
val animators = buildPropertyAnimators(view, toStyles)
|
|
75
|
-
if (animators.isEmpty()) {
|
|
86
|
+
if (animators.isEmpty()) {
|
|
87
|
+
callback(true, null)
|
|
88
|
+
return@post
|
|
89
|
+
}
|
|
76
90
|
|
|
77
91
|
val interpolator = resolveInterpolator(easing)
|
|
78
92
|
val set = AnimatorSet()
|
|
@@ -81,7 +95,9 @@ class AnimationModule : NativeModule {
|
|
|
81
95
|
set.startDelay = delay
|
|
82
96
|
set.interpolator = interpolator
|
|
83
97
|
set.addListener(object : AnimatorListenerAdapter() {
|
|
84
|
-
override fun onAnimationEnd(a: Animator) {
|
|
98
|
+
override fun onAnimationEnd(a: Animator) {
|
|
99
|
+
callback(true, null)
|
|
100
|
+
}
|
|
85
101
|
})
|
|
86
102
|
set.start()
|
|
87
103
|
}
|
|
@@ -100,11 +116,17 @@ class AnimationModule : NativeModule {
|
|
|
100
116
|
val duration = StyleEngine.toInt(options["duration"], 500).toLong()
|
|
101
117
|
val delay = StyleEngine.toInt(options["delay"], 0).toLong()
|
|
102
118
|
|
|
103
|
-
val view = bridge.nodeViews[nodeId] ?: run {
|
|
119
|
+
val view = bridge.nodeViews[nodeId] ?: run {
|
|
120
|
+
callback(null, "spring: view $nodeId not found")
|
|
121
|
+
return
|
|
122
|
+
}
|
|
104
123
|
|
|
105
124
|
mainHandler.post {
|
|
106
125
|
val animators = buildPropertyAnimators(view, toStyles)
|
|
107
|
-
if (animators.isEmpty()) {
|
|
126
|
+
if (animators.isEmpty()) {
|
|
127
|
+
callback(true, null)
|
|
128
|
+
return@post
|
|
129
|
+
}
|
|
108
130
|
|
|
109
131
|
// Android doesn't have built-in spring for ObjectAnimator pre-API 23 DynamicAnimation.
|
|
110
132
|
// Use overshoot interpolator to approximate spring feel.
|
|
@@ -114,7 +136,9 @@ class AnimationModule : NativeModule {
|
|
|
114
136
|
set.startDelay = delay
|
|
115
137
|
set.interpolator = android.view.animation.OvershootInterpolator(1.5f)
|
|
116
138
|
set.addListener(object : AnimatorListenerAdapter() {
|
|
117
|
-
override fun onAnimationEnd(a: Animator) {
|
|
139
|
+
override fun onAnimationEnd(a: Animator) {
|
|
140
|
+
callback(true, null)
|
|
141
|
+
}
|
|
118
142
|
})
|
|
119
143
|
set.start()
|
|
120
144
|
}
|
|
@@ -127,11 +151,17 @@ class AnimationModule : NativeModule {
|
|
|
127
151
|
|
|
128
152
|
private fun handleKeyframe(args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
129
153
|
val nodeId = StyleEngine.toInt(args.getOrNull(0), -1)
|
|
130
|
-
val stepsRaw = args.getOrNull(1) as? List<*> ?: run {
|
|
154
|
+
val stepsRaw = args.getOrNull(1) as? List<*> ?: run {
|
|
155
|
+
callback(null, "keyframe: invalid keyframes")
|
|
156
|
+
return
|
|
157
|
+
}
|
|
131
158
|
val options = toStringKeyMap(args.getOrNull(2)) ?: emptyMap()
|
|
132
159
|
val duration = StyleEngine.toInt(options["duration"], 300).toLong()
|
|
133
160
|
|
|
134
|
-
val view = bridge.nodeViews[nodeId] ?: run {
|
|
161
|
+
val view = bridge.nodeViews[nodeId] ?: run {
|
|
162
|
+
callback(null, "keyframe: view $nodeId not found")
|
|
163
|
+
return
|
|
164
|
+
}
|
|
135
165
|
|
|
136
166
|
// Parse keyframe steps into Map<String, List<Pair<Float, Float>>> (property -> [(offset, value)])
|
|
137
167
|
val propertyKeyframes = mutableMapOf<String, MutableList<Pair<Float, Float>>>()
|
|
@@ -146,7 +176,10 @@ class AnimationModule : NativeModule {
|
|
|
146
176
|
}
|
|
147
177
|
}
|
|
148
178
|
|
|
149
|
-
if (propertyKeyframes.isEmpty()) {
|
|
179
|
+
if (propertyKeyframes.isEmpty()) {
|
|
180
|
+
callback(null, null)
|
|
181
|
+
return
|
|
182
|
+
}
|
|
150
183
|
|
|
151
184
|
mainHandler.post {
|
|
152
185
|
val animators = mutableListOf<Animator>()
|
|
@@ -164,12 +197,17 @@ class AnimationModule : NativeModule {
|
|
|
164
197
|
}
|
|
165
198
|
}
|
|
166
199
|
|
|
167
|
-
if (animators.isEmpty()) {
|
|
200
|
+
if (animators.isEmpty()) {
|
|
201
|
+
callback(null, null)
|
|
202
|
+
return@post
|
|
203
|
+
}
|
|
168
204
|
|
|
169
205
|
val set = AnimatorSet()
|
|
170
206
|
set.playTogether(animators)
|
|
171
207
|
set.addListener(object : AnimatorListenerAdapter() {
|
|
172
|
-
override fun onAnimationEnd(a: Animator) {
|
|
208
|
+
override fun onAnimationEnd(a: Animator) {
|
|
209
|
+
callback(null, null)
|
|
210
|
+
}
|
|
173
211
|
})
|
|
174
212
|
set.start()
|
|
175
213
|
}
|
|
@@ -179,9 +217,15 @@ class AnimationModule : NativeModule {
|
|
|
179
217
|
// args[0]: List<Map> animations [{ type, viewId, toStyles, options }, ...]
|
|
180
218
|
|
|
181
219
|
private fun handleSequence(args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
182
|
-
val animationsRaw = args.getOrNull(0) as? List<*> ?: run {
|
|
220
|
+
val animationsRaw = args.getOrNull(0) as? List<*> ?: run {
|
|
221
|
+
callback(null, "sequence: invalid args")
|
|
222
|
+
return
|
|
223
|
+
}
|
|
183
224
|
val animations = animationsRaw.mapNotNull { toStringKeyMap(it) }
|
|
184
|
-
if (animations.isEmpty()) {
|
|
225
|
+
if (animations.isEmpty()) {
|
|
226
|
+
callback(null, null)
|
|
227
|
+
return
|
|
228
|
+
}
|
|
185
229
|
|
|
186
230
|
runSequenceStep(animations, 0, bridge, callback)
|
|
187
231
|
}
|
|
@@ -192,7 +236,10 @@ class AnimationModule : NativeModule {
|
|
|
192
236
|
bridge: NativeBridge,
|
|
193
237
|
callback: (Any?, String?) -> Unit
|
|
194
238
|
) {
|
|
195
|
-
if (index >= animations.size) {
|
|
239
|
+
if (index >= animations.size) {
|
|
240
|
+
callback(null, null)
|
|
241
|
+
return
|
|
242
|
+
}
|
|
196
243
|
|
|
197
244
|
val animData = animations[index]
|
|
198
245
|
val method = animData["type"]?.toString() ?: "timing"
|
|
@@ -202,7 +249,10 @@ class AnimationModule : NativeModule {
|
|
|
202
249
|
|
|
203
250
|
val subArgs: List<Any?> = listOf(viewId, toStyles, options)
|
|
204
251
|
invoke(method, subArgs, bridge) { _, error ->
|
|
205
|
-
if (error != null) {
|
|
252
|
+
if (error != null) {
|
|
253
|
+
callback(null, error)
|
|
254
|
+
return@invoke
|
|
255
|
+
}
|
|
206
256
|
runSequenceStep(animations, index + 1, bridge, callback)
|
|
207
257
|
}
|
|
208
258
|
}
|
|
@@ -211,9 +261,15 @@ class AnimationModule : NativeModule {
|
|
|
211
261
|
// args[0]: List<Map> animations [{ type, viewId, toStyles, options }, ...]
|
|
212
262
|
|
|
213
263
|
private fun handleParallel(args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
214
|
-
val animationsRaw = args.getOrNull(0) as? List<*> ?: run {
|
|
264
|
+
val animationsRaw = args.getOrNull(0) as? List<*> ?: run {
|
|
265
|
+
callback(null, "parallel: invalid args")
|
|
266
|
+
return
|
|
267
|
+
}
|
|
215
268
|
val animations = animationsRaw.mapNotNull { toStringKeyMap(it) }
|
|
216
|
-
if (animations.isEmpty()) {
|
|
269
|
+
if (animations.isEmpty()) {
|
|
270
|
+
callback(null, null)
|
|
271
|
+
return
|
|
272
|
+
}
|
|
217
273
|
|
|
218
274
|
val total = animations.size
|
|
219
275
|
var completed = 0
|
|
@@ -12,20 +12,35 @@ class AsyncStorageModule : NativeModule {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
override fun invoke(method: String, args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
15
|
-
val p = prefs ?: run {
|
|
15
|
+
val p = prefs ?: run {
|
|
16
|
+
callback(null, "Storage not initialized")
|
|
17
|
+
return
|
|
18
|
+
}
|
|
16
19
|
when (method) {
|
|
17
20
|
"getItem" -> {
|
|
18
|
-
val key = args.getOrNull(0)?.toString() ?: run {
|
|
21
|
+
val key = args.getOrNull(0)?.toString() ?: run {
|
|
22
|
+
callback(null, "Missing key")
|
|
23
|
+
return
|
|
24
|
+
}
|
|
19
25
|
callback(p.getString(key, null), null)
|
|
20
26
|
}
|
|
21
27
|
"setItem" -> {
|
|
22
|
-
val key
|
|
23
|
-
|
|
28
|
+
val key = args.getOrNull(0)?.toString() ?: run {
|
|
29
|
+
callback(null, "Missing key")
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
val value = args.getOrNull(1)?.toString() ?: run {
|
|
33
|
+
callback(null, "Missing value")
|
|
34
|
+
return
|
|
35
|
+
}
|
|
24
36
|
p.edit().putString(key, value).apply()
|
|
25
37
|
callback(null, null)
|
|
26
38
|
}
|
|
27
39
|
"removeItem" -> {
|
|
28
|
-
val key = args.getOrNull(0)?.toString() ?: run {
|
|
40
|
+
val key = args.getOrNull(0)?.toString() ?: run {
|
|
41
|
+
callback(null, "Missing key")
|
|
42
|
+
return
|
|
43
|
+
}
|
|
29
44
|
p.edit().remove(key).apply()
|
|
30
45
|
callback(null, null)
|
|
31
46
|
}
|
|
@@ -31,19 +31,28 @@ class BackgroundTaskModule : NativeModule {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
override fun invoke(method: String, args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
34
|
-
val ctx = appContext ?: run {
|
|
34
|
+
val ctx = appContext ?: run {
|
|
35
|
+
callback(null, "BackgroundTask not initialized")
|
|
36
|
+
return
|
|
37
|
+
}
|
|
35
38
|
|
|
36
39
|
when (method) {
|
|
37
40
|
"scheduleTask" -> {
|
|
38
41
|
val taskId = args.getOrNull(0)?.toString()
|
|
39
|
-
?: run {
|
|
42
|
+
?: run {
|
|
43
|
+
callback(null, "scheduleTask: missing taskId")
|
|
44
|
+
return
|
|
45
|
+
}
|
|
40
46
|
val type = args.getOrNull(1)?.toString() ?: "refresh"
|
|
41
47
|
val options = args.getOrNull(2) as? Map<*, *> ?: emptyMap<String, Any>()
|
|
42
48
|
scheduleTask(ctx, taskId, type, options, callback)
|
|
43
49
|
}
|
|
44
50
|
"cancelTask" -> {
|
|
45
51
|
val taskId = args.getOrNull(0)?.toString()
|
|
46
|
-
?: run {
|
|
52
|
+
?: run {
|
|
53
|
+
callback(null, "cancelTask: missing taskId")
|
|
54
|
+
return
|
|
55
|
+
}
|
|
47
56
|
WorkManager.getInstance(ctx).cancelUniqueWork(taskId)
|
|
48
57
|
callback(null, null)
|
|
49
58
|
}
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/BiometryModule.kt
CHANGED
|
@@ -27,12 +27,15 @@ class BiometryModule : NativeModule {
|
|
|
27
27
|
) {
|
|
28
28
|
when (method) {
|
|
29
29
|
"getSupportedBiometry" -> {
|
|
30
|
-
val ctx = context ?: run {
|
|
30
|
+
val ctx = context ?: run {
|
|
31
|
+
callback("none", null)
|
|
32
|
+
return
|
|
33
|
+
}
|
|
31
34
|
val biometricManager = BiometricManager.from(ctx)
|
|
32
35
|
val result = when (biometricManager.canAuthenticate(
|
|
33
36
|
BiometricManager.Authenticators.BIOMETRIC_STRONG
|
|
34
37
|
)) {
|
|
35
|
-
BiometricManager.BIOMETRIC_SUCCESS -> "faceID"
|
|
38
|
+
BiometricManager.BIOMETRIC_SUCCESS -> "faceID" // Android doesn't distinguish
|
|
36
39
|
BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE -> "none"
|
|
37
40
|
BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE -> "none"
|
|
38
41
|
BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED -> "biometric" // HW present, not enrolled
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/BluetoothModule.kt
CHANGED
|
@@ -52,39 +52,80 @@ class BluetoothModule : NativeModule {
|
|
|
52
52
|
}
|
|
53
53
|
"connect" -> {
|
|
54
54
|
val deviceId = args.getOrNull(0)?.toString() ?: run {
|
|
55
|
-
callback(null, "Missing deviceId")
|
|
55
|
+
callback(null, "Missing deviceId")
|
|
56
|
+
return
|
|
56
57
|
}
|
|
57
58
|
connect(deviceId, callback)
|
|
58
59
|
}
|
|
59
60
|
"disconnect" -> {
|
|
60
61
|
val deviceId = args.getOrNull(0)?.toString() ?: run {
|
|
61
|
-
callback(null, "Missing deviceId")
|
|
62
|
+
callback(null, "Missing deviceId")
|
|
63
|
+
return
|
|
62
64
|
}
|
|
63
65
|
disconnect(deviceId, callback)
|
|
64
66
|
}
|
|
65
67
|
"readCharacteristic" -> {
|
|
66
|
-
val deviceId = args.getOrNull(0)?.toString() ?: run {
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
val deviceId = args.getOrNull(0)?.toString() ?: run {
|
|
69
|
+
callback(null, "Missing deviceId")
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
val serviceUUID = args.getOrNull(1)?.toString() ?: run {
|
|
73
|
+
callback(null, "Missing serviceUUID")
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
val charUUID = args.getOrNull(2)?.toString() ?: run {
|
|
77
|
+
callback(null, "Missing charUUID")
|
|
78
|
+
return
|
|
79
|
+
}
|
|
69
80
|
readCharacteristic(deviceId, serviceUUID, charUUID, callback)
|
|
70
81
|
}
|
|
71
82
|
"writeCharacteristic" -> {
|
|
72
|
-
val deviceId = args.getOrNull(0)?.toString() ?: run {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
val deviceId = args.getOrNull(0)?.toString() ?: run {
|
|
84
|
+
callback(null, "Missing deviceId")
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
val serviceUUID = args.getOrNull(1)?.toString() ?: run {
|
|
88
|
+
callback(null, "Missing serviceUUID")
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
val charUUID = args.getOrNull(2)?.toString() ?: run {
|
|
92
|
+
callback(null, "Missing charUUID")
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
val dataBase64 = args.getOrNull(3)?.toString() ?: run {
|
|
96
|
+
callback(null, "Missing data")
|
|
97
|
+
return
|
|
98
|
+
}
|
|
76
99
|
writeCharacteristic(deviceId, serviceUUID, charUUID, dataBase64, callback)
|
|
77
100
|
}
|
|
78
101
|
"subscribeToCharacteristic" -> {
|
|
79
|
-
val deviceId = args.getOrNull(0)?.toString() ?: run {
|
|
80
|
-
|
|
81
|
-
|
|
102
|
+
val deviceId = args.getOrNull(0)?.toString() ?: run {
|
|
103
|
+
callback(null, "Missing deviceId")
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
val serviceUUID = args.getOrNull(1)?.toString() ?: run {
|
|
107
|
+
callback(null, "Missing serviceUUID")
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
val charUUID = args.getOrNull(2)?.toString() ?: run {
|
|
111
|
+
callback(null, "Missing charUUID")
|
|
112
|
+
return
|
|
113
|
+
}
|
|
82
114
|
subscribeToCharacteristic(deviceId, serviceUUID, charUUID, callback)
|
|
83
115
|
}
|
|
84
116
|
"unsubscribeFromCharacteristic" -> {
|
|
85
|
-
val deviceId = args.getOrNull(0)?.toString() ?: run {
|
|
86
|
-
|
|
87
|
-
|
|
117
|
+
val deviceId = args.getOrNull(0)?.toString() ?: run {
|
|
118
|
+
callback(null, "Missing deviceId")
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
val serviceUUID = args.getOrNull(1)?.toString() ?: run {
|
|
122
|
+
callback(null, "Missing serviceUUID")
|
|
123
|
+
return
|
|
124
|
+
}
|
|
125
|
+
val charUUID = args.getOrNull(2)?.toString() ?: run {
|
|
126
|
+
callback(null, "Missing charUUID")
|
|
127
|
+
return
|
|
128
|
+
}
|
|
88
129
|
unsubscribeFromCharacteristic(deviceId, serviceUUID, charUUID, callback)
|
|
89
130
|
}
|
|
90
131
|
"getState" -> {
|
|
@@ -151,8 +192,14 @@ class BluetoothModule : NativeModule {
|
|
|
151
192
|
|
|
152
193
|
@Suppress("MissingPermission")
|
|
153
194
|
private fun readCharacteristic(deviceId: String, serviceUUID: String, charUUID: String, callback: (Any?, String?) -> Unit) {
|
|
154
|
-
val gatt = gattConnections[deviceId] ?: run {
|
|
155
|
-
|
|
195
|
+
val gatt = gattConnections[deviceId] ?: run {
|
|
196
|
+
callback(null, "Device not connected")
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
val char = findCharacteristic(gatt, serviceUUID, charUUID) ?: run {
|
|
200
|
+
callback(null, "Characteristic not found")
|
|
201
|
+
return
|
|
202
|
+
}
|
|
156
203
|
val key = "$deviceId:$serviceUUID:$charUUID"
|
|
157
204
|
readCallbacks[key] = callback
|
|
158
205
|
gatt.readCharacteristic(char)
|
|
@@ -160,8 +207,14 @@ class BluetoothModule : NativeModule {
|
|
|
160
207
|
|
|
161
208
|
@Suppress("MissingPermission")
|
|
162
209
|
private fun writeCharacteristic(deviceId: String, serviceUUID: String, charUUID: String, dataBase64: String, callback: (Any?, String?) -> Unit) {
|
|
163
|
-
val gatt = gattConnections[deviceId] ?: run {
|
|
164
|
-
|
|
210
|
+
val gatt = gattConnections[deviceId] ?: run {
|
|
211
|
+
callback(null, "Device not connected")
|
|
212
|
+
return
|
|
213
|
+
}
|
|
214
|
+
val char = findCharacteristic(gatt, serviceUUID, charUUID) ?: run {
|
|
215
|
+
callback(null, "Characteristic not found")
|
|
216
|
+
return
|
|
217
|
+
}
|
|
165
218
|
val data = Base64.decode(dataBase64, Base64.DEFAULT)
|
|
166
219
|
val key = "$deviceId:$serviceUUID:$charUUID"
|
|
167
220
|
writeCallbacks[key] = callback
|
|
@@ -171,8 +224,14 @@ class BluetoothModule : NativeModule {
|
|
|
171
224
|
|
|
172
225
|
@Suppress("MissingPermission")
|
|
173
226
|
private fun subscribeToCharacteristic(deviceId: String, serviceUUID: String, charUUID: String, callback: (Any?, String?) -> Unit) {
|
|
174
|
-
val gatt = gattConnections[deviceId] ?: run {
|
|
175
|
-
|
|
227
|
+
val gatt = gattConnections[deviceId] ?: run {
|
|
228
|
+
callback(null, "Device not connected")
|
|
229
|
+
return
|
|
230
|
+
}
|
|
231
|
+
val char = findCharacteristic(gatt, serviceUUID, charUUID) ?: run {
|
|
232
|
+
callback(null, "Characteristic not found")
|
|
233
|
+
return
|
|
234
|
+
}
|
|
176
235
|
gatt.setCharacteristicNotification(char, true)
|
|
177
236
|
val descriptor = char.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"))
|
|
178
237
|
descriptor?.let {
|
|
@@ -184,8 +243,14 @@ class BluetoothModule : NativeModule {
|
|
|
184
243
|
|
|
185
244
|
@Suppress("MissingPermission")
|
|
186
245
|
private fun unsubscribeFromCharacteristic(deviceId: String, serviceUUID: String, charUUID: String, callback: (Any?, String?) -> Unit) {
|
|
187
|
-
val gatt = gattConnections[deviceId] ?: run {
|
|
188
|
-
|
|
246
|
+
val gatt = gattConnections[deviceId] ?: run {
|
|
247
|
+
callback(null, "Device not connected")
|
|
248
|
+
return
|
|
249
|
+
}
|
|
250
|
+
val char = findCharacteristic(gatt, serviceUUID, charUUID) ?: run {
|
|
251
|
+
callback(null, "Characteristic not found")
|
|
252
|
+
return
|
|
253
|
+
}
|
|
189
254
|
gatt.setCharacteristicNotification(char, false)
|
|
190
255
|
callback(null, null)
|
|
191
256
|
}
|