52 lines
2.4 KiB
Swift
52 lines
2.4 KiB
Swift
import Adw
|
|
|
|
public extension Banner {
|
|
/// Creates a Banner with static title, visibility, and button label.
|
|
///
|
|
/// Values are applied once when the widget mounts.
|
|
/// - Parameter title: The banner title.
|
|
/// - Parameter revealed: The optional visibility state.
|
|
/// - Parameter buttonLabel: The optional button label.
|
|
@_disfavoredOverload
|
|
init<S: StringProtocol>(_ title: S, revealed: Bool? = nil, buttonLabel: String? = nil) {
|
|
self.init(title: String(title))
|
|
if let revealed { self = self.revealed(revealed) }
|
|
if let buttonLabel { self = self.buttonLabel(buttonLabel) }
|
|
}
|
|
|
|
/// Creates a Banner whose title, visibility, and button label follow bindings.
|
|
///
|
|
/// Binding modifiers update the widget in place and write widget changes back.
|
|
/// - Parameter title: The title binding.
|
|
/// - Parameter revealed: The optional visibility binding.
|
|
/// - Parameter buttonLabel: The optional button-label binding.
|
|
init(_ title: Portico.Binding<String>, revealed: Portico.Binding<Bool>? = nil, buttonLabel: Portico.Binding<String>? = nil) {
|
|
self.init(title: title)
|
|
if let revealed { self = self.revealed(revealed) }
|
|
if let buttonLabel { self = self.buttonLabel(buttonLabel) }
|
|
}
|
|
|
|
/// Creates a Banner with live interpolated title and button text.
|
|
///
|
|
/// Interpolated segments are re-evaluated when their dependencies change.
|
|
/// - Parameter title: The interpolated title.
|
|
/// - Parameter revealed: The optional visibility state.
|
|
/// - Parameter buttonLabel: The optional interpolated button label.
|
|
init(_ title: Portico.InterpolatedText, revealed: Bool? = nil, buttonLabel: Portico.InterpolatedText? = nil) {
|
|
self.init(title: title)
|
|
if let revealed { self = self.revealed(revealed) }
|
|
if let buttonLabel { self = self.buttonLabel(buttonLabel) }
|
|
}
|
|
|
|
/// Creates a Banner with a static title and bound visibility.
|
|
///
|
|
/// The visibility binding updates the widget in place and receives widget changes.
|
|
/// - Parameter title: The banner title.
|
|
/// - Parameter revealed: The required visibility binding.
|
|
/// - Parameter buttonLabel: The optional static button label.
|
|
init<S: StringProtocol>(_ title: S, revealed: Portico.Binding<Bool>, buttonLabel: String? = nil) {
|
|
self.init(title: String(title))
|
|
self = self.revealed(revealed)
|
|
if let buttonLabel { self = self.buttonLabel(buttonLabel) }
|
|
}
|
|
}
|