diff GeoQuiz/Components/RecentGame.swift @ 20:e281791e0494

finish implementation
author Dennis C. M. <dennis@denniscm.com>
date Sun, 23 Oct 2022 11:48:39 +0100
parents GeoQuiz/Components/RecentGameHelper.swift@f140bb277c96
children b145c408f791
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GeoQuiz/Components/RecentGame.swift	Sun Oct 23 11:48:39 2022 +0100
@@ -0,0 +1,52 @@
+//
+//  RecentGame.swift
+//  GeoQuiz
+//
+//  Created by Dennis Concepción Martín on 19/10/22.
+//
+
+import SwiftUI
+
+struct RecentGame: View {
+    let game: PlayedGame
+    let gameInfo: GameInfo
+    
+    init(game: PlayedGame) {
+        self.game = game
+        self.gameInfo = GameInfoController.getInfo(for: game.type)
+    }
+    
+    var body: some View {
+        HStack(alignment: .center, spacing: 15) {
+            RoundedRectangle(cornerRadius: 5)
+                .fill(
+                    LinearGradient(
+                        gradient: gameInfo.gradient,
+                        startPoint: .top, endPoint: .bottom
+                    )
+                )
+                .frame(width: 35, height: 35)
+                .overlay(
+                    Image(systemName: gameInfo.symbol)
+                        .font(.headline)
+                        .foregroundColor(.white)
+                        .padding(5)
+                )
+            
+            VStack(alignment: .leading) {
+                Text(gameInfo.name)
+                    .font(.headline)
+                
+                Text("\(game.date ?? Date(), format: .dateTime)")
+                    .font(.callout)
+                    .foregroundColor(.secondary)
+            }
+            
+            Spacer()
+            
+            Text("\(game.score, format: .number) ⭐️")
+                .font(.headline)
+            
+        }
+    }
+}