16
|
1 //
|
|
2 // RecentGameHelper.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
|
19
|
12 let gameInfo: GameInfo
|
|
13
|
|
14 init(game: PlayedGame) {
|
|
15 self.game = game
|
|
16 self.gameInfo = GameInfoController.getInfo(for: game.type)
|
|
17 }
|
16
|
18
|
|
19 var body: some View {
|
|
20 HStack(alignment: .center, spacing: 15) {
|
|
21 RoundedRectangle(cornerRadius: 5)
|
|
22 .fill(
|
|
23 LinearGradient(
|
19
|
24 gradient: gameInfo.gradient,
|
16
|
25 startPoint: .top, endPoint: .bottom
|
|
26 )
|
|
27 )
|
|
28 .frame(width: 35, height: 35)
|
|
29 .overlay(
|
19
|
30 Image(systemName: gameInfo.symbol)
|
16
|
31 .font(.headline)
|
|
32 .foregroundColor(.white)
|
|
33 .padding(5)
|
|
34 )
|
|
35
|
|
36 VStack(alignment: .leading) {
|
19
|
37 Text(gameInfo.name)
|
16
|
38 .font(.headline)
|
|
39
|
|
40 Text("\(game.date, format: .dateTime)")
|
|
41 .font(.callout)
|
|
42 .foregroundColor(.secondary)
|
|
43 }
|
|
44
|
|
45 Spacer()
|
|
46
|
|
47 Text("\(game.score, format: .number) ⭐️")
|
17
|
48 .font(.headline)
|
16
|
49
|
|
50 }
|
19
|
51 .padding()
|
|
52 .background(Color(.secondarySystemGroupedBackground))
|
|
53 .cornerRadius(20)
|
16
|
54 }
|
|
55 }
|