Add a refresh button, loading status, and show errors if there is any, along with some mobile improvements
This commit is contained in:
1 parent
1ed0338795
commit
e6293b2fc4
2 files changed
+55
-20
No files matched your search
@@ -389,7 +389,7 @@
|
|||||||
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
|
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
|
||||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
|
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
|
||||||
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
|
||||||
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
|
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.5;
|
MACOSX_DEPLOYMENT_TARGET = 13.5;
|
||||||
@@ -428,7 +428,7 @@
|
|||||||
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
|
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
|
||||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
|
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
|
||||||
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
|
||||||
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
|
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.5;
|
MACOSX_DEPLOYMENT_TARGET = 13.5;
|
||||||
@@ -453,7 +453,7 @@
|
|||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_TEAM = UA7XPYM6ZB;
|
DEVELOPMENT_TEAM = UA7XPYM6ZB;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
|
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.5;
|
MACOSX_DEPLOYMENT_TARGET = 13.5;
|
||||||
MARKETING_VERSION = 1.0;
|
MARKETING_VERSION = 1.0;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "xyz.lncvrt.Berry-LeaderboardsTests";
|
PRODUCT_BUNDLE_IDENTIFIER = "xyz.lncvrt.Berry-LeaderboardsTests";
|
||||||
@@ -475,7 +475,7 @@
|
|||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_TEAM = UA7XPYM6ZB;
|
DEVELOPMENT_TEAM = UA7XPYM6ZB;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
|
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.5;
|
MACOSX_DEPLOYMENT_TARGET = 13.5;
|
||||||
MARKETING_VERSION = 1.0;
|
MARKETING_VERSION = 1.0;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "xyz.lncvrt.Berry-LeaderboardsTests";
|
PRODUCT_BUNDLE_IDENTIFIER = "xyz.lncvrt.Berry-LeaderboardsTests";
|
||||||
@@ -496,7 +496,7 @@
|
|||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_TEAM = UA7XPYM6ZB;
|
DEVELOPMENT_TEAM = UA7XPYM6ZB;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
|
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.5;
|
MACOSX_DEPLOYMENT_TARGET = 13.5;
|
||||||
MARKETING_VERSION = 1.0;
|
MARKETING_VERSION = 1.0;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "xyz.lncvrt.Berry-LeaderboardsUITests";
|
PRODUCT_BUNDLE_IDENTIFIER = "xyz.lncvrt.Berry-LeaderboardsUITests";
|
||||||
@@ -517,7 +517,7 @@
|
|||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_TEAM = UA7XPYM6ZB;
|
DEVELOPMENT_TEAM = UA7XPYM6ZB;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
|
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.5;
|
MACOSX_DEPLOYMENT_TARGET = 13.5;
|
||||||
MARKETING_VERSION = 1.0;
|
MARKETING_VERSION = 1.0;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "xyz.lncvrt.Berry-LeaderboardsUITests";
|
PRODUCT_BUNDLE_IDENTIFIER = "xyz.lncvrt.Berry-LeaderboardsUITests";
|
||||||
|
|||||||
@@ -9,39 +9,74 @@ import SwiftUI
|
|||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
@State private var players: [Player] = []
|
@State private var players: [Player] = []
|
||||||
|
@State private var loading = false
|
||||||
|
@State private var errorMessage: String?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
VisualEffectBlur()
|
VisualEffectBlur()
|
||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
|
#elseif os(iOS)
|
||||||
|
Color(red: 24/255, green: 24/255, blue: 24/255)
|
||||||
|
.ignoresSafeArea()
|
||||||
#endif
|
#endif
|
||||||
List(players) { player in
|
|
||||||
|
VStack(spacing: 8) {
|
||||||
HStack {
|
HStack {
|
||||||
Text(player.username)
|
|
||||||
Spacer()
|
Spacer()
|
||||||
Text("\(player.score)")
|
Button("Refresh") {
|
||||||
.bold()
|
Task { await loadPlayers() }
|
||||||
|
}
|
||||||
|
.padding(.top, 8)
|
||||||
|
.padding(.trailing, 12)
|
||||||
|
}
|
||||||
|
|
||||||
|
if loading {
|
||||||
|
Text("Loading...").padding()
|
||||||
|
} else if let errorMessage {
|
||||||
|
Text("Error: \(errorMessage)")
|
||||||
|
.foregroundColor(.red)
|
||||||
|
.padding()
|
||||||
|
}
|
||||||
|
|
||||||
|
List(players) { player in
|
||||||
|
HStack {
|
||||||
|
Text(player.username)
|
||||||
|
Spacer()
|
||||||
|
Text("\(player.score)").bold()
|
||||||
|
}
|
||||||
|
.padding(.vertical, 4)
|
||||||
|
#if os(macOS)
|
||||||
|
.listRowBackground(Color.clear)
|
||||||
|
#elseif os(iOS)
|
||||||
|
.listRowBackground(Color(red: 48/255, green: 48/255, blue: 48/255))
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
.background(Color.clear)
|
||||||
|
#if os(macOS)
|
||||||
|
.scrollContentBackground(.hidden)
|
||||||
|
#elseif os(iOS)
|
||||||
|
.scrollContentBackground(.hidden)
|
||||||
|
.listStyle(.plain)
|
||||||
|
#endif
|
||||||
|
.task {
|
||||||
|
await loadPlayers()
|
||||||
}
|
}
|
||||||
.padding(.vertical, 4)
|
|
||||||
.listRowBackground(Color.clear)
|
|
||||||
}
|
|
||||||
.background(Color.clear)
|
|
||||||
#if os(macOS)
|
|
||||||
.scrollContentBackground(.hidden)
|
|
||||||
#endif
|
|
||||||
.task {
|
|
||||||
await loadPlayers()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadPlayers() async {
|
func loadPlayers() async {
|
||||||
|
loading = true
|
||||||
|
errorMessage = nil
|
||||||
do {
|
do {
|
||||||
|
players = []
|
||||||
players = try await loadLeaderboard()
|
players = try await loadLeaderboard()
|
||||||
} catch {
|
} catch {
|
||||||
print("Failed to load leaderboard:", error)
|
errorMessage = error.localizedDescription
|
||||||
}
|
}
|
||||||
|
loading = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user