Skip to content

Latest commit

 

History

History
57 lines (46 loc) · 1.18 KB

README.md

File metadata and controls

57 lines (46 loc) · 1.18 KB

NavUI

Description

NavUI is a framework to handle with navigation in SwiftUI using NavigationStack. With NavUI it is possible to use easily Coordinators flows.

Example of usage

With Navigation class, you can keep the object in Coordinator, for example:

import NavUI

final class MainCoordinator {
	let navigation: Navigation
	
	init(navigation: Navigation = .init())
		self.navigation = navigation
	}
	
	func start() -> some View {
		return navigation.start(root: ExampleRootView())
	}
}

In this way, you can start the app scene calling the start method of your coordinator, like:

@main
struct NavUaiApp: App {
    var body: some Scene {
        WindowGroup {
          MainCoordinator().start()
        }
    }
}

With that, another features/coordinator, can be pushed in navigation just with inject the Navigation object

final class MainCoordinator {
	[...]
	func goToAnotherFeature() {
		AnotherFeatureCoordinator(navigation: navigation).start()
	}
}

final class AnotherFeatureCoordinator {
	let navigation: Navigation
	
	init(navigation: Navigation = .init())
		self.navigation = navigation
	}
	
	func start() {
		navigation.push(FirstFeatureView())
	}
}