Skip to content

Commit d804fba

Browse files
authored
Merge pull request #112 from DSM-PICK/feature/(#110)-classMove_Floor_chore
🔗 :: (#110) 교실이동 수락 특정 층 레이아웃 수정
2 parents 060ce63 + 009c3c8 commit d804fba

2 files changed

Lines changed: 61 additions & 42 deletions

File tree

Projects/Feature/AcceptFeature/Sources/Scene/AcceptView.swift

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public struct AcceptView: View {
1616
@Environment(\.dismiss) var dismiss
1717
@State private var isApplyBottomSheetPresented = false
1818
@State private var selectedOption: ApplicationType = .outgoing
19-
@State private var selectedFloor: Int = 1
19+
@State private var selectedFloor: Int = 3
2020
@State private var showApprovePopup = false
2121
@State private var showRejectPopup = false
2222
let store: StoreOf<AcceptReducer>
@@ -64,31 +64,44 @@ public struct AcceptView: View {
6464
.padding(.horizontal, 24)
6565

6666
if selectedOption == .classroomMove {
67-
ScrollView(.horizontal, showsIndicators: false) {
68-
HStack(spacing: 8) {
69-
ForEach(1...5, id: \.self) { floor in
70-
Button {
71-
selectedFloor = floor
72-
viewStore.send(.fetchApplicationsByFloor(floor: floor))
73-
} label: {
74-
Text("\(floor)")
75-
.pickText(
76-
type: .body1,
77-
textColor: selectedFloor == floor ? .Primary.primary500 : .Gray.gray600
78-
)
79-
.frame(width: 114, height: 32)
80-
.background(
81-
selectedFloor == floor
82-
? Color.Primary.primary50
83-
: Color.clear
84-
)
85-
.cornerRadius(8)
67+
ScrollViewReader { proxy in
68+
ScrollView(.horizontal, showsIndicators: false) {
69+
HStack(spacing: 8) {
70+
ForEach([1, 2, 3, 4, 5], id: \.self) { floor in
71+
Button {
72+
selectedFloor = floor
73+
viewStore.send(.fetchApplicationsByFloor(floor: floor))
74+
} label: {
75+
Text("\(floor)")
76+
.pickText(
77+
type: .body1,
78+
textColor: selectedFloor == floor ? .Primary.primary500 : .Gray.gray600
79+
)
80+
.frame(width: 114, height: 32)
81+
.background(
82+
selectedFloor == floor
83+
? Color.Primary.primary50
84+
: Color.clear
85+
)
86+
.cornerRadius(8)
87+
}
88+
.id(floor)
8689
}
8790
}
91+
.padding(.horizontal, 24)
8892
}
89-
.padding(.horizontal, 24)
93+
.onAppear {
94+
proxy.scrollTo(3, anchor: .center)
95+
}
96+
.onChange(of: selectedOption) { newValue in
97+
if newValue == .classroomMove {
98+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
99+
proxy.scrollTo(3, anchor: .center)
100+
}
101+
}
102+
}
103+
.padding(.top, 16)
90104
}
91-
.padding(.top, 16)
92105
}
93106

94107
HStack(spacing: 0) {

Projects/Feature/ClassroomMoveListFeature/Sources/Scene/ClassroomMoveListView.swift

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,35 @@ public struct ClassroomMoveListView: View {
4343
.padding(.horizontal, 24)
4444

4545
if viewStore.currentType == .floor {
46-
ScrollView(.horizontal, showsIndicators: false) {
47-
HStack(spacing: 8) {
48-
ForEach([2, 3, 4], id: \.self) { floor in
49-
Button {
50-
selectedFloor = floor
51-
viewStore.send(.fetchFloor(floor))
52-
} label: {
53-
Text("\(floor)")
54-
.pickText(
55-
type: .body1,
56-
textColor: selectedFloor == floor ? .Primary.primary500 : .Gray.gray600
57-
)
58-
.frame(width: 114, height: 32)
59-
.background(
60-
selectedFloor == floor
61-
? Color.Primary.primary50
62-
: Color.clear
63-
)
64-
.cornerRadius(8)
46+
ScrollViewReader { proxy in
47+
ScrollView(.horizontal, showsIndicators: false) {
48+
HStack(spacing: 8) {
49+
ForEach([1, 2, 3, 4, 5], id: \.self) { floor in
50+
Button {
51+
selectedFloor = floor
52+
viewStore.send(.fetchFloor(floor))
53+
} label: {
54+
Text("\(floor)")
55+
.pickText(
56+
type: .body1,
57+
textColor: selectedFloor == floor ? .Primary.primary500 : .Gray.gray600
58+
)
59+
.frame(width: 114, height: 32)
60+
.background(
61+
selectedFloor == floor
62+
? Color.Primary.primary50
63+
: Color.clear
64+
)
65+
.cornerRadius(8)
66+
}
67+
.id(floor)
6568
}
6669
}
70+
.padding(.horizontal, 24)
71+
}
72+
.onAppear {
73+
proxy.scrollTo(3, anchor: .center)
6774
}
68-
.padding(.horizontal, 24)
6975
}
7076
.padding(.top, 16)
7177
} else {

0 commit comments

Comments
 (0)