comparison GeoQuiz/Components/LinkHelper.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/LinkComponent.swift@3540c7efc216
children f140bb277c96
comparison
equal deleted inserted replaced
9:3540c7efc216 10:a793f33f05fb
1 //
2 // LinkHelper.swift
3 // GeoQuiz
4 //
5 // Created by Dennis Concepción Martín on 7/10/22.
6 //
7
8 import SwiftUI
9
10 struct LinkComponent: View {
11 var color: Color
12 var iconName: String
13 var text: String
14 var url: URL
15
16 @Environment(\.openURL) var openURL
17
18 var body: some View {
19 Link(destination: url) {
20 HStack(alignment: .center, spacing: 20) {
21 Image(systemName: iconName)
22 .imageScale(.large)
23 .foregroundColor(color)
24
25 Text(text)
26 .foregroundColor(.primary)
27 }
28 }
29 }
30 }
31
32 struct LinkComponent_Previews: PreviewProvider {
33 static var previews: some View {
34 LinkComponent(
35 color: .mayaBlue,
36 iconName: "info.circle.fill",
37 text: "About",
38 url: URL(string: "https://dennistech.io")!
39 )
40 }
41 }