adding admin users loading screen, renaming tests

This commit is contained in:
Andy Pack 2022-12-10 14:55:15 +00:00
parent afee0ecea4
commit 32af8e8432
Signed by: sarsoo
GPG Key ID: A55BA3536A5E0ED7
3 changed files with 35 additions and 26 deletions

View File

@ -15,30 +15,37 @@ struct UsersList: View {
@EnvironmentObject var liveUser: LiveUser
@State private var users: [User] = []
@State var isLoading = true
var body: some View {
List{
Section { // Weird? added empty header as list renders with space for header then jumps up, not nice
if self.users.count > 0 {
ForEach(self.users.indices, id: \.self){ userIdx in
NavigationLink(destination: UserView(user: self.$users[userIdx])) {
Text(self.users[userIdx].username)
if isLoading {
LoadingScreen()
.onAppear {
self.get_users()
}
}
else {
List{
Section { // Weird? added empty header as list renders with space for header then jumps up, not nice
if self.users.count > 0 {
ForEach(self.users.indices, id: \.self){ userIdx in
NavigationLink(destination: UserView(user: self.$users[userIdx])) {
Text(self.users[userIdx].username)
}
}
}else {
HStack {
Text("No Users")
.multilineTextAlignment(.center)
Spacer()
}
}
}else {
HStack {
Text("No Users")
.multilineTextAlignment(.center)
Spacer()
}
}
}
}
// .id(UUID())
.navigationBarTitle("Users")
.onAppear {
self.get_users()
// .id(UUID())
.navigationBarTitle("Users")
}
}
@ -64,6 +71,8 @@ struct UsersList: View {
return user1.username < user2.username
})
self.isLoading = false
} else {
Logger.net.error("failed to get users from view")
}
@ -73,7 +82,7 @@ struct UsersList: View {
struct UsersList_Previews: PreviewProvider {
static var previews: some View {
UsersList()
UsersList(isLoading: false)
.environmentObject(LiveUser.get_preview_user())
}
}

View File

@ -1,15 +1,15 @@
//
// Music_ToolsTests.swift
// Music ToolsTests
// MixonomerTests.swift
// MixonomerTests
//
// Created by Andy Pack on 16/02/2020.
// Copyright © 2020 Sarsoo. All rights reserved.
//
import XCTest
@testable import Music_Tools
@testable import Mixonomer
class Music_ToolsTests: XCTestCase {
class MixonomerTests: XCTestCase {
override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.

View File

@ -1,6 +1,6 @@
//
// Music_ToolsUITests.swift
// Music ToolsUITests
// MixonomerUITests.swift
// MixonomerUITests
//
// Created by Andy Pack on 16/02/2020.
// Copyright © 2020 Sarsoo. All rights reserved.
@ -8,7 +8,7 @@
import XCTest
class Music_ToolsUITests: XCTestCase {
class MixonomerUITests: XCTestCase {
override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.