Skip to content

Commit

Permalink
Add EmptyModifier
Browse files Browse the repository at this point in the history
  • Loading branch information
aabewhite committed Aug 27, 2024
1 parent 71f5618 commit d251f18
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 56 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ Support levels:
</details>
</td>
</tr>
<tr>
<td>✅</td>
<td><code>EmptyModifier</code></td>
</tr>
<tr>
<td>✅</td>
<td><code>EmptyView</code></td>
Expand Down
62 changes: 6 additions & 56 deletions Sources/SkipUI/SkipUI/System/EmptyModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d251f18

Please sign in to comment.