- Welcome
- Getting started
- Latest updates
- Foundations
-
Components
- Accordion
- Alert
- Alignment
- App Search Modal
- Aria live
- Autosuggest
- Badge
- Banner alert
- Bar chart
- Blockquote
- Bottom navigation
- Bottom sheet
- Breadcrumb
- Breakpoint
- Button
- Calendar
- Card
- Card list
- Card button
- Carousel
- Checkbox
- Chip
- Chip group
- Code
- Content cards
- Data Table
- Datepicker
- Description list
- Dialog
- Divider
- Drawer
- Field Set
- Flare
- Flat list
- Flight leg
- Floating action button
- Floating notification
- Form label
- Form validation
- Graphic promotion
- Horizontal navigation
- Icon
- Image
- Image Gallery
- Infinite scroll
- Info Banner
- Inset Banner
- Link
- List
- Map
- Mobile scroll container
- Modal
- Navigation bar
- Navigation Tab Group
- Nudger
- Overlay
- Page indicator
- Pagination
- Panel
- Phone input
- Picker
- Popover
- Price
- Progress bar
- Radio button
- Rating
- Rating Bar
- Scrollable calendar
- Search Modal
- Section header
- Section list
- Select
- Skeleton
- Skip link
- Slider
- Snackbar
- Snippet
- Spinner
- Split input
- Star rating
- Swap Button
- Switch
- Table
- Text
- Text input
- Theming
- Ticket
- Toast
- Tooltip
- Touchable native feedback
- Touchable overlay
- Search Input Summary
- Content
- Accessibility
- Contributing
- Localisation
Image Gallery
Backpack-SwiftUI/ImageGalleryGrid
Usage
You can use the grid with categories as BPKChips or Images, this style is set by the style parameter.
With Images
Day | Night |
---|---|
@State var selectedCategory: Int = 0
@State var isPresented: Bool = false
BPKButton("Show Chips Image Grid") {
isPresented.toggle()
}.bpkImageGalleryGrid(
isPresented: $isPresented,
selectedCategory: $selectedCategory,
style: .image(categories)
closeAccessibilityLabel: "Close Gallery",
onImageTapped: { category, image in
print("Image tapped: \(category) - \(image)")
},
onCloseTapped: {
isPresented.toggle()
},
)
var categories: [BPKImageGalleryImageGridStyle.ImageCategory] {
[
.init(
title: "category 1",
images: [
.init(
title: "Image 1",
content: image("image1")
),
],
categoryImage: {
image("cateogory image 1")
}
)
]
}
func image(_ name: String) -> some View {
Image(name)
.resizable()
.aspectRatio(contentMode: .fill)
}
With BPKChips
Day | Night |
---|---|
@State var selectedCategory: Int = 0
@State var isPresented: Bool = false
BPKButton("Show Chips Image Grid") {
isPresented.toggle()
}.bpkImageGalleryGrid(
isPresented: $isPresented,
selectedCategory: $selectedCategory,
style: .chip(categories)
closeAccessibilityLabel: "Close Gallery",
onImageTapped: { category, image in
print("Image tapped: \(category) - \(image)")
},
onCloseTapped: {
isPresented.toggle()
},
)
var categories: [BPKImageGalleryImageGridStyle.ChipCategory] {
[
.init(
title: "category 1",
images: [
.init(
title: "Image 1",
content: image("image1")
),
]
)
]
}
func image(_ name: String) -> some View {
Image(name)
.resizable()
.aspectRatio(contentMode: .fill)
}
Backpack-SwiftUI/ImageGalleryPreview
Default
Day | Night |
---|---|
Usage
You can pass in an array of Images to the BPKImageGalleryPreview and it will display them in a carousel. You can also pass in a currentIndex to control which image is displayed and an onImageClicked closure to be notified when an image is clicked.
@State var currentIndex: Int = 0
BPKImageGalleryPreview(
images: [image("Paris"), image("Barcelona"), image("London")],
currentIndex: $currentIndex,
onImageClicked: { selectedIndex in
print("User tapped on image number \(selectedIndex)")
}
)
func image(_ name: String) -> Image {
Image(name)
.resizable()
.aspectRatio(contentMode: .fill)
}
Backpack-SwiftUI/ImageGallerySlideshow
Default
Day | Night |
---|---|
Usage
@State var currentIndex: Int = 0
@State var isPresented: Bool = false
BPKButton("Show Slideshow") {
currentIndex = 0
}.bpkImageGallerySlideshow(
isPresented: $isPresented,
images: [
BPKImageGalleryImage(
title: "London",
description: "London is the capital and largest city of England and the UK.",
credit: "John Doe",
) {
image("London-brigde")
},
],
closeAccessibilityLabel: "Close",
currentIndex: $currentIndex,
onCloseTapped: {
isPresented = false
}
)
func image(_ name: String) -> some View {
Image(name)
.resizable()
.aspectRatio(contentMode: .fill)
}
Made with ❤️ by Skyscanner © 2024
© 2024 Skyscanner Backpack. Page last updated on Apr 11, 2024, 17:05