Skip to content

Commit

Permalink
feat: 사진 스크롤 TabView 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
leemhyungyu committed Oct 27, 2024
1 parent bc1a947 commit fddd839
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,30 @@ public struct PhotoSharePingPongView: View {
private let isActive: Bool
private let pingPongTitle: String
private let photoShareState: PingPongPhotoStatus
private let myProfileImageURL: String?
private let otherProfileImageURL: String?
private let otherProfileImageURLs: [String]?
@Binding var isSelctedYesButton: Bool
@Binding var isSelctedNoButton: Bool
private let doneButtonAction: (() -> Void)?
@Binding var selectionIndex: Int

public init(
isActive: Bool,
pingPongTitle: String,
pingPongTitle: String,
photoShareState: PingPongPhotoStatus,
myProfileImageURL: String?,
otherProfileImageURL: String?,
isSelctedYesButton: Binding<Bool> = .constant(false),
isSelctedNoButton: Binding<Bool> = .constant(false),
doneButtonAction: (() -> Void)? = nil
isSelctedNoButton: Binding<Bool> = .constant(false),
doneButtonAction: (() -> Void)? = nil,
selectionIndex: Binding<Int> = .constant(0),
otherProfileImageURLs: [String]? = ["1", "2", "3"]
) {
self.isActive = isActive
self.pingPongTitle = pingPongTitle
self.photoShareState = photoShareState
self.myProfileImageURL = myProfileImageURL
self.otherProfileImageURL = otherProfileImageURL
self._isSelctedYesButton = isSelctedYesButton
self._isSelctedNoButton = isSelctedNoButton
self.doneButtonAction = doneButtonAction
self._selectionIndex = selectionIndex
self.otherProfileImageURLs = otherProfileImageURLs
}

public var body: some View {
Expand Down Expand Up @@ -140,16 +140,24 @@ private extension PhotoSharePingPongView {
makeRightBubbleText(text: "사진 공개가 실패했어요")
}

@ViewBuilder
var bothPublicView: some View {
HStack(spacing: .sm) {
peerProfileImage
.frame(maxWidth: .infinity)
myProfileImage
.frame(maxWidth: .infinity)
if let images = otherProfileImageURLs {
GeometryReader { geo in
TabView(selection: $selectionIndex) {
ForEach(images.indices, id: \.self) { index in
makePeerProfileImage(url: images[0])
}
}
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
.frame(height: geo.size.width - 10)
}
.aspectRatio(1, contentMode: .fit)
} else {
EmptyView()
}
}


@ViewBuilder
var questionText: some View {
if photoShareState != .disabled
Expand All @@ -168,43 +176,16 @@ private extension PhotoSharePingPongView {
}
}

@ViewBuilder
var peerProfileImage: some View {
if let peerProfileImageURL = otherProfileImageURL {
GeometryReader { geo in
RemoteImageView(
imageURL: peerProfileImageURL,
downsamplingWidth: 150,
downsamplingHeight: 150
)
.frame(height: geo.size.width)
.preventScreenshot()
}
.aspectRatio(1, contentMode: .fit)
.clipped()
.cornerRadius(.md, corenrs: [.topRight, .bottomLeft, .bottomRight])
} else {
EmptyView()
}
}

@ViewBuilder
var myProfileImage: some View {
if let myProfileImageURL = myProfileImageURL {
GeometryReader { geo in
RemoteImageView(
imageURL: myProfileImageURL,
downsamplingWidth: 150,
downsamplingHeight: 150
)
.frame(height: geo.size.width)
.preventScreenshot()
}
.aspectRatio(1, contentMode: .fit)
.clipped()
.cornerRadius(.md, corenrs: [.topRight, .topLeft, .bottomLeft])
} else {
EmptyView()
}
func makePeerProfileImage(url: String) -> some View {
RemoteImageView(
imageURL: url,
downsamplingWidth: 150,
downsamplingHeight: 150
)
.preventScreenshot()
.aspectRatio(1, contentMode: .fit)
.clipped()
.cornerRadius(.md, corenrs: [.topRight, .bottomLeft, .bottomRight])
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,12 @@ public struct QuestionAndAnswerView: View {
isActive: store.photoShareIsActive,
pingPongTitle: "사진 공개",
photoShareState: store.photoShareStateType,
myProfileImageURL: store.photoInfo?.myProfileImageURL,
otherProfileImageURL: store.photoInfo?.otherProfileImageURL,
isSelctedYesButton: $store.photoIsSelctedYesButton,
isSelctedNoButton: $store.photoIsSelctedNoButton,
doneButtonAction: {
store.send(.sharePhotoSelectButtonDidTapped(willShare: store.photoIsSelctedYesButton))
}
},
otherProfileImageURLs: store.photoInfo?.otherProfileImageURLs
)

FinalSelectPingPongView(
Expand Down

0 comments on commit fddd839

Please sign in to comment.