From cd4fc6b1bfeda638c237aefd663c5a5eb682506f Mon Sep 17 00:00:00 2001 From: Daniela Zavala Date: Mon, 6 Jan 2025 13:53:03 -0800 Subject: [PATCH 1/2] Fixing floatingButton horizontalPadding --- Sources/FluentUI_iOS/Components/Button/FluentButtonStyle.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/FluentUI_iOS/Components/Button/FluentButtonStyle.swift b/Sources/FluentUI_iOS/Components/Button/FluentButtonStyle.swift index 34b72a398..19a66aea7 100644 --- a/Sources/FluentUI_iOS/Components/Button/FluentButtonStyle.swift +++ b/Sources/FluentUI_iOS/Components/Button/FluentButtonStyle.swift @@ -97,12 +97,11 @@ public struct FluentButtonStyle: SwiftUI.ButtonStyle { private var edgeInsets: EdgeInsets { let size = size let horizontalPadding = ButtonTokenSet.horizontalPadding(style: style, size: size) - let fabAlternativePadding = ButtonTokenSet.fabAlternativePadding(size) return EdgeInsets( top: .zero, leading: horizontalPadding, bottom: .zero, - trailing: style.isFloating ? fabAlternativePadding : horizontalPadding + trailing: horizontalPadding ) } From 2d80675e897937e84ff51a6ef027bb2000dce22b Mon Sep 17 00:00:00 2001 From: Daniela Zavala Date: Thu, 9 Jan 2025 16:34:54 -0800 Subject: [PATCH 2/2] Using alternative padding for floating with text only --- .../Components/Button/FluentButtonStyle.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Sources/FluentUI_iOS/Components/Button/FluentButtonStyle.swift b/Sources/FluentUI_iOS/Components/Button/FluentButtonStyle.swift index 19a66aea7..6c7542f53 100644 --- a/Sources/FluentUI_iOS/Components/Button/FluentButtonStyle.swift +++ b/Sources/FluentUI_iOS/Components/Button/FluentButtonStyle.swift @@ -8,8 +8,9 @@ import UIKit /// `ButtonStyle` which configures the `Button` according to its state and design tokens. public struct FluentButtonStyle: SwiftUI.ButtonStyle { - public init(style: ButtonStyle) { + public init(style: ButtonStyle, isIconOnly: Bool = false) { self.style = style + self.isIconOnly = isIconOnly } public func makeBody(configuration: Configuration) -> some View { @@ -79,6 +80,7 @@ public struct FluentButtonStyle: SwiftUI.ButtonStyle { @Environment(\.isFocused) private var isFocused: Bool private let style: ButtonStyle + private let isIconOnly: Bool private var size: ButtonSizeCategory { switch controlSize { @@ -97,11 +99,16 @@ public struct FluentButtonStyle: SwiftUI.ButtonStyle { private var edgeInsets: EdgeInsets { let size = size let horizontalPadding = ButtonTokenSet.horizontalPadding(style: style, size: size) + let fabAlternativePadding = ButtonTokenSet.fabAlternativePadding(size) + + // If the button is floating and includes text, use fabAlternativePadding; otherwise, use horizontalPadding. + let trailingPadding = style.isFloating && !isIconOnly ? fabAlternativePadding : horizontalPadding + return EdgeInsets( top: .zero, leading: horizontalPadding, bottom: .zero, - trailing: horizontalPadding + trailing: trailingPadding ) }