Created
December 5, 2021 13:38
-
-
Save enyciaa/eccd49e7636339dd5e4466cadc534e11 to your computer and use it in GitHub Desktop.
screen-template-4
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
struct MyFabScreenDestination: View { | |
let myFabScreenViewModel: MyFabScreenViewModel | |
@State private var viewState: MyFabScreenViewModel.ViewState | |
init(myFabScreenViewModel: MyFabScreenViewModel) { | |
self.myFabScreenViewModel = myFabScreenViewModel | |
_viewState = State(initialValue: myFabScreenViewModel.defaultViewState()) | |
} | |
var body: some View { | |
JuicyScreenTemplate( | |
screenState: viewState.screenState, | |
screenToolbarViewState: viewState.screenToolbarViewState, | |
screenCallToActionViewState: viewState.screenCallToActionViewState, | |
onCallToActionTapped: { myFabScreenViewModel.onAction(action: MyFabScreenViewModel.UiActionNextClicked()) }, | |
content: { | |
VStack { | |
Text("Loaded!") | |
} | |
} | |
) | |
.onAppear { | |
myFabScreenViewModel.onAttach() | |
myFabScreenViewModel.nativeViewStateStream().watch { state in | |
guard let newState = state else { | |
return | |
} | |
self.viewState = newState | |
} | |
} | |
.onDisappear { | |
myFabScreenViewModel.onDetach() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment