diff GeoQuiz/Helpers/FormLink.swift @ 26:425078c01194

refactor code
author Dennis C. M. <dennis@denniscm.com>
date Wed, 09 Nov 2022 10:30:01 +0100
parents GeoQuiz/Components/FormLink.swift@e281791e0494
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GeoQuiz/Helpers/FormLink.swift	Wed Nov 09 10:30:01 2022 +0100
@@ -0,0 +1,41 @@
+//
+//  FormLink.swift
+//  GeoQuiz
+//
+//  Created by Dennis Concepción Martín on 7/10/22.
+//
+
+import SwiftUI
+
+struct FormLink: View {
+    var color: Color
+    var symbol: String
+    var text: String
+    var url: URL
+    
+    @Environment(\.openURL) var openURL
+    
+    var body: some View {
+        Link(destination: url) {
+            HStack(alignment: .center, spacing: 20) {
+                Image(systemName: symbol)
+                    .imageScale(.large)
+                    .foregroundColor(color)
+                
+                Text(text)
+                    .foregroundColor(.primary)
+            }
+        }
+    }
+}
+
+struct FormLink_Previews: PreviewProvider {
+    static var previews: some View {
+        FormLink(
+            color: .mayaBlue,
+            symbol: "info.circle.fill",
+            text: "About",
+            url: URL(string: "https://dennistech.io")!
+        )
+    }
+}