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 serverName = "";
@State private var publicUsers: [publicUser] = [];
@State private var lastPublicUsers: [publicUser] = [];
@Binding var rootIsActive : Bool
let userUUID = UUID();
@ -258,12 +259,47 @@ struct ConnectToServerView: View {
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 {
Section(header: Text("\(serverSkipped ? "Reauthenticate" : "Login") to \(serverName)")) {
ForEach(publicUsers, id: \.id) { pubuser in
HStack() {
Button() {
if(pubuser.hasPassword) {
_lastPublicUsers.wrappedValue = _publicUsers.wrappedValue
_publicUsers.wrappedValue = []
} else {
_publicUsers.wrappedValue = []

View File

@ -9,9 +9,20 @@ import SwiftUI
struct SettingsView: View {
@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 {
NavigationView() {
Text("SettingsView not implemented.")
Form() {
Section(header: Text("Playback settings")) {
}
}
.navigationBarTitle("Settings", displayMode: .inline)
.toolbar {
ToolbarItemGroup(placement: .navigationBarLeading) {
@ -24,6 +35,6 @@ struct SettingsView: View {
}
}
}
}
}.onAppear(perform: onAppear)
}
}