Skip to content

Commit

Permalink
feat #95: 그래프 회전 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
enebin committed Sep 14, 2023
1 parent 546e68d commit 890d3fc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Projects/Features/Sources/MainPage/MainPageFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public struct MainPageFeature: Reducer {
@Box var home: HomeFeature.State
@Box var myPage: MyPageFeature.State

var view: View = .none
enum View: Equatable { case none }

public init(userId: Int, nickname: String) {
self._home = .init(.init(nickname: nickname))
self._myPage = .init(.init(userId: userId, nickname: nickname))
Expand Down
2 changes: 1 addition & 1 deletion Projects/Features/Sources/MainPage/MainPageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct KeymeMainView: View {

var body: some View {
NavigationStack {
WithViewStore(store, observe: { $0 }) { _ in
WithViewStore(store, observe: { $0.view }) { _ in
TabView(selection: $selectedTab) {
HomeView(store: store.scope(state: \.home, action: MainPageFeature.Action.home))
.tabItem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public class CirclePackViewOption<DetailView: View> {
}

public struct CirclePackView<DetailView: View>: View {
// @Namespace private var namespace
private let namespace: Namespace.ID

// 애니메이션 관련
Expand Down
11 changes: 11 additions & 0 deletions Projects/Features/Sources/MyPage/MyPageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import SwiftUI
struct MyPageView: View {
@Namespace private var namespace

@State var graphRotationAngle: Angle = .degrees(45)
@State var lastRotationAngle: Angle = .degrees(45)

private let store: StoreOf<MyPageFeature>

init(store: StoreOf<MyPageFeature>) {
Expand All @@ -26,6 +29,7 @@ struct MyPageView: View {
CirclePackView(
namespace: namespace,
data: viewStore.shownCircleDatalist,
rotationAngle: graphRotationAngle,
detailViewBuilder: { data in
let scoreListStore = store.scope(
state: \.scoreListState,
Expand All @@ -50,6 +54,13 @@ struct MyPageView: View {
}
}
.graphFrame(length: viewStore.imageExportMode ? 560 : 700)
.simultaneousGesture(
RotationGesture()
.onChanged { angle in
graphRotationAngle = lastRotationAngle + angle * 0.01
lastRotationAngle = graphRotationAngle
}
)
.ignoresSafeArea(.container)

if viewStore.imageExportMode {
Expand Down

0 comments on commit 890d3fc

Please sign in to comment.