@craft-native/ios 0.0.206 → 0.0.207

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@craft-native/ios",
3
- "version": "0.0.206",
3
+ "version": "0.0.207",
4
4
  "homepage": "https://github.com/craft-native/craft/tree/main/packages/ios#readme",
5
5
  "repository": {
6
6
  "type": "git",
@@ -854,9 +854,11 @@ final class CraftHybrid: NSObject {
854
854
  let show: (CraftHybridController) -> Void = { [weak self] controller in
855
855
  if native { controller.showNative(path: path, replace: false, fromLink: true) } else { self?.openOutside(url.absoluteString) }
856
856
  }
857
- guard let controller else {
857
+ guard let controller, controller.isViewLoaded else {
858
858
  // Before the shell: a hybrid app's page has it; an all-native app
859
859
  // opens it once the shell is up (a link that launched the app).
860
+ // Construction assigns controller before viewDidLoad makes the
861
+ // navigation stacks; a link in that interval must wait too.
860
862
  guard !hasWeb else { return false }
861
863
  untilShell.append(show)
862
864
  return true
@@ -21,6 +21,13 @@ private func number(_ value: Any?) -> CGFloat? {
21
21
  return value.isFinite ? value : nil
22
22
  }
23
23
 
24
+ private func craftNativeFontWeight(_ value: Any?) -> String? {
25
+ if let value = value as? String { return value }
26
+ guard !(value is Bool), let number = value as? NSNumber, number.doubleValue.isFinite else { return nil }
27
+ let integer = number.doubleValue.rounded()
28
+ return integer == number.doubleValue ? String(Int(integer)) : nil
29
+ }
30
+
24
31
  private func craftNativePickerValue(_ value: Any?) -> String? {
25
32
  if let value = value as? String, !value.isEmpty { return value }
26
33
  if let value = value as? NSNumber, value.doubleValue.isFinite { return String(value.doubleValue) }
@@ -1228,6 +1235,11 @@ private final class CraftNativeMapView: MKMapView, MKMapViewDelegate {
1228
1235
  return MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: latitude, longitude: longitude), span: MKCoordinateSpan(latitudeDelta: latitudeDelta, longitudeDelta: longitudeDelta))
1229
1236
  }
1230
1237
 
1238
+ private func nonEmptyHandler(_ handler: String?) -> String? {
1239
+ guard let handler, !handler.isEmpty else { return nil }
1240
+ return handler
1241
+ }
1242
+
1231
1243
  private static func color(_ value: String?) -> UIColor {
1232
1244
  switch value?.lowercased() {
1233
1245
  case "red": return .systemRed
@@ -6610,7 +6622,7 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
6610
6622
  (icon as? CraftNativeIconView)?.defaultBox = box == nil && fontSize == nil ? 20 : nil
6611
6623
  let pointSize = fontSize ?? (box ?? 20) * 0.84
6612
6624
  let weight: UIImage.SymbolWeight
6613
- switch style["fontWeight"] as? String {
6625
+ switch craftNativeFontWeight(style["fontWeight"]) {
6614
6626
  case "100": weight = .ultraLight
6615
6627
  case "200": weight = .thin
6616
6628
  case "300": weight = .light