Skip to content

Commit

Permalink
wip (#199)
Browse files Browse the repository at this point in the history
Co-authored-by: Brandon Williams <mbrandonw@hey.com>
  • Loading branch information
stephencelis and mbrandonw authored Aug 13, 2024
1 parent 9992ac1 commit baff7b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ final class StaticNavigationStackController: NavigationStackController, UIKitCas
let isPresentedInSheet = true
private var model: Model!

@MainActor
convenience init() {
@UIBindable var model = Model()
convenience init(model: Model) {
@UIBindable var model = model
self.init(path: $model.path) {
RootViewController(model: model)
}
Expand Down Expand Up @@ -170,5 +169,5 @@ private class FeatureViewController: UIViewController {
}

#Preview {
StaticNavigationStackController()
StaticNavigationStackController(model: StaticNavigationStackController.Model())
}
2 changes: 1 addition & 1 deletion Examples/CaseStudies/UIKit/UIKitCaseStudies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct UIKitCaseStudiesView: View {
ConciseEnumNavigationViewController()
}
CaseStudyGroupView("Stack navigation") {
StaticNavigationStackController()
StaticNavigationStackController(model: StaticNavigationStackController.Model())
ErasedNavigationStackController(model: ErasedNavigationStackController.Model())
// TODO: state restoration
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,36 @@
set { pathDelegate.base = newValue }
}

public convenience init<Data: RandomAccessCollection & RangeReplaceableCollection>(
public required init<Data: RandomAccessCollection & RangeReplaceableCollection>(
navigationBarClass: AnyClass? = nil,
toolbarClass: AnyClass? = nil,
path: UIBinding<Data>,
root: () -> UIViewController
) where Data.Element: Hashable {
self.init(navigationBarClass: navigationBarClass, toolbarClass: toolbarClass)
super.init(navigationBarClass: navigationBarClass, toolbarClass: toolbarClass)
self._path = path.path
let root = root()
self.root = root
self.viewControllers = [root]
}

public convenience init(
public required init(
navigationBarClass: AnyClass? = nil,
toolbarClass: AnyClass? = nil,
path: UIBinding<UINavigationPath>,
root: () -> UIViewController
) {
self.init(navigationBarClass: navigationBarClass, toolbarClass: toolbarClass)
super.init(navigationBarClass: navigationBarClass, toolbarClass: toolbarClass)
self._path = path.elements
let root = root()
self.root = root
self.viewControllers = [root]
}


public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

open override func viewDidLoad() {
super.viewDidLoad()

Expand Down

0 comments on commit baff7b2

Please # to comment.