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,45 +14,52 @@ struct GameInfoSheet: View {
var body: some View { var body: some View {
iOSNav { iOSNav {
VStack { List {
if let icon = game.icon { Section {}
Image(uiImage: icon) header: {
.resizable() VStack(alignment: .center) {
.aspectRatio(contentMode: .fit) if let icon = game.icon {
.frame(width: 250, height: 250) Image(uiImage: icon)
.cornerRadius(10) .resizable()
.padding() .aspectRatio(contentMode: .fit)
.contextMenu { .frame(width: 250, height: 250)
Button { .cornerRadius(10)
UIImageWriteToSavedPhotosAlbum(icon, nil, nil, nil) .padding()
} label: { .contextMenu {
Label("Save to Photos", systemImage: "square.and.arrow.down") Button {
} UIImageWriteToSavedPhotosAlbum(icon, nil, nil, nil)
} label: {
Label("Save to Photos", systemImage: "square.and.arrow.down")
}
}
} else {
Image(systemName: "questionmark.circle")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 150, height: 150)
.padding()
} }
} else { VStack(alignment: .center) {
Image(systemName: "questionmark.circle") Text("**\(game.titleName)** | \(game.titleId.capitalized)")
.resizable() .multilineTextAlignment(.center)
.aspectRatio(contentMode: .fit) Text(game.developer)
.frame(width: 150, height: 150) .font(.caption)
.padding() .foregroundStyle(.secondary)
}
.padding(.vertical, 3)
}
.frame(maxWidth: .infinity)
} }
VStack(alignment: .leading) { Section {
VStack(alignment: .leading) { HStack {
Text("**\(game.titleName)** | \(game.titleId.capitalized)") Text("**Version**")
Text(game.developer) Spacer()
.font(.caption) Text(game.version)
.foregroundStyle(.secondary) .foregroundStyle(Color.secondary)
} }
.padding(.vertical, 3) HStack {
Text("**Title ID**")
VStack(alignment: .leading, spacing: 5) {
Text("Information")
.font(.title2)
.bold()
Text("**Version:** \(game.version)")
Text("**Title ID:** \(game.titleId)")
.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") Spacer()
Text("**File Type:** .\(getFileType(game.fileURL))") Text(game.titleId)
Text("**Game URL:** \(trimGameURL(game.fileURL))") .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)
Spacer()
} }
.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"
} }
} }