You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/NiceComponents/Button/NiceButton.swift
+19-3Lines changed: 19 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -16,10 +16,14 @@ public struct NiceButton: View {
16
16
/// The style configuration for the button.
17
17
letstyle:NiceButtonStyle
18
18
19
-
/// Padding between the button text/images and edges of the button. Default is 8.
19
+
/// Padding between the button text/images and edges of the button.
20
+
/// Default is nil, unless contentHorizontalAlignment has been set, in which case it is 16.
20
21
/// Set this to `nil` to have the button fill it's available space, like you'd set `maxWidth: .infinity`.
21
22
varhorizontalContentPadding:CGFloat?
22
23
24
+
/// When set, aligns the content of the button, including images inside the button. Default is `center`.
25
+
varcontentHorizontalAlignment:TextAlignment
26
+
23
27
/// An optional image to display on the left side of the button.
24
28
varleftImage:NiceButtonImage?
25
29
@@ -42,15 +46,18 @@ public struct NiceButton: View {
42
46
/// - style: The style configuration for the button.
43
47
/// - inactive: A Boolean value that determines whether the button is inactive. Defaults to `false`.
44
48
/// - balanceImages: A Boolean value indicating whether the images should be balanced. Defaults to `true`.
49
+
/// - contentHorizontalAlignment: Optionally align all content within the button. Defaults to `center`.
45
50
/// - leftImage: An optional image to display on the left side of the button.
46
51
/// - rightImage: An optional image to display on the right side of the button.
47
-
/// - horizontalContentPadding: Padding between the button content and edges of the button. Default is nil, causing the button to expand to fill all available space.
52
+
/// - horizontalContentPadding: Padding between the button content and edges of the button.
53
+
/// Default is nil, unless contentHorizontalAlignment has been set, in which case it is 16.
48
54
/// - action: The closure to execute when the button is tapped.
49
55
publicinit(
50
56
_ text:String,
51
57
style:NiceButtonStyle,
52
58
inactive:Bool=false,
53
59
balanceImages:Bool=true,
60
+
contentHorizontalAlignment:TextAlignment?=nil,
54
61
leftImage:NiceButtonImage?=nil,
55
62
rightImage:NiceButtonImage?=nil,
56
63
horizontalContentPadding:CGFloat?=nil,
@@ -60,9 +67,10 @@ public struct NiceButton: View {
0 commit comments