@craft-native/ios 0.0.148 → 0.0.150

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.148",
3
+ "version": "0.0.150",
4
4
  "homepage": "https://github.com/craft-native/craft/tree/main/packages/ios#readme",
5
5
  "repository": {
6
6
  "type": "git",
@@ -566,6 +566,18 @@ final class CraftChrome: ObservableObject {
566
566
  tabBarVisible = true
567
567
  }
568
568
 
569
+ /// A native screen that wants the whole screen (a workout under way) asks
570
+ /// the bar away while it shows (`tabBarHidden`, CraftNativeScreen.swift);
571
+ /// the next screen shown says again. The page's own hideTabBar is apart.
572
+ private(set) var hiddenByScreen = false
573
+ func setHiddenByScreen(_ hidden: Bool) {
574
+ guard hiddenByScreen != hidden else { return }
575
+ hiddenByScreen = hidden
576
+ pendingHide?.cancel()
577
+ withAnimation(Self.motion(.easeInOut(duration: 0.2))) { tabBarVisible = !hidden && !tabs.isEmpty }
578
+ publishLayout()
579
+ }
580
+
569
581
  /// However the page behaves, the splash is gone after `seconds`
570
582
  /// (`splashMaxSeconds`, three by default). It used to be ten: a page that
571
583
  /// never painted held a logo on screen for ten seconds, which reads as a
@@ -595,7 +607,7 @@ final class CraftChrome: ObservableObject {
595
607
  let dark = (body["tintDark"] as? String).flatMap { UIColor(hex: $0) }
596
608
  tint = light.map { light in dark.map { dark in UIColor { $0.userInterfaceStyle == .dark ? dark : light } } ?? light }
597
609
  }
598
- withAnimation(Self.motion(.easeOut(duration: 0.2))) { tabBarVisible = !tabs.isEmpty }
610
+ withAnimation(Self.motion(.easeOut(duration: 0.2))) { tabBarVisible = !tabs.isEmpty && !hiddenByScreen }
599
611
  publishLayout()
600
612
  case "selectTab":
601
613
  if let id = body["id"] as? String, id != selected {
@@ -2335,9 +2335,21 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
2335
2335
  // a screen that hid its own.
2336
2336
  navigationController?.setNavigationBarHidden(false, animated: animated)
2337
2337
  }
2338
+ // Each screen says whether it wants the tab bar, so one that hid it
2339
+ // never leaves it hidden for the next.
2340
+ CraftChrome.shared.setHiddenByScreen(tabBarHidden)
2338
2341
  refreshTraitDefaults()
2339
2342
  }
2340
2343
 
2344
+ override func viewWillDisappear(_ animated: Bool) {
2345
+ super.viewWillDisappear(animated)
2346
+ // Popped (or its stack dismissed) while the bar was away: it comes
2347
+ // back for whatever shows next, a web page included.
2348
+ if tabBarHidden, isMovingFromParent || isBeingDismissed || navigationController?.isBeingDismissed == true {
2349
+ CraftChrome.shared.setHiddenByScreen(false)
2350
+ }
2351
+ }
2352
+
2341
2353
  override func viewDidAppear(_ animated: Bool) {
2342
2354
  super.viewDidAppear(animated)
2343
2355
  screenVisibilityChanged(true)
@@ -2852,6 +2864,8 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
2852
2864
  private var rootTopToSafeArea: NSLayoutConstraint?
2853
2865
  private var rootTopToView: NSLayoutConstraint?
2854
2866
  private var navigationBarHidden: Bool?
2867
+ /// The app's tab bar away while this screen shows (`tabBarHidden`).
2868
+ private var tabBarHidden = false
2855
2869
  private var prefersLargeTitle: Bool?
2856
2870
 
2857
2871
  /// Whether this screen asked for a bar of its own through `setOptions`: a
@@ -2879,6 +2893,12 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
2879
2893
  if largeTitle { navigationController?.navigationBar.prefersLargeTitles = true }
2880
2894
  trackContentScrollView()
2881
2895
  }
2896
+ if let hidden = options["tabBarHidden"] as? Bool {
2897
+ tabBarHidden = hidden
2898
+ if navigationController?.topViewController === self, view.window != nil {
2899
+ CraftChrome.shared.setHiddenByScreen(hidden)
2900
+ }
2901
+ }
2882
2902
  if let hidden = options["hidden"] as? Bool {
2883
2903
  navigationBarHidden = hidden
2884
2904
  if navigationController?.topViewController === self {
@@ -3274,6 +3294,12 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
3274
3294
  if navigationController?.topViewController === self {
3275
3295
  navigationController?.popViewController(animated: true)
3276
3296
  }
3297
+ case "NAVIGATE_POP_TO_ROOT":
3298
+ // Back to the first screen of this screen's stack in one move: a
3299
+ // finished task (a saved workout) closes the way it was reached.
3300
+ if navigationController?.topViewController === self {
3301
+ navigationController?.popToRootViewController(animated: true)
3302
+ }
3277
3303
  case "API_REQUEST":
3278
3304
  guard let id = message["id"] as? String else { return }
3279
3305
  let args = payload["args"] as? [Any] ?? []