From 103761126869f61c82bd0a41ad30a6dd9cb243f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Leinha=CC=88upl?= Date: Tue, 17 Oct 2023 11:22:15 +0200 Subject: [PATCH 1/5] =?UTF-8?q?=E2=9C=A8=20Add=20FontModifier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SwiftUIExtensions/FontModifier.swift | 34 +++++++++++++++++++ ACKategories.xcodeproj/project.pbxproj | 13 +++++++ 2 files changed, 47 insertions(+) create mode 100644 ACKategories-iOS/SwiftUIExtensions/FontModifier.swift diff --git a/ACKategories-iOS/SwiftUIExtensions/FontModifier.swift b/ACKategories-iOS/SwiftUIExtensions/FontModifier.swift new file mode 100644 index 00000000..a4caa652 --- /dev/null +++ b/ACKategories-iOS/SwiftUIExtensions/FontModifier.swift @@ -0,0 +1,34 @@ +import SwiftUI + +@available(iOSApplicationExtension 14.0, *) +extension View { + /// Sets font and line height for text in this view. + /// + /// - Parameters: + /// - font: The font to use in this view. + /// - lineHeight: The line height to use in this view. + /// - textStyle: The text style for relative font scaling. If `nil`is specified then dynamic type is turned off. + func font( + _ font: UIFont, + lineHeight: Double, + textStyle: Font.TextStyle? + ) -> some View { + let customFont: Font + + // Do not scale font based on dynamic type when nil `relativeTo` specified + if let textStyle = textStyle { + customFont = .custom( + font.fontName, + size: font.pointSize, + relativeTo: textStyle + ) + } else { + customFont = Font(font) + } + + return self + .font(customFont) + .lineSpacing(lineHeight - font.lineHeight) + .padding(.vertical, (lineHeight - font.lineHeight) / 2) + } +} diff --git a/ACKategories.xcodeproj/project.pbxproj b/ACKategories.xcodeproj/project.pbxproj index 732ebe3a..9cea631e 100644 --- a/ACKategories.xcodeproj/project.pbxproj +++ b/ACKategories.xcodeproj/project.pbxproj @@ -107,6 +107,7 @@ 69FA5FBD23C868A900B44BCD /* ModalFlowCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69FA5FAC23C868A900B44BCD /* ModalFlowCoordinator.swift */; }; 69FA5FC223C8690A00B44BCD /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 69FA5FC123C8690A00B44BCD /* LaunchScreen.storyboard */; }; 6A31C9F3250572FE0047A983 /* SelfSizingTableHeaderFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A31C9F2250572FE0047A983 /* SelfSizingTableHeaderFooterView.swift */; }; + 6A572DB92ADE89B0002BD518 /* FontModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A572DB82ADE89B0002BD518 /* FontModifier.swift */; }; 88EDD90425B8252E00207987 /* GradientViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88EDD90325B8252E00207987 /* GradientViewController.swift */; }; A33559012555270F009B9D89 /* FlowCoordinatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A33559002555270F009B9D89 /* FlowCoordinatorTests.swift */; }; A38883E3257E2D2D00B958DD /* ErrorHandlers.swift in Sources */ = {isa = PBXBuildFile; fileRef = A38883E2257E2D2D00B958DD /* ErrorHandlers.swift */; }; @@ -265,6 +266,7 @@ 69FA5FC323C869A200B44BCD /* ACKategories.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; path = ACKategories.podspec; sourceTree = ""; }; 69FA5FE423C8712D00B44BCD /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; 6A31C9F2250572FE0047A983 /* SelfSizingTableHeaderFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelfSizingTableHeaderFooterView.swift; sourceTree = ""; }; + 6A572DB82ADE89B0002BD518 /* FontModifier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FontModifier.swift; sourceTree = ""; }; 88EDD90325B8252E00207987 /* GradientViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GradientViewController.swift; sourceTree = ""; }; A33559002555270F009B9D89 /* FlowCoordinatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlowCoordinatorTests.swift; sourceTree = ""; }; A38883E2257E2D2D00B958DD /* ErrorHandlers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorHandlers.swift; sourceTree = ""; }; @@ -450,6 +452,8 @@ 69E81A0823C773370054687B /* ACKategories-iOS */ = { isa = PBXGroup; children = ( + 6950963023C7747C00E8F457 /* Base */, + 6A572DB72ADE8994002BD518 /* SwiftUIExtensions */, 697CECF023C877B20019FE61 /* Aliases.swift */, A38883E2257E2D2D00B958DD /* ErrorHandlers.swift */, 6950964823C7751600E8F457 /* GradientView.swift */, @@ -588,6 +592,14 @@ path = "Flow coordinators"; sourceTree = ""; }; + 6A572DB72ADE8994002BD518 /* SwiftUIExtensions */ = { + isa = PBXGroup; + children = ( + 6A572DB82ADE89B0002BD518 /* FontModifier.swift */, + ); + path = SwiftUIExtensions; + sourceTree = ""; + }; 88EDD8FD25B824C200207987 /* GradientView */ = { isa = PBXGroup; children = ( @@ -979,6 +991,7 @@ 6950967023C78AC900E8F457 /* UIControlEvents.swift in Sources */, 6950965723C7754D00E8F457 /* Reusable.swift in Sources */, 69F83E972A617A2500E9C8EA /* Combine+Concurrency.swift in Sources */, + 6A572DB92ADE89B0002BD518 /* FontModifier.swift in Sources */, 6950962A23C7740B00E8F457 /* Logger.swift in Sources */, 6950967823C78AC900E8F457 /* UIViewController+Children.swift in Sources */, 6950967223C78AC900E8F457 /* UIViewExtensions.swift in Sources */, From 21273bd34e6f50d6f86723f79c9ffe0e26430e1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Leinha=CC=88upl?= Date: Thu, 2 Nov 2023 12:45:23 +0100 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=91=8C=20Change=20availability=20from?= =?UTF-8?q?=20iOSApplicationExtension=20to=20iOS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ACKategories-iOS/SwiftUIExtensions/FontModifier.swift | 2 +- ACKategories.xcodeproj/project.pbxproj | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ACKategories-iOS/SwiftUIExtensions/FontModifier.swift b/ACKategories-iOS/SwiftUIExtensions/FontModifier.swift index a4caa652..2cbbe7bd 100644 --- a/ACKategories-iOS/SwiftUIExtensions/FontModifier.swift +++ b/ACKategories-iOS/SwiftUIExtensions/FontModifier.swift @@ -1,6 +1,6 @@ import SwiftUI -@available(iOSApplicationExtension 14.0, *) +@available(iOS 14.0, *) extension View { /// Sets font and line height for text in this view. /// diff --git a/ACKategories.xcodeproj/project.pbxproj b/ACKategories.xcodeproj/project.pbxproj index 9cea631e..6efa608f 100644 --- a/ACKategories.xcodeproj/project.pbxproj +++ b/ACKategories.xcodeproj/project.pbxproj @@ -479,7 +479,6 @@ 6984CE122A5C218A001EE958 /* UIViewController+FrontMost.swift */, 6950966723C78AC800E8F457 /* UIViewController+SafeAreaCompat.swift */, 6950966323C78AC800E8F457 /* UIViewExtensions.swift */, - 6950963023C7747C00E8F457 /* Base */, 6950963523C7749F00E8F457 /* Supporting files */, ); path = "ACKategories-iOS"; From c6817c8b2844a39dfe9ad915e70c61dcc4b985c5 Mon Sep 17 00:00:00 2001 From: Jakub Olejnik Date: Fri, 3 Nov 2023 12:49:40 +0100 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=94=A7=20Use=20recommended=20build=20?= =?UTF-8?q?settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ACKategories-iOS/UIView+Spacer.swift | 11 +++++------ ACKategories.xcodeproj/project.pbxproj | 7 ++++++- .../xcshareddata/xcschemes/ACKategories-iOS.xcscheme | 2 +- .../xcshareddata/xcschemes/ACKategoriesCore.xcscheme | 2 +- .../xcschemes/ACKategoriesExample.xcscheme | 2 +- ACKategoriesCore/Combine+Concurrency.swift | 1 - 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ACKategories-iOS/UIView+Spacer.swift b/ACKategories-iOS/UIView+Spacer.swift index 7fad1855..9d7e4ec4 100644 --- a/ACKategories-iOS/UIView+Spacer.swift +++ b/ACKategories-iOS/UIView+Spacer.swift @@ -5,7 +5,7 @@ import UIKit public extension UIView { private final class Spacer: UIView { fileprivate var observation: NSKeyValueObservation? - + init( size: CGFloat, axis: NSLayoutConstraint.Axis, @@ -18,9 +18,9 @@ public extension UIView { height: axis == .vertical ? size : 0 ) )) - + translatesAutoresizingMaskIntoConstraints = false - + switch axis { case .horizontal: let constraint = widthAnchor.constraint(equalToConstant: size) @@ -33,12 +33,12 @@ public extension UIView { default: assertionFailure("Unknown axis \(axis)") } } - + required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } } - + private func createSpacer(_ size: CGFloat, axis: NSLayoutConstraint.Axis, priority: Float) -> UIView { let spacer = Spacer(size: size, axis: axis, priority: priority) spacer.isHidden = isHidden @@ -58,4 +58,3 @@ public extension UIView { createSpacer(width, axis: .horizontal, priority: priority) } } - diff --git a/ACKategories.xcodeproj/project.pbxproj b/ACKategories.xcodeproj/project.pbxproj index 6efa608f..2080bdf5 100644 --- a/ACKategories.xcodeproj/project.pbxproj +++ b/ACKategories.xcodeproj/project.pbxproj @@ -785,8 +785,9 @@ 69E819DF23C773010054687B /* Project object */ = { isa = PBXProject; attributes = { + BuildIndependentTargetsInParallel = YES; LastSwiftUpdateCheck = 1130; - LastUpgradeCheck = 1400; + LastUpgradeCheck = 1500; TargetAttributes = { 695096D723C7908B00E8F457 = { CreatedOnToolsVersion = 11.3; @@ -1208,6 +1209,7 @@ DEAD_CODE_STRIPPING = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -1246,6 +1248,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; DEAD_CODE_STRIPPING = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -1587,6 +1590,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; @@ -1668,6 +1672,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; diff --git a/ACKategories.xcodeproj/xcshareddata/xcschemes/ACKategories-iOS.xcscheme b/ACKategories.xcodeproj/xcshareddata/xcschemes/ACKategories-iOS.xcscheme index bad8fc3f..944dd746 100644 --- a/ACKategories.xcodeproj/xcshareddata/xcschemes/ACKategories-iOS.xcscheme +++ b/ACKategories.xcodeproj/xcshareddata/xcschemes/ACKategories-iOS.xcscheme @@ -1,6 +1,6 @@ Date: Fri, 3 Nov 2023 12:58:16 +0100 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=94=A7=20Do=20not=20run=20changelog?= =?UTF-8?q?=20check=20for=20forks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/checks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 1f3dccdc..1b468473 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -14,6 +14,7 @@ jobs: changelog: name: Changelog runs-on: ubuntu-latest + if: ${{ !github.event.pull_request.head.repo.fork }} steps: - uses: actions/checkout@v4 - name: Changelog Reminder From 0a7738712c42458dab853f6e2bba9f04265b4f07 Mon Sep 17 00:00:00 2001 From: Jakub Olejnik Date: Fri, 3 Nov 2023 13:09:45 +0100 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=93=9D=20Update=20changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a682e0fd..3cbe77e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ``` ## Next +- Bump deployment target to iOS 12 ([#137](https://github.com/AckeeCZ/ACKategories/pull/137), kudos to @olejnjak) +- Add Font modifier for SwiftUI fonts ([#134](https://github.com/AckeeCZ/ACKategories/pull/134), kudos to @leinhauplk) ## 6.12.3 - Added `BetterURL` implementation to improve URL parsing ([#129](https://github.com/AckeeCZ/ACKategories/pull/129), kudos to @AGr-AlexandrGrigoryev)