diff 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
line wrap: on
line diff
--- a/LazyBear/Views/Profile/ProfileView.swift	Sat Apr 24 12:21:23 2021 +0200
+++ b/LazyBear/Views/Profile/ProfileView.swift	Sat Apr 24 17:44:02 2021 +0200
@@ -37,6 +37,13 @@
                 }
                 .navigationTitle("My profile")
                 .navigationBarTitleDisplayMode(.inline)
+                .toolbar {
+                    ToolbarItem(placement: .navigationBarTrailing) {
+                        Button(action: {}) {
+                            Image(systemName: "plus")
+                        }
+                    }
+                }
             }
         } else {
             ProgressView()
@@ -45,19 +52,23 @@
     }
     
     private func prepareUrl() {
-        let symbols = watchlistCompanies.map { $0.symbol }  // Get symbols in watchlists
-        var url = "https://api.lazybear.app/profile/type=init/symbols="
+        if watchlistCompanies.isEmpty {
+            profile.showView = true
+        } else {
+            let symbols = watchlistCompanies.map { $0.symbol }  // Get symbols in watchlists
+            var url = "https://api.lazybear.app/profile/type=init/symbols="
 
-        var counter = 0
-        for symbol in symbols {
-            counter += 1
-            if counter == 1 {
-                url += symbol
-            } else {
-                url += ",\(symbol)"
+            var counter = 0
+            for symbol in symbols {
+                counter += 1
+                if counter == 1 {
+                    url += symbol
+                } else {
+                    url += ",\(symbol)"
+                }
             }
+            profile.request(url)
         }
-        profile.request(url)
     }
 }