From c48a42676e70dc4d2e7117ec25c618b782a5c370 Mon Sep 17 00:00:00 2001 From: leemhyungyu Date: Sun, 27 Oct 2024 22:42:37 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=82=AC=EC=A7=84=20=EA=B3=B5=EA=B0=9C?= =?UTF-8?q?=20=ED=95=98=EB=8B=A8=20indicator=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/PhotoSharePingPongView.swift | 50 ++++++++++++++----- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/Projects/Feature/BottleStorage/Interface/Sources/PingPongDetail/View/PhotoSharePingPongView.swift b/Projects/Feature/BottleStorage/Interface/Sources/PingPongDetail/View/PhotoSharePingPongView.swift index 88a8e003..c551279f 100644 --- a/Projects/Feature/BottleStorage/Interface/Sources/PingPongDetail/View/PhotoSharePingPongView.swift +++ b/Projects/Feature/BottleStorage/Interface/Sources/PingPongDetail/View/PhotoSharePingPongView.swift @@ -19,7 +19,7 @@ public struct PhotoSharePingPongView: View { @Binding var isSelctedYesButton: Bool @Binding var isSelctedNoButton: Bool private let doneButtonAction: (() -> Void)? - @Binding var selectionIndex: Int + @State var selectedIndex: Int = 0 public init( isActive: Bool, @@ -28,8 +28,7 @@ public struct PhotoSharePingPongView: View { isSelctedYesButton: Binding = .constant(false), isSelctedNoButton: Binding = .constant(false), doneButtonAction: (() -> Void)? = nil, - selectionIndex: Binding = .constant(0), - otherProfileImageURLs: [String]? = ["1", "2", "3"] + otherProfileImageURLs: [String]? ) { self.isActive = isActive self.pingPongTitle = pingPongTitle @@ -37,7 +36,6 @@ public struct PhotoSharePingPongView: View { self._isSelctedYesButton = isSelctedYesButton self._isSelctedNoButton = isSelctedNoButton self.doneButtonAction = doneButtonAction - self._selectionIndex = selectionIndex self.otherProfileImageURLs = otherProfileImageURLs } @@ -143,21 +141,49 @@ private extension PhotoSharePingPongView { @ViewBuilder var bothPublicView: some View { if let images = otherProfileImageURLs { - GeometryReader { geo in - TabView(selection: $selectionIndex) { - ForEach(images.indices, id: \.self) { index in - makePeerProfileImage(url: images[0]) + VStack(spacing: .lg) { + GeometryReader { geo in + TabView(selection: $selectedIndex) { + ForEach(images.indices, id: \.self) { index in + makePeerProfileImage(url: images[index]) + .tag(index) + } } - } - .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never)) - .frame(height: geo.size.width - 10) + .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never)) + .frame(height: geo.size.width - 10) + } + .aspectRatio(1, contentMode: .fit) + + photoIndicatorView } - .aspectRatio(1, contentMode: .fit) } else { EmptyView() } } + var photoIndicatorView: some View { + HStack(spacing: .xxl) { + BottleImageView(type: .local(bottleImageSystem: .icon(.leftArrow))) + .foregroundStyle(to: ColorToken.icon(.primary)) + .asButton { + if selectedIndex > 0 { + selectedIndex -= 1 + } + } + + PageIndicatorView(pageInfo: .init(nowPage: selectedIndex + 1, totalCount: otherProfileImageURLs?.count ?? 0)) + + BottleImageView(type: .local(bottleImageSystem: .icon(.leftArrow))) + .foregroundStyle(to: ColorToken.icon(.primary)) + .rotationEffect(.degrees(180)) + .asButton { + if selectedIndex + 1 < otherProfileImageURLs?.count ?? 0 { + selectedIndex += 1 + } + } + } + } + @ViewBuilder var questionText: some View { if photoShareState != .disabled