import Adw public extension ButtonRow { /// Creates a ButtonRow with static text, icons, and activation behavior. /// /// Values are applied once when the widget mounts. /// - Parameter title: The row title. /// - Parameter startIconName: The optional leading icon name. /// - Parameter endIconName: The optional trailing icon name. /// - Parameter onActivated: The optional activation callback. @_disfavoredOverload init(_ title: S, startIconName: String? = nil, endIconName: String? = nil, _ onActivated: (() -> Void)? = nil) { self.init() self = self.title(String(title)) if let startIconName { self = self.startIconName(startIconName) } if let endIconName { self = self.endIconName(endIconName) } if let onActivated { self = self.onActivated(onActivated) } } /// Creates a ButtonRow whose text and icons follow bindings. /// /// Binding modifiers update the widget in place and write widget changes back. /// - Parameter title: The title binding. /// - Parameter startIconName: The optional leading icon binding. /// - Parameter endIconName: The optional trailing icon binding. /// - Parameter onActivated: The optional activation callback. init(_ title: Portico.Binding, startIconName: Portico.Binding? = nil, endIconName: Portico.Binding? = nil, _ onActivated: (() -> Void)? = nil) { self.init() self = self.title(title) if let startIconName { self = self.startIconName(startIconName) } if let endIconName { self = self.endIconName(endIconName) } if let onActivated { self = self.onActivated(onActivated) } } /// Creates a ButtonRow with live interpolated text values. /// /// Interpolated segments are re-evaluated when their dependencies change. /// - Parameter title: The interpolated title. /// - Parameter startIconName: The optional leading interpolated icon name. /// - Parameter endIconName: The optional trailing interpolated icon name. /// - Parameter onActivated: The optional activation callback. init(_ title: Portico.InterpolatedText, startIconName: Portico.InterpolatedText? = nil, endIconName: Portico.InterpolatedText? = nil, _ onActivated: (() -> Void)? = nil) { self.init() self = self.title(title) if let startIconName { self = self.startIconName(startIconName) } if let endIconName { self = self.endIconName(endIconName) } if let onActivated { self = self.onActivated(onActivated) } } } extension WidgetView where Target: Adw.ButtonRow { /// Applies the `.suggested-action` style class. /// /// Accent colors; denotes the important/affirmative action. /// /// - Parameter enabled: Whether the style class is applied. /// - Returns: A copy of this view with the modifier applied. public func suggestedAction(_ enabled: Bool = true) -> Self { styleClass("suggested-action", enabled) } /// Applies the `.suggested-action` style class. /// /// Accent colors; denotes the important/affirmative action. /// /// - Parameter enabled: A binding that controls whether the class is applied. /// - Returns: A copy of this view with the modifier applied. public func suggestedAction(_ enabled: Binding) -> Self { styleClass("suggested-action", enabled) } /// Applies the `.destructive-action` style class. /// /// Destructive colors, warninging user about damaging consequences. /// /// - Parameter enabled: Whether the style class is applied. /// - Returns: A copy of this view with the modifier applied. public func destructiveAction(_ enabled: Bool = true) -> Self { styleClass("destructive-action", enabled) } /// Applies the `.destructive-action` style class. /// /// Destructive colors, warninging user about damaging consequences. /// /// - Parameter enabled: A binding that controls whether the class is applied. /// - Returns: A copy of this view with the modifier applied. public func destructiveAction(_ enabled: Binding) -> Self { styleClass("destructive-action", enabled) } }