comparison LazyBear/Views/Profile/ProfileView.swift @ 388:79c39987aaa4

Implementing Watchlists in ProfileView
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Sat, 24 Apr 2021 17:44:02 +0200
parents c206bd0bdb4e
children db8bc3ed526a
comparison
equal deleted inserted replaced
387:c206bd0bdb4e 388:79c39987aaa4
35 } 35 }
36 } 36 }
37 } 37 }
38 .navigationTitle("My profile") 38 .navigationTitle("My profile")
39 .navigationBarTitleDisplayMode(.inline) 39 .navigationBarTitleDisplayMode(.inline)
40 .toolbar {
41 ToolbarItem(placement: .navigationBarTrailing) {
42 Button(action: {}) {
43 Image(systemName: "plus")
44 }
45 }
46 }
40 } 47 }
41 } else { 48 } else {
42 ProgressView() 49 ProgressView()
43 .onAppear { prepareUrl() } 50 .onAppear { prepareUrl() }
44 } 51 }
45 } 52 }
46 53
47 private func prepareUrl() { 54 private func prepareUrl() {
48 let symbols = watchlistCompanies.map { $0.symbol } // Get symbols in watchlists 55 if watchlistCompanies.isEmpty {
49 var url = "https://api.lazybear.app/profile/type=init/symbols=" 56 profile.showView = true
57 } else {
58 let symbols = watchlistCompanies.map { $0.symbol } // Get symbols in watchlists
59 var url = "https://api.lazybear.app/profile/type=init/symbols="
50 60
51 var counter = 0 61 var counter = 0
52 for symbol in symbols { 62 for symbol in symbols {
53 counter += 1 63 counter += 1
54 if counter == 1 { 64 if counter == 1 {
55 url += symbol 65 url += symbol
56 } else { 66 } else {
57 url += ",\(symbol)" 67 url += ",\(symbol)"
68 }
58 } 69 }
70 profile.request(url)
59 } 71 }
60 profile.request(url)
61 } 72 }
62 } 73 }
63 74
64 struct ProfileView_Previews: PreviewProvider { 75 struct ProfileView_Previews: PreviewProvider {
65 static var previews: some View { 76 static var previews: some View {