Added GameView and used it in Overview last pickups, latest finishings and game series games view.

This commit is contained in:
2021-05-25 17:46:49 +02:00
parent 4cf7e520a1
commit 3e369f6c28
5 changed files with 101 additions and 60 deletions

View File

@@ -42,6 +42,7 @@
B9EC0987238555BF004BC9AB /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9EC0986238555BF004BC9AB /* SettingsView.swift */; }; 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 */; }; 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 */; }; 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 */; }; B9F44ABA22F312E600FC6B29 /* ConsoleLibraryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9F44AB922F312E600FC6B29 /* ConsoleLibraryView.swift */; };
B9F44ABE22F31DEF00FC6B29 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9F44ABD22F31DEF00FC6B29 /* SceneDelegate.swift */; }; B9F44ABE22F31DEF00FC6B29 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9F44ABD22F31DEF00FC6B29 /* SceneDelegate.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
@@ -110,6 +111,7 @@
B9EC0986238555BF004BC9AB /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; }; B9EC0986238555BF004BC9AB /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
B9ED3DD6265534C000FD2D46 /* test_date_utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = test_date_utils.swift; sourceTree = "<group>"; }; B9ED3DD6265534C000FD2D46 /* test_date_utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = test_date_utils.swift; sourceTree = "<group>"; };
B9ED3DD8265D1E5600FD2D46 /* CDPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CDPreview.swift; sourceTree = "<group>"; }; B9ED3DD8265D1E5600FD2D46 /* CDPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CDPreview.swift; sourceTree = "<group>"; };
B9ED3DDA265D47EB00FD2D46 /* GameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameView.swift; sourceTree = "<group>"; };
B9F44AB922F312E600FC6B29 /* ConsoleLibraryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsoleLibraryView.swift; sourceTree = "<group>"; }; B9F44AB922F312E600FC6B29 /* ConsoleLibraryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsoleLibraryView.swift; sourceTree = "<group>"; };
B9F44ABD22F31DEF00FC6B29 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; }; B9F44ABD22F31DEF00FC6B29 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@@ -157,6 +159,7 @@
B9A0550222F8C2740054D9A0 /* MainView.swift */, B9A0550222F8C2740054D9A0 /* MainView.swift */,
B9EC0986238555BF004BC9AB /* SettingsView.swift */, B9EC0986238555BF004BC9AB /* SettingsView.swift */,
B9839982233A086A002F9946 /* Overview.swift */, B9839982233A086A002F9946 /* Overview.swift */,
B9ED3DDA265D47EB00FD2D46 /* GameView.swift */,
); );
path = Views; path = Views;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -398,6 +401,7 @@
B9E2A07E233B6E4F00EAEB14 /* ConsoleAllView.swift in Sources */, B9E2A07E233B6E4F00EAEB14 /* ConsoleAllView.swift in Sources */,
B9BCCEB92653BDEA005F46D6 /* ICloudManager.swift in Sources */, B9BCCEB92653BDEA005F46D6 /* ICloudManager.swift in Sources */,
B9EC0987238555BF004BC9AB /* SettingsView.swift in Sources */, B9EC0987238555BF004BC9AB /* SettingsView.swift in Sources */,
B9ED3DDB265D47EC00FD2D46 /* GameView.swift in Sources */,
B9ED3DD9265D1E5600FD2D46 /* CDPreview.swift in Sources */, B9ED3DD9265D1E5600FD2D46 /* CDPreview.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;

View File

@@ -21,11 +21,19 @@ struct GamePickupsView: View {
_games = FetchRequest(fetchRequest: gamesFR) _games = FetchRequest(fetchRequest: gamesFR)
} }
let columns : [GridItem] = [
GridItem(.adaptive(minimum: 100))
]
var body: some View { var body: some View {
List(games) { game in ScrollView {
NavigationLink(destination: GameDetailView(game: game)) { LazyVGrid(columns: columns, spacing: 20) {
Text("\(game.name)") 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 .padding(.top) // Workaround, damit die Liste beim scrollen nicht unter der NavigationView angezeigt wird
.navigationBarTitle(Text("Zuletzt gehortete Spiele")) .navigationBarTitle(Text("Zuletzt gehortete Spiele"))

View File

@@ -27,25 +27,19 @@ struct GameSeriesLibraryView: View {
_games = FetchRequest(fetchRequest: gamesFR) _games = FetchRequest(fetchRequest: gamesFR)
} }
let columns : [GridItem] = [
GridItem(.adaptive(minimum: 100))
]
var body: some View { var body: some View {
List(games) { game in ScrollView {
NavigationLink(destination: GameDetailView(game: game)) { LazyVGrid(columns: columns, spacing: 20) {
Text("\(game.name)") ForEach(games) { game in
NavigationLink(destination: GameDetailView(game: game)) {
if game.isDigital { GameView(game: game)
Image("digitalGame") }
.resizable()
.aspectRatio(contentMode: .fit)
.frame(height: 15)
} }
}.padding()
if game.inWishlist {
Image("wishlist")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(height: 15)
}
}
} }
.navigationBarTitle(Text(self.gameSeries.name ?? "n/a")) .navigationBarTitle(Text(self.gameSeries.name ?? "n/a"))
.navigationBarItems(trailing: .navigationBarItems(trailing:
@@ -56,3 +50,5 @@ struct GameSeriesLibraryView: View {
.padding() .padding()
} }
} }

View File

@@ -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)
}
}
}

View File

@@ -57,6 +57,9 @@ struct Overview: View {
@FetchRequest(entity: Game.entity(), sortDescriptors: [NSSortDescriptor(key: "createdAt", ascending: false), NSSortDescriptor(key: "name", ascending: true)]) @FetchRequest(entity: Game.entity(), sortDescriptors: [NSSortDescriptor(key: "createdAt", ascending: false), NSSortDescriptor(key: "name", ascending: true)])
var games: FetchedResults<Game> var games: FetchedResults<Game>
@FetchRequest(entity: Game.entity(), sortDescriptors: [NSSortDescriptor(key: "finishedDate", ascending: false), NSSortDescriptor(key: "name", ascending: true)])
var gamesFinished: FetchedResults<Game>
@FetchRequest(entity: Console.entity(), sortDescriptors: [NSSortDescriptor(key: "name", ascending: true)]) @FetchRequest(entity: Console.entity(), sortDescriptors: [NSSortDescriptor(key: "name", ascending: true)])
var consoles: FetchedResults<Console> var consoles: FetchedResults<Console>
@@ -115,10 +118,37 @@ struct Overview: View {
NavigationLink(destination: GameDetailView(game: game)) { NavigationLink(destination: GameDetailView(game: game)) {
VStack(alignment: .leading) { VStack(alignment: .leading) {
Group { Group {
Image(uiImage: ICloudManager.imageFrom(path: game.cover_icloud_path) ?? defaultImage) GameView(game: game)
.resizable() }
.aspectRatio(contentMode: .fit) .frame(width: 100, height: 100)
.cornerRadius(5)
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) .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 { var body: some View {
NavigationView { NavigationView {
ScrollView(.vertical, showsIndicators: true) { ScrollView(.vertical, showsIndicators: true) {
VStack { VStack {
////featured
//Text("TODO FEATURED")
//Divider()
ConsolesOverview ConsolesOverview
Divider() Divider()
GamesOverview GamesOverview
Divider() Divider()
GamesFinished
Divider()
GameSeriesOverview GameSeriesOverview
}.navigationBarTitle("Zockerhöhle") }.navigationBarTitle("Zockerhöhle")
}.navigationBarItems(trailing: }.navigationBarItems(trailing: