Mercurial > public > geoquiz
diff GeoQuiz/Components/AnswerButtonHelper.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/AnswerButton.swift@e09959b4e4a8 |
children | f140bb277c96 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GeoQuiz/Components/AnswerButtonHelper.swift Sat Oct 08 21:36:40 2022 +0200 @@ -0,0 +1,39 @@ +// +// AnswerButtonHelper.swift +// GeoQuiz +// +// Created by Dennis Concepción Martín on 14/9/22. +// + +import SwiftUI + +struct AnswerButton: View { + let optionName: String + let color: Color + + var body: some View { + RoundedRectangle(cornerRadius: 15) + .foregroundColor(.white) + .overlay( + Text(optionName) + .font(.title2.bold()) + .foregroundColor(color) + ) + } +} + +struct AnswerButton_Previews: PreviewProvider { + static var previews: some View { + ZStack { + LinearGradient(gradient: .main, startPoint: .top, endPoint: .bottom) + .ignoresSafeArea() + + VStack { + Spacer() + AnswerButton(optionName: "Madrid", color: .royalLightBlue) + .frame(height: 70) + } + .padding() + } + } +}