diff LazyBear/Views/Profile/Helpers/ProfileStockRow.swift @ 453:37c13ebda381

Improve hierarchy and minor bugs fixed
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Sun, 27 Jun 2021 14:18:29 +0200
parents 3ca32ff79630
children
line wrap: on
line diff
--- a/LazyBear/Views/Profile/Helpers/ProfileStockRow.swift	Sat Jun 26 18:45:31 2021 +0200
+++ b/LazyBear/Views/Profile/Helpers/ProfileStockRow.swift	Sun Jun 27 14:18:29 2021 +0200
@@ -12,9 +12,6 @@
     var companies: [CompanyModel]
 
     @State private var showWatchlistSheet = false
-    @State private var willRenameWatchlist = false
-    @State private var showRenameWatchlistSheet = false
-    @Environment(\.managedObjectContext) private var moc
     
     var body: some View {
         VStack(alignment: .leading) {
@@ -32,9 +29,15 @@
                 }
                 
                 Spacer()
-                Button("See all", action: { showWatchlistSheet = true })
-                    .buttonStyle(BorderlessButtonStyle())
-                    .padding(.horizontal)
+                NavigationLink(destination: WatchlistSheet(listName: watchlistName, apiCompanies: companies)
+                                .navigationTitle(watchlistName)
+                ) {
+                    HStack {
+                        Text("See all")
+                        Image(systemName: "chevron.right")
+                    }
+                }
+                .padding(.horizontal)
             }
             
             ScrollView(.horizontal, showsIndicators: false) {
@@ -48,23 +51,6 @@
             .frame(height: 250)
         }
         .padding(.bottom)
-        .sheet(isPresented: $showWatchlistSheet, onDismiss: didDismissWatchlistSheet) {
-            WatchlistSheet(listName: watchlistName, apiCompanies: companies, willRenameWatchlist: $willRenameWatchlist)
-                .environment(\.managedObjectContext, self.moc)
-        }
-        .sheet(isPresented: $showRenameWatchlistSheet) {
-            RenameListSheet(oldWatchlistName: watchlistName)
-                .environment(\.managedObjectContext, self.moc)
-        }
-    }
-    
-    /*
-     If user wants to rename watchlist -> when WatchlistSheet is dismissed, show RenameListSheet
-     */
-    private func didDismissWatchlistSheet() {
-        if willRenameWatchlist {
-            showRenameWatchlistSheet = true
-        }
     }
 }