Created
December 16, 2021 16:27
-
-
Save Lascorbe/4369bb19d334d82652655905abeca303 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 UIKit | |
import SwiftUI | |
final class LoginViewController: UIHostingController<LoginView> { | |
private let viewModel: LoginViewModel | |
init(viewModel: LoginViewModel) { | |
self.viewModel = viewModel | |
super.init(rootView: LoginView(viewModel: viewModel)) | |
} | |
@MainActor @objc required dynamic init?(coder aDecoder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
private func changeNameBarItemDidTap() { | |
viewModel.userName = "Christian" | |
} | |
} | |
final class LoginViewModel: ObservableObject { | |
@Published var userName = "Luis" | |
} | |
struct LoginView: View { | |
@ObservedObject var viewModel: LoginViewModel | |
var body: some View { | |
Text(viewModel.userName) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment