71 lines
2.1 KiB
Swift
71 lines
2.1 KiB
Swift
//
|
|
// ImageViewerView.swift
|
|
// SodaLive
|
|
//
|
|
// Created by klaus on 9/2/25.
|
|
//
|
|
|
|
import SwiftUI
|
|
import Kingfisher
|
|
|
|
struct ImageViewerView: View {
|
|
let images: [String]
|
|
@Binding var selectedIndex: Int
|
|
@Environment(\.dismiss) private var dismiss
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
Color.black.ignoresSafeArea()
|
|
|
|
TabView(selection: $selectedIndex) {
|
|
ForEach(Array(images.enumerated()), id: \.offset) { index, imageUrl in
|
|
KFImage(URL(string: imageUrl))
|
|
.placeholder {
|
|
ProgressView()
|
|
.tint(.white)
|
|
}
|
|
.cancelOnDisappear(true)
|
|
.downsampling(size: CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height))
|
|
.resizable()
|
|
.aspectRatio(contentMode: .fit)
|
|
.tag(index)
|
|
}
|
|
}
|
|
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
|
|
|
|
VStack {
|
|
HStack {
|
|
Spacer()
|
|
|
|
Button {
|
|
dismiss()
|
|
} label: {
|
|
Image(systemName: "xmark")
|
|
.font(.title2)
|
|
.foregroundColor(.white)
|
|
.padding()
|
|
}
|
|
}
|
|
|
|
Spacer()
|
|
|
|
// 페이지 인디케이터
|
|
HStack(spacing: 8) {
|
|
ForEach(0..<images.count, id: \.self) { index in
|
|
Circle()
|
|
.fill(selectedIndex == index ? Color.white : Color.white.opacity(0.3))
|
|
.frame(width: 8, height: 8)
|
|
}
|
|
}
|
|
.padding(.bottom, 50)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
ImageViewerView(
|
|
images: ["https://picsum.photos/400/500"],
|
|
selectedIndex: .constant(0)
|
|
)
|
|
} |