adwaita-swift/Sources/Core/View/Banner+.swift
david-swift 8eeda083e9
All checks were successful
Deploy Docs / publish (push) Successful in 18m28s
SwiftLint / SwiftLint (push) Successful in 5s
Separate AnyView extensions from widgets
2024-10-16 14:22:34 +02:00

34 lines
748 B
Swift

//
// Banner+.swift
// Adwaita
//
// Created by david-swift on 17.01.24.
//
import CAdw
extension Banner {
/// Initialize a text widget.
/// - Parameters:
/// - title: The content.
/// - visible: Whether the banner is visible.
public init(_ title: String, visible: Bool) {
self.init(title: title)
self = self.revealed(visible)
}
/// Configure the banner's button.
/// - Parameters:
/// - label: The button's title.
/// - handler: The button's handler.
/// - Returns: The banner.
public func button(_ label: String, handler: @escaping () -> Void) -> Self {
buttonLabel(label)
.buttonClicked {
handler()
}
}
}