Changed console library game view to lazy gridview
This commit is contained in:
@@ -32,6 +32,7 @@ class ICloudManager {
|
||||
|
||||
static public func fileExists(at path : String?) -> Bool {
|
||||
guard let path = path else { return false }
|
||||
if path == "" { return false }
|
||||
|
||||
if let url = documents_folder?.appendingPathComponent(path) {
|
||||
return FileManager.default.fileExists(atPath: url.path)
|
||||
|
||||
@@ -95,6 +95,12 @@ struct ConsoleLibraryView : View {
|
||||
self.accessoryFetchRequest = FetchRequest<Accessory>(entity: Accessory.entity(), sortDescriptors: [NSSortDescriptor(key: "name", ascending: true)], predicate: NSPredicate(format: "console == %@", console))
|
||||
}
|
||||
|
||||
let columns : [GridItem] = [
|
||||
GridItem(.adaptive(minimum: 100))
|
||||
]
|
||||
|
||||
let defaultImage = UIImage()
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
HStack {
|
||||
@@ -107,19 +113,38 @@ struct ConsoleLibraryView : View {
|
||||
Spacer()
|
||||
}
|
||||
if self.isVideogamesSelected {
|
||||
List(games.filter({$0.inWishlist == self.showWishlist})) { game in
|
||||
NavigationLink(destination: GameDetailView(game: game)) {
|
||||
HStack {
|
||||
Text("\(game.name ?? "n/a")")
|
||||
|
||||
if game.isDigital {
|
||||
Image("digitalGame")
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(height: 15)
|
||||
ScrollView {
|
||||
LazyVGrid(columns: columns, spacing: 20) {
|
||||
ForEach(games.filter({$0.inWishlist == self.showWishlist})) { game in
|
||||
NavigationLink(destination: GameDetailView(game: game)) {
|
||||
if ICloudManager.fileExists(at: game.cover_icloud_path) {
|
||||
Image(uiImage: ICloudManager.imageFrom(path: game.cover_icloud_path) ?? defaultImage)
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.cornerRadius(5)
|
||||
}else{
|
||||
Group {
|
||||
Text(game.name)
|
||||
.font(.caption)
|
||||
.foregroundColor(Color.black)
|
||||
.padding()
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(Color.gray)
|
||||
.cornerRadius(5)
|
||||
}
|
||||
|
||||
|
||||
// if game.isDigital {
|
||||
// Image("digitalGame")
|
||||
// .resizable()
|
||||
// .aspectRatio(contentMode: .fit)
|
||||
// .frame(height: 15)
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}.padding()
|
||||
}
|
||||
}else {
|
||||
List(accessories.filter({$0.inWishlist == self.showWishlist})) {accessory in
|
||||
|
||||
@@ -91,7 +91,7 @@ struct Overview: View {
|
||||
|
||||
Text("\(console.name)")
|
||||
.font(.caption)
|
||||
.frame(width: 100)
|
||||
.frame(width: 100)
|
||||
|
||||
}.padding(.leading, 15)
|
||||
}.buttonStyle(PlainButtonStyle())
|
||||
|
||||
Reference in New Issue
Block a user