From b551e5e1b48624c78c1b694b53d73ef66a6edfc7 Mon Sep 17 00:00:00 2001 From: Levi Eggert Date: Fri, 20 Dec 2024 09:08:35 -0500 Subject: [PATCH 1/3] Add attribute to set horizontal and vertical padding on button title --- .../Share/SwiftUI Views/GTBlueButton/GTBlueButton.swift | 9 +++++++-- .../SwiftUI Views/GTWhiteButton/GTWhiteButton.swift | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/godtools/App/Share/SwiftUI Views/GTBlueButton/GTBlueButton.swift b/godtools/App/Share/SwiftUI Views/GTBlueButton/GTBlueButton.swift index 5fab1e677c..9e24fc008b 100644 --- a/godtools/App/Share/SwiftUI Views/GTBlueButton/GTBlueButton.swift +++ b/godtools/App/Share/SwiftUI Views/GTBlueButton/GTBlueButton.swift @@ -15,16 +15,20 @@ struct GTBlueButton: View { let width: CGFloat let height: CGFloat let cornerRadius: CGFloat + let titleHorizontalPadding: CGFloat? + let titleVerticalPadding: CGFloat? let highlightsTitleOnTap: Bool let accessibility: AccessibilityStrings.Button? let action: () -> Void - init(title: String, font: Font? = nil, fontSize: CGFloat? = nil, width: CGFloat, height: CGFloat, cornerRadius: CGFloat = 6, highlightsTitleOnTap: Bool = true, accessibility: AccessibilityStrings.Button? = nil, action: @escaping () -> Void) { + init(title: String, font: Font? = nil, fontSize: CGFloat? = nil, width: CGFloat, height: CGFloat, cornerRadius: CGFloat = 6, titleHorizontalPadding: CGFloat? = nil, titleVerticalPadding: CGFloat? = nil, highlightsTitleOnTap: Bool = true, accessibility: AccessibilityStrings.Button? = nil, action: @escaping () -> Void) { self.title = title self.width = width self.height = height self.cornerRadius = cornerRadius + self.titleHorizontalPadding = titleHorizontalPadding + self.titleVerticalPadding = titleVerticalPadding self.highlightsTitleOnTap = highlightsTitleOnTap self.accessibility = accessibility self.action = action @@ -80,7 +84,8 @@ struct GTBlueButton: View { Text(title) .font(font) .foregroundColor(Color.white) - .padding() + .padding([.leading, .trailing], titleHorizontalPadding) + .padding([.top, .bottom], titleVerticalPadding) } } diff --git a/godtools/App/Share/SwiftUI Views/GTWhiteButton/GTWhiteButton.swift b/godtools/App/Share/SwiftUI Views/GTWhiteButton/GTWhiteButton.swift index 108fc724f2..67ab616c6f 100644 --- a/godtools/App/Share/SwiftUI Views/GTWhiteButton/GTWhiteButton.swift +++ b/godtools/App/Share/SwiftUI Views/GTWhiteButton/GTWhiteButton.swift @@ -17,13 +17,17 @@ struct GTWhiteButton: View { let width: CGFloat let height: CGFloat let cornerRadius: CGFloat + let titleHorizontalPadding: CGFloat? + let titleVerticalPadding: CGFloat? let action: () -> Void - init(title: String, font: Font? = nil, fontSize: CGFloat? = nil, width: CGFloat, height: CGFloat, cornerRadius: CGFloat = 6, accessibility: AccessibilityStrings.Button? = nil, action: @escaping () -> Void) { + init(title: String, font: Font? = nil, fontSize: CGFloat? = nil, width: CGFloat, height: CGFloat, cornerRadius: CGFloat = 6, titleHorizontalPadding: CGFloat? = nil, titleVerticalPadding: CGFloat? = nil, accessibility: AccessibilityStrings.Button? = nil, action: @escaping () -> Void) { self.title = title self.width = width self.height = height self.cornerRadius = cornerRadius + self.titleHorizontalPadding = titleHorizontalPadding + self.titleVerticalPadding = titleVerticalPadding self.accessibility = accessibility self.action = action @@ -58,7 +62,8 @@ struct GTWhiteButton: View { Text(title) .font(font) .foregroundColor(ColorPalette.gtBlue.color) - .padding() + .padding([.leading, .trailing], titleHorizontalPadding) + .padding([.top, .bottom], titleVerticalPadding) } } .frame(width: width, height: height, alignment: .center) From 932e09820197aa7b34d2909b9e328e9043f5246c Mon Sep 17 00:00:00 2001 From: Levi Eggert Date: Fri, 20 Dec 2024 09:09:10 -0500 Subject: [PATCH 2/3] Add attribute to set horizontal title padding on tool card nav buttons --- .../Tools/Subviews/ToolCard/ToolCardView.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolCard/ToolCardView.swift b/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolCard/ToolCardView.swift index c12caaa314..7393cb1a2e 100644 --- a/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolCard/ToolCardView.swift +++ b/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolCard/ToolCardView.swift @@ -21,6 +21,7 @@ struct ToolCardView: View { private let navButtonWidth: CGFloat = 92 private let navButtonHeight: CGFloat = 30 private let navButtonSpacing: CGFloat = 8 + private let navButtonTitleHorizontalPadding: CGFloat? private let contentHorizontalInsets: CGFloat = 15 private let showsCategory: Bool private let accessibility: AccessibilityStrings.Button? @@ -31,7 +32,7 @@ struct ToolCardView: View { @ObservedObject private var viewModel: ToolCardViewModel - init(viewModel: ToolCardViewModel, geometry: GeometryProxy, layout: ToolCardLayout, showsCategory: Bool, accessibility: AccessibilityStrings.Button?, favoriteTappedClosure: (() -> Void)?, toolDetailsTappedClosure: (() -> Void)?, openToolTappedClosure: (() -> Void)?, toolTappedClosure: (() -> Void)?) { + init(viewModel: ToolCardViewModel, geometry: GeometryProxy, layout: ToolCardLayout, showsCategory: Bool, navButtonTitleHorizontalPadding: CGFloat?, accessibility: AccessibilityStrings.Button?, favoriteTappedClosure: (() -> Void)?, toolDetailsTappedClosure: (() -> Void)?, openToolTappedClosure: (() -> Void)?, toolTappedClosure: (() -> Void)?) { var navButtons: [ToolCardNavButtonType] = Array() @@ -50,6 +51,7 @@ struct ToolCardView: View { self.layout = layout self.navButtons = navButtons self.showsCategory = showsCategory + self.navButtonTitleHorizontalPadding = navButtonTitleHorizontalPadding self.accessibility = accessibility self.favoriteTappedClosure = favoriteTappedClosure self.toolDetailsTappedClosure = toolDetailsTappedClosure @@ -147,12 +149,12 @@ struct ToolCardView: View { Spacer() } - GTWhiteButton(title: viewModel.detailsButtonTitle, font: navButtonFont, width: navButtonWidth, height: navButtonHeight, accessibility: .toolDetails) { + GTWhiteButton(title: viewModel.detailsButtonTitle, font: navButtonFont, width: navButtonWidth, height: navButtonHeight, titleHorizontalPadding: navButtonTitleHorizontalPadding, accessibility: .toolDetails) { toolDetailsTappedClosure?() } - GTBlueButton(title: viewModel.openButtonTitle, font: navButtonFont, width: navButtonWidth, height: navButtonHeight, accessibility: .openTool) { + GTBlueButton(title: viewModel.openButtonTitle, font: navButtonFont, width: navButtonWidth, height: navButtonHeight, titleHorizontalPadding: navButtonTitleHorizontalPadding, accessibility: .openTool) { openToolTappedClosure?() } @@ -224,6 +226,7 @@ struct ToolCardView_Previews: PreviewProvider { geometry: geometry, layout: .landscape, showsCategory: true, + navButtonTitleHorizontalPadding: nil, accessibility: nil, favoriteTappedClosure: nil, toolDetailsTappedClosure: nil, From 2ccf577c4473ee060e1fd8e3e2c50bc9d0bdea05 Mon Sep 17 00:00:00 2001 From: Levi Eggert Date: Fri, 20 Dec 2024 09:09:42 -0500 Subject: [PATCH 3/3] Set horizontal padding of 5 on favorites tool cards --- .../Tools/Subviews/ToolSpotlight/ToolSpotlightView.swift | 1 + .../Features/Dashboard/Presentation/Tools/ToolsView.swift | 1 + .../AllYourFavoriteTools/AllYourFavoriteToolsView.swift | 1 + .../Subviews/YourFavoriteTools/YourFavoriteToolsView.swift | 5 ++++- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolSpotlight/ToolSpotlightView.swift b/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolSpotlight/ToolSpotlightView.swift index 30c78d7271..69fd7eefbb 100644 --- a/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolSpotlight/ToolSpotlightView.swift +++ b/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolSpotlight/ToolSpotlightView.swift @@ -51,6 +51,7 @@ struct ToolSpotlightView: View { geometry: geometry, layout: .thumbnail, showsCategory: false, + navButtonTitleHorizontalPadding: nil, accessibility: .spotlightTool, favoriteTappedClosure: { diff --git a/godtools/App/Features/Dashboard/Presentation/Tools/ToolsView.swift b/godtools/App/Features/Dashboard/Presentation/Tools/ToolsView.swift index ed4348fa9e..c08ba1e935 100644 --- a/godtools/App/Features/Dashboard/Presentation/Tools/ToolsView.swift +++ b/godtools/App/Features/Dashboard/Presentation/Tools/ToolsView.swift @@ -71,6 +71,7 @@ struct ToolsView: View { geometry: geometry, layout: .landscape, showsCategory: true, + navButtonTitleHorizontalPadding: nil, accessibility: .tool, favoriteTappedClosure: { diff --git a/godtools/App/Features/Favorites/Presentation/AllYourFavoriteTools/AllYourFavoriteToolsView.swift b/godtools/App/Features/Favorites/Presentation/AllYourFavoriteTools/AllYourFavoriteToolsView.swift index 26d1849b12..84c608ff48 100644 --- a/godtools/App/Features/Favorites/Presentation/AllYourFavoriteTools/AllYourFavoriteToolsView.swift +++ b/godtools/App/Features/Favorites/Presentation/AllYourFavoriteTools/AllYourFavoriteToolsView.swift @@ -45,6 +45,7 @@ struct AllYourFavoriteToolsView: View { geometry: geometry, layout: .landscape, showsCategory: true, + navButtonTitleHorizontalPadding: YourFavoriteToolsView.toolCardNavButtonTitleHorizontalPadding, accessibility: .favoriteTool, favoriteTappedClosure: { diff --git a/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/YourFavoriteTools/YourFavoriteToolsView.swift b/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/YourFavoriteTools/YourFavoriteToolsView.swift index eb0c66010e..ba3fa04c55 100644 --- a/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/YourFavoriteTools/YourFavoriteToolsView.swift +++ b/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/YourFavoriteTools/YourFavoriteToolsView.swift @@ -9,7 +9,9 @@ import SwiftUI struct YourFavoriteToolsView: View { - + + static let toolCardNavButtonTitleHorizontalPadding: CGFloat = 5 + private let geometry: GeometryProxy private let contentHorizontalInsets: CGFloat private let toolCardSpacing: CGFloat @@ -47,6 +49,7 @@ struct YourFavoriteToolsView: View { geometry: geometry, layout: .thumbnail, showsCategory: true, + navButtonTitleHorizontalPadding: Self.toolCardNavButtonTitleHorizontalPadding, accessibility: .favoriteTool, favoriteTappedClosure: {