Skip to content
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

답변 완료 화면에서 답변이 한 개 일 시 스크롤이 안되는 현상 해결 #92

Open
wants to merge 3 commits into
base: refactor/signin
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Ahobsu/Model/Answer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ extension Answer {
userId: 0,
missionId: 0,
imageUrl: "https://wallpapershome.com/images/pages/pic_h/11603.jpg",
content: "Hello",
content: "Hello\nHello\nHello\nHello\nHello\nHello\nHello\nHello\nHello\nHello\nHello\nHello\nHello\nHello\nHello\nHello\nHello\nHello\nHello\nHello",
date: "2020-02-01",
setDate: "2020-02-01",
mission: Mission(id: 0, title: "더미 질문", isContent: true, isImage: true),
Expand Down
1 change: 0 additions & 1 deletion Ahobsu/MotiViews/AnswerComplete/AnswerCompleteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ struct AnswerCompleteView: View {
pageWidthCompensation: 0,
index: $currentPage,
pages: models.map { AnswerCompleteCardView(answer: $0) })
.disabled(models.count == 1)
if models.count != 1 {
VStack {
Spacer()
Expand Down
21 changes: 13 additions & 8 deletions Ahobsu/MotiViews/Main/SupportViews/SwiftUIPagerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ struct SwiftUIPagerView<Content: View & Identifiable>: View {

var body: some View {
GeometryReader { geometry in
ScrollView(.horizontal, showsIndicators: false) {
HStack(alignment: .center, spacing: self.spacing) {
ForEach(self.pages) { page in
page
.frame(width: geometry.size.width + self.pageWidthCompensation, height: nil)
if (self.pages.count > 1) {
ScrollView(.horizontal, showsIndicators: false) {
HStack(alignment: .center, spacing: self.spacing) {
ForEach(self.pages) { page in
page
.frame(width: geometry.size.width + self.pageWidthCompensation, height: nil)
}
}
}
}
// 2
.content.offset(x: self.isGestureActive ? self.offset : -((geometry.size.width + self.widthCompensation) * CGFloat(self.index)))
.content.offset(x: self.isGestureActive ? self.offset : -((geometry.size.width + self.widthCompensation) * CGFloat(self.index)))
// 3
.frame(width: geometry.size.width, height: nil, alignment: .leading)
.gesture(DragGesture().onChanged({ value in
Expand All @@ -56,7 +57,11 @@ struct SwiftUIPagerView<Content: View & Identifiable>: View {
// 7
DispatchQueue.main.async { self.isGestureActive = false }
}))
.padding([.leading], -self.pageWidthCompensation)
.padding(.leading, -self.pageWidthCompensation)
} else {
self.pages[0]
.frame(width: geometry.size.width + self.pageWidthCompensation, height: nil)
}
}
}
}