Desp0o/PhotoBoxKit
PhotoBoxKit is a lightweight, Swift-native library designed for seamless photo viewing experiences in SwiftUI. It enables developers to present images with customizable backgrounds, swipe gestures, and smooth transitions.
API Reference
| Parameter | Type | Description | Default | |------------------|----------------------|-------------------------------------------------------|---------| | activeIndex | Binding<Int> | current active undex of image. | N/A | | isVisible | Binding<Bool> | show or hide photobox. | N/A | | urls | [String] | urls of images. | N/A | | counter | Bool | visible or not image counter. | true | | gallery | Bool | visible or not bottom gallery. | true | | cornerRadius | CGFloat | Corner radius of images. | 0.0 | | bgColor | Color | backgorund color. | Color.black.opacity(0.9) | | counterColor | Color | color of image counter. | Color.white |
Simple Usage
Just pass these three parameters for a basic setup:
- activeIndex – a state to track the currently selected image
- isVisible – a state to show or hide the photo box
- urls – an array of image URLs
That’s all you need to get started!
struct ContentView: View {
@State private var isVisible: Bool = false
@State private var activeIndex = 0
let imageUrls: [String] = ["url1", "url2" ..... "url100"]
var body: some View {
VStack {
// your code logic here
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.photoBoxKit(activeIndex: $activeIndex, isVisible: $isVisible, urls: imageUrls)
}
}
Custom PhotoBox
struct ContentView: View {
@State private var isVisible: Bool = false
@State private var activeIndex = 0
let imageUrls: [String] = ["url1", "url2" ..... "url100"]
var body: some View {
VStack {
// your code logic here
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.photoBoxKit(
activeIndex: $activeIndex,
isVisible: $isVisible,
urls: imageUrls,
counter: true,
gallery: false,
cornerRadius: 12,
bgColor: .teal,
counterColor: .black
)
}
}Demo 📸
[0603]
Package Metadata
Repository: Desp0o/PhotoBoxKit
Stars: 5
Forks: 0
Open issues: 0
Default branch: main
Primary language: swift
License: MIT
Topics: photo-gallery, photobox, spm, swift, swiftpackagemanager, swiftui
README: README.md