comparison 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
comparison
equal deleted inserted replaced
18:d20cf93c9812 19:f140bb277c96
7 7
8 import SwiftUI 8 import SwiftUI
9 9
10 struct LinkComponent: View { 10 struct LinkComponent: View {
11 var color: Color 11 var color: Color
12 var iconName: String 12 var symbol: String
13 var text: String 13 var text: String
14 var url: URL 14 var url: URL
15 15
16 @Environment(\.openURL) var openURL 16 @Environment(\.openURL) var openURL
17 17
18 var body: some View { 18 var body: some View {
19 Link(destination: url) { 19 Link(destination: url) {
20 HStack(alignment: .center, spacing: 20) { 20 HStack(alignment: .center, spacing: 20) {
21 Image(systemName: iconName) 21 Image(systemName: symbol)
22 .imageScale(.large) 22 .imageScale(.large)
23 .foregroundColor(color) 23 .foregroundColor(color)
24 24
25 Text(text) 25 Text(text)
26 .foregroundColor(.primary) 26 .foregroundColor(.primary)
31 31
32 struct LinkComponent_Previews: PreviewProvider { 32 struct LinkComponent_Previews: PreviewProvider {
33 static var previews: some View { 33 static var previews: some View {
34 LinkComponent( 34 LinkComponent(
35 color: .mayaBlue, 35 color: .mayaBlue,
36 iconName: "info.circle.fill", 36 symbol: "info.circle.fill",
37 text: "About", 37 text: "About",
38 url: URL(string: "https://dennistech.io")! 38 url: URL(string: "https://dennistech.io")!
39 ) 39 )
40 } 40 }
41 } 41 }