-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
209 additions
and
39 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
Sources/SwiftfulRouting/Components/ModuleSupportView.swift
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,64 @@ | ||
// | ||
// ModuleSupportView.swift | ||
// | ||
// | ||
// Created by Nick Sarno on 1/21/24. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
struct ModuleSupportView<Content:View>: View { | ||
|
||
let addNavigationView: Bool | ||
let moduleDelegate: ModuleDelegate | ||
let screens: Binding<[AnyDestination]>? | ||
|
||
@Binding var selection: AnyTransitionWithDestination | ||
let modules: [AnyTransitionWithDestination] | ||
@ViewBuilder var content: (AnyRouter) -> Content | ||
let currentTransition: TransitionOption | ||
|
||
var body: some View { | ||
ZStack { | ||
LazyZStack(allowSimultaneous: false, selection: selection, items: modules) { data in | ||
if data == modules.first { | ||
RouterViewInternal( | ||
addNavigationView: addNavigationView, | ||
moduleDelegate: moduleDelegate, | ||
screens: screens, | ||
route: nil, | ||
routes: nil, | ||
environmentRouter: nil, | ||
content: content | ||
) | ||
.transition( | ||
.asymmetric( | ||
insertion: currentTransition.insertion, | ||
removal: .customRemoval(direction: currentTransition.reversed) | ||
) | ||
) | ||
} else { | ||
RouterViewInternal( | ||
addNavigationView: addNavigationView, | ||
moduleDelegate: moduleDelegate, | ||
screens: screens, | ||
route: nil, | ||
routes: nil, | ||
environmentRouter: nil, | ||
content: { router in | ||
data.destination(router).destination | ||
} | ||
) | ||
.transition( | ||
.asymmetric( | ||
insertion: currentTransition.insertion, | ||
removal: .customRemoval(direction: currentTransition.reversed) | ||
) | ||
) | ||
} | ||
} | ||
.animation(.easeInOut, value: selection.id) | ||
} | ||
} | ||
} |
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