Mercurial > public > geoquiz
comparison GeoQuiz/Helpers/RecentGame.swift @ 26:425078c01194
refactor code
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Wed, 09 Nov 2022 10:30:01 +0100 |
parents | GeoQuiz/Components/RecentGame.swift@56add5561261 |
children |
comparison
equal
deleted
inserted
replaced
25:b3df0f5dc750 | 26:425078c01194 |
---|---|
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 = GameInfoModel.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.day().month().year())") | |
41 .font(.callout) | |
42 .foregroundColor(.secondary) | |
43 } | |
44 | |
45 Spacer() | |
46 | |
47 Text("\(game.score, format: .number) ⭐️") | |
48 .font(.headline) | |
49 } | |
50 } | |
51 } |