Repository navigation
[FEAT] 메인 TabView 및 탭별 NavigationStack 연결 #36
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
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
544701d
🩹chore: 파일 추적 해제
devBambu 52e699b
🚚build: 폴더 및 파일 추가, 이동
devBambu 29e7bc1
✨feat: MohaView 파일 생성 및 TabView 추가
devBambu 61498b3
✨feat: Route 프로토콜 생성 및 구현
devBambu 937263f
✨feat: HomeRoute 생성
devBambu 0b025db
✨feat: MainRouter 생성 및 기초 구현
devBambu e2d73b9
✨feat: MainRouter 프로퍼티 수정
devBambu 69029b9
✨feat: Router 프로토콜 정의
devBambu c3056fe
✨feat: 탭별 Router 및 Route 생성, 마지막 탭 이름 변경(MyPage -> Settings)
devBambu 825958f
🚚build: Route, Router 폴더 분리
devBambu 685adba
✨feat: MohaView 프로퍼티 수정
devBambu 9f6d910
✨feat: HomeNavigationStack 생성 및 기초 구현
devBambu 60bad05
✨feat: ReportNavigationStack 생성 및 기초 구현
devBambu 2002e61
✨feat: SettingsNavigationStack 생성 및 기초 구현
devBambu f645af1
✨feat: TabView 각 NavigationStack 연결
devBambu 9bb31c1
✨feat: MainRouter environment 등록
devBambu dfc2cdb
🩹chore: Router 프로토콜 네이밍 수정 -> NavigationRouter
devBambu 2667ab9
✨feat: 앱 진입 메인뷰 변경
devBambu d434586
🐞fix: workflow yml 파일 수정
devBambu 813c0b5
✨feat: NavigationRouter 함수 매개변수 타입 수정
devBambu 60bd52c
✨feat: Route 프로토콜 id 속성 및 hash 함수 삭제
devBambu 008d723
✨feat: TabItem 의존성 분리
devBambu d22a9cd
🐞fix: selectedTab의 TabItem 의존성 삭제
devBambu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Binary file removed
BIN
-15.8 KB
...roj/project.xcworkspace/xcuserdata/byeon-yerin.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or 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,47 @@ | ||
| // | ||
| // MohaView.swift | ||
| // Moha | ||
| // | ||
| // Created by 변예린 on 8/19/26. | ||
| // | ||
|
|
||
| import SwiftUI | ||
|
|
||
| struct MohaView: View { | ||
| @State private var router = MainRouter() | ||
|
|
||
| var body: some View { | ||
| TabView(selection: $router.selectedTab) { | ||
| HomeNavigationStack(router: router.homeRouter) | ||
| .tag(TabItem.home) | ||
| .tabItem { | ||
| Label("Home", systemImage: "house") | ||
| } | ||
|
|
||
| ReportNavigationStack(router: router.reportRouter) | ||
| .tag(TabItem.report) | ||
| .tabItem { | ||
| Label("Report", systemImage: "chart.xyaxis.line") | ||
| } | ||
|
|
||
| SettingsNavigationStack(router: router.settingsRouter) | ||
| .tag(TabItem.settings) | ||
| .tabItem { | ||
| Label("Settings", systemImage: "person") | ||
| } | ||
| } | ||
| .environment(router) | ||
| } | ||
| } | ||
|
|
||
| //MARK: Tab Item | ||
| enum TabItem { | ||
| case home | ||
| case report | ||
| case settings | ||
| } | ||
|
|
||
| //MARK: - MohaView Preview | ||
| #Preview { | ||
| MohaView() | ||
| } |
File renamed without changes.
This file contains hidden or 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
29 changes: 29 additions & 0 deletions
29
Moha/Moha/Sources/Navigation/NavigationStack/HomeNavigationStack.swift
This file contains hidden or 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,29 @@ | ||
| // | ||
| // HomeNavigationStack.swift | ||
| // Moha | ||
| // | ||
| // Created by 변예린 on 8/21/26. | ||
| // | ||
|
|
||
| import SwiftUI | ||
|
|
||
| struct HomeNavigationStack: View { | ||
| @Bindable var router: HomeRouter | ||
|
|
||
| var body: some View { | ||
| NavigationStack(path: $router.path) { | ||
| Text("Home") //TODO: HomeView로 수정 필요 | ||
| .navigationDestination(for: HomeRoute.self) { route in | ||
| destinationView(for: route) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private func destinationView(for route: HomeRoute) -> some View { | ||
| switch route { | ||
| case .createTodo: | ||
| Text("Create") | ||
| } | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
Moha/Moha/Sources/Navigation/NavigationStack/ReportNavigationStack.swift
This file contains hidden or 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,29 @@ | ||
| // | ||
| // ReportNavigationStack.swift | ||
| // Moha | ||
| // | ||
| // Created by 변예린 on 8/21/26. | ||
| // | ||
|
|
||
| import SwiftUI | ||
|
|
||
| struct ReportNavigationStack: View { | ||
| @Bindable var router: ReportRouter | ||
|
|
||
| var body: some View { | ||
| NavigationStack(path: $router.path) { | ||
| Text("Report") //TODO: ReportView로 수정 필요 | ||
| .navigationDestination(for: ReportRoute.self) { route in | ||
| destinationView(for: route) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private func destinationView(for route: ReportRoute) -> some View { | ||
| switch route { | ||
| case .createTodo: | ||
| Text("Create") | ||
| } | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
Moha/Moha/Sources/Navigation/NavigationStack/SettingsNavigationStack.swift
This file contains hidden or 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,29 @@ | ||
| // | ||
| // SettingsNavigationStack.swift | ||
| // Moha | ||
| // | ||
| // Created by 변예린 on 8/21/26. | ||
| // | ||
|
|
||
| import SwiftUI | ||
|
|
||
| struct SettingsNavigationStack: View { | ||
| @Bindable var router: SettingsRouter | ||
|
|
||
| var body: some View { | ||
| NavigationStack(path: $router.path) { | ||
| Text("Settings") //TODO: SettingsView로 수정 필요 | ||
| .navigationDestination(for: SettingsRoute.self) { route in | ||
| destinationView(for: route) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private func destinationView(for route: SettingsRoute) -> some View { | ||
| switch route { | ||
| case .createTodo: | ||
| Text("Create") | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,10 @@ | ||
| // | ||
| // HomeRoute.swift | ||
| // Moha | ||
| // | ||
| // Created by 변예린 on 8/20/26. | ||
| // | ||
|
|
||
| enum HomeRoute: Route { | ||
| case createTodo | ||
| } |
This file contains hidden or 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,10 @@ | ||
| // | ||
| // ReportRoute.swift | ||
| // Moha | ||
| // | ||
| // Created by 변예린 on 8/20/26. | ||
| // | ||
|
|
||
| enum ReportRoute: Route { | ||
| case createTodo | ||
| } |
This file contains hidden or 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,8 @@ | ||
| // | ||
| // Route.swift | ||
| // Moha | ||
| // | ||
| // Created by 변예린 on 8/20/26. | ||
| // | ||
|
|
||
| protocol Route: Hashable { } |
This file contains hidden or 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,10 @@ | ||
| // | ||
| // SettingsRoute.swift | ||
| // Moha | ||
| // | ||
| // Created by 변예린 on 8/20/26. | ||
| // | ||
|
|
||
| enum SettingsRoute: Route { | ||
| case createTodo | ||
| } |
This file contains hidden or 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,20 @@ | ||
| // | ||
| // MainRouter.swift | ||
| // Moha | ||
| // | ||
| // Created by 변예린 on 8/20/26. | ||
| // | ||
|
|
||
| import SwiftUI | ||
| import Combine | ||
|
|
||
| @Observable | ||
| final class MainRouter: ObservableObject { | ||
| var selectedTab = TabItem.home | ||
|
|
||
| let homeRouter = HomeRouter() | ||
| let reportRouter = ReportRouter() | ||
| let settingsRouter = SettingsRouter() | ||
|
|
||
|
|
||
| } |
60 changes: 60 additions & 0 deletions
60
Moha/Moha/Sources/Navigation/Router/NavigationRouter.swift
This file contains hidden or 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,60 @@ | ||
| // | ||
| // Router.swift | ||
| // Moha | ||
| // | ||
| // Created by 변예린 on 8/20/26. | ||
| // | ||
|
|
||
| import SwiftUI | ||
|
|
||
| protocol NavigationRouter: AnyObject { | ||
| associatedtype Destination: Route | ||
|
|
||
| var path: NavigationPath { get set } | ||
| } | ||
|
|
||
| extension NavigationRouter { | ||
| func push(to route: Destination) { | ||
| path.append(route) | ||
| } | ||
|
|
||
| func pop() { | ||
| guard !path.isEmpty else { return } | ||
| path.removeLast() | ||
| } | ||
|
|
||
| func reset() { | ||
| path = NavigationPath() | ||
| } | ||
|
|
||
| func popTo(count: Int) { | ||
| guard count > 0, count <= path.count else { return } | ||
| path.removeLast(count) | ||
| } | ||
|
|
||
| func replace(with route: Destination) { | ||
| path = NavigationPath() | ||
| path.append(route) | ||
| } | ||
| } | ||
|
|
||
| @Observable | ||
| final class HomeRouter: NavigationRouter { | ||
| typealias Destination = HomeRoute | ||
|
|
||
| var path = NavigationPath() | ||
| } | ||
|
|
||
| @Observable | ||
| final class ReportRouter: NavigationRouter { | ||
| typealias Destination = ReportRoute | ||
|
|
||
| var path = NavigationPath() | ||
| } | ||
|
|
||
| @Observable | ||
| final class SettingsRouter: NavigationRouter { | ||
| typealias Destination = SettingsRoute | ||
|
|
||
| var path = NavigationPath() | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.