Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created November 12, 2022 03:14
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 laevandus/eb4328e03d20886f8feb48630f022350 to your computer and use it in GitHub Desktop.
Save laevandus/eb4328e03d20886f8feb48630f022350 to your computer and use it in GitHub Desktop.
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