Mercurial > public > geoquiz
diff GeoQuiz/Helpers/GameButton.swift @ 0:413e2d21333e
first commit
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Tue, 20 Sep 2022 08:13:26 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GeoQuiz/Helpers/GameButton.swift Tue Sep 20 08:13:26 2022 +0200 @@ -0,0 +1,64 @@ +// +// GameButton.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() + } + } +} + +struct PlayButton_Previews: PreviewProvider { + static var previews: some View { + GameButton( + gradient: Gradient(colors: [Color("MainDark"), Color("Main")]), + level: "Level 1", + symbol: "checkmark", + name: "Guess the flag" + ) + } +}