Skip to content

Instantly share code, notes, and snippets.

@cardoso cardoso/LoginView.swift Secret
Created May 17, 2020

Embed
What would you like to do?
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
You can’t perform that action at this time.