Last active
October 10, 2019 00:29
-
-
Save khirotaka/a0acf5c4f797205704557b09b107ec6b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import SwiftUI | |
import PlaygroundSupport | |
/*: | |
# Example of SwiftUI Page Transition | |
Run on Swift Playground (iPad) | |
nest is too deep... | |
*/ | |
struct ContentView: View { | |
@State private var pushed: Bool = false | |
var body: some View { | |
VStack { | |
if self.pushed { | |
VStack { | |
SecondView().padding(10) | |
Button(action: { | |
self.pushed = false | |
}) { | |
Text("Back") | |
} | |
} | |
} | |
else { | |
VStack { | |
FirstView().padding(10) | |
Button(action: { | |
self.pushed = true | |
}) { | |
Text("Change") | |
} | |
} | |
} | |
} | |
} | |
} | |
struct FirstView: View { | |
var body: some View { | |
Text("FIRST") | |
} | |
} | |
struct SecondView: View { | |
var body: some View { | |
Text("SECOND") | |
} | |
} | |
PlaygroundPage.current.liveView = | |
UIHostingController(rootView: ContentView()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment