changeset 56:de12e60753be

Fix units StockCharts
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Wed, 20 Jan 2021 11:46:55 +0100
parents 4dd944509d42
children fa7df6b161f4
files LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate lazybear/Supply views/StockStats.swift
diffstat 2 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/lazybear/Supply views/StockStats.swift	Wed Jan 20 11:39:33 2021 +0100
+++ b/lazybear/Supply views/StockStats.swift	Wed Jan 20 11:46:55 2021 +0100
@@ -37,24 +37,27 @@
     @State var type: String
     
     var body: some View {
+        let units = unit()
         RoundedRectangle(cornerRadius: 25)
             .foregroundColor(.white)
             .overlay(
-                Text("\(unit()) \(data, specifier: "%.2f")")
+                Text("\(units.0) \(data, specifier: "%.2f") \(units.1)")
                     .foregroundColor(colour)
                     .dataModifier()
-                
-                //Text("TOTAL: $\(totalPrice, specifier: "%.2f")")
             )
     }
     
-    func unit() -> String {
+    func unit() -> (String, String) {
+        var dollar = ""
+        var pct = ""
         if type == "price" {
-            return "$ "
+            dollar = "$"
         }
-        else {
-            return ""
+        else if type == "daily percentage change" {
+            pct = "%"
         }
+        
+        return (dollar, pct)
     }
 }
 extension Text {