Skip to content

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.

License

Notifications You must be signed in to change notification settings

Desp0o/PhotoBoxKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PhotoBoxKit

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. To improve performance and memory efficiency, PhotoBoxKit leverages NSCache for smart image caching and reuse.

Swift Static Badge iOS Framework Xcode

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

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages