-
Notifications
You must be signed in to change notification settings - Fork 2
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
Refactor/#146 report navigation mvi #176
Closed
Closed
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2a0343e
refactor: #146 신고하기 MVI로 refactoring
juri123123 6abb526
Merge branch 'juri' into refactor/#146-reportNavigationMVI
juri123123 29f5753
chore: #146 중복 로직 제거
juri123123 bc3a8a0
refactor: #146 explore, report - navigation MVI 적용
juri123123 6cbf720
Merge branch 'juri' into refactor/#146-reportNavigationMVI
juri123123 b0b6ae0
refactor: #146 search - navigation MVI 적용
juri123123 13aa3f8
chore: #146 상수 -> 변수 오류 수정
juri123123 5a99cb0
chore: #146 키보드 내려가는 기능 추가
juri123123 b047f0c
chore: #146 build 고민... -> 미해결
juri123123 38ece9d
Merge branch 'juri' into refactor/#146-reportNavigationMVI
juri123123 5cd1ba6
Merge branch 'juri' into refactor/#146-reportNavigationMVI
juri123123 4b9073e
Merge branch 'juri' into refactor/#146-reportNavigationMVI
juri123123 4f6e076
chore: #146 안쓰는 변수 및 case 삭제
juri123123 b22aea1
chore: #146 안쓰는 코드 삭제
juri123123 2128275
chore: #146 안쓰는 코드 삭제
juri123123 6d1aab1
chore: #146 안쓰는 파일 삭제
juri123123 42aa171
chore: #146 코드 정리
juri123123 d0f3032
chore: #146 코드리뷰반영
juri123123 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 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
75 changes: 0 additions & 75 deletions
75
Spoony-iOS/Spoony-iOS/Resource/Tab/NavigationManager.swift
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
Spoony-iOS/Spoony-iOS/Resource/Tab/Store/NavigationIntent.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,19 @@ | ||
// | ||
// NavigationIntent.swift | ||
// Spoony-iOS | ||
// | ||
// Created by 최주리 on 1/24/25. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
enum NavigationIntent { | ||
case changeTab(TabType) | ||
case push(ViewType) | ||
case pop(Int) | ||
case popToRoot | ||
case showPopup(PopupType?) | ||
case changePath([ViewType], TabType) | ||
case changeCurrentLocation(String?) | ||
} |
95 changes: 95 additions & 0 deletions
95
Spoony-iOS/Spoony-iOS/Resource/Tab/Store/NavigationManager.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,95 @@ | ||
// | ||
// NavigationManager.swift | ||
// SpoonMe | ||
// | ||
// Created by 최주리 on 1/7/25. | ||
// | ||
|
||
import SwiftUI | ||
|
||
final class NavigationManager: ObservableObject { | ||
@Published private(set) var state = NavigationState() | ||
|
||
func dispatch(_ intent: NavigationIntent) { | ||
switch intent { | ||
case .changeTab(let tab): | ||
state.selectedTab = tab | ||
case .push(let nextView): | ||
push(nextView) | ||
case .pop(let depth): | ||
pop(depth) | ||
case .popToRoot: | ||
popToRoot() | ||
case .showPopup(let popup): | ||
state.popup = popup | ||
case .changePath(let path, let tab): | ||
switch tab { | ||
case .map: | ||
state.mapPath = path | ||
case .explore: | ||
state.explorePath = path | ||
case .register: | ||
state.registerPath = path | ||
} | ||
case .changeCurrentLocation(let location): | ||
state.currentLocation = location | ||
} | ||
} | ||
|
||
//TODO: 여기 어떻게 할지 생각해보기......... | ||
@ViewBuilder | ||
func build(_ view: ViewType) -> some View { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 고민을 해봐도 답이 안 나오네요... |
||
switch view { | ||
case .searchView: | ||
SearchView() | ||
case .locationView: | ||
Home() | ||
case .detailView(let postId): | ||
DetailView(postId: postId) | ||
case .report(let postId): | ||
Report(postId: postId) | ||
} | ||
} | ||
} | ||
|
||
extension NavigationManager { | ||
private func push(_ view: ViewType) { | ||
switch state.selectedTab { | ||
case .map: | ||
state.mapPath.append(view) | ||
case .explore: | ||
state.explorePath.append(view) | ||
case .register: | ||
state.registerPath.append(view) | ||
} | ||
} | ||
|
||
private func pop(_ depth: Int) { | ||
switch state.selectedTab { | ||
case .map: | ||
if state.mapPath.isEmpty || state.mapPath.contains(where: { | ||
if case .locationView = $0 { return true } | ||
return false | ||
}) { | ||
state.currentLocation = nil | ||
} | ||
state.mapPath.removeLast(depth) | ||
|
||
case .explore: | ||
state.explorePath.removeLast(depth) | ||
case .register: | ||
state.registerPath.removeLast(depth) | ||
} | ||
} | ||
|
||
private func popToRoot() { | ||
switch state.selectedTab { | ||
case .map: | ||
state.mapPath = [] | ||
case .explore: | ||
state.explorePath = [] | ||
case .register: | ||
state.registerPath = [] | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Spoony-iOS/Spoony-iOS/Resource/Tab/Store/NavigationState.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,17 @@ | ||
// | ||
// NavigationState.swift | ||
// Spoony-iOS | ||
// | ||
// Created by 최주리 on 1/24/25. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct NavigationState { | ||
var selectedTab: TabType = .map | ||
var mapPath: [ViewType] = [] | ||
var explorePath: [ViewType] = [] | ||
var registerPath: [ViewType] = [] | ||
var currentLocation: String? | ||
var popup: PopupType? | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SwiftUI를 import 해야되나요?