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 {
|
static public func fileExists(at path : String?) -> Bool {
|
||||||
guard let path = path else { return false }
|
guard let path = path else { return false }
|
||||||
|
if path == "" { return false }
|
||||||
|
|
||||||
if let url = documents_folder?.appendingPathComponent(path) {
|
if let url = documents_folder?.appendingPathComponent(path) {
|
||||||
return FileManager.default.fileExists(atPath: url.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))
|
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 {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
HStack {
|
HStack {
|
||||||
@@ -107,19 +113,38 @@ struct ConsoleLibraryView : View {
|
|||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
if self.isVideogamesSelected {
|
if self.isVideogamesSelected {
|
||||||
List(games.filter({$0.inWishlist == self.showWishlist})) { game in
|
ScrollView {
|
||||||
|
LazyVGrid(columns: columns, spacing: 20) {
|
||||||
|
ForEach(games.filter({$0.inWishlist == self.showWishlist})) { game in
|
||||||
NavigationLink(destination: GameDetailView(game: game)) {
|
NavigationLink(destination: GameDetailView(game: game)) {
|
||||||
HStack {
|
if ICloudManager.fileExists(at: game.cover_icloud_path) {
|
||||||
Text("\(game.name ?? "n/a")")
|
Image(uiImage: ICloudManager.imageFrom(path: game.cover_icloud_path) ?? defaultImage)
|
||||||
|
|
||||||
if game.isDigital {
|
|
||||||
Image("digitalGame")
|
|
||||||
.resizable()
|
.resizable()
|
||||||
.aspectRatio(contentMode: .fit)
|
.scaledToFit()
|
||||||
.frame(height: 15)
|
.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 {
|
}else {
|
||||||
List(accessories.filter({$0.inWishlist == self.showWishlist})) {accessory in
|
List(accessories.filter({$0.inWishlist == self.showWishlist})) {accessory in
|
||||||
|
|||||||
Reference in New Issue
Block a user