Finalize public user sign-in screen
This commit is contained in:
parent
1307194e4e
commit
bc60710ae4
|
@ -172,7 +172,7 @@ struct ConnectToServerView: View {
|
||||||
Form {
|
Form {
|
||||||
if(!isConnected) {
|
if(!isConnected) {
|
||||||
Section(header: Text("Server Information")) {
|
Section(header: Text("Server Information")) {
|
||||||
TextField("Server URL", text: $uri)
|
TextField("Jellyfin Server URL", text: $uri)
|
||||||
.disableAutocorrection(true)
|
.disableAutocorrection(true)
|
||||||
.autocapitalization(.none)
|
.autocapitalization(.none)
|
||||||
Button {
|
Button {
|
||||||
|
@ -193,34 +193,37 @@ struct ConnectToServerView: View {
|
||||||
if(server.StartupWizardCompleted) {
|
if(server.StartupWizardCompleted) {
|
||||||
_isConnected.wrappedValue = true;
|
_isConnected.wrappedValue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let request2 = RestRequest(method: .get, url: uri + "/users/public")
|
||||||
|
request2.responseData() { (result: Result<RestResponse<Data>, RestError>) in
|
||||||
|
switch result {
|
||||||
|
case .success(let response):
|
||||||
|
do {
|
||||||
|
let body = response.body;
|
||||||
|
let json = try JSON(data: body);
|
||||||
|
|
||||||
|
for (_,publicUserDto):(String, JSON) in json {
|
||||||
|
let newPublicUser = publicUser()
|
||||||
|
newPublicUser.username = publicUserDto["Name"].string ?? ""
|
||||||
|
newPublicUser.hasPassword = publicUserDto["HasPassword"].bool ?? true
|
||||||
|
newPublicUser.primaryImageTag = publicUserDto["PrimaryImageTag"].string ?? ""
|
||||||
|
newPublicUser.id = publicUserDto["Id"].string ?? ""
|
||||||
|
_publicUsers.wrappedValue.append(newPublicUser)
|
||||||
|
}
|
||||||
|
} catch(_) {
|
||||||
|
|
||||||
|
}
|
||||||
|
_isWorking.wrappedValue = false;
|
||||||
|
break
|
||||||
|
case .failure(_):
|
||||||
|
_isErrored.wrappedValue = true;
|
||||||
|
_isWorking.wrappedValue = false;
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
case .failure(_):
|
case .failure(_):
|
||||||
_isErrored.wrappedValue = true;
|
_isErrored.wrappedValue = true;
|
||||||
}
|
_isWorking.wrappedValue = false;
|
||||||
_isWorking.wrappedValue = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let request2 = RestRequest(method: .get, url: uri + "/users/public")
|
|
||||||
request2.responseData() { (result: Result<RestResponse<Data>, RestError>) in
|
|
||||||
switch result {
|
|
||||||
case .success(let response):
|
|
||||||
do {
|
|
||||||
let body = response.body;
|
|
||||||
let json = try JSON(data: body);
|
|
||||||
|
|
||||||
for (_,publicUserDto):(String, JSON) in json {
|
|
||||||
let newPublicUser = publicUser()
|
|
||||||
newPublicUser.username = publicUserDto["Name"].string ?? ""
|
|
||||||
newPublicUser.hasPassword = publicUserDto["HasPassword"].bool ?? true
|
|
||||||
newPublicUser.primaryImageTag = publicUserDto["PrimaryImageTag"].string ?? ""
|
|
||||||
newPublicUser.id = publicUserDto["Id"].string ?? ""
|
|
||||||
_publicUsers.wrappedValue.append(newPublicUser)
|
|
||||||
}
|
|
||||||
} catch(_) {
|
|
||||||
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case .failure(_):
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} label: {
|
} label: {
|
||||||
|
@ -256,12 +259,11 @@ struct ConnectToServerView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Section(header: Text("\(serverSkipped ? "re" : "")Authenticate 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) {
|
||||||
_username.wrappedValue = pubuser.username
|
|
||||||
_publicUsers.wrappedValue = []
|
_publicUsers.wrappedValue = []
|
||||||
} else {
|
} else {
|
||||||
_publicUsers.wrappedValue = []
|
_publicUsers.wrappedValue = []
|
||||||
|
@ -273,17 +275,45 @@ struct ConnectToServerView: View {
|
||||||
HStack() {
|
HStack() {
|
||||||
Text(pubuser.username).font(.subheadline).fontWeight(.semibold)
|
Text(pubuser.username).font(.subheadline).fontWeight(.semibold)
|
||||||
Spacer()
|
Spacer()
|
||||||
WebImage(url: URL(string: "\(uri)/Users/\(pubuser.id)/Images/Primary?width=200&quality=80&tag=\(pubuser.primaryImageTag)")!)
|
if(pubuser.primaryImageTag != "") {
|
||||||
.resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size
|
WebImage(url: URL(string: "\(uri)/Users/\(pubuser.id)/Images/Primary?width=200&quality=80&tag=\(pubuser.primaryImageTag)")!)
|
||||||
.aspectRatio(contentMode: .fill)
|
.resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size
|
||||||
.shadow(radius: 5)
|
.aspectRatio(contentMode: .fill)
|
||||||
.frame(width: 60, height: 60)
|
.frame(width: 60, height: 60)
|
||||||
.cornerRadius(30.0)
|
.cornerRadius(30.0)
|
||||||
|
.shadow(radius: 6)
|
||||||
|
} else {
|
||||||
|
Image(systemName: "person.fill")
|
||||||
|
.foregroundColor(Color(red: 1, green: 1, blue: 1).opacity(0.8))
|
||||||
|
.font(.system(size: 35))
|
||||||
|
.frame(width: 60, height: 60)
|
||||||
|
.background(Color(red: 98/255, green: 121/255, blue: 205/255))
|
||||||
|
.cornerRadius(30.0)
|
||||||
|
.shadow(radius: 6)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Section() {
|
||||||
|
Button() {
|
||||||
|
_publicUsers.wrappedValue = []
|
||||||
|
} label: {
|
||||||
|
HStack() {
|
||||||
|
Text("Other User").font(.subheadline).fontWeight(.semibold)
|
||||||
|
Spacer()
|
||||||
|
Image(systemName: "person.fill.questionmark")
|
||||||
|
.foregroundColor(Color(red: 1, green: 1, blue: 1).opacity(0.8))
|
||||||
|
.font(.system(size: 35))
|
||||||
|
.frame(width: 60, height: 60)
|
||||||
|
.background(Color(red: 98/255, green: 121/255, blue: 205/255))
|
||||||
|
.cornerRadius(30.0)
|
||||||
|
.shadow(radius: 6)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.navigationTitle("Connect to Server")
|
}.navigationTitle("Connect to Server")
|
||||||
|
|
|
@ -334,11 +334,11 @@ struct ContentView: View {
|
||||||
if(needsToSelectServer) {
|
if(needsToSelectServer) {
|
||||||
NavigationView() {
|
NavigationView() {
|
||||||
ConnectToServerView(isActive: $needsToSelectServer)
|
ConnectToServerView(isActive: $needsToSelectServer)
|
||||||
}.environmentObject(globalData)
|
}.environmentObject(globalData).navigationViewStyle(StackNavigationViewStyle())
|
||||||
} else if(isSignInErrored) {
|
} else if(isSignInErrored) {
|
||||||
NavigationView() {
|
NavigationView() {
|
||||||
ConnectToServerView(skip_server: true, skip_server_prefill: globalData.server, reauth_deviceId: globalData.user?.device_uuid ?? "", isActive: $isSignInErrored)
|
ConnectToServerView(skip_server: true, skip_server_prefill: globalData.server, reauth_deviceId: globalData.user?.device_uuid ?? "", isActive: $isSignInErrored)
|
||||||
}.environmentObject(globalData)
|
}.environmentObject(globalData).navigationViewStyle(StackNavigationViewStyle())
|
||||||
} else {
|
} else {
|
||||||
if(!jsi.did) {
|
if(!jsi.did) {
|
||||||
LoadingView(isShowing: $isLoading) {
|
LoadingView(isShowing: $isLoading) {
|
||||||
|
@ -379,6 +379,7 @@ struct ContentView: View {
|
||||||
}
|
}
|
||||||
}.fullScreenCover( isPresented: $showSettingsPopover) { SettingsView(close: $showSettingsPopover).environmentObject(globalData) }
|
}.fullScreenCover( isPresented: $showSettingsPopover) { SettingsView(close: $showSettingsPopover).environmentObject(globalData) }
|
||||||
}
|
}
|
||||||
|
.navigationViewStyle(StackNavigationViewStyle())
|
||||||
.tabItem({
|
.tabItem({
|
||||||
Text("Home")
|
Text("Home")
|
||||||
Image(systemName: "house")
|
Image(systemName: "house")
|
||||||
|
|
Loading…
Reference in New Issue