comparison LazyBearWatchOS Extension/Views/WatchOSProfileView.swift @ 457:c6913f0ce46e

Minor UI Updates
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Mon, 28 Jun 2021 14:03:50 +0200
parents b560babcd5ed
children
comparison
equal deleted inserted replaced
456:d576b2b59014 457:c6913f0ce46e
13 @FetchRequest(entity: WatchlistCompany.entity(), sortDescriptors: []) var watchlistCompanies: FetchedResults<WatchlistCompany> 13 @FetchRequest(entity: WatchlistCompany.entity(), sortDescriptors: []) var watchlistCompanies: FetchedResults<WatchlistCompany>
14 @State private var timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() /// Set recurrent price request 14 @State private var timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() /// Set recurrent price request
15 15
16 var body: some View { 16 var body: some View {
17 if profile.showView { 17 if profile.showView {
18 NavigationView { 18 ScrollView {
19 ScrollView { 19 VStack {
20 VStack { 20 if let companies = profile.data.quotes {
21 if let companies = profile.data.quotes { 21 ForEach(companies, id: \.self) { company in
22 ForEach(companies, id: \.self) { company in 22 NavigationLink(destination: WatchOSCompanyView(symbol: company.symbol)
23 NavigationLink(destination: WatchOSCompanyView(symbol: company.symbol) 23 .navigationTitle(company.companyName.capitalized)
24 .navigationTitle(company.companyName.capitalized) 24 ) {
25 ) { 25 WatchOSCompanyRow(company: company)
26 WatchOSCompanyRow(company: company)
27 }
28 } 26 }
27 .buttonStyle(PlainButtonStyle())
29 } 28 }
30 } 29 }
31 } 30 }
32 .navigationTitle("Lazybear") 31 .navigationTitle("Lazybear")
33 .onAppear { self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() } /// Start timer 32 .onAppear { self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() } /// Start timer
48 let symbolsString = symbols.joined(separator:",") 47 let symbolsString = symbols.joined(separator:",")
49 48
50 switch requestType { 49 switch requestType {
51 case .initial: 50 case .initial:
52 let url = "https://api.lazybear.app/profile/type=initial/symbols=\(symbolsString)" 51 let url = "https://api.lazybear.app/profile/type=initial/symbols=\(symbolsString)"
53 print(watchlistCompanies)
54 profile.request(url, .initial) 52 profile.request(url, .initial)
55 53
56 default: 54 default:
57 let url = "https://api.lazybear.app/profile/type=streaming/symbols=\(symbolsString)" 55 let url = "https://api.lazybear.app/profile/type=streaming/symbols=\(symbolsString)"
58 profile.request(url, .streaming) 56 profile.request(url, .streaming)