changeset 222:031e4e513ffc

Implement colour row
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Sun, 28 Feb 2021 13:12:27 +0000
parents f83d3f2d5e1a
children 05d1acc290ad
files LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate LazyBear/UI/Search.swift LazyBear/UI/Watchlist.swift
diffstat 3 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/LazyBear/UI/Search.swift	Sun Feb 28 13:12:18 2021 +0000
+++ b/LazyBear/UI/Search.swift	Sun Feb 28 13:12:27 2021 +0000
@@ -15,11 +15,15 @@
     
     var body: some View {
         NavigationView {
-            List(filterList(), id: \.symbol) { company in
-                NavigationLink(destination: CompanyView(hudManager: hudManager, name: company.securityName ?? "-", symbol: company.symbol)
-                                .navigationTitle(company.symbol)
+            let colorNumber = ["1", "2", "3", "4", "5"]
+            let list = filterList()
+            List(list.indices, id: \.self) { i in
+                let name = list[i].securityName ?? "-"
+                let symbol = list[i].symbol
+                NavigationLink(destination: CompanyView(hudManager: hudManager, name: name, symbol: symbol)
+                                .navigationTitle(symbol)
                 ) {
-                    CompanyRow(symbol: company.symbol, name: company.securityName ?? "-", rowNumber: 1)
+                    CompanyRow(symbol: symbol, name: name, rowNumber: i % colorNumber.count)
                 }
             }
             .navigationBarSearch(self.$company)
--- a/LazyBear/UI/Watchlist.swift	Sun Feb 28 13:12:18 2021 +0000
+++ b/LazyBear/UI/Watchlist.swift	Sun Feb 28 13:12:27 2021 +0000
@@ -15,12 +15,15 @@
     
     var body: some View {
         NavigationView {
+            let colorNumber = ["1", "2", "3", "4", "5"]
             List {
-                ForEach(companies, id: \.self) { company in
-                    NavigationLink(destination: CompanyView(hudManager: hudManager, name: company.name, symbol: company.symbol)
-                                    .navigationTitle(company.symbol)
+                ForEach(companies.indices) { i in
+                    let name = companies[i].name
+                    let symbol = companies[i].symbol
+                    NavigationLink(destination: CompanyView(hudManager: hudManager, name: name, symbol: symbol)
+                                    .navigationTitle(symbol)
                     ) {
-                        CompanyRow(symbol: company.symbol, name: company.name, rowNumber: 1)
+                        CompanyRow(symbol: symbol, name: name, rowNumber: i % colorNumber.count)
                     }
                 }
                 .onDelete(perform: removeCompany)