view GeoQuiz/Components/PlayedGamesList.swift @ 20:e281791e0494

finish implementation
author Dennis C. M. <dennis@denniscm.com>
date Sun, 23 Oct 2022 11:48:39 +0100
parents
children b145c408f791
line wrap: on
line source

//
//  PlayedGamesList.swift
//  GeoQuiz
//
//  Created by Dennis Concepción Martín on 23/10/22.
//

import SwiftUI

struct PlayedGamesList: View {
    var playedGames: FetchedResults<PlayedGame>
    
    @Environment(\.managedObjectContext) var moc
    
    var body: some View {
        List {
            ForEach(playedGames, id: \.id) { game in
                RecentGame(game: game)
            }
            .onDelete { indexSet in
                CoreDataController.deleteGame(at: indexSet, from: playedGames, with: moc)
            }
        }
        .navigationTitle("Played games")
        .navigationBarTitleDisplayMode(.inline)
        .toolbar {
            EditButton()
        }
    }
}