comparison LazyBear/Views/Home/HomeView.swift @ 424:6dd97877f575

Improve code, reorganize files
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Sun, 13 Jun 2021 19:40:42 +0200
parents a38e8acccb85
children 4effac4733b0
comparison
equal deleted inserted replaced
423:bdfdf3a1b34e 424:6dd97877f575
32 32
33 if let lists = home.data.lists { 33 if let lists = home.data.lists {
34 let mirror = Mirror(reflecting: lists) 34 let mirror = Mirror(reflecting: lists)
35 ForEach(Array(mirror.children), id: \.label) { child in 35 ForEach(Array(mirror.children), id: \.label) { child in
36 if let list = child.value as? [String : QuoteModel] { 36 if let list = child.value as? [String : QuoteModel] {
37 StockRow(listName: "\(adaptListTitle(child.label!))", list: list, intradayPrices: home.data.intradayPrices, addOnDelete: false) 37 StockRow(list: [child.label!: list], intradayPrices: home.data.intradayPrices)
38 .listRowInsets(EdgeInsets()) 38 .listRowInsets(EdgeInsets())
39 } 39 }
40 } 40 }
41 } 41 }
42 if let latestCurrencies = home.data.latestCurrencies { 42 if let latestCurrencies = home.data.latestCurrencies {
69 home.request("https://api.lazybear.app/home/type=init", .initial) 69 home.request("https://api.lazybear.app/home/type=init", .initial)
70 } 70 }
71 71
72 } 72 }
73 } 73 }
74
75 /*
76 Get list keys (mostactive, losers, active) and adapt them to diplay
77 */
78 private func adaptListTitle(_ title: String) -> String {
79 if title == "mostactive" {
80 return "Most active"
81 } else {
82 return title.capitalized
83 }
84 }
85 } 74 }
86 75
87 struct HomeView_Previews: PreviewProvider { 76 struct HomeView_Previews: PreviewProvider {
88 static var previews: some View { 77 static var previews: some View {
89 HomeView() 78 HomeView()