Mercurial > public > geoquiz
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GeoQuiz/Components/GameButtonHelper.swift Sat Oct 08 21:36:40 2022 +0200 @@ -0,0 +1,65 @@ +// +// GameButtonHelper.swift +// GeoQuiz +// +// Created by Dennis Concepción Martín on 5/9/22. +// + +import SwiftUI + +struct GameButton: View { + let gradient: Gradient + let level: String + let symbol: String + let name: String + + var body: some View { + ZStack { + RoundedRectangle(cornerRadius: 20) + .fill( + LinearGradient( + gradient: gradient, + startPoint: .trailing, endPoint: .leading + ) + ) + .frame(height: 180) + + VStack(alignment: .leading) { + HStack { + Image(systemName: symbol) + .font(.headline) + .padding(5) + .background( + RoundedRectangle(cornerRadius: 5) + .stroke(lineWidth: 1.5) + ) + + Spacer() + } + .padding(.bottom) + + VStack(alignment: .leading, spacing: 5) { + Text(level) + .font(.callout) + + Text(name) + .font(.title.bold()) + } + } + .foregroundColor(.white) + .padding() + } + .frame(maxWidth: 700) + } +} + +struct GameButton_Previews: PreviewProvider { + static var previews: some View { + GameButton( + gradient: .main, + level: "Level 1", + symbol: "checkmark", + name: "Guess the flag" + ) + } +}