@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
package/dist/cli.js
CHANGED
|
@@ -10,7 +10,7 @@ import { join, dirname } from "path";
|
|
|
10
10
|
import { fileURLToPath } from "url";
|
|
11
11
|
import { existsSync } from "fs";
|
|
12
12
|
import pc from "picocolors";
|
|
13
|
-
var VERSION = "0.4.
|
|
13
|
+
var VERSION = "0.4.13";
|
|
14
14
|
var createCommand = new Command("create").description("Create a new Vue Native project").argument("<name>", "project name").option("-t, --template <template>", "project template (blank, tabs, drawer)", "blank").action(async (name, options) => {
|
|
15
15
|
const template = options.template;
|
|
16
16
|
if (!["blank", "tabs", "drawer"].includes(template)) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[*.{kt,kts}]
|
|
2
|
+
# ktlint settings
|
|
3
|
+
ktlint_code_style = android_studio
|
|
4
|
+
|
|
5
|
+
# Relaxed rules for a library project
|
|
6
|
+
max_line_length = 150
|
|
7
|
+
indent_size = 4
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
|
|
10
|
+
# Disable rules that are too strict for our codebase
|
|
11
|
+
ktlint_standard_no-wildcard-imports = disabled
|
|
12
|
+
ktlint_standard_max-line-length = disabled
|
|
13
|
+
ktlint_standard_function-naming = disabled
|
|
14
|
+
ktlint_standard_package-name = disabled
|
|
15
|
+
ktlint_standard_filename = disabled
|
|
16
|
+
ktlint_standard_wrapping = disabled
|
|
17
|
+
ktlint_standard_argument-list-wrapping = disabled
|
|
18
|
+
ktlint_standard_function-signature = disabled
|
|
19
|
+
ktlint_standard_indent = disabled
|
|
20
|
+
ktlint_standard_spacing-between-declarations-with-annotations = disabled
|
|
21
|
+
ktlint_standard_parameter-list-wrapping = disabled
|
|
22
|
+
ktlint_standard_trailing-comma-on-call-site = disabled
|
|
23
|
+
ktlint_standard_trailing-comma-on-declaration-site = disabled
|
|
24
|
+
ktlint_standard_property-naming = disabled
|
|
25
|
+
ktlint_standard_discouraged-comment-location = disabled
|
|
@@ -2,6 +2,7 @@ plugins {
|
|
|
2
2
|
id("com.android.library")
|
|
3
3
|
id("org.jetbrains.kotlin.android")
|
|
4
4
|
id("maven-publish")
|
|
5
|
+
id("org.jlleitschuh.gradle.ktlint")
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
android {
|
|
@@ -39,6 +40,12 @@ android {
|
|
|
39
40
|
lint {
|
|
40
41
|
abortOnError = false
|
|
41
42
|
}
|
|
43
|
+
|
|
44
|
+
testOptions {
|
|
45
|
+
unitTests {
|
|
46
|
+
isIncludeAndroidResources = true
|
|
47
|
+
}
|
|
48
|
+
}
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
dependencies {
|
|
@@ -87,6 +94,23 @@ dependencies {
|
|
|
87
94
|
// Credential Manager + Google Identity (for SocialAuthModule)
|
|
88
95
|
implementation("androidx.credentials:credentials:1.2.2")
|
|
89
96
|
implementation("com.google.android.libraries.identity.googleid:googleid:1.1.1")
|
|
97
|
+
|
|
98
|
+
// Testing
|
|
99
|
+
testImplementation("junit:junit:4.13.2")
|
|
100
|
+
testImplementation("org.robolectric:robolectric:4.11.1")
|
|
101
|
+
testImplementation("androidx.test:core:1.5.0")
|
|
102
|
+
testImplementation("androidx.test.ext:junit:1.1.5")
|
|
103
|
+
testImplementation("io.mockk:mockk:1.13.9")
|
|
104
|
+
testImplementation("com.google.truth:truth:1.1.5")
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
ktlint {
|
|
108
|
+
android.set(true)
|
|
109
|
+
outputToConsole.set(true)
|
|
110
|
+
ignoreFailures.set(false)
|
|
111
|
+
filter {
|
|
112
|
+
exclude("**/generated/**")
|
|
113
|
+
}
|
|
90
114
|
}
|
|
91
115
|
|
|
92
116
|
afterEvaluate {
|
|
@@ -95,7 +119,7 @@ afterEvaluate {
|
|
|
95
119
|
create<MavenPublication>("release") {
|
|
96
120
|
groupId = "com.vuenative"
|
|
97
121
|
artifactId = "core"
|
|
98
|
-
version = "0.4.
|
|
122
|
+
version = "0.4.13"
|
|
99
123
|
from(components["release"])
|
|
100
124
|
}
|
|
101
125
|
}
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/JSPolyfills.kt
CHANGED
|
@@ -5,8 +5,8 @@ import android.os.Looper
|
|
|
5
5
|
import android.util.Log
|
|
6
6
|
import com.eclipsesource.v8.JavaCallback
|
|
7
7
|
import com.eclipsesource.v8.JavaVoidCallback
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import java.io.IOException
|
|
9
|
+
import java.security.SecureRandom
|
|
10
10
|
import okhttp3.Call
|
|
11
11
|
import okhttp3.Callback
|
|
12
12
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
|
@@ -15,8 +15,6 @@ import okhttp3.Request
|
|
|
15
15
|
import okhttp3.RequestBody.Companion.toRequestBody
|
|
16
16
|
import okhttp3.Response
|
|
17
17
|
import org.json.JSONObject
|
|
18
|
-
import java.io.IOException
|
|
19
|
-
import java.security.SecureRandom
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
20
|
* Registers browser-like APIs in the V8 context.
|
|
@@ -81,12 +79,15 @@ object JSPolyfills {
|
|
|
81
79
|
listOf("log", "warn", "error", "debug", "info").forEach { level ->
|
|
82
80
|
v8.registerJavaMethod(JavaVoidCallback { _, params ->
|
|
83
81
|
try {
|
|
84
|
-
val msg = if (params.length() == 0)
|
|
85
|
-
|
|
82
|
+
val msg = if (params.length() == 0) {
|
|
83
|
+
"undefined"
|
|
84
|
+
} else {
|
|
85
|
+
params.get(0)?.toString() ?: "null"
|
|
86
|
+
}
|
|
86
87
|
when (level) {
|
|
87
88
|
"error" -> Log.e("VueNative JS", msg)
|
|
88
|
-
"warn"
|
|
89
|
-
else
|
|
89
|
+
"warn" -> Log.w("VueNative JS", msg)
|
|
90
|
+
else -> Log.d("VueNative JS", msg)
|
|
90
91
|
}
|
|
91
92
|
} finally {
|
|
92
93
|
params.close()
|
|
@@ -356,7 +357,11 @@ object JSPolyfills {
|
|
|
356
357
|
} finally {
|
|
357
358
|
params.close()
|
|
358
359
|
}
|
|
359
|
-
val opts = try {
|
|
360
|
+
val opts = try {
|
|
361
|
+
JSONObject(optsJson)
|
|
362
|
+
} catch (e: Exception) {
|
|
363
|
+
JSONObject()
|
|
364
|
+
}
|
|
360
365
|
|
|
361
366
|
val method = opts.optString("method", "GET").uppercase()
|
|
362
367
|
val bodyStr = opts.optString("body", "")
|
|
@@ -370,7 +375,9 @@ object JSPolyfills {
|
|
|
370
375
|
bodyStr.toRequestBody(ct.toMediaTypeOrNull())
|
|
371
376
|
} else if (method != "GET" && method != "HEAD") {
|
|
372
377
|
"".toRequestBody()
|
|
373
|
-
} else
|
|
378
|
+
} else {
|
|
379
|
+
null
|
|
380
|
+
}
|
|
374
381
|
|
|
375
382
|
builder.method(method, requestBody)
|
|
376
383
|
|
|
@@ -5,8 +5,8 @@ import android.os.Handler
|
|
|
5
5
|
import android.os.HandlerThread
|
|
6
6
|
import android.os.Looper
|
|
7
7
|
import android.util.Log
|
|
8
|
-
import com.eclipsesource.v8.V8
|
|
9
8
|
import com.eclipsesource.v8.JavaVoidCallback
|
|
9
|
+
import com.eclipsesource.v8.V8
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Core JavaScript runtime. Wraps J2V8's V8 engine on a dedicated HandlerThread.
|
|
@@ -167,10 +167,10 @@ class JSRuntime(private val context: Context) {
|
|
|
167
167
|
try {
|
|
168
168
|
val args = Array<Any?>(params.length()) { i ->
|
|
169
169
|
when {
|
|
170
|
-
params.getType(i) == 1 -> params.getInteger(i)
|
|
171
|
-
params.getType(i) == 2 -> params.getDouble(i)
|
|
172
|
-
params.getType(i) == 3 -> params.getBoolean(i)
|
|
173
|
-
params.getType(i) == 4 -> params.getString(i)
|
|
170
|
+
params.getType(i) == 1 -> params.getInteger(i) // INT
|
|
171
|
+
params.getType(i) == 2 -> params.getDouble(i) // DOUBLE
|
|
172
|
+
params.getType(i) == 3 -> params.getBoolean(i) // BOOLEAN
|
|
173
|
+
params.getType(i) == 4 -> params.getString(i) // STRING
|
|
174
174
|
else -> null
|
|
175
175
|
}
|
|
176
176
|
}
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/NativeBridge.kt
CHANGED
|
@@ -105,19 +105,19 @@ class NativeBridge(private val context: Context) {
|
|
|
105
105
|
val args = op.optJSONArray("args") ?: JSONArray()
|
|
106
106
|
|
|
107
107
|
when (opName) {
|
|
108
|
-
"create"
|
|
109
|
-
"createText"
|
|
110
|
-
"setText"
|
|
111
|
-
"setElementText"
|
|
112
|
-
"updateProp"
|
|
113
|
-
"updateStyle"
|
|
114
|
-
"appendChild"
|
|
115
|
-
"insertBefore"
|
|
116
|
-
"removeChild"
|
|
117
|
-
"setRootView"
|
|
118
|
-
"addEventListener"
|
|
119
|
-
"removeEventListener"
|
|
120
|
-
"invokeNativeModule"
|
|
108
|
+
"create" -> handleCreate(args)
|
|
109
|
+
"createText" -> handleCreateText(args)
|
|
110
|
+
"setText" -> handleSetText(args)
|
|
111
|
+
"setElementText" -> handleSetElementText(args)
|
|
112
|
+
"updateProp" -> handleUpdateProp(args)
|
|
113
|
+
"updateStyle" -> handleUpdateStyle(args)
|
|
114
|
+
"appendChild" -> handleAppendChild(args)
|
|
115
|
+
"insertBefore" -> handleInsertBefore(args)
|
|
116
|
+
"removeChild" -> handleRemoveChild(args)
|
|
117
|
+
"setRootView" -> handleSetRootView(args)
|
|
118
|
+
"addEventListener" -> handleAddEventListener(args)
|
|
119
|
+
"removeEventListener" -> handleRemoveEventListener(args)
|
|
120
|
+
"invokeNativeModule" -> handleInvokeNativeModule(args)
|
|
121
121
|
"invokeNativeModuleSync" -> handleInvokeNativeModuleSync(args)
|
|
122
122
|
else -> Log.w(TAG, "Unknown operation: $opName")
|
|
123
123
|
}
|
|
@@ -25,34 +25,34 @@ class ComponentRegistry private constructor(private val context: Context) {
|
|
|
25
25
|
private val factories = mutableMapOf<String, NativeComponentFactory>()
|
|
26
26
|
|
|
27
27
|
private fun registerDefaults() {
|
|
28
|
-
register("VView",
|
|
29
|
-
register("VText",
|
|
30
|
-
register("VButton",
|
|
31
|
-
register("VInput",
|
|
32
|
-
register("VSwitch",
|
|
28
|
+
register("VView", VViewFactory())
|
|
29
|
+
register("VText", VTextFactory())
|
|
30
|
+
register("VButton", VButtonFactory())
|
|
31
|
+
register("VInput", VInputFactory())
|
|
32
|
+
register("VSwitch", VSwitchFactory())
|
|
33
33
|
register("VActivityIndicator", VActivityIndicatorFactory())
|
|
34
|
-
register("VScrollView",
|
|
35
|
-
register("VImage",
|
|
36
|
-
register("VKeyboardAvoiding",
|
|
37
|
-
register("VSafeArea",
|
|
38
|
-
register("VSlider",
|
|
39
|
-
register("VList",
|
|
40
|
-
register("VModal",
|
|
41
|
-
register("VAlertDialog",
|
|
42
|
-
register("VStatusBar",
|
|
43
|
-
register("VWebView",
|
|
44
|
-
register("VProgressBar",
|
|
45
|
-
register("VPicker",
|
|
46
|
-
register("VSegmentedControl",
|
|
47
|
-
register("VActionSheet",
|
|
48
|
-
register("VRefreshControl",
|
|
49
|
-
register("VPressable",
|
|
50
|
-
register("VSectionList",
|
|
51
|
-
register("VCheckbox",
|
|
52
|
-
register("VRadio",
|
|
53
|
-
register("VDropdown",
|
|
54
|
-
register("VVideo",
|
|
55
|
-
register("__ROOT__",
|
|
34
|
+
register("VScrollView", VScrollViewFactory())
|
|
35
|
+
register("VImage", VImageFactory())
|
|
36
|
+
register("VKeyboardAvoiding", VKeyboardAvoidingFactory())
|
|
37
|
+
register("VSafeArea", VSafeAreaFactory())
|
|
38
|
+
register("VSlider", VSliderFactory())
|
|
39
|
+
register("VList", VListFactory())
|
|
40
|
+
register("VModal", VModalFactory())
|
|
41
|
+
register("VAlertDialog", VAlertDialogFactory())
|
|
42
|
+
register("VStatusBar", VStatusBarFactory())
|
|
43
|
+
register("VWebView", VWebViewFactory())
|
|
44
|
+
register("VProgressBar", VProgressBarFactory())
|
|
45
|
+
register("VPicker", VPickerFactory())
|
|
46
|
+
register("VSegmentedControl", VSegmentedControlFactory())
|
|
47
|
+
register("VActionSheet", VActionSheetFactory())
|
|
48
|
+
register("VRefreshControl", VRefreshControlFactory())
|
|
49
|
+
register("VPressable", VPressableFactory())
|
|
50
|
+
register("VSectionList", VSectionListFactory())
|
|
51
|
+
register("VCheckbox", VCheckboxFactory())
|
|
52
|
+
register("VRadio", VRadioFactory())
|
|
53
|
+
register("VDropdown", VDropdownFactory())
|
|
54
|
+
register("VVideo", VVideoFactory())
|
|
55
|
+
register("__ROOT__", VRootFactory())
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
fun register(type: String, factory: NativeComponentFactory) {
|
|
@@ -12,7 +12,7 @@ class VActionSheetFactory : NativeComponentFactory {
|
|
|
12
12
|
var message: String = "",
|
|
13
13
|
var actions: List<Map<String, String>> = emptyList()
|
|
14
14
|
)
|
|
15
|
-
private val props
|
|
15
|
+
private val props = mutableMapOf<View, SheetProps>()
|
|
16
16
|
private val actionHandlers = mutableMapOf<View, (Any?) -> Unit>()
|
|
17
17
|
private val cancelHandlers = mutableMapOf<View, (Any?) -> Unit>()
|
|
18
18
|
|
|
@@ -24,14 +24,16 @@ class VActionSheetFactory : NativeComponentFactory {
|
|
|
24
24
|
override fun updateProp(view: View, key: String, value: Any?) {
|
|
25
25
|
val p = props.getOrPut(view) { SheetProps() }
|
|
26
26
|
when (key) {
|
|
27
|
-
"visible" -> {
|
|
28
|
-
|
|
27
|
+
"visible" -> {
|
|
28
|
+
if (value == true || value == "true") showSheet(view, p)
|
|
29
|
+
}
|
|
30
|
+
"title" -> p.title = value?.toString() ?: ""
|
|
29
31
|
"message" -> p.message = value?.toString() ?: ""
|
|
30
32
|
"actions" -> {
|
|
31
33
|
p.actions = when (value) {
|
|
32
34
|
is JSONArray -> (0 until value.length()).map { i ->
|
|
33
35
|
val a = value.getJSONObject(i)
|
|
34
|
-
mapOf("label" to a.optString("label",""), "style" to a.optString("style","default"))
|
|
36
|
+
mapOf("label" to a.optString("label", ""), "style" to a.optString("style", "default"))
|
|
35
37
|
}
|
|
36
38
|
is List<*> -> value.filterIsInstance<Map<String, String>>()
|
|
37
39
|
else -> emptyList()
|
|
@@ -25,7 +25,7 @@ class VActivityIndicatorFactory : NativeComponentFactory {
|
|
|
25
25
|
val sizePx = when (value) {
|
|
26
26
|
"small" -> (20 * view.context.resources.displayMetrics.density).toInt()
|
|
27
27
|
"large" -> (48 * view.context.resources.displayMetrics.density).toInt()
|
|
28
|
-
else
|
|
28
|
+
else -> (32 * view.context.resources.displayMetrics.density).toInt()
|
|
29
29
|
}
|
|
30
30
|
pb.layoutParams?.also { lp ->
|
|
31
31
|
lp.width = sizePx
|
|
@@ -14,8 +14,8 @@ class VAlertDialogFactory : NativeComponentFactory {
|
|
|
14
14
|
)
|
|
15
15
|
private val props = mutableMapOf<View, DialogProps>()
|
|
16
16
|
private val confirmHandlers = mutableMapOf<View, (Any?) -> Unit>()
|
|
17
|
-
private val cancelHandlers
|
|
18
|
-
private val actionHandlers
|
|
17
|
+
private val cancelHandlers = mutableMapOf<View, (Any?) -> Unit>()
|
|
18
|
+
private val actionHandlers = mutableMapOf<View, (Any?) -> Unit>()
|
|
19
19
|
|
|
20
20
|
override fun createView(context: Context): View {
|
|
21
21
|
return View(context).apply {
|
|
@@ -30,13 +30,13 @@ class VAlertDialogFactory : NativeComponentFactory {
|
|
|
30
30
|
"visible" -> {
|
|
31
31
|
if (value == true || value == "true") showDialog(view, p)
|
|
32
32
|
}
|
|
33
|
-
"title"
|
|
33
|
+
"title" -> p.title = value?.toString() ?: ""
|
|
34
34
|
"message" -> p.message = value?.toString() ?: ""
|
|
35
35
|
"buttons" -> {
|
|
36
36
|
p.buttons = when (value) {
|
|
37
37
|
is JSONArray -> (0 until value.length()).map { i ->
|
|
38
38
|
val btn = value.getJSONObject(i)
|
|
39
|
-
mapOf("label" to btn.optString("label","OK"), "style" to btn.optString("style","default"))
|
|
39
|
+
mapOf("label" to btn.optString("label", "OK"), "style" to btn.optString("style", "default"))
|
|
40
40
|
}
|
|
41
41
|
is List<*> -> value.filterIsInstance<Map<String, String>>()
|
|
42
42
|
else -> emptyList()
|
|
@@ -52,15 +52,27 @@ class VAlertDialogFactory : NativeComponentFactory {
|
|
|
52
52
|
.setMessage(p.message.ifEmpty { null })
|
|
53
53
|
|
|
54
54
|
if (p.buttons.isEmpty()) {
|
|
55
|
-
builder.setPositiveButton("OK") { d, _ ->
|
|
55
|
+
builder.setPositiveButton("OK") { d, _ ->
|
|
56
|
+
d.dismiss()
|
|
57
|
+
confirmHandlers[view]?.invoke(null)
|
|
58
|
+
}
|
|
56
59
|
} else {
|
|
57
60
|
p.buttons.forEach { btn ->
|
|
58
61
|
val label = btn["label"] ?: "OK"
|
|
59
62
|
val style = btn["style"] ?: "default"
|
|
60
63
|
when (style) {
|
|
61
|
-
"cancel"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
"cancel" -> builder.setNegativeButton(label) { d, _ ->
|
|
65
|
+
d.dismiss()
|
|
66
|
+
cancelHandlers[view]?.invoke(null)
|
|
67
|
+
}
|
|
68
|
+
"destructive" -> builder.setNeutralButton(label) { d, _ ->
|
|
69
|
+
d.dismiss()
|
|
70
|
+
confirmHandlers[view]?.invoke(mapOf("label" to label))
|
|
71
|
+
}
|
|
72
|
+
else -> builder.setPositiveButton(label) { d, _ ->
|
|
73
|
+
d.dismiss()
|
|
74
|
+
confirmHandlers[view]?.invoke(mapOf("label" to label))
|
|
75
|
+
}
|
|
64
76
|
}
|
|
65
77
|
}
|
|
66
78
|
}
|
|
@@ -70,15 +82,15 @@ class VAlertDialogFactory : NativeComponentFactory {
|
|
|
70
82
|
override fun addEventListener(view: View, event: String, handler: (Any?) -> Unit) {
|
|
71
83
|
when (event) {
|
|
72
84
|
"confirm" -> confirmHandlers[view] = handler
|
|
73
|
-
"cancel"
|
|
74
|
-
"action"
|
|
85
|
+
"cancel" -> cancelHandlers[view] = handler
|
|
86
|
+
"action" -> actionHandlers[view] = handler
|
|
75
87
|
}
|
|
76
88
|
}
|
|
77
89
|
override fun removeEventListener(view: View, event: String) {
|
|
78
90
|
when (event) {
|
|
79
91
|
"confirm" -> confirmHandlers.remove(view)
|
|
80
|
-
"cancel"
|
|
81
|
-
"action"
|
|
92
|
+
"cancel" -> cancelHandlers.remove(view)
|
|
93
|
+
"action" -> actionHandlers.remove(view)
|
|
82
94
|
}
|
|
83
95
|
}
|
|
84
96
|
}
|
|
@@ -63,8 +63,11 @@ class VButtonFactory : NativeComponentFactory {
|
|
|
63
63
|
override fun insertChild(parent: View, child: View, index: Int) {
|
|
64
64
|
val flex = parent as? FlexboxLayout ?: return
|
|
65
65
|
val lp = StyleEngine.buildFlexLayoutParams(child)
|
|
66
|
-
if (index >= flex.childCount)
|
|
67
|
-
|
|
66
|
+
if (index >= flex.childCount) {
|
|
67
|
+
flex.addView(child, lp)
|
|
68
|
+
} else {
|
|
69
|
+
flex.addView(child, index, lp)
|
|
70
|
+
}
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
override fun removeChild(parent: View, child: View) {
|
|
@@ -9,7 +9,7 @@ import coil.request.CachePolicy
|
|
|
9
9
|
import org.json.JSONObject
|
|
10
10
|
|
|
11
11
|
class VImageFactory : NativeComponentFactory {
|
|
12
|
-
private val loadHandlers
|
|
12
|
+
private val loadHandlers = mutableMapOf<ImageView, (Any?) -> Unit>()
|
|
13
13
|
private val errorHandlers = mutableMapOf<ImageView, (Any?) -> Unit>()
|
|
14
14
|
|
|
15
15
|
override fun createView(context: Context): View {
|
|
@@ -40,17 +40,17 @@ class VImageFactory : NativeComponentFactory {
|
|
|
40
40
|
diskCachePolicy(CachePolicy.ENABLED)
|
|
41
41
|
listener(
|
|
42
42
|
onSuccess = { _, _ -> loadHandlers[iv]?.invoke(null) },
|
|
43
|
-
onError
|
|
43
|
+
onError = { _, err -> errorHandlers[iv]?.invoke(mapOf("message" to (err.throwable.message ?: "Load failed"))) }
|
|
44
44
|
)
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
"resizeMode" -> {
|
|
48
48
|
iv.scaleType = when (value) {
|
|
49
|
-
"cover"
|
|
49
|
+
"cover" -> ImageView.ScaleType.CENTER_CROP
|
|
50
50
|
"contain" -> ImageView.ScaleType.FIT_CENTER
|
|
51
51
|
"stretch" -> ImageView.ScaleType.FIT_XY
|
|
52
|
-
"center"
|
|
53
|
-
else
|
|
52
|
+
"center" -> ImageView.ScaleType.CENTER
|
|
53
|
+
else -> ImageView.ScaleType.CENTER_CROP
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
else -> StyleEngine.apply(key, value, view)
|
|
@@ -60,7 +60,7 @@ class VImageFactory : NativeComponentFactory {
|
|
|
60
60
|
override fun addEventListener(view: View, event: String, handler: (Any?) -> Unit) {
|
|
61
61
|
val iv = view as? ImageView ?: return
|
|
62
62
|
when (event) {
|
|
63
|
-
"load"
|
|
63
|
+
"load" -> loadHandlers[iv] = handler
|
|
64
64
|
"error" -> errorHandlers[iv] = handler
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -68,7 +68,7 @@ class VImageFactory : NativeComponentFactory {
|
|
|
68
68
|
override fun removeEventListener(view: View, event: String) {
|
|
69
69
|
val iv = view as? ImageView ?: return
|
|
70
70
|
when (event) {
|
|
71
|
-
"load"
|
|
71
|
+
"load" -> loadHandlers.remove(iv)
|
|
72
72
|
"error" -> errorHandlers.remove(iv)
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -71,12 +71,12 @@ class VInputFactory : NativeComponentFactory {
|
|
|
71
71
|
}
|
|
72
72
|
"returnKeyType" -> {
|
|
73
73
|
et.imeOptions = when (value) {
|
|
74
|
-
"done"
|
|
75
|
-
"go"
|
|
76
|
-
"next"
|
|
74
|
+
"done" -> EditorInfo.IME_ACTION_DONE
|
|
75
|
+
"go" -> EditorInfo.IME_ACTION_GO
|
|
76
|
+
"next" -> EditorInfo.IME_ACTION_NEXT
|
|
77
77
|
"search" -> EditorInfo.IME_ACTION_SEARCH
|
|
78
|
-
"send"
|
|
79
|
-
else
|
|
78
|
+
"send" -> EditorInfo.IME_ACTION_SEND
|
|
79
|
+
else -> EditorInfo.IME_ACTION_DONE
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
"maxLength" -> {
|
|
@@ -96,10 +96,10 @@ class VInputFactory : NativeComponentFactory {
|
|
|
96
96
|
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES).inv()
|
|
97
97
|
et.inputType = when (value) {
|
|
98
98
|
"characters", "allCharacters" -> baseType or InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS
|
|
99
|
-
"words"
|
|
100
|
-
"sentences"
|
|
101
|
-
"none"
|
|
102
|
-
else
|
|
99
|
+
"words" -> baseType or InputType.TYPE_TEXT_FLAG_CAP_WORDS
|
|
100
|
+
"sentences" -> baseType or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
|
|
101
|
+
"none" -> baseType
|
|
102
|
+
else -> baseType or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
"autoCorrect", "autocorrect" -> {
|
|
@@ -111,10 +111,10 @@ class VInputFactory : NativeComponentFactory {
|
|
|
111
111
|
}
|
|
112
112
|
"textAlign", "textAlignment" -> {
|
|
113
113
|
et.textAlignment = when (value) {
|
|
114
|
-
"left"
|
|
114
|
+
"left" -> View.TEXT_ALIGNMENT_TEXT_START
|
|
115
115
|
"center" -> View.TEXT_ALIGNMENT_CENTER
|
|
116
|
-
"right"
|
|
117
|
-
else
|
|
116
|
+
"right" -> View.TEXT_ALIGNMENT_TEXT_END
|
|
117
|
+
else -> View.TEXT_ALIGNMENT_TEXT_START
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
"color" -> {
|
|
@@ -39,8 +39,11 @@ class VListFactory : NativeComponentFactory {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
"bounces" -> {
|
|
42
|
-
rv.overScrollMode = if (value == false || value == "false")
|
|
43
|
-
View.OVER_SCROLL_NEVER
|
|
42
|
+
rv.overScrollMode = if (value == false || value == "false") {
|
|
43
|
+
View.OVER_SCROLL_NEVER
|
|
44
|
+
} else {
|
|
45
|
+
View.OVER_SCROLL_ALWAYS
|
|
46
|
+
}
|
|
44
47
|
}
|
|
45
48
|
"showsScrollIndicator" -> {
|
|
46
49
|
val show = value != false && value != "false"
|
|
@@ -81,8 +81,11 @@ class VModalFactory : NativeComponentFactory {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
val lp = StyleEngine.buildFlexLayoutParams(child)
|
|
84
|
-
if (index >= container.childCount)
|
|
85
|
-
|
|
84
|
+
if (index >= container.childCount) {
|
|
85
|
+
container.addView(child, lp)
|
|
86
|
+
} else {
|
|
87
|
+
container.addView(child, index, lp)
|
|
88
|
+
}
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
override fun removeChild(parent: View, child: View) {
|
|
@@ -4,7 +4,6 @@ import android.content.Context
|
|
|
4
4
|
import android.view.View
|
|
5
5
|
import android.view.ViewGroup
|
|
6
6
|
import android.widget.DatePicker
|
|
7
|
-
import android.widget.TimePicker
|
|
8
7
|
import java.util.Calendar
|
|
9
8
|
|
|
10
9
|
class VPickerFactory : NativeComponentFactory {
|
|
@@ -53,5 +52,7 @@ class VPickerFactory : NativeComponentFactory {
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
override fun removeEventListener(view: View, event: String) {
|
|
55
|
+
override fun removeEventListener(view: View, event: String) {
|
|
56
|
+
changeHandlers.remove(view)
|
|
57
|
+
}
|
|
57
58
|
}
|
|
@@ -3,7 +3,6 @@ package com.vuenative.core
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import android.view.MotionEvent
|
|
5
5
|
import android.view.View
|
|
6
|
-
import android.view.ViewGroup
|
|
7
6
|
import com.google.android.flexbox.FlexboxLayout
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -68,8 +67,11 @@ class VPressableFactory : NativeComponentFactory {
|
|
|
68
67
|
override fun insertChild(parent: View, child: View, index: Int) {
|
|
69
68
|
val flex = parent as? FlexboxLayout ?: return
|
|
70
69
|
val lp = StyleEngine.buildFlexLayoutParams(child)
|
|
71
|
-
if (index >= flex.childCount)
|
|
72
|
-
|
|
70
|
+
if (index >= flex.childCount) {
|
|
71
|
+
flex.addView(child, lp)
|
|
72
|
+
} else {
|
|
73
|
+
flex.addView(child, index, lp)
|
|
74
|
+
}
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
override fun removeChild(parent: View, child: View) {
|
|
@@ -33,7 +33,10 @@ class VRootFactory : NativeComponentFactory {
|
|
|
33
33
|
override fun insertChild(parent: View, child: View, index: Int) {
|
|
34
34
|
val flex = parent as? FlexboxLayout ?: return
|
|
35
35
|
val lp = StyleEngine.buildFlexLayoutParams(child)
|
|
36
|
-
if (index >= flex.childCount)
|
|
37
|
-
|
|
36
|
+
if (index >= flex.childCount) {
|
|
37
|
+
flex.addView(child, lp)
|
|
38
|
+
} else {
|
|
39
|
+
flex.addView(child, index, lp)
|
|
40
|
+
}
|
|
38
41
|
}
|
|
39
42
|
}
|
|
@@ -94,8 +94,11 @@ class VScrollViewFactory : NativeComponentFactory {
|
|
|
94
94
|
val srf = parent as? SwipeRefreshLayout ?: return
|
|
95
95
|
val content = states[srf]?.content ?: return
|
|
96
96
|
val lp = StyleEngine.buildFlexLayoutParams(child)
|
|
97
|
-
if (index >= content.childCount)
|
|
98
|
-
|
|
97
|
+
if (index >= content.childCount) {
|
|
98
|
+
content.addView(child, lp)
|
|
99
|
+
} else {
|
|
100
|
+
content.addView(child, index, lp)
|
|
101
|
+
}
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
override fun removeChild(parent: View, child: View) {
|
|
@@ -36,8 +36,11 @@ class VSectionListFactory : NativeComponentFactory {
|
|
|
36
36
|
val rv = view as? RecyclerView ?: return
|
|
37
37
|
when (key) {
|
|
38
38
|
"bounces" -> {
|
|
39
|
-
rv.overScrollMode = if (value == false || value == "false")
|
|
40
|
-
View.OVER_SCROLL_NEVER
|
|
39
|
+
rv.overScrollMode = if (value == false || value == "false") {
|
|
40
|
+
View.OVER_SCROLL_NEVER
|
|
41
|
+
} else {
|
|
42
|
+
View.OVER_SCROLL_ALWAYS
|
|
43
|
+
}
|
|
41
44
|
}
|
|
42
45
|
"showsScrollIndicator" -> {
|
|
43
46
|
val show = value != false && value != "false"
|