# HG changeset patch # User Dennis Concepción Martín # Date 1624446180 -7200 # Node ID 4255f94d0767185012a581d2947a4d7497f676ed # Parent f71761f166f2d69d30f32d6e321bdb8c6503b2f3 Minor updates diff -r f71761f166f2 -r 4255f94d0767 LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed diff -r f71761f166f2 -r 4255f94d0767 LazyBear/ContentView.swift --- 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 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 { diff -r f71761f166f2 -r 4255f94d0767 LazyBear/Views/Home/Helpers/StockRow.swift --- 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) } diff -r f71761f166f2 -r 4255f94d0767 LazyBear/Views/Home/HomeView.swift --- 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) + } }