-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
85 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
FiveGuyes/FiveGuyes/Sources/Stores/NavigationCoodinaotr.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// NavigationCoodinaotr.swift | ||
// FiveGuyes | ||
// | ||
// Created by zaehorang on 11/6/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
// TODO: ์ถ๊ฐ๋๋ ๋ทฐ ์ถ๊ฐํ๊ธฐ | ||
enum Screens { | ||
case mainHome | ||
case empthNoti | ||
case bookSearch | ||
} | ||
|
||
@Observable | ||
final class NavigationCoordinator { | ||
var paths = NavigationPath() | ||
|
||
@ViewBuilder | ||
func navigate(to screen: Screens) -> some View { | ||
// TODO: ์ถ๊ฐ๋๋ ๋ทฐ ์ถ๊ฐํ๊ธฐ | ||
switch screen { | ||
case .mainHome: MainHomeView() | ||
case .empthNoti: EmptyNotiView() | ||
case .bookSearch: BookSearchView() | ||
} | ||
} | ||
|
||
// add screen | ||
func push(_ screen: Screens) { | ||
paths.append(screen) | ||
} | ||
|
||
// remove last screen | ||
func pop() { | ||
paths.removeLast() | ||
} | ||
|
||
// go to root screen | ||
func popToRoot() { | ||
paths.removeLast(paths.count) | ||
} | ||
} |