@craft-native/ios 0.0.142 → 0.0.143
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/package.json
CHANGED
|
@@ -38,7 +38,7 @@ enum CraftNativeActions {
|
|
|
38
38
|
private static let sqliteTransient = unsafeBitCast(-1, to: sqlite3_destructor_type.self)
|
|
39
39
|
|
|
40
40
|
static func capabilities(config: CraftConfig) -> [String] {
|
|
41
|
-
var values = ["device", "clipboard", "haptics", "storage", "lifecycle", "fetch"]
|
|
41
|
+
var values = ["device", "clipboard", "haptics", "storage", "lifecycle", "fetch", "dialog"]
|
|
42
42
|
if config.enableBiometric { values.append("biometric") }
|
|
43
43
|
if config.enableSecureStorage { values.append("secureStorage") }
|
|
44
44
|
if config.enableLocalDatabase { values.append("database") }
|
|
@@ -146,6 +146,23 @@ enum CraftNativeActions {
|
|
|
146
146
|
}
|
|
147
147
|
databaseQueue.async { complete(requestToken, database(method: method, args: args), completion) }
|
|
148
148
|
return
|
|
149
|
+
case ("Dialog", _):
|
|
150
|
+
// The system's own alert, confirmation and action sheet, the same
|
|
151
|
+
// ones a page gets (CraftNativeUI.swift), over the native screen.
|
|
152
|
+
let body = args.first as? [String: Any] ?? [:]
|
|
153
|
+
DispatchQueue.main.async {
|
|
154
|
+
switch method {
|
|
155
|
+
case "alert":
|
|
156
|
+
CraftDialogs.alert(body, from: nil) { complete(requestToken, .success(NSNull()), completion) }
|
|
157
|
+
case "confirm":
|
|
158
|
+
CraftDialogs.confirm(body, from: nil) { complete(requestToken, .success($0), completion) }
|
|
159
|
+
case "actionSheet":
|
|
160
|
+
CraftDialogs.actionSheet(body, from: nil) { complete(requestToken, .success($0 ?? NSNull()), completion) }
|
|
161
|
+
default:
|
|
162
|
+
complete(requestToken, failure("UNKNOWN_ACTION", "Unsupported Dialog method"), completion)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return
|
|
149
166
|
case ("Health", _):
|
|
150
167
|
// Apple Health, the same as a page's `craft.health` (CraftHealth.swift).
|
|
151
168
|
guard config.enableHealthKit else {
|
|
@@ -525,7 +525,7 @@ final class CraftNativeFlatList: UICollectionView, UICollectionViewDelegateFlowL
|
|
|
525
525
|
|
|
526
526
|
private static func identity(for node: [String: Any]) -> String? {
|
|
527
527
|
let props = node["props"] as? [String: Any] ?? [:]
|
|
528
|
-
return [node["
|
|
528
|
+
return [node["key"], props["key"], props["testID"], node["id"]]
|
|
529
529
|
.compactMap { $0 as? String }
|
|
530
530
|
.first { !$0.isEmpty }
|
|
531
531
|
}
|
|
@@ -3528,7 +3528,7 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
|
|
|
3528
3528
|
private func explicitKey(_ node: [String: Any], props: [String: Any]) -> String? {
|
|
3529
3529
|
// The current @stacksjs/stx native compiler emits key in props; accept the IR
|
|
3530
3530
|
// field too so keyed children keep working when the compiler adopts it.
|
|
3531
|
-
[node["
|
|
3531
|
+
[node["key"], props["key"], props["testID"], node["id"]]
|
|
3532
3532
|
.compactMap { $0 as? String }
|
|
3533
3533
|
.first { !$0.isEmpty }
|
|
3534
3534
|
}
|
|
@@ -4328,7 +4328,7 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
|
|
|
4328
4328
|
view.accessibilityValue = nil
|
|
4329
4329
|
}
|
|
4330
4330
|
let role = props["accessibilityRole"] as? String
|
|
4331
|
-
view.isAccessibilityElement = role != "none" && (view.accessibilityLabel != nil || role != nil || ["Text", "Button", "Link", "Image", "TextInput", "Picker", "Switch", "Slider"].contains(type))
|
|
4331
|
+
view.isAccessibilityElement = role != "none" && (view.accessibilityLabel != nil || role != nil || ["Text", "Button", "Link", "Image", "Video", "TextInput", "Picker", "Switch", "Slider"].contains(type))
|
|
4332
4332
|
var traits: UIAccessibilityTraits = []
|
|
4333
4333
|
switch role ?? type.lowercased() {
|
|
4334
4334
|
case "button": traits.insert(.button)
|