comparison LazyBear/Views/Home/HomeView.swift @ 441:417148200aaf

Change background color and minor UI updates
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Sun, 20 Jun 2021 19:52:21 +0200
parents 5ca468751db2
children ffbb1dbab531
comparison
equal deleted inserted replaced
440:01fa77358b82 441:417148200aaf
22 let dueDate = Date() 22 let dueDate = Date()
23 23
24 var body: some View { 24 var body: some View {
25 if home.showView { 25 if home.showView {
26 NavigationView { 26 NavigationView {
27 List { 27 ScrollView(showsIndicators: false) {
28 if let sectorPerformance = home.data.sectorPerformance { 28 VStack {
29 SectorRow(sectorPerformance: sectorPerformance) 29 if let sectorPerformance = home.data.sectorPerformance {
30 .listRowInsets(EdgeInsets()) 30 SectorRow(sectorPerformance: sectorPerformance)
31 } 31 .listRowInsets(EdgeInsets())
32 32 }
33 if let lists = home.data.lists { 33
34 let listNames = Array(lists.keys.sorted()) 34 if let lists = home.data.lists {
35 ForEach(listNames, id: \.self) { listName in 35 let listNames = Array(lists.keys.sorted())
36 StockRow(listName: listName, companies: lists[listName]!) 36 ForEach(listNames, id: \.self) { listName in
37 StockRow(listName: listName, companies: lists[listName]!)
38 .listRowInsets(EdgeInsets())
39 }
40 }
41
42 if let latestCurrencies = home.data.latestCurrencies {
43 CurrencyRow(latestCurrencies: latestCurrencies)
37 .listRowInsets(EdgeInsets()) 44 .listRowInsets(EdgeInsets())
38 } 45 }
39 } 46 }
40 47 .onAppear { self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() } /// Restart timer
41 if let latestCurrencies = home.data.latestCurrencies { 48 .onReceive(timer) { _ in home.request("https://api.lazybear.app/home/type=streaming", .streaming) } /// Receive timer notification
42 CurrencyRow(latestCurrencies: latestCurrencies) 49 .onDisappear { self.timer.upstream.connect().cancel() } // Stop timer
43 .listRowInsets(EdgeInsets()) 50 .navigationTitle("\(dueDate, formatter: Self.taskDateFormat)")
44 } 51 .toolbar {
45 } 52 ToolbarItem(placement: .navigationBarTrailing) {
46 .onAppear { self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() } /// Restart timer 53 Button(action: { showTradingDates = true }) {
47 .onReceive(timer) { _ in home.request("https://api.lazybear.app/home/type=streaming", .streaming) } /// Receive timer notification 54 Image(systemName: "calendar.badge.clock")
48 .onDisappear { self.timer.upstream.connect().cancel() } // Stop timer 55 }
49 .navigationTitle("\(dueDate, formatter: Self.taskDateFormat)")
50 .navigationBarTitleDisplayMode(.inline)
51 .navigationViewStyle(StackNavigationViewStyle())
52 .toolbar {
53 ToolbarItem(placement: .navigationBarTrailing) {
54 Button(action: { showTradingDates = true }) {
55 Image(systemName: "calendar.badge.clock")
56 } 56 }
57 } 57 }
58 } 58 }
59 .background(Color("customBackground").edgesIgnoringSafeArea(.all))
59 } 60 }
61 .navigationViewStyle(StackNavigationViewStyle())
60 .sheet(isPresented: $showTradingDates) { 62 .sheet(isPresented: $showTradingDates) {
61 if let dates = home.data.tradingDates { 63 if let dates = home.data.tradingDates {
62 TradingDates(dates: dates) 64 TradingDates(dates: dates)
63 } 65 }
64 } 66 }