-
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.
[Feat] InfoDetailView Coordinator 연결 - #2
- Loading branch information
Showing
7 changed files
with
161 additions
and
5 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
2 changes: 1 addition & 1 deletion
2
Whidy-iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
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
111 changes: 111 additions & 0 deletions
111
Whidy-iOS/Presentation/Main/StudyMap/View/Info/InfoDetailView.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,111 @@ | ||
// | ||
// InfoDetailView.swift | ||
// Whidy-iOS | ||
// | ||
// Created by JinwooLee on 2/1/25. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct InfoDetailView: View { | ||
@Perception.Bindable var store: StoreOf<InfoDetailFeature> | ||
@State private var scrollOffset: CGFloat = 0 | ||
@State private var dragOffset: CGFloat = 0 | ||
|
||
var body: some View { | ||
VStack { | ||
ScrollView { | ||
VStack(spacing: 20) { | ||
ForEach(0..<50) { index in | ||
Text("Item \(index)") | ||
.frame(maxWidth: .infinity) | ||
.padding() | ||
.background(Color.gray.opacity(0.2)) | ||
.cornerRadius(8) | ||
} | ||
} | ||
.background(GeometryReader { geometry in | ||
Color.clear | ||
.preference( | ||
key: ScrollOffsetKey.self, | ||
value: geometry.frame(in: .named("scrollView")).origin.y | ||
) | ||
}) | ||
} | ||
.coordinateSpace(name: "scrollView") | ||
.onPreferenceChange(ScrollOffsetKey.self) { value in | ||
scrollOffset = value // ScrollView의 오프셋 업데이트 | ||
Logger.debug("scrollOffset: \(scrollOffset)") | ||
|
||
if scrollOffset >= 120 { | ||
store.send(.viewTransition(.dismiss)) | ||
} | ||
} | ||
} | ||
.background(Color.white) | ||
.edgesIgnoringSafeArea(.all) | ||
} | ||
} | ||
|
||
// ScrollView의 오프셋을 감지하기 위한 PreferenceKey | ||
struct ScrollOffsetKey: PreferenceKey { | ||
static var defaultValue: CGFloat = 0 | ||
|
||
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { | ||
value += nextValue() | ||
} | ||
} | ||
|
||
import ComposableArchitecture | ||
|
||
@Reducer | ||
struct InfoDetailFeature { | ||
@ObservableState | ||
struct State : Equatable { | ||
let id = UUID() | ||
|
||
} | ||
|
||
enum Action : BindableAction { | ||
case binding(BindingAction<State>) | ||
case networkResponse(NetworkReponse) | ||
case buttonTapped(ButtonTapped) | ||
case viewTransition(ViewTransition) | ||
case anyAction(AnyAction) | ||
} | ||
|
||
enum ViewTransition { | ||
case onAppear | ||
case dismiss | ||
} | ||
|
||
enum NetworkReponse { | ||
|
||
} | ||
|
||
enum ButtonTapped { | ||
|
||
} | ||
|
||
|
||
enum AnyAction { | ||
|
||
} | ||
|
||
@Dependency(\.networkManager) var networkManager | ||
|
||
var body : some ReducerOf<Self> { | ||
|
||
BindingReducer() | ||
|
||
Reduce { state, action in | ||
switch action { | ||
|
||
|
||
default : | ||
break | ||
} | ||
return .none | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Whidy-iOS/Presentation/Main/StudyMap/View/Info/InfoView.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,18 @@ | ||
// | ||
// InfoView.swift | ||
// Whidy-iOS | ||
// | ||
// Created by JinwooLee on 2/1/25. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct InfoView: View { | ||
var body: some View { | ||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) | ||
} | ||
} | ||
|
||
#Preview { | ||
InfoView() | ||
} |