import SwiftUI | |
import StreamChatClient | |
struct LoginView: View { | |
@State | |
private var username: String = "" | |
@State | |
private var success: Bool? | |
var body: some View { | |
VStack { | |
TextField("Type username", text: $username).padding() | |
NavigationLink(destination: ChatView(), tag: true, selection: $success) { | |
EmptyView() | |
} | |
Button(action: logIn) { | |
Text("Log in") | |
} | |
} | |
.frame(maxHeight: .infinity, alignment: .top) | |
.navigationBarTitle("Log in", displayMode: .inline) | |
} | |
func logIn() { | |
Client.shared.set(user: User(id: username), token: .development) { result in | |
switch result { | |
case .success: | |
self.success = true | |
case .failure: | |
self.success = false | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment