diff --git a/Zockerhoehle.xcodeproj/project.pbxproj b/Zockerhoehle.xcodeproj/project.pbxproj index e240ff3..252620f 100644 --- a/Zockerhoehle.xcodeproj/project.pbxproj +++ b/Zockerhoehle.xcodeproj/project.pbxproj @@ -42,6 +42,7 @@ B9EC0987238555BF004BC9AB /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9EC0986238555BF004BC9AB /* SettingsView.swift */; }; B9ED3DD7265534C000FD2D46 /* test_date_utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9ED3DD6265534C000FD2D46 /* test_date_utils.swift */; }; B9ED3DD9265D1E5600FD2D46 /* CDPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9ED3DD8265D1E5600FD2D46 /* CDPreview.swift */; }; + B9ED3DDB265D47EC00FD2D46 /* GameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9ED3DDA265D47EB00FD2D46 /* GameView.swift */; }; B9F44ABA22F312E600FC6B29 /* ConsoleLibraryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9F44AB922F312E600FC6B29 /* ConsoleLibraryView.swift */; }; B9F44ABE22F31DEF00FC6B29 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9F44ABD22F31DEF00FC6B29 /* SceneDelegate.swift */; }; /* End PBXBuildFile section */ @@ -110,6 +111,7 @@ B9EC0986238555BF004BC9AB /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = ""; }; B9ED3DD6265534C000FD2D46 /* test_date_utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = test_date_utils.swift; sourceTree = ""; }; B9ED3DD8265D1E5600FD2D46 /* CDPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CDPreview.swift; sourceTree = ""; }; + B9ED3DDA265D47EB00FD2D46 /* GameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameView.swift; sourceTree = ""; }; B9F44AB922F312E600FC6B29 /* ConsoleLibraryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsoleLibraryView.swift; sourceTree = ""; }; B9F44ABD22F31DEF00FC6B29 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -157,6 +159,7 @@ B9A0550222F8C2740054D9A0 /* MainView.swift */, B9EC0986238555BF004BC9AB /* SettingsView.swift */, B9839982233A086A002F9946 /* Overview.swift */, + B9ED3DDA265D47EB00FD2D46 /* GameView.swift */, ); path = Views; sourceTree = ""; @@ -398,6 +401,7 @@ B9E2A07E233B6E4F00EAEB14 /* ConsoleAllView.swift in Sources */, B9BCCEB92653BDEA005F46D6 /* ICloudManager.swift in Sources */, B9EC0987238555BF004BC9AB /* SettingsView.swift in Sources */, + B9ED3DDB265D47EC00FD2D46 /* GameView.swift in Sources */, B9ED3DD9265D1E5600FD2D46 /* CDPreview.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Zockerhoehle/Views/GamePickupsView.swift b/Zockerhoehle/Views/GamePickupsView.swift index 2e181eb..354ecf7 100644 --- a/Zockerhoehle/Views/GamePickupsView.swift +++ b/Zockerhoehle/Views/GamePickupsView.swift @@ -21,11 +21,19 @@ struct GamePickupsView: View { _games = FetchRequest(fetchRequest: gamesFR) } + let columns : [GridItem] = [ + GridItem(.adaptive(minimum: 100)) + ] + var body: some View { - List(games) { game in - NavigationLink(destination: GameDetailView(game: game)) { - Text("\(game.name)") - } + ScrollView { + LazyVGrid(columns: columns, spacing: 20) { + ForEach(games) { game in + NavigationLink(destination: GameDetailView(game: game)) { + GameView(game: game) + } + } + }.padding() } .padding(.top) // Workaround, damit die Liste beim scrollen nicht unter der NavigationView angezeigt wird .navigationBarTitle(Text("Zuletzt gehortete Spiele")) diff --git a/Zockerhoehle/Views/GameSeriesLibraryView.swift b/Zockerhoehle/Views/GameSeriesLibraryView.swift index 476187e..6345ca5 100644 --- a/Zockerhoehle/Views/GameSeriesLibraryView.swift +++ b/Zockerhoehle/Views/GameSeriesLibraryView.swift @@ -27,25 +27,19 @@ struct GameSeriesLibraryView: View { _games = FetchRequest(fetchRequest: gamesFR) } + let columns : [GridItem] = [ + GridItem(.adaptive(minimum: 100)) + ] + var body: some View { - List(games) { game in - NavigationLink(destination: GameDetailView(game: game)) { - Text("\(game.name)") - - if game.isDigital { - Image("digitalGame") - .resizable() - .aspectRatio(contentMode: .fit) - .frame(height: 15) + ScrollView { + LazyVGrid(columns: columns, spacing: 20) { + ForEach(games) { game in + NavigationLink(destination: GameDetailView(game: game)) { + GameView(game: game) + } } - - if game.inWishlist { - Image("wishlist") - .resizable() - .aspectRatio(contentMode: .fit) - .frame(height: 15) - } - } + }.padding() } .navigationBarTitle(Text(self.gameSeries.name ?? "n/a")) .navigationBarItems(trailing: @@ -56,3 +50,5 @@ struct GameSeriesLibraryView: View { .padding() } } + + diff --git a/Zockerhoehle/Views/GameView.swift b/Zockerhoehle/Views/GameView.swift new file mode 100644 index 0000000..08154f7 --- /dev/null +++ b/Zockerhoehle/Views/GameView.swift @@ -0,0 +1,36 @@ +// +// GameView.swift +// Zockerhoehle +// +// Created by Julian-Steffen Müller on 25.05.21. +// Copyright © 2021 Julian-Steffen Müller. All rights reserved. +// + +import Foundation +import SwiftUI + +struct GameView : View { + @ObservedObject var game : Game + + let defaultImage = UIImage() + + var body: some View { + 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) + } + } +} diff --git a/Zockerhoehle/Views/Overview.swift b/Zockerhoehle/Views/Overview.swift index 27beef0..4921516 100644 --- a/Zockerhoehle/Views/Overview.swift +++ b/Zockerhoehle/Views/Overview.swift @@ -57,6 +57,9 @@ struct Overview: View { @FetchRequest(entity: Game.entity(), sortDescriptors: [NSSortDescriptor(key: "createdAt", ascending: false), NSSortDescriptor(key: "name", ascending: true)]) var games: FetchedResults + @FetchRequest(entity: Game.entity(), sortDescriptors: [NSSortDescriptor(key: "finishedDate", ascending: false), NSSortDescriptor(key: "name", ascending: true)]) + var gamesFinished: FetchedResults + @FetchRequest(entity: Console.entity(), sortDescriptors: [NSSortDescriptor(key: "name", ascending: true)]) var consoles: FetchedResults @@ -115,10 +118,37 @@ struct Overview: View { NavigationLink(destination: GameDetailView(game: game)) { VStack(alignment: .leading) { Group { - Image(uiImage: ICloudManager.imageFrom(path: game.cover_icloud_path) ?? defaultImage) - .resizable() - .aspectRatio(contentMode: .fit) - .cornerRadius(5) + GameView(game: game) + } + .frame(width: 100, height: 100) + + Text("\(game.name)") + .font(.caption) + .frame(width: 100) + + }.padding(.leading, 15) + }.buttonStyle(PlainButtonStyle()) + } + }.padding(.trailing, 15) + } + } + } + } + + var GamesFinished : some View { + VStack(alignment: .leading) { + OverviewHeader(title: "Zuletzt durchgezockt", destination: GamePickupsView()) + + if gamesFinished.count == 0 { + EmptyCategory("Keine Spiele in der Zockerhöhle") + }else { + ScrollView(.horizontal, showsIndicators: false) { + HStack(alignment: .top, spacing: 0) { + ForEach(gamesFinished.prefix(last_picksups_limit).filter({$0.isFinished})) { game in + NavigationLink(destination: GameDetailView(game: game)) { + VStack(alignment: .leading) { + Group { + GameView(game: game) } .frame(width: 100, height: 100) @@ -168,49 +198,16 @@ struct Overview: View { } } - /*var featured : some View { - VStack(alignment: .leading) { - HStack { - Text("Gerade Aktuell") - .font(.headline) - .padding(.leading, 15) - .padding(.top, 5) - Spacer() - } - HStack { - Spacer() - if featuredStore.featuredConsole != nil { - NavigationLink(destination: ConsoleLibraryView(console: featuredStore.featuredConsole!)) { - if ICloudManager.fileExists(at: featuredStore.featuredConsole?.logo_icloud_path) { - Image(uiImage: ICloudManager.imageFrom(path: featuredStore.featuredConsole?.logo_icloud_path) ?? defaultImage) - .resizable() - .padding(10) - .cornerRadius(5) - }else{ - //TODO: Symbol für fehlendes Bild - Image(systemName: "cave").frame(width: 200, height: 200) - } - }.buttonStyle(PlainButtonStyle()) - }else { - EmptyCategory("Nichts aktuelles :(") - } - Spacer() - } - - } - }*/ - var body: some View { NavigationView { ScrollView(.vertical, showsIndicators: true) { VStack { - ////featured - //Text("TODO FEATURED") - //Divider() ConsolesOverview Divider() GamesOverview Divider() + GamesFinished + Divider() GameSeriesOverview }.navigationBarTitle("Zockerhöhle") }.navigationBarItems(trailing: