Skip to content

Instantly share code, notes, and snippets.

@enyciaa
Created December 5, 2021 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enyciaa/eccd49e7636339dd5e4466cadc534e11 to your computer and use it in GitHub Desktop.
Save enyciaa/eccd49e7636339dd5e4466cadc534e11 to your computer and use it in GitHub Desktop.
screen-template-4
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