@craft-native/ios 0.0.471 → 0.0.475
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
package/templates/CraftApp.swift
CHANGED
|
@@ -819,6 +819,7 @@ final class CraftChrome: ObservableObject {
|
|
|
819
819
|
var image: String? = nil
|
|
820
820
|
/// A compact floating icon, instead of the system full-width accessory shelf.
|
|
821
821
|
var iconOnly = false
|
|
822
|
+
var companions: [Tab] = []
|
|
822
823
|
}
|
|
823
824
|
|
|
824
825
|
@Published var tabs: [Tab] = []
|
|
@@ -828,8 +829,12 @@ final class CraftChrome: ObservableObject {
|
|
|
828
829
|
/// The visible destination may be the accessory, independently of its owning stack.
|
|
829
830
|
@Published var visiblePath: String?
|
|
830
831
|
var accessorySelected: Bool {
|
|
831
|
-
guard let
|
|
832
|
-
return
|
|
832
|
+
guard let accessory = tabAccessory else { return false }
|
|
833
|
+
return ([accessory] + accessory.companions).contains { accessorySelected($0) }
|
|
834
|
+
}
|
|
835
|
+
func accessorySelected(_ accessory: Tab) -> Bool {
|
|
836
|
+
guard let path = visiblePath else { return false }
|
|
837
|
+
return path == accessory.id || path.hasPrefix(accessory.id + "/")
|
|
833
838
|
}
|
|
834
839
|
var highlightedTab: String? { accessorySelected ? nil : selected }
|
|
835
840
|
let tabSwipeProgress = CraftTabSwipeProgress()
|
|
@@ -954,7 +959,14 @@ final class CraftChrome: ObservableObject {
|
|
|
954
959
|
next = Tab(id: path, title: title, symbol: item["symbol"] as? String ?? "message",
|
|
955
960
|
badge: (item["badge"] as? String).flatMap { $0.isEmpty ? nil : String($0.prefix(8)) },
|
|
956
961
|
accessibilityLabel: item["accessibilityLabel"] as? String,
|
|
957
|
-
iconOnly: item["iconOnly"] as? Bool ?? false
|
|
962
|
+
iconOnly: item["iconOnly"] as? Bool ?? false,
|
|
963
|
+
companions: ((item["companions"] as? [[String: Any]]) ?? []).prefix(2).compactMap { action in
|
|
964
|
+
guard let companionPath = action["path"] as? String,
|
|
965
|
+
companionPath.hasPrefix("/"), !companionPath.hasPrefix("//"), companionPath != path,
|
|
966
|
+
let companionTitle = action["title"] as? String else { return nil }
|
|
967
|
+
return Tab(id: companionPath, title: companionTitle, symbol: action["symbol"] as? String ?? "circle",
|
|
968
|
+
accessibilityLabel: action["accessibilityLabel"] as? String, iconOnly: true)
|
|
969
|
+
})
|
|
958
970
|
} else {
|
|
959
971
|
next = nil
|
|
960
972
|
}
|
|
@@ -1265,43 +1277,45 @@ private struct CraftTabBarContent: View {
|
|
|
1265
1277
|
if !chrome.tabs.isEmpty {
|
|
1266
1278
|
HStack(spacing: 8) {
|
|
1267
1279
|
bar
|
|
1268
|
-
if let
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1280
|
+
if let primary = chrome.tabAccessory {
|
|
1281
|
+
ForEach(primary.companions + [primary]) { accessory in
|
|
1282
|
+
Button { CraftHybrid.shared.open(accessory.id) } label: {
|
|
1283
|
+
surface {
|
|
1284
|
+
Image(systemName: accessory.symbol)
|
|
1285
|
+
.font(.system(size: iconSize))
|
|
1286
|
+
.foregroundStyle(chrome.accessorySelected(accessory) ? selectedColor : Color.primary)
|
|
1287
|
+
.frame(width: 62, height: 62)
|
|
1288
|
+
.background {
|
|
1289
|
+
if chrome.accessorySelected(accessory) {
|
|
1290
|
+
Circle().fill(selectedColor.opacity(0.14)).padding(4)
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
.contentShape(Rectangle())
|
|
1295
|
+
.overlay(alignment: .topTrailing) {
|
|
1296
|
+
if let badge = accessory.badge {
|
|
1297
|
+
Text(badge)
|
|
1298
|
+
.font(.system(size: badgeSize, weight: .bold))
|
|
1299
|
+
.foregroundStyle(.white)
|
|
1300
|
+
.padding(.horizontal, 4)
|
|
1301
|
+
.frame(minWidth: 18, minHeight: 18)
|
|
1302
|
+
.background(Capsule().fill(Color.red))
|
|
1278
1303
|
}
|
|
1279
1304
|
}
|
|
1280
1305
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
.buttonStyle(.plain)
|
|
1294
|
-
.accessibilityShowsLargeContentViewer {
|
|
1295
|
-
Image(systemName: accessory.symbol)
|
|
1296
|
-
Text(accessory.accessibilityLabel ?? accessory.title)
|
|
1306
|
+
.buttonStyle(.plain)
|
|
1307
|
+
.accessibilityShowsLargeContentViewer {
|
|
1308
|
+
Image(systemName: accessory.symbol)
|
|
1309
|
+
Text(accessory.accessibilityLabel ?? accessory.title)
|
|
1310
|
+
}
|
|
1311
|
+
// Keep accessibility intent for the viewer; displayed
|
|
1312
|
+
// sizes come from the bounded metrics owned above.
|
|
1313
|
+
.environment(\.dynamicTypeSize, viewerTextSize)
|
|
1314
|
+
.accessibilityLabel(accessory.accessibilityLabel ?? accessory.title)
|
|
1315
|
+
.accessibilityValue(accessory.badge ?? "")
|
|
1316
|
+
.accessibilityIdentifier("craft-tab-accessory")
|
|
1317
|
+
.accessibilityAddTraits(chrome.accessorySelected(accessory) ? .isSelected : [])
|
|
1297
1318
|
}
|
|
1298
|
-
// Keep accessibility intent for the viewer; displayed
|
|
1299
|
-
// sizes come from the bounded metrics owned above.
|
|
1300
|
-
.environment(\.dynamicTypeSize, viewerTextSize)
|
|
1301
|
-
.accessibilityLabel(accessory.accessibilityLabel ?? accessory.title)
|
|
1302
|
-
.accessibilityValue(accessory.badge ?? "")
|
|
1303
|
-
.accessibilityIdentifier("craft-tab-accessory")
|
|
1304
|
-
.accessibilityAddTraits(chrome.accessorySelected ? .isSelected : [])
|
|
1305
1319
|
}
|
|
1306
1320
|
}
|
|
1307
1321
|
.padding(.horizontal, 16)
|
|
@@ -1192,6 +1192,9 @@ final class CraftHybridController: UITabBarController, UITabBarControllerDelegat
|
|
|
1192
1192
|
private var synchronizingTabs = false
|
|
1193
1193
|
private var accessoryModel: CraftChrome.Tab?
|
|
1194
1194
|
private let accessoryButton = UIButton(type: .system)
|
|
1195
|
+
private var companionButtons: [UIButton] = []
|
|
1196
|
+
private var companionModels: [CraftChrome.Tab] = []
|
|
1197
|
+
private var companionGlasses: [UIVisualEffectView] = []
|
|
1195
1198
|
private let accessoryBadge = UILabel()
|
|
1196
1199
|
private let accessoryGlass = UIVisualEffectView(effect: UIBlurEffect(style: .systemMaterial))
|
|
1197
1200
|
private static let tabPictures = NSCache<NSURL, UIImage>()
|
|
@@ -1410,6 +1413,40 @@ final class CraftHybridController: UITabBarController, UITabBarControllerDelegat
|
|
|
1410
1413
|
private func updateSystemAccessory(hidden: Bool) {
|
|
1411
1414
|
let chrome = CraftChrome.shared
|
|
1412
1415
|
let model = hidden ? nil : chrome.tabAccessory
|
|
1416
|
+
// Keep controls when only the selected destination or unread badge changes.
|
|
1417
|
+
let companions = model?.iconOnly == true ? model?.companions ?? [] : []
|
|
1418
|
+
if companionModels != companions {
|
|
1419
|
+
companionModels = companions
|
|
1420
|
+
for button in companionButtons { button.removeFromSuperview() }
|
|
1421
|
+
for glass in companionGlasses { glass.removeFromSuperview() }
|
|
1422
|
+
companionButtons.removeAll()
|
|
1423
|
+
companionGlasses.removeAll()
|
|
1424
|
+
for action in companions {
|
|
1425
|
+
let button = UIButton(type: .system)
|
|
1426
|
+
var configuration = UIButton.Configuration.plain()
|
|
1427
|
+
configuration.image = UIImage(systemName: action.symbol)
|
|
1428
|
+
button.configuration = configuration
|
|
1429
|
+
button.accessibilityIdentifier = "craft-tab-companion:" + action.id
|
|
1430
|
+
button.accessibilityLabel = action.accessibilityLabel ?? action.title
|
|
1431
|
+
button.accessibilityValue = action.badge
|
|
1432
|
+
button.accessibilityTraits = chrome.accessorySelected(action) ? [.button, .selected] : [.button]
|
|
1433
|
+
button.addAction(UIAction { [weak self] _ in self?.hybrid.open(action.id) }, for: .touchUpInside)
|
|
1434
|
+
let glass = UIVisualEffectView(effect: UIBlurEffect(style: .systemMaterial))
|
|
1435
|
+
#if compiler(>=6.2)
|
|
1436
|
+
if #available(iOS 26.0, *) { glass.effect = UIGlassEffect() }
|
|
1437
|
+
#endif
|
|
1438
|
+
glass.layer.cornerRadius = 24
|
|
1439
|
+
glass.clipsToBounds = true
|
|
1440
|
+
glass.isUserInteractionEnabled = false
|
|
1441
|
+
view.addSubview(glass)
|
|
1442
|
+
view.addSubview(button)
|
|
1443
|
+
companionGlasses.append(glass)
|
|
1444
|
+
companionButtons.append(button)
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
for (index, action) in companionModels.enumerated() {
|
|
1448
|
+
companionButtons[index].accessibilityTraits = chrome.accessorySelected(action) ? [.button, .selected] : [.button]
|
|
1449
|
+
}
|
|
1413
1450
|
if let model {
|
|
1414
1451
|
var configuration = UIButton.Configuration.plain()
|
|
1415
1452
|
configuration.image = UIImage(systemName: model.symbol)
|
|
@@ -1419,7 +1456,7 @@ final class CraftHybridController: UITabBarController, UITabBarControllerDelegat
|
|
|
1419
1456
|
accessoryButton.configuration = configuration
|
|
1420
1457
|
accessoryButton.accessibilityLabel = model.accessibilityLabel ?? model.displayTitle
|
|
1421
1458
|
accessoryButton.accessibilityValue = model.badge
|
|
1422
|
-
accessoryButton.accessibilityTraits = chrome.accessorySelected ? [.button, .selected] : [.button]
|
|
1459
|
+
accessoryButton.accessibilityTraits = chrome.accessorySelected(model) ? [.button, .selected] : [.button]
|
|
1423
1460
|
}
|
|
1424
1461
|
#if compiler(>=6.2)
|
|
1425
1462
|
if #available(iOS 26.0, *), model?.iconOnly != true {
|
|
@@ -1493,6 +1530,11 @@ final class CraftHybridController: UITabBarController, UITabBarControllerDelegat
|
|
|
1493
1530
|
let x = iconOnly ? view.bounds.maxX - view.safeAreaInsets.right - width - 20 : 16
|
|
1494
1531
|
accessoryButton.frame = CGRect(x: x, y: tabBar.frame.minY - height - (iconOnly ? 8 : 0), width: width, height: height)
|
|
1495
1532
|
accessoryGlass.frame = accessoryButton.frame
|
|
1533
|
+
for (index, button) in companionButtons.enumerated() {
|
|
1534
|
+
// Array order reads left to right, ending at the primary action.
|
|
1535
|
+
button.frame = accessoryButton.frame.offsetBy(dx: -CGFloat(companionButtons.count - index) * (width + 12), dy: 0)
|
|
1536
|
+
companionGlasses[index].frame = button.frame
|
|
1537
|
+
}
|
|
1496
1538
|
let badgeWidth = max(18, accessoryBadge.intrinsicContentSize.width + 8)
|
|
1497
1539
|
accessoryBadge.frame = CGRect(x: accessoryButton.frame.maxX - badgeWidth + 4, y: accessoryButton.frame.minY - 3, width: badgeWidth, height: 18)
|
|
1498
1540
|
// A compact action floats over the page, not across its whole width.
|
|
@@ -11444,6 +11444,17 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
|
|
|
11444
11444
|
// UISwitch also owns its native identity and enabled/on state.
|
|
11445
11445
|
// Assigning .button changes its legacy AX type into a button while
|
|
11446
11446
|
// modern XCTest still identifies its UIKit class as a switch.
|
|
11447
|
+
// The solid variant publishes "1"/"0" as a string from
|
|
11448
|
+
// refreshAccessibility(). A UISwitch left to UIKit does not: the value
|
|
11449
|
+
// it hands XCTest arrives as a number, so every `value as? String`
|
|
11450
|
+
// read finds nothing. The driver's flip check is one of those reads,
|
|
11451
|
+
// which is why a switch that did flip was reported as never flipping,
|
|
11452
|
+
// and only sometimes - it depends which representation the accessibility
|
|
11453
|
+
// snapshot was built from. Publishing the string makes both variants
|
|
11454
|
+
// answer the same way. An authored accessibilityValue still wins.
|
|
11455
|
+
if let toggle = view as? UISwitch, !authoredAccessibilityValues.contains(id) {
|
|
11456
|
+
view.accessibilityValue = toggle.isOn ? "1" : "0"
|
|
11457
|
+
}
|
|
11447
11458
|
if view is UITextView || view is UISwitch { return }
|
|
11448
11459
|
if let toggle = view as? CraftNativeSolidSwitch { toggle.refreshAccessibility(); return }
|
|
11449
11460
|
view.accessibilityTraits = traits
|
|
@@ -30,14 +30,22 @@ enum CraftPresenter {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/// Present over whatever is on screen. A controller that shows as a
|
|
33
|
-
/// popover
|
|
34
|
-
/// `view`, or sits in the middle of it with no
|
|
35
|
-
/// exception for a popover with neither. False
|
|
36
|
-
/// so the caller answers rather than waiting.
|
|
33
|
+
/// popover (an action sheet, a share sheet, on a regular-width screen)
|
|
34
|
+
/// points at `anchor` in `view`, or sits in the middle of it with no
|
|
35
|
+
/// arrow; iPadOS raises an exception for a popover with neither. False
|
|
36
|
+
/// when nothing can present, so the caller answers rather than waiting.
|
|
37
|
+
///
|
|
38
|
+
/// Only where the presentation really is a popover. A `.actionSheet`
|
|
39
|
+
/// always carries a `popoverPresentationController`, phone included, and
|
|
40
|
+
/// from iOS 26 configuring it is enough to make the phone present the
|
|
41
|
+
/// sheet as a centred popover -- which silently drops its cancel action,
|
|
42
|
+
/// as UIKit never draws one in a popover. A compact screen is left alone
|
|
43
|
+
/// and gets the standard sheet, with its Cancel.
|
|
37
44
|
@discardableResult
|
|
38
45
|
static func present(_ controller: UIViewController, from view: UIView?, anchor: CGRect? = nil) -> Bool {
|
|
39
46
|
guard let top = topViewController() else { return false }
|
|
40
|
-
|
|
47
|
+
let asPopover = (view ?? top.view)?.traitCollection.horizontalSizeClass == .regular
|
|
48
|
+
if asPopover, let popover = controller.popoverPresentationController {
|
|
41
49
|
let source = view ?? top.view!
|
|
42
50
|
popover.sourceView = source
|
|
43
51
|
if let anchor {
|