@craft-native/ios 0.0.224 → 0.0.225

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.224",
3
+ "version": "0.0.225",
4
4
  "homepage": "https://github.com/craft-native/craft/tree/main/packages/ios#readme",
5
5
  "repository": {
6
6
  "type": "git",
@@ -266,6 +266,8 @@ protocol CraftHybridScreenEvents: AnyObject {
266
266
  func nativeScreen(_ screen: CraftNativeScreenController, didFail message: String)
267
267
  /// `craft.navigation.open(path)`.
268
268
  func nativeScreen(_ screen: CraftNativeScreenController, open path: String)
269
+ /// `craft.navigation.replace(path)`: finish the current flow atomically.
270
+ func nativeScreen(_ screen: CraftNativeScreenController, replace path: String)
269
271
  }
270
272
 
271
273
  // MARK: - The shell
@@ -938,6 +940,10 @@ extension CraftHybrid: CraftHybridScreenEvents {
938
940
  func nativeScreen(_ screen: CraftNativeScreenController, open path: String) {
939
941
  open(path)
940
942
  }
943
+
944
+ func nativeScreen(_ screen: CraftNativeScreenController, replace path: String) {
945
+ controller?.showNative(path: path, replace: true)
946
+ }
941
947
  }
942
948
 
943
949
  /// The page's `craftHybrid` channel, only from a trusted origin's main frame.
@@ -1519,6 +1525,10 @@ final class CraftHybridController: UIViewController, UINavigationControllerDeleg
1519
1525
  interruptTabSwipe(restoringSelection: true)
1520
1526
  let tabs = hybrid.tabIds
1521
1527
  if let tab = tabs.first(where: { CraftHybridRoutes.normalize($0) == match.path }) {
1528
+ // Finish the flow in its original tab before selecting another.
1529
+ if replace, let current = visibleStack, current.viewControllers.count > 1 {
1530
+ current.setViewControllers(Array(current.viewControllers.dropLast()), animated: false)
1531
+ }
1522
1532
  if tab != currentTab {
1523
1533
  selectTabAsIfTapped(tab)
1524
1534
  }
@@ -1541,7 +1551,7 @@ final class CraftHybridController: UIViewController, UINavigationControllerDeleg
1541
1551
  return
1542
1552
  }
1543
1553
  let screen = entry(for: raw, isTabRoot: false, depth: nil)
1544
- if replace, nav.viewControllers.count > 1 {
1554
+ if replace, !nav.viewControllers.isEmpty {
1545
1555
  nav.setViewControllers(Array(nav.viewControllers.dropLast()) + [screen], animated: true)
1546
1556
  } else {
1547
1557
  nav.pushViewController(screen, animated: true)
@@ -1900,6 +1910,11 @@ final class CraftHybridController: UIViewController, UINavigationControllerDeleg
1900
1910
  open(path)
1901
1911
  }
1902
1912
 
1913
+ func nativeScreen(_ screen: CraftNativeScreenController, replace path: String) {
1914
+ guard screen.navigationController?.topViewController === screen else { return }
1915
+ showNative(path: path, replace: true)
1916
+ }
1917
+
1903
1918
  private func log(_ message: String) {
1904
1919
  #if DEBUG
1905
1920
  NSLog("[craft hybrid] %@", message)
@@ -5416,6 +5416,10 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
5416
5416
  guard !isAppScript, navigationController?.topViewController === self,
5417
5417
  let screen = payload["screen"] as? String, !screen.isEmpty,
5418
5418
  let navigation = navigationController else { return }
5419
+ if type == "NAVIGATE_REPLACE", screen.hasPrefix("/") {
5420
+ hybridEvents?.nativeScreen(self, replace: screen)
5421
+ return
5422
+ }
5419
5423
  let params = payload["params"] as? [String: Any] ?? [:]
5420
5424
  let next = CraftNativeScreenController(config: config, routeName: screen, routeParams: params)
5421
5425
  next.hybridEvents = hybridEvents
@@ -7006,6 +7010,7 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
7006
7010
  view.clipsToBounds = overflow == "hidden"
7007
7011
  || (view is UIScrollView && overflow != "visible")
7008
7012
  || (view is UILabel && (view.craftRequestedCornerRadius ?? 0) > 0)
7013
+ || (view is UIImageView && (borderRadius > 0 || hasCornerRadii))
7009
7014
  view.layer.masksToBounds = view.clipsToBounds
7010
7015
  view.craftLayoutStyle = CraftNativeLayoutStyle(style)
7011
7016
  (view as? CraftNativeFlowView)?.invalidateMeasurements()