david-swift 8eb004c9ea Add support for carousels
Add support for any Libadwaita insertable container
2024-01-01 20:33:06 +01:00

38 lines
764 B
Swift

//
// Carousel.swift
// Adwaita
//
// Created by david-swift on 01.01.24.
//
import Libadwaita
/// A carousel view.
public struct Carousel<Element>: View where Element: Identifiable {
/// The elements.
var elements: [Element]
/// The content.
var content: (Element) -> Body
/// The view.
public var view: Body {
Container(elements, content: content) {
Libadwaita.Carousel()
}
}
/// Initialize `Carousel`.
/// - Parameters:
/// - elements: The elements.
/// - content: The view for an element.
public init(
_ elements: [Element],
@ViewBuilder content: @escaping (Element) -> Body
) {
self.content = content
self.elements = elements
}
}