comparison 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
comparison
equal deleted inserted replaced
19:f140bb277c96 20:e281791e0494
1 //
2 // RecentGame.swift
3 // GeoQuiz
4 //
5 // Created by Dennis Concepción Martín on 19/10/22.
6 //
7
8 import SwiftUI
9
10 struct RecentGame: View {
11 let game: PlayedGame
12 let gameInfo: GameInfo
13
14 init(game: PlayedGame) {
15 self.game = game
16 self.gameInfo = GameInfoController.getInfo(for: game.type)
17 }
18
19 var body: some View {
20 HStack(alignment: .center, spacing: 15) {
21 RoundedRectangle(cornerRadius: 5)
22 .fill(
23 LinearGradient(
24 gradient: gameInfo.gradient,
25 startPoint: .top, endPoint: .bottom
26 )
27 )
28 .frame(width: 35, height: 35)
29 .overlay(
30 Image(systemName: gameInfo.symbol)
31 .font(.headline)
32 .foregroundColor(.white)
33 .padding(5)
34 )
35
36 VStack(alignment: .leading) {
37 Text(gameInfo.name)
38 .font(.headline)
39
40 Text("\(game.date ?? Date(), format: .dateTime)")
41 .font(.callout)
42 .foregroundColor(.secondary)
43 }
44
45 Spacer()
46
47 Text("\(game.score, format: .number) ⭐️")
48 .font(.headline)
49
50 }
51 }
52 }