From d251f1847b2e1d47b4f891c096dd474e833c0ab3 Mon Sep 17 00:00:00 2001 From: Abe White Date: Tue, 27 Aug 2024 13:28:06 -0500 Subject: [PATCH] Add EmptyModifier --- README.md | 4 ++ .../SkipUI/SkipUI/System/EmptyModifier.swift | 62 ++----------------- 2 files changed, 10 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 6d4e98ab..ac2212c1 100644 --- a/README.md +++ b/README.md @@ -416,6 +416,10 @@ Support levels: + + ✅ + EmptyModifier + ✅ EmptyView diff --git a/Sources/SkipUI/SkipUI/System/EmptyModifier.swift b/Sources/SkipUI/SkipUI/System/EmptyModifier.swift index 03356d68..fa598366 100644 --- a/Sources/SkipUI/SkipUI/System/EmptyModifier.swift +++ b/Sources/SkipUI/SkipUI/System/EmptyModifier.swift @@ -4,62 +4,12 @@ // under the terms of the GNU Lesser General Public License 3.0 // as published by the Free Software Foundation https://fsf.org -// TODO: Process for use in SkipUI +#if SKIP +public struct EmptyModifier : ViewModifier { + public static let identity: EmptyModifier = EmptyModifier() -#if false - -/// An empty, or identity, modifier, used during development to switch -/// modifiers at compile time. -/// -/// Use the empty modifier to switch modifiers at compile time during -/// development. In the example below, in a debug build the ``Text`` -/// view inside `ContentView` has a yellow background and a red border. -/// A non-debug build reflects the default system, or container supplied -/// appearance. -/// -/// struct EmphasizedLayout: ViewModifier { -/// func body(content: Content) -> some View { -/// content -/// .background(Color.yellow) -/// .border(Color.red) -/// } -/// } -/// -/// struct ContentView: View { -/// var body: some View { -/// Text("Hello, World!") -/// .modifier(modifier) -/// } -/// -/// var modifier: some ViewModifier { -/// #if DEBUG -/// return EmphasizedLayout() -/// #else -/// return EmptyModifier() -/// #endif -/// } -/// } -/// -@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) -@frozen public struct EmptyModifier : ViewModifier { - public static let identity: EmptyModifier = { fatalError() }() - - /// The type of view representing the body. - public typealias Body = Content - - @inlinable public init() { fatalError() } - - /// Gets the current body of the caller. - /// - /// `content` is a proxy for the view that will have the modifier - /// represented by `Self` applied to it. - @MainActor public func body() -> EmptyModifier.Body { fatalError() } - public typealias Content = Never + public func body(content: Content) -> some View { + content + } } - -@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) -extension EmptyModifier : Sendable { -} - - #endif