diff --git a/Sources/Adwaita/AnyView+.swift b/Sources/Adwaita/AnyView+.swift index d3eac6d..04ed566 100644 --- a/Sources/Adwaita/AnyView+.swift +++ b/Sources/Adwaita/AnyView+.swift @@ -300,15 +300,19 @@ extension AnyView { } /// Whether the view has a width higher or equal to its natural width. - /// - Parameter matches: Whether the content view matches the breakpoint. - public func naturalWidth(matches: Binding) -> AnyView { - BreakpointBin(condition: .naturalWidth, matches: matches) { self } + /// - Parameters: + /// - matches: Whether the content view matches the breakpoint. + /// - padding: Increase the natural width by a certain padding. + public func naturalWidth(matches: Binding, padding: Int = 0) -> AnyView { + BreakpointBin(condition: .naturalWidth(padding: padding), matches: matches) { self } } /// Whether the view has a height higher or equal to its natural height. - /// - Parameter matches: Whether the content view matches the breakpoint. - public func naturalHeight(matches: Binding) -> AnyView { - BreakpointBin(condition: .naturalHeight, matches: matches) { self } + /// - Parameters: + /// - matches: Whether the content view matches the breakpoint. + /// - padding: Increase the natural height by a certain padding. + public func naturalHeight(matches: Binding, padding: Int = 0) -> AnyView { + BreakpointBin(condition: .naturalHeight(padding: padding), matches: matches) { self } } } diff --git a/Sources/Core/View/BreakpointBin.swift b/Sources/Core/View/BreakpointBin.swift index 91a6e39..c7b93ad 100644 --- a/Sources/Core/View/BreakpointBin.swift +++ b/Sources/Core/View/BreakpointBin.swift @@ -32,16 +32,16 @@ public struct BreakpointBin: AdwaitaWidget { set: { bin, condition, storage in let string: OpaquePointer switch condition { - case .naturalWidth: + case let .naturalWidth(padding): let child = adw_breakpoint_bin_get_child(bin.cast()) var size: Int32 = 0 gtk_widget_measure(child, GTK_ORIENTATION_HORIZONTAL, -1, nil, &size, nil, nil) - string = adw_breakpoint_condition_parse(BreakpointCondition.minWidth(.init(size)).condition) - case .naturalHeight: + string = adw_breakpoint_condition_parse(BreakpointCondition.minWidth(.init(size) + padding).condition) + case let .naturalHeight(padding): let child = adw_breakpoint_bin_get_child(bin.cast()) var size: Int32 = 0 gtk_widget_measure(child, GTK_ORIENTATION_VERTICAL, -1, nil, &size, nil, nil) - string = adw_breakpoint_condition_parse(BreakpointCondition.minHeight(.init(size)).condition) + string = adw_breakpoint_condition_parse(BreakpointCondition.minHeight(.init(size) + padding).condition) default: string = adw_breakpoint_condition_parse(condition.condition) } @@ -111,9 +111,9 @@ public enum BreakpointCondition: Equatable { /// Define a minimum height. case minHeight(_ height: Int) /// The minimum width is the content's natural width. - case naturalWidth + case naturalWidth(padding: Int = 0) /// The minimum height is the content's natural height. - case naturalHeight + case naturalHeight(padding: Int = 0) /// The condition to parse. var condition: String? { diff --git a/Sources/Demo/Page.swift b/Sources/Demo/Page.swift index 5aa4f0b..61f3807 100644 --- a/Sources/Demo/Page.swift +++ b/Sources/Demo/Page.swift @@ -48,7 +48,7 @@ enum Page: String, Identifiable, CaseIterable, Codable, CustomStringConvertible case .alertDialog: return "Alert Dialog" case .passwordChecker: - return "Password Checker is such a long name..." + return "Password Checker" default: return rawValue.capitalized }