changeset 449:4255f94d0767

Minor updates
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Wed, 23 Jun 2021 13:03:00 +0200
parents f71761f166f2
children 4b8031e696e8
files LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate LazyBear/ContentView.swift LazyBear/Views/Home/Helpers/StockRow.swift LazyBear/Views/Home/HomeView.swift
diffstat 4 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/LazyBear/ContentView.swift	Wed Jun 23 11:47:14 2021 +0200
+++ b/LazyBear/ContentView.swift	Wed Jun 23 13:03:00 2021 +0200
@@ -9,35 +9,37 @@
 
 struct ContentView: View {
     @State private var showWelcome = false
-    @State var selectedView = 1
+    @State var selectedTab: Tab = .home
+    @StateObject var hapticsManager = HapticsManager()
     
     @Environment(\.managedObjectContext) private var moc
     @FetchRequest(entity: WatchlistCompany.entity(), sortDescriptors: [])
     var watchlistCompanies: FetchedResults<WatchlistCompany>
     
     var body: some View {
-        TabView(selection: $selectedView) {
+        TabView(selection: $selectedTab) {
             HomeView()
                 .tabItem {
                     Image(systemName: "house")
                     Text("Home")
                 }
-                .tag(1)  // Do not remove tags. It causes an odd behaviour when showView is activated
+                .tag(Tab.home)  /// Do not remove tags. It causes an odd behaviour when showView is activated
             SearchView()
                 .tabItem {
                     Image(systemName: "magnifyingglass")
                     Text("Search")
                 }
-                .tag(2)
+                .tag(Tab.search)
             ProfileView()
                 .tabItem {
                     Image(systemName: "person")
                     Text("Profile")
                 }
-                .tag(3)
+                .tag(Tab.profile)
         }
         .onAppear {
 //            isAppAlreadyLaunchedOnce()
+            hapticsManager.prepareHaptics()
             createDefaultWatchlist()
         }
         .sheet(isPresented: $showWelcome) {
@@ -78,6 +80,13 @@
         }
     }
 }
+extension ContentView {
+    enum Tab: Hashable {
+        case home
+        case search
+        case profile
+    }
+}
 
 struct ContentView_Previews: PreviewProvider {
     static var previews: some View {
--- a/LazyBear/Views/Home/Helpers/StockRow.swift	Wed Jun 23 11:47:14 2021 +0200
+++ b/LazyBear/Views/Home/Helpers/StockRow.swift	Wed Jun 23 13:03:00 2021 +0200
@@ -39,9 +39,8 @@
             ScrollView(.horizontal, showsIndicators: false) {
                 HStack(spacing: 20) {
                     ForEach(companies, id: \.self) { company in
-                        NavigationLink(destination:
-                            CompanyView(symbol: company.symbol, name: company.companyName)
-                                        .navigationTitle(company.symbol.uppercased())
+                        NavigationLink(destination:CompanyView(symbol: company.symbol, name: company.companyName)
+                            .navigationTitle(company.symbol.uppercased())
                         ) {
                             StockItem(company: company)
                         }
--- a/LazyBear/Views/Home/HomeView.swift	Wed Jun 23 11:47:14 2021 +0200
+++ b/LazyBear/Views/Home/HomeView.swift	Wed Jun 23 13:03:00 2021 +0200
@@ -68,6 +68,7 @@
             ProgressView()
                 .onAppear {
                     home.request("https://api.lazybear.app/home/type=initial", .initial)
+                        
                 }
 
         }