Remake XCode project with iOS (iPhone / iPad) support
This commit is contained in:
1 parent
5a5234cff8
commit
6b40bf00d9
37 files changed
+167
-147
No files matched your search
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// ContentView.swift
|
||||
// BerryLeaderboards
|
||||
//
|
||||
// Created by Lncvrt on 6/9/25.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
@State private var players: [Player] = []
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
#if os(macOS)
|
||||
VisualEffectBlur()
|
||||
.ignoresSafeArea()
|
||||
#endif
|
||||
List(players) { player in
|
||||
HStack {
|
||||
Text(player.username)
|
||||
Spacer()
|
||||
Text("\(player.score)")
|
||||
.bold()
|
||||
}
|
||||
.padding(.vertical, 4)
|
||||
.listRowBackground(Color.clear)
|
||||
}
|
||||
.background(Color.clear)
|
||||
#if os(macOS)
|
||||
.scrollContentBackground(.hidden)
|
||||
#endif
|
||||
.task {
|
||||
await loadPlayers()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func loadPlayers() async {
|
||||
do {
|
||||
players = try await loadLeaderboard()
|
||||
} catch {
|
||||
print("Failed to load leaderboard:", error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func loadLeaderboard() async throws -> [Player] {
|
||||
let url = URL(string: "https://berrydash.lncvrt.xyz/database/getTopPlayersAPI.php")!
|
||||
let (data, _) = try await URLSession.shared.data(from: url)
|
||||
guard let raw = String(data: data, encoding: .utf8) else { return [] }
|
||||
return parseLeaderboard(raw)
|
||||
}
|
||||
Reference in new issue
Block a user