GameInfo UI enhancement

This commit is contained in:
Daniil Vinogradov 2025-02-16 13:38:41 +01:00
parent df2b17ddd6
commit 2a7cfa5650

View File

@ -14,7 +14,10 @@ struct GameInfoSheet: View {
var body: some View { var body: some View {
iOSNav { iOSNav {
VStack { List {
Section {}
header: {
VStack(alignment: .center) {
if let icon = game.icon { if let icon = game.icon {
Image(uiImage: icon) Image(uiImage: icon)
.resizable() .resizable()
@ -36,23 +39,27 @@ struct GameInfoSheet: View {
.frame(width: 150, height: 150) .frame(width: 150, height: 150)
.padding() .padding()
} }
VStack(alignment: .center) {
VStack(alignment: .leading) {
VStack(alignment: .leading) {
Text("**\(game.titleName)** | \(game.titleId.capitalized)") Text("**\(game.titleName)** | \(game.titleId.capitalized)")
.multilineTextAlignment(.center)
Text(game.developer) Text(game.developer)
.font(.caption) .font(.caption)
.foregroundStyle(.secondary) .foregroundStyle(.secondary)
} }
.padding(.vertical, 3) .padding(.vertical, 3)
}
.frame(maxWidth: .infinity)
}
VStack(alignment: .leading, spacing: 5) { Section {
Text("Information") HStack {
.font(.title2) Text("**Version**")
.bold() Spacer()
Text(game.version)
Text("**Version:** \(game.version)") .foregroundStyle(Color.secondary)
Text("**Title ID:** \(game.titleId)") }
HStack {
Text("**Title ID**")
.contextMenu { .contextMenu {
Button { Button {
UIPasteboard.general.string = game.titleId UIPasteboard.general.string = game.titleId
@ -60,15 +67,32 @@ struct GameInfoSheet: View {
Text("Copy Title ID") Text("Copy Title ID")
} }
} }
Text("**Game Size:** \(fetchFileSize(for: game.fileURL) ?? 0) bytes")
Text("**File Type:** .\(getFileType(game.fileURL))")
Text("**Game URL:** \(trimGameURL(game.fileURL))")
}
}
Spacer() Spacer()
Text(game.titleId)
.foregroundStyle(Color.secondary)
}
HStack {
Text("**Game Size**")
Spacer()
Text("\(fetchFileSize(for: game.fileURL) ?? 0) bytes")
.foregroundStyle(Color.secondary)
}
HStack {
Text("**File Type**")
Spacer()
Text(getFileType(game.fileURL))
.foregroundStyle(Color.secondary)
}
VStack(alignment: .leading, spacing: 4) {
Text("**Game URL**")
Text(trimGameURL(game.fileURL))
.foregroundStyle(Color.secondary)
}
} header: {
Text("Information")
}
.headerProminence(.increased)
} }
.padding(.horizontal, 5)
.navigationTitle(game.titleName) .navigationTitle(game.titleName)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.toolbar { .toolbar {
@ -103,10 +127,6 @@ struct GameInfoSheet: View {
} }
func getFileType(_ url: URL) -> String { func getFileType(_ url: URL) -> String {
let path = url.path url.pathExtension
if let range = path.range(of: ".") {
return String(path[range.upperBound...])
}
return "Unknown"
} }
} }