add back button on login screen

This commit is contained in:
Aiden Vigue 2021-05-23 17:35:11 -04:00
parent bc60710ae4
commit c46838905f
2 changed files with 49 additions and 2 deletions

View File

@ -34,6 +34,7 @@ struct ConnectToServerView: View {
@State private var isConnected = false; @State private var isConnected = false;
@State private var serverName = ""; @State private var serverName = "";
@State private var publicUsers: [publicUser] = []; @State private var publicUsers: [publicUser] = [];
@State private var lastPublicUsers: [publicUser] = [];
@Binding var rootIsActive : Bool @Binding var rootIsActive : Bool
let userUUID = UUID(); let userUUID = UUID();
@ -258,12 +259,47 @@ struct ConnectToServerView: View {
Alert(title: Text("Error"), message: Text("Invalid credentials"), dismissButton: .default(Text("Back"))) Alert(title: Text("Error"), message: Text("Invalid credentials"), dismissButton: .default(Text("Back")))
} }
} }
if(serverSkipped) {
Section() {
Button {
_serverSkippedAlert.wrappedValue = false;
_server_id.wrappedValue = ""
_serverName.wrappedValue = ""
_isConnected.wrappedValue = false;
_serverSkipped.wrappedValue = false;
} label: {
HStack() {
HStack() {
Image(systemName: "chevron.left")
Text("Change Server")
}
Spacer()
}
}
}
} else {
Section() {
Button {
_publicUsers.wrappedValue = _lastPublicUsers.wrappedValue
} label: {
HStack() {
HStack() {
Image(systemName: "chevron.left")
Text("Back")
}
Spacer()
}
}
}
}
} else { } else {
Section(header: Text("\(serverSkipped ? "Reauthenticate" : "Login") to \(serverName)")) { Section(header: Text("\(serverSkipped ? "Reauthenticate" : "Login") to \(serverName)")) {
ForEach(publicUsers, id: \.id) { pubuser in ForEach(publicUsers, id: \.id) { pubuser in
HStack() { HStack() {
Button() { Button() {
if(pubuser.hasPassword) { if(pubuser.hasPassword) {
_lastPublicUsers.wrappedValue = _publicUsers.wrappedValue
_publicUsers.wrappedValue = [] _publicUsers.wrappedValue = []
} else { } else {
_publicUsers.wrappedValue = [] _publicUsers.wrappedValue = []

View File

@ -9,9 +9,20 @@ import SwiftUI
struct SettingsView: View { struct SettingsView: View {
@Binding var close: Bool; @Binding var close: Bool;
@EnvironmentObject private var globalData: GlobalData
@State private var username: String = "";
func onAppear() {
_username.wrappedValue = globalData.user?.username ?? "";
}
var body: some View { var body: some View {
NavigationView() { NavigationView() {
Text("SettingsView not implemented.") Form() {
Section(header: Text("Playback settings")) {
}
}
.navigationBarTitle("Settings", displayMode: .inline) .navigationBarTitle("Settings", displayMode: .inline)
.toolbar { .toolbar {
ToolbarItemGroup(placement: .navigationBarLeading) { ToolbarItemGroup(placement: .navigationBarLeading) {
@ -24,6 +35,6 @@ struct SettingsView: View {
} }
} }
} }
} }.onAppear(perform: onAppear)
} }
} }