comparison GeoQuiz/Components/GameButtonHelper.swift @ 10:a793f33f05fb

refactor code and fix layout
author Dennis C. M. <dennis@denniscm.com>
date Sat, 08 Oct 2022 21:36:40 +0200
parents GeoQuiz/Helpers/GameButton.swift@413e2d21333e
children 039b26a99a48
comparison
equal deleted inserted replaced
9:3540c7efc216 10:a793f33f05fb
1 //
2 // GameButtonHelper.swift
3 // GeoQuiz
4 //
5 // Created by Dennis Concepción Martín on 5/9/22.
6 //
7
8 import SwiftUI
9
10 struct GameButton: View {
11 let gradient: Gradient
12 let level: String
13 let symbol: String
14 let name: String
15
16 var body: some View {
17 ZStack {
18 RoundedRectangle(cornerRadius: 20)
19 .fill(
20 LinearGradient(
21 gradient: gradient,
22 startPoint: .trailing, endPoint: .leading
23 )
24 )
25 .frame(height: 180)
26
27 VStack(alignment: .leading) {
28 HStack {
29 Image(systemName: symbol)
30 .font(.headline)
31 .padding(5)
32 .background(
33 RoundedRectangle(cornerRadius: 5)
34 .stroke(lineWidth: 1.5)
35 )
36
37 Spacer()
38 }
39 .padding(.bottom)
40
41 VStack(alignment: .leading, spacing: 5) {
42 Text(level)
43 .font(.callout)
44
45 Text(name)
46 .font(.title.bold())
47 }
48 }
49 .foregroundColor(.white)
50 .padding()
51 }
52 .frame(maxWidth: 700)
53 }
54 }
55
56 struct GameButton_Previews: PreviewProvider {
57 static var previews: some View {
58 GameButton(
59 gradient: .main,
60 level: "Level 1",
61 symbol: "checkmark",
62 name: "Guess the flag"
63 )
64 }
65 }