Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use NavigationStack + @Observable #10

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -654,7 +654,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand All @@ -675,7 +675,7 @@
DEVELOPMENT_TEAM = GH868RP95T;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = NiceArchitectureExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -700,7 +700,7 @@
DEVELOPMENT_TEAM = GH868RP95T;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = NiceArchitectureExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ enum PostsRoute {
/// it should be responsible for holding references to each of the viewModels it manages
/// and use that information, plus any changes in state, to decide which View to present.
/// ViewModels can interact with their coordinator to update the state or navigate to other pages.
class PostsCoordinator: ObservableObject, Coordinator {
@Published var viewModel: PostsViewModel!
@Published var postDetailViewModel: PostDetailViewModel?
@Observable class PostsCoordinator: Coordinator {
var viewModel: PostsViewModel!
var postDetailViewModel: PostDetailViewModel?

init() {
viewModel = PostsViewModel(coordinator: self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import SwiftUI
/// managing transitioning between Views.
/// Doing so reduces the complexity of individual Views, and helps with things like navigation.
struct PostsCoordinatorView: View {
@ObservedObject var coordinator: PostsCoordinator
@Bindable var coordinator: PostsCoordinator

var body: some View {
NavigationView {
NavigationStack {
PostsView(viewModel: coordinator.viewModel)
.navigation(item: $coordinator.postDetailViewModel) { viewModel in
PostDetailView(viewModel: viewModel)
Expand Down