From 20d92be34535497e9271332be8cb32f10cb9ce1e Mon Sep 17 00:00:00 2001 From: Jakub Olejnik Date: Thu, 9 Nov 2023 00:34:47 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20`EdgeInsets.zero`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ACKategories-iOSTests/EdgeInsetsTests.swift | 12 ++++++++++++ ACKategoriesCore/EdgeInsetsExtensions.swift | 2 ++ ACKategoriesCoreTests/EdegeInsetsTests.swift | 12 ++++++++++++ CHANGELOG.md | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ACKategories-iOSTests/EdgeInsetsTests.swift b/ACKategories-iOSTests/EdgeInsetsTests.swift index 9962281c..9516013b 100644 --- a/ACKategories-iOSTests/EdgeInsetsTests.swift +++ b/ACKategories-iOSTests/EdgeInsetsTests.swift @@ -14,4 +14,16 @@ final class EdgeInsetsTests: XCTestCase { ) ) } + + func test_zero() { + XCTAssertEqual( + EdgeInsets.zero, + .init( + top: 0, + leading: 0, + bottom: 0, + trailing: 0 + ) + ) + } } diff --git a/ACKategoriesCore/EdgeInsetsExtensions.swift b/ACKategoriesCore/EdgeInsetsExtensions.swift index f708eb23..2cc2171a 100644 --- a/ACKategoriesCore/EdgeInsetsExtensions.swift +++ b/ACKategoriesCore/EdgeInsetsExtensions.swift @@ -2,6 +2,8 @@ import SwiftUI @available(iOS 13.0, macOS 10.15, *) public extension SwiftUI.EdgeInsets { + static var zero: Self { .init(0) } + /// Initialize edge insets with the same padding for all edges init(_ size: CGFloat) { self.init( diff --git a/ACKategoriesCoreTests/EdegeInsetsTests.swift b/ACKategoriesCoreTests/EdegeInsetsTests.swift index e3762b17..8fdc8f25 100644 --- a/ACKategoriesCoreTests/EdegeInsetsTests.swift +++ b/ACKategoriesCoreTests/EdegeInsetsTests.swift @@ -14,4 +14,16 @@ final class EdgeInsetsTests: XCTestCase { ) ) } + + func test_zero() { + XCTAssertEqual( + EdgeInsets.zero, + .init( + top: 0, + leading: 0, + bottom: 0, + trailing: 0 + ) + ) + } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c1009a1..10c7ed0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ ``` ## Next -- Add helper init for `SwiftUI.EdgeInsets` that creates insets with equal values for all edges ([#138](https://github.com/AckeeCZ/ACKategories/pull/138), kudos to @olejnjak) +- Add helpers for `SwiftUI.EdgeInsets` ([#138](https://github.com/AckeeCZ/ACKategories/pull/138), kudos to @olejnjak) - 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)