Files
Fluxup_PAP/node_modules/react-native-screens/ios/gamma/stack/host/RNSStackController.swift
2026-03-10 16:18:05 +00:00

66 lines
1.7 KiB
Swift

import Foundation
import UIKit
@objc
public class RNSStackController: UINavigationController, ReactMountingTransactionObserving {
private var needsChildViewControllersUpdate = false
private let stackHostComponentView: RNSStackHostComponentView
@objc public required init(stackHostComponentView: RNSStackHostComponentView) {
self.stackHostComponentView = stackHostComponentView
super.init(nibName: nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
return nil
}
// MARK: Signals
@objc
public func setNeedsUpdateOfChildViewControllers() {
needsChildViewControllersUpdate = true
}
// MARK: Updating
@objc
public func updateChildViewControllersIfNeeded() {
if needsChildViewControllersUpdate {
updateChildViewControllers()
}
}
@objc
public func updateChildViewControllers() {
precondition(
needsChildViewControllersUpdate,
"[RNScreens] Child view controller must be invalidated when update is forced!")
let activeControllers = sourceAllViewControllers()
.filter { screenCtrl in screenCtrl.screen.activityMode == .attached }
setViewControllers(activeControllers, animated: true)
needsChildViewControllersUpdate = false
}
private func sourceAllViewControllers() -> [RNSStackScreenController] {
let screenStackComponents =
stackHostComponentView.reactSubviews() as! [RNSStackScreenComponentView]
return screenStackComponents.lazy.map(\.controller)
}
// MARK: ReactMountingTransactionObserving
@objc
public func reactMountingTransactionWillMount() {
// noop
}
@objc
public func reactMountingTransactionDidMount() {
updateChildViewControllersIfNeeded()
}
}