Created
November 11, 2019 12:21
-
-
Save kumamotone/b070150250915455cc326eef3299fec4 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 | |
struct GameSettings { | |
var isHard: Bool = false | |
} | |
struct NextView: View { | |
@Binding var settings: GameSettings | |
var body: some View { | |
Toggle(isOn: $settings.isHard) { | |
if self.settings.isHard { | |
Text("Hard") | |
} else { | |
Text("Easy") | |
} | |
} | |
} | |
} | |
struct ContentView: View { | |
@State var settings: GameSettings = GameSettings() | |
var body: some View { | |
NavigationView { | |
List { | |
NavigationLink(destination: NextView(settings: $settings)) { | |
Text("\(settings.isHard ? "Hard" : "Easy")") | |
} | |
} | |
} | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment