diff GeoQuiz/Components/ProgressBarHelper.swift @ 16:1011e56b7832

implement user profile
author Dennis C. M. <dennis@denniscm.com>
date Thu, 20 Oct 2022 13:49:42 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GeoQuiz/Components/ProgressBarHelper.swift	Thu Oct 20 13:49:42 2022 +0200
@@ -0,0 +1,38 @@
+//
+//  ProgressBarHelper.swift
+//  GeoQuiz
+//
+//  Created by Dennis Concepción Martín on 20/10/22.
+//
+
+import SwiftUI
+
+struct ProgressBar: View {
+    let pctScore: Double
+    let gradient: Gradient
+    
+    var body: some View {
+        GeometryReader { geo in
+            ZStack(alignment: .leading) {
+                Capsule()
+                    .foregroundColor(.customBackground)
+                    .frame(height: 6)
+                
+                Capsule()
+                    .fill(
+                        LinearGradient(
+                            gradient: gradient,
+                            startPoint: .trailing, endPoint: .leading
+                        )
+                    )
+                    .frame(width: geo.size.width * pctScore, height: 6)
+            }
+        }
+    }
+}
+
+struct ProgressBar_Previews: PreviewProvider {
+    static var previews: some View {
+        ProgressBar(pctScore: 0.3, gradient: .main)
+    }
+}