diff LazyBear/Views/Global Helpers/StockItem.swift @ 375:f3cb5bdea8e5

Update Codable requests in HomeView
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Wed, 21 Apr 2021 16:19:50 +0200
parents eb97439e46cd
children a7e2c5a7b4f6
line wrap: on
line diff
--- a/LazyBear/Views/Global Helpers/StockItem.swift	Sat Apr 17 00:01:59 2021 +0200
+++ b/LazyBear/Views/Global Helpers/StockItem.swift	Wed Apr 21 16:19:50 2021 +0200
@@ -12,15 +12,16 @@
 }
 
 struct StockItem: View {
+    var symbol: String
     var company: QuoteModel
-    var intradayPrices: [IntradayPricesModel]?
+    var intradayPrices: [IntradayPriceModel]?
     var orientation: OrientationView
     
     var body: some View {
         if orientation == .vertical {
-            return AnyView(VerticalStockRow(company: company, intradayPrices: intradayPrices))
+            return AnyView(VerticalStockRow(symbol: symbol, company: company, intradayPrices: intradayPrices))
         } else {
-            return AnyView(HorizontalStockRow(company: company, intradayPrices: intradayPrices))
+            return AnyView(HorizontalStockRow(symbol: symbol, company: company, intradayPrices: intradayPrices))
         }
     }
 }
@@ -28,16 +29,17 @@
 struct StockItem_Previews: PreviewProvider {
     static var previews: some View {
         StockItem(
-            company: QuoteModel(companyName: "apple inc", symbol: "aapl", latestPrice: 130.3, changePercent: 0.03),
-            intradayPrices: [IntradayPricesModel(open: 130.3), IntradayPricesModel(open: 132.3)], orientation: .horizontal
+            symbol: "AAPL", company: QuoteModel(changePercent: 0.03, companyName: "apple inc", latestPrice: 130.3),
+            intradayPrices: [IntradayPriceModel(open: 130.3), IntradayPriceModel(open: 132.3)], orientation: .horizontal
         )
     }
 }
 
 
 struct VerticalStockRow: View {
+    var symbol: String
     var company: QuoteModel
-    var intradayPrices: [IntradayPricesModel]?
+    var intradayPrices: [IntradayPriceModel]?
     
     var body: some View {
         RoundedRectangle(cornerRadius: 20)
@@ -47,7 +49,7 @@
             .overlay(
                 VStack(alignment: .leading) {
                     Group {
-                        Text(company.symbol.uppercased())
+                        Text(symbol.uppercased())
                             .fontWeight(.semibold)
                             .padding(.top)
                         
@@ -80,13 +82,14 @@
 
 
 struct HorizontalStockRow: View {
+    var symbol: String
     var company: QuoteModel
-    var intradayPrices: [IntradayPricesModel]?
+    var intradayPrices: [IntradayPriceModel]?
     
     var body: some View {
         HStack {
             VStack(alignment: .leading) {
-                Text(company.symbol.uppercased())
+                Text(symbol.uppercased())
                     .fontWeight(.semibold)
                 
                 Text(company.companyName.capitalized)