-
-
Save laevandus/eb4328e03d20886f8feb48630f022350 to your computer and use it in GitHub Desktop.
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 ContentView: View { | |
@StateObject var viewModel = ViewModel() | |
var body: some View { | |
VStack { | |
Image(systemName: "globe") | |
.imageScale(.large) | |
.foregroundColor(.accentColor) | |
Text(viewModel.title) | |
.font(.title) | |
} | |
.padding() | |
} | |
} | |
extension ContentView { | |
final class ViewModel: ObservableObject { | |
@Published var style: Style = .hello | |
var title: String { | |
switch style { | |
case .hello: return "Hello World!" | |
case .welcome: return "Welcome World!" | |
} | |
} | |
} | |
enum Style { | |
case hello, welcome | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment