Added realse and pickup dates. Games no Always go to DetailView and not editmode

This commit is contained in:
2021-06-24 16:23:09 +02:00
parent 87dbc9d1da
commit 2b5615f3fa
8 changed files with 1396 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
{
"data" : [
{
"filename" : "libExp_2021-05-20T16:53:25+0200.json",
"filename" : "libExp_2021-05-27T20:52:02+0200.json",
"idiom" : "universal",
"universal-type-identifier" : "public.json"
}

File diff suppressed because one or more lines are too long

View File

@@ -14,6 +14,7 @@ import SwiftUI
@objc(Game)
public class Game: NSManagedObject, Identifiable {
public static func compareByCreationDate(gameA : Game, gameB : Game) -> Bool {
return gameA.releaseDate < gameB.releaseDate
}
@@ -61,6 +62,8 @@ extension Game : Encodable {
try container.encode(pickupDate.formattedInTimeZone(), forKey: .pickupDate)
}
try container.encode(pickupDescription ?? "", forKey: .pickupDescription)
try container.encode(publisher ?? "", forKey: .publisher)
try container.encode(isFinished, forKey: .isFinished)
try container.encode(finishedDate, forKey: .finishedDate)

View File

@@ -17,7 +17,6 @@ extension Game {
return NSFetchRequest<Game>(entityName: "Game")
}
@NSManaged public var circumstances: String?
@NSManaged public var releaseDate : Date
@NSManaged public var pickupDate: Date?
@NSManaged public var pickupDescription : String?

View File

@@ -78,6 +78,11 @@ class LibraryImport {
}
}
private func noneIfEmpty(_ str : String?) -> String? {
if str == "" { return .none }
return str
}
private func makeCDGame(from game: BHLGame, _ gameDict: inout [UUID : Game], _ cdConsole: Console) {
let cdGame = Game(context: self.CDContext)
gameDict[game.uuid] = cdGame
@@ -88,7 +93,8 @@ class LibraryImport {
cdGame.finishedDate = game.finishedDate
cdGame.lentTo = game.lentTo
cdGame.cover_icloud_path = game.cover_icloud_path
cdGame.pickupDescription = game.pickupDescription
cdGame.notes = noneIfEmpty(game.notes)
cdGame.pickupDescription = noneIfEmpty(game.pickupDescription)
cdGame.isDigital = game.isDigital
cdGame.playtime_h = game.playtime_h ?? 0
cdGame.playtime_min = game.playtime_min ?? 0

View File

@@ -55,6 +55,7 @@ struct GameView : View {
}
}
var body: some View {
ScrollView {
VStack {
@@ -87,10 +88,15 @@ struct GameView : View {
}
.padding(.vertical)
HeadlinedMultilineText(headline: "Notizen", multilineText: "Ganz toller multiline\nText")
.padding(.bottom)
if game.notes != .none {
HeadlinedMultilineText(headline: "Notizen", multilineText: game.notes ?? "n/a")
.padding(.bottom)
}
if game.pickupDescription != .none {
HeadlinedMultilineText(headline: "Hinter den Kulissen", multilineText: game.pickupDescription ?? "n/a")
}
HeadlinedMultilineText(headline: "Hinter den Kulissen", multilineText: "Ich habe für das Spiel bei MCMedia Games angestanden")
Spacer()
}
@@ -144,7 +150,7 @@ struct GameDetailView : View {
Button(action: {
isInEditMode.toggle()
},
label: { Image(systemName: "plus")})
label: { Image(systemName: "wrench.fill")})
}
}
}

View File

@@ -115,7 +115,7 @@ struct Overview: View {
ScrollView(.horizontal, showsIndicators: false) {
HStack(alignment: .top, spacing: 0) {
ForEach(games.prefix(last_picksups_limit)) { game in
NavigationLink(destination: GameEditMode(game: game)) {
NavigationLink(destination: GameDetailView(game: game)) {
VStack(alignment: .leading) {
Group {
GameCover(game: game)
@@ -145,7 +145,7 @@ struct Overview: View {
ScrollView(.horizontal, showsIndicators: false) {
HStack(alignment: .top, spacing: 0) {
ForEach(gamesFinished.prefix(last_picksups_limit).filter({$0.isFinished})) { game in
NavigationLink(destination: GameEditMode(game: game)) {
NavigationLink(destination: GameDetailView(game: game)) {
VStack(alignment: .leading) {
Group {
GameCover(game: game)