Mercurial > public > geoquiz
annotate GeoQuiz/Components/LinkHelper.swift @ 19:f140bb277c96
refactor code
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Sun, 23 Oct 2022 00:11:38 +0100 |
parents | a793f33f05fb |
children |
rev | line source |
---|---|
9 | 1 // |
10
a793f33f05fb
refactor code and fix layout
Dennis C. M. <dennis@denniscm.com>
parents:
9
diff
changeset
|
2 // LinkHelper.swift |
9 | 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 | |
19 | 12 var symbol: String |
9 | 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) { | |
19 | 21 Image(systemName: symbol) |
9 | 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, | |
19 | 36 symbol: "info.circle.fill", |
9 | 37 text: "About", |
38 url: URL(string: "https://dennistech.io")! | |
39 ) | |
40 } | |
41 } |