-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d2d564
commit 518c63f
Showing
15 changed files
with
594 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// Copyright (c) Nathan Tannar | ||
// | ||
|
||
import SwiftUI | ||
|
||
extension _ConditionalContent: MultiView where TrueContent: View, FalseContent: View { | ||
|
||
public func makeSubviewIterator() -> some MultiViewIterator { | ||
ConditionalContentSubviewIterator(content: unsafeBitCast(self, to: _Storage.self)) | ||
} | ||
|
||
enum _Storage { | ||
case trueContent(TrueContent) | ||
case falseContent(FalseContent) | ||
} | ||
} | ||
|
||
private struct ConditionalContentSubviewIterator< | ||
TrueContent: View, | ||
FalseContent: View | ||
>: MultiViewIterator { | ||
|
||
var content: _ConditionalContent<TrueContent, FalseContent>._Storage | ||
|
||
func visit< | ||
Visitor: MultiViewVisitor | ||
>( | ||
visitor: UnsafeMutablePointer<Visitor>, | ||
context: Context, | ||
stop: inout Bool | ||
) { | ||
var context = context | ||
switch content { | ||
case .trueContent(let trueContent): | ||
context.id.append(TrueContent.self) | ||
trueContent.visit(visitor: visitor, context: context, stop: &stop) | ||
case .falseContent(let falseContent): | ||
context.id.append(FalseContent.self) | ||
falseContent.visit(visitor: visitor, context: context, stop: &stop) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.