changeset 340:d17dd5c28211

Implementing SearchView
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Sat, 03 Apr 2021 17:46:05 +0200
parents e81c18164afb
children 4e6c47a81b80
files LazyBear.xcodeproj/project.pbxproj LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate LazyBear.xcodeproj/xcshareddata/xcschemes/LazyBear.xcscheme LazyBear/ContentView.swift LazyBear/Global functions/ParseJSON.swift LazyBear/HudManager.swift LazyBear/LazyBearApp.swift LazyBear/Resources/popularCompanies.json LazyBear/Views/Global Helpers/BackgroundShadow.swift LazyBear/Views/Global Helpers/BlurBackground.swift LazyBear/Views/Search/CompanyList.swift LazyBear/Views/Search/Helpers/CompanyRow.swift LazyBear/Views/Search/Helpers/HelpSheet.swift LazyBear/Views/Search/Helpers/PopularCompanyHelper.swift LazyBear/Views/Search/Networking/BatchCompanyQuoteModel.swift LazyBear/Views/Search/Networking/PopularCompanyModel.swift LazyBear/Views/Search/Networking/SearchData.swift LazyBear/Views/Search/Networking/SearchModel.swift LazyBear/Views/Search/SearchView.swift
diffstat 19 files changed, 348 insertions(+), 206 deletions(-) [+]
line wrap: on
line diff
--- a/LazyBear.xcodeproj/project.pbxproj	Sat Apr 03 13:02:40 2021 +0200
+++ b/LazyBear.xcodeproj/project.pbxproj	Sat Apr 03 17:46:05 2021 +0200
@@ -10,6 +10,14 @@
 		950C36E3260FB6180081CF53 /* HapticsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950C36E2260FB6180081CF53 /* HapticsManager.swift */; };
 		950C36E8260FBB550081CF53 /* UserSettings+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950C36E6260FBB550081CF53 /* UserSettings+CoreDataClass.swift */; };
 		950C36E9260FBB550081CF53 /* UserSettings+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950C36E7260FBB550081CF53 /* UserSettings+CoreDataProperties.swift */; };
+		950D0E192618AA4900D17AD7 /* CompanyList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950D0E182618AA4900D17AD7 /* CompanyList.swift */; };
+		950D0E222618AD4A00D17AD7 /* SearchModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950D0E212618AD4A00D17AD7 /* SearchModel.swift */; };
+		950D0E252618ADD000D17AD7 /* SearchData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950D0E242618ADD000D17AD7 /* SearchData.swift */; };
+		950D0E292618AEC800D17AD7 /* CompanyRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950D0E282618AEC800D17AD7 /* CompanyRow.swift */; };
+		950D0E2D2618B2B900D17AD7 /* HelpSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950D0E2C2618B2B900D17AD7 /* HelpSheet.swift */; };
+		950D0E302618B34600D17AD7 /* BlurBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950D0E2F2618B34600D17AD7 /* BlurBackground.swift */; };
+		950D0E332618B44800D17AD7 /* HudManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950D0E322618B44800D17AD7 /* HudManager.swift */; };
+		950D0E362618B61000D17AD7 /* BackgroundShadow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950D0E352618B61000D17AD7 /* BackgroundShadow.swift */; };
 		951490552610BD2B00BDEEB5 /* WelcomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951490542610BD2B00BDEEB5 /* WelcomeView.swift */; };
 		951566E72613A2B6007C0F36 /* TradingDates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951566E62613A2B6007C0F36 /* TradingDates.swift */; };
 		951566EA2613A37C007C0F36 /* TradingDatesItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951566E92613A37C007C0F36 /* TradingDatesItem.swift */; };
@@ -32,16 +40,11 @@
 		95893DCE2613C46B003698C5 /* CompanyQuoteModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95893DCD2613C46B003698C5 /* CompanyQuoteModel.swift */; };
 		958A735225E0170900FD7ECA /* CloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 958A735125E0170900FD7ECA /* CloudKit.framework */; };
 		95A5186A26185AAB0002D27C /* GenericRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A5186926185AAB0002D27C /* GenericRequest.swift */; };
-		95A5186E26186A6E0002D27C /* popularCompanies.json in Resources */ = {isa = PBXBuildFile; fileRef = 95A5186D26186A6E0002D27C /* popularCompanies.json */; };
-		95A5187126186C120002D27C /* PopularCompanyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A5187026186C120002D27C /* PopularCompanyModel.swift */; };
 		95A5187426186C680002D27C /* SectorPerformanceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A5187326186C680002D27C /* SectorPerformanceModel.swift */; };
 		95A5187726186C830002D27C /* IntradayPricesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A5187626186C830002D27C /* IntradayPricesModel.swift */; };
 		95A5187A26186C960002D27C /* TradingDatesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A5187926186C960002D27C /* TradingDatesModel.swift */; };
-		95A5188226186DB30002D27C /* SearchData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A5188126186DB30002D27C /* SearchData.swift */; };
 		95A5188626186F590002D27C /* PriceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A5188526186F590002D27C /* PriceView.swift */; };
-		95A51889261873D50002D27C /* BatchCompanyQuoteModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A51888261873D50002D27C /* BatchCompanyQuoteModel.swift */; };
 		95A7C066261639E0003E2EC1 /* SearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A7C065261639DF003E2EC1 /* SearchView.swift */; };
-		95A7C06A26163B54003E2EC1 /* PopularCompanyHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A7C06926163B54003E2EC1 /* PopularCompanyHelper.swift */; };
 		95A7C0742616409D003E2EC1 /* ParseJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A7C0732616409D003E2EC1 /* ParseJSON.swift */; };
 		95AD4A2D26078C1400498079 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95AD4A2C26078C1400498079 /* ContentView.swift */; };
 		95E745DA2614624500744A1E /* HomeDataPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95E745D92614624500744A1E /* HomeDataPreview.swift */; };
@@ -55,6 +58,14 @@
 		950C36E2260FB6180081CF53 /* HapticsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HapticsManager.swift; sourceTree = "<group>"; };
 		950C36E6260FBB550081CF53 /* UserSettings+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserSettings+CoreDataClass.swift"; sourceTree = "<group>"; };
 		950C36E7260FBB550081CF53 /* UserSettings+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserSettings+CoreDataProperties.swift"; sourceTree = "<group>"; };
+		950D0E182618AA4900D17AD7 /* CompanyList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompanyList.swift; sourceTree = "<group>"; };
+		950D0E212618AD4A00D17AD7 /* SearchModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchModel.swift; sourceTree = "<group>"; };
+		950D0E242618ADD000D17AD7 /* SearchData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchData.swift; sourceTree = "<group>"; };
+		950D0E282618AEC800D17AD7 /* CompanyRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompanyRow.swift; sourceTree = "<group>"; };
+		950D0E2C2618B2B900D17AD7 /* HelpSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HelpSheet.swift; sourceTree = "<group>"; };
+		950D0E2F2618B34600D17AD7 /* BlurBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlurBackground.swift; sourceTree = "<group>"; };
+		950D0E322618B44800D17AD7 /* HudManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HudManager.swift; sourceTree = "<group>"; };
+		950D0E352618B61000D17AD7 /* BackgroundShadow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundShadow.swift; sourceTree = "<group>"; };
 		951490542610BD2B00BDEEB5 /* WelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeView.swift; sourceTree = "<group>"; };
 		951566E62613A2B6007C0F36 /* TradingDates.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TradingDates.swift; sourceTree = "<group>"; };
 		951566E92613A37C007C0F36 /* TradingDatesItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TradingDatesItem.swift; sourceTree = "<group>"; };
@@ -79,16 +90,11 @@
 		958A734E25E016FD00FD7ECA /* LazyBear.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = LazyBear.entitlements; sourceTree = "<group>"; };
 		958A735125E0170900FD7ECA /* CloudKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CloudKit.framework; path = System/Library/Frameworks/CloudKit.framework; sourceTree = SDKROOT; };
 		95A5186926185AAB0002D27C /* GenericRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenericRequest.swift; sourceTree = "<group>"; };
-		95A5186D26186A6E0002D27C /* popularCompanies.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = popularCompanies.json; sourceTree = "<group>"; };
-		95A5187026186C120002D27C /* PopularCompanyModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopularCompanyModel.swift; sourceTree = "<group>"; };
 		95A5187326186C680002D27C /* SectorPerformanceModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectorPerformanceModel.swift; sourceTree = "<group>"; };
 		95A5187626186C830002D27C /* IntradayPricesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntradayPricesModel.swift; sourceTree = "<group>"; };
 		95A5187926186C960002D27C /* TradingDatesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TradingDatesModel.swift; sourceTree = "<group>"; };
-		95A5188126186DB30002D27C /* SearchData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchData.swift; sourceTree = "<group>"; };
 		95A5188526186F590002D27C /* PriceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PriceView.swift; sourceTree = "<group>"; };
-		95A51888261873D50002D27C /* BatchCompanyQuoteModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BatchCompanyQuoteModel.swift; sourceTree = "<group>"; };
 		95A7C065261639DF003E2EC1 /* SearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchView.swift; sourceTree = "<group>"; };
-		95A7C06926163B54003E2EC1 /* PopularCompanyHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopularCompanyHelper.swift; sourceTree = "<group>"; };
 		95A7C0732616409D003E2EC1 /* ParseJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParseJSON.swift; sourceTree = "<group>"; };
 		95AD4A2C26078C1400498079 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
 		95E745D92614624500744A1E /* HomeDataPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeDataPreview.swift; sourceTree = "<group>"; };
@@ -109,6 +115,24 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
+		950D0E202618AD3D00D17AD7 /* Networking */ = {
+			isa = PBXGroup;
+			children = (
+				950D0E242618ADD000D17AD7 /* SearchData.swift */,
+				950D0E212618AD4A00D17AD7 /* SearchModel.swift */,
+			);
+			path = Networking;
+			sourceTree = "<group>";
+		};
+		950D0E272618AEBB00D17AD7 /* Helpers */ = {
+			isa = PBXGroup;
+			children = (
+				950D0E282618AEC800D17AD7 /* CompanyRow.swift */,
+				950D0E2C2618B2B900D17AD7 /* HelpSheet.swift */,
+			);
+			path = Helpers;
+			sourceTree = "<group>";
+		};
 		951490572610BD3000BDEEB5 /* Welcome */ = {
 			isa = PBXGroup;
 			children = (
@@ -138,7 +162,6 @@
 			isa = PBXGroup;
 			children = (
 				9523ED412615BDB2006D3D6F /* phrases.json */,
-				95A5186D26186A6E0002D27C /* popularCompanies.json */,
 			);
 			path = Resources;
 			sourceTree = "<group>";
@@ -207,6 +230,7 @@
 				95AD4A2C26078C1400498079 /* ContentView.swift */,
 				95672B9725DDA54700DCBE4A /* Persistence.swift */,
 				950C36E2260FB6180081CF53 /* HapticsManager.swift */,
+				950D0E322618B44800D17AD7 /* HudManager.swift */,
 				95B1874925DDAC4D0068A364 /* Views */,
 				952045132610C7A200A76362 /* Global functions */,
 				954D7E9D260BBA5200A13C50 /* Global Models */,
@@ -244,6 +268,8 @@
 				95ECCA5F261216D500A67EFA /* LineView.swift */,
 				95ECCA5C2612169200A67EFA /* LineShape.swift */,
 				95A5188526186F590002D27C /* PriceView.swift */,
+				950D0E2F2618B34600D17AD7 /* BlurBackground.swift */,
+				950D0E352618B61000D17AD7 /* BackgroundShadow.swift */,
 			);
 			path = "Global Helpers";
 			sourceTree = "<group>";
@@ -260,30 +286,13 @@
 			isa = PBXGroup;
 			children = (
 				95A7C065261639DF003E2EC1 /* SearchView.swift */,
-				95A7C06226163951003E2EC1 /* Helpers */,
-				95A7C06326163957003E2EC1 /* Networking */,
+				950D0E182618AA4900D17AD7 /* CompanyList.swift */,
+				950D0E272618AEBB00D17AD7 /* Helpers */,
+				950D0E202618AD3D00D17AD7 /* Networking */,
 			);
 			path = Search;
 			sourceTree = "<group>";
 		};
-		95A7C06226163951003E2EC1 /* Helpers */ = {
-			isa = PBXGroup;
-			children = (
-				95A7C06926163B54003E2EC1 /* PopularCompanyHelper.swift */,
-			);
-			path = Helpers;
-			sourceTree = "<group>";
-		};
-		95A7C06326163957003E2EC1 /* Networking */ = {
-			isa = PBXGroup;
-			children = (
-				95A5188126186DB30002D27C /* SearchData.swift */,
-				95A5187026186C120002D27C /* PopularCompanyModel.swift */,
-				95A51888261873D50002D27C /* BatchCompanyQuoteModel.swift */,
-			);
-			path = Networking;
-			sourceTree = "<group>";
-		};
 		95B1874925DDAC4D0068A364 /* Views */ = {
 			isa = PBXGroup;
 			children = (
@@ -374,7 +383,6 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				95A5186E26186A6E0002D27C /* popularCompanies.json in Resources */,
 				95672B9625DDA54700DCBE4A /* Preview Assets.xcassets in Resources */,
 				9523ED422615BDB2006D3D6F /* phrases.json in Resources */,
 				95672B9325DDA54700DCBE4A /* Assets.xcassets in Resources */,
@@ -396,6 +404,7 @@
 				9550444926111FC9000E0BCB /* TopStockRow.swift in Sources */,
 				9523ED542615CB7F006D3D6F /* HomeData.swift in Sources */,
 				9550444326111E7A000E0BCB /* SectorRow.swift in Sources */,
+				950D0E302618B34600D17AD7 /* BlurBackground.swift in Sources */,
 				95ECCA60261216D500A67EFA /* LineView.swift in Sources */,
 				9550443A26111B2B000E0BCB /* HomeView.swift in Sources */,
 				950C36E8260FBB550081CF53 /* UserSettings+CoreDataClass.swift in Sources */,
@@ -406,18 +415,21 @@
 				954D7EA8260BBA6600A13C50 /* WatchlistCompany+CoreDataProperties.swift in Sources */,
 				951566E72613A2B6007C0F36 /* TradingDates.swift in Sources */,
 				95893DCE2613C46B003698C5 /* CompanyQuoteModel.swift in Sources */,
+				950D0E332618B44800D17AD7 /* HudManager.swift in Sources */,
+				950D0E2D2618B2B900D17AD7 /* HelpSheet.swift in Sources */,
 				95672B8F25DDA54700DCBE4A /* LazyBearApp.swift in Sources */,
+				950D0E222618AD4A00D17AD7 /* SearchModel.swift in Sources */,
 				95A7C066261639E0003E2EC1 /* SearchView.swift in Sources */,
-				95A51889261873D50002D27C /* BatchCompanyQuoteModel.swift in Sources */,
 				95ECCA5D2612169200A67EFA /* LineShape.swift in Sources */,
-				95A7C06A26163B54003E2EC1 /* PopularCompanyHelper.swift in Sources */,
 				9550444C26111FED000E0BCB /* TopStockItem.swift in Sources */,
+				950D0E192618AA4900D17AD7 /* CompanyList.swift in Sources */,
+				950D0E362618B61000D17AD7 /* BackgroundShadow.swift in Sources */,
+				950D0E292618AEC800D17AD7 /* CompanyRow.swift in Sources */,
 				951566EA2613A37C007C0F36 /* TradingDatesItem.swift in Sources */,
+				950D0E252618ADD000D17AD7 /* SearchData.swift in Sources */,
 				951490552610BD2B00BDEEB5 /* WelcomeView.swift in Sources */,
-				95A5188226186DB30002D27C /* SearchData.swift in Sources */,
 				95A5187A26186C960002D27C /* TradingDatesModel.swift in Sources */,
 				9550444626111EE5000E0BCB /* SectorItem.swift in Sources */,
-				95A5187126186C120002D27C /* PopularCompanyModel.swift in Sources */,
 				954D7EA7260BBA6600A13C50 /* WatchlistCompany+CoreDataClass.swift in Sources */,
 				95672B9B25DDA54800DCBE4A /* LazyBear.xcdatamodeld in Sources */,
 				95AD4A2D26078C1400498079 /* ContentView.swift in Sources */,
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/LazyBear.xcodeproj/xcshareddata/xcschemes/LazyBear.xcscheme	Sat Apr 03 13:02:40 2021 +0200
+++ b/LazyBear.xcodeproj/xcshareddata/xcschemes/LazyBear.xcscheme	Sat Apr 03 17:46:05 2021 +0200
@@ -31,7 +31,7 @@
       </Testables>
    </TestAction>
    <LaunchAction
-      buildConfiguration = "Release"
+      buildConfiguration = "Debug"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       launchStyle = "0"
--- a/LazyBear/ContentView.swift	Sat Apr 03 13:02:40 2021 +0200
+++ b/LazyBear/ContentView.swift	Sat Apr 03 17:46:05 2021 +0200
@@ -9,33 +9,42 @@
 
 struct ContentView: View {
     @State private var showWelcome = false
+    @EnvironmentObject var hudManager: HudManager
     
     var body: some View {
-        TabView {
-            HomeView()
-                .tabItem {
-                    Image(systemName: "house")
-                    Text("Home")
-                }
-            SearchView()
-                .tabItem {
-                    Image(systemName: "magnifyingglass")
-                    Text("Search")
-                }
-            Text("The Last Tab")
-                .tabItem {
-                    Image(systemName: "3.square.fill")
-                    Text("Third")
-                }
-            Text("The Last Tab")
-                .tabItem {
-                    Image(systemName: "3.square.fill")
-                    Text("Forth")
-                }
-        }
-//        .onAppear { isAppAlreadyLaunchedOnce() }
-        .sheet(isPresented: $showWelcome) {
+        ZStack {
+            TabView {
+                HomeView()
+                    .tabItem {
+                        Image(systemName: "house")
+                        Text("Home")
+                    }
+                SearchView()
+                    .tabItem {
+                        Image(systemName: "magnifyingglass")
+                        Text("Search")
+                    }
+                Text("The Last Tab")
+                    .tabItem {
+                        Image(systemName: "3.square.fill")
+                        Text("Third")
+                    }
+                Text("The Last Tab")
+                    .tabItem {
+                        Image(systemName: "3.square.fill")
+                        Text("Forth")
+                    }
+            }
+    //        .onAppear { isAppAlreadyLaunchedOnce() }
+            .sheet(isPresented: $showWelcome) {
+                
+            }
+            BackgroundShadow()
             
+            HelpSheet()
+                .offset(y: hudManager.showSearchHelper ? 0 : 700)
+                .animation(.easeInOut)
+                .padding(.horizontal)
         }
     }
     
@@ -52,5 +61,6 @@
 struct ContentView_Previews: PreviewProvider {
     static var previews: some View {
         ContentView()
+            .environmentObject(HudManager())
     }
 }
--- a/LazyBear/Global functions/ParseJSON.swift	Sat Apr 03 13:02:40 2021 +0200
+++ b/LazyBear/Global functions/ParseJSON.swift	Sat Apr 03 17:46:05 2021 +0200
@@ -7,8 +7,6 @@
 
 import Foundation
 
-let popularCompanies: [PopularCompanyModel] = parseJSON("popularCompanies.json")
-
 func parseJSON<T: Decodable>(_ filename: String) -> T {
     let data: Data
     
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LazyBear/HudManager.swift	Sat Apr 03 17:46:05 2021 +0200
@@ -0,0 +1,12 @@
+//
+//  HudManager.swift
+//  LazyBear
+//
+//  Created by Dennis Concepción Martín on 3/4/21.
+//
+
+import SwiftUI
+
+class HudManager: ObservableObject {
+    @Published var showSearchHelper = false
+}
--- a/LazyBear/LazyBearApp.swift	Sat Apr 03 13:02:40 2021 +0200
+++ b/LazyBear/LazyBearApp.swift	Sat Apr 03 17:46:05 2021 +0200
@@ -10,11 +10,14 @@
 @main
 struct LazyBearApp: App {
     let persistenceController = PersistenceController.shared  // Core Data init
+    
+    @ObservedObject var hudManager = HudManager()
 
     var body: some Scene {
         WindowGroup {
             ContentView()
                 .environment(\.managedObjectContext, persistenceController.container.viewContext)
+                .environmentObject(hudManager)
         }
     }
 }
--- a/LazyBear/Resources/popularCompanies.json	Sat Apr 03 13:02:40 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-[
-    {
-        "symbol": "aapl"
-    },
-    {
-        "symbol": "msft"
-    },
-    {
-        "symbol": "amzn"
-    },
-    {
-        "symbol": "fb"
-    },
-    {
-        "symbol": "tsla"
-    },
-    {
-        "symbol": "jpm"
-    },
-    {
-        "symbol": "v"
-    },
-    {
-        "symbol": "jnj"
-    },
-    {
-        "symbol": "wmt"
-    },
-    {
-        "symbol": "ma"
-    },
-    {
-        "symbol": "bac"
-    },
-    {
-        "symbol": "pg"
-    },
-    {
-        "symbol": "pypl"
-    },
-    {
-        "symbol": "nke"
-    }
-]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LazyBear/Views/Global Helpers/BackgroundShadow.swift	Sat Apr 03 17:46:05 2021 +0200
@@ -0,0 +1,27 @@
+//
+//  BackgroundShadow.swift
+//  LazyBear
+//
+//  Created by Dennis Concepción Martín on 3/4/21.
+//
+
+import SwiftUI
+
+struct BackgroundShadow: View {
+    @EnvironmentObject var hudManager: HudManager
+    
+    var body: some View {
+        Color(.black)
+            .edgesIgnoringSafeArea(.all)
+            .opacity(hudManager.showSearchHelper ? 0.2: 0)
+            .animation(.easeInOut)
+            .onTapGesture { hudManager.showSearchHelper = false }
+    }
+}
+
+struct BackgroundShadow_Previews: PreviewProvider {
+    static var previews: some View {
+        BackgroundShadow()
+            .environmentObject(HudManager())
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LazyBear/Views/Global Helpers/BlurBackground.swift	Sat Apr 03 17:46:05 2021 +0200
@@ -0,0 +1,20 @@
+//
+//  BlurBackground.swift
+//  LazyBear
+//
+//  Created by Dennis Concepción Martín on 3/4/21.
+//
+
+import SwiftUI
+
+struct BlurBackground: UIViewRepresentable {
+    var style: UIBlurEffect.Style
+    
+    func makeUIView(context: Context) -> UIVisualEffectView {
+        return UIVisualEffectView(effect: UIBlurEffect(style: style))
+    }
+    
+    func updateUIView(_ uiView: UIVisualEffectView, context: Context) {
+        uiView.effect = UIBlurEffect(style: style)
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LazyBear/Views/Search/CompanyList.swift	Sat Apr 03 17:46:05 2021 +0200
@@ -0,0 +1,25 @@
+//
+//  CompanyList.swift
+//  LazyBear
+//
+//  Created by Dennis Concepción Martín on 3/4/21.
+//
+
+import SwiftUI
+
+struct CompanyList: View {
+    var searchResult: [SearchModel]
+    
+    var body: some View {
+        List(searchResult, id: \.self) { company in
+            CompanyRow(company: company)
+        }
+        .listStyle(GroupedListStyle())
+    }
+}
+
+struct CompanyList_Previews: PreviewProvider {
+    static var previews: some View {
+        CompanyList(searchResult: [SearchModel(securityName: "aaple inc", symbol: "aapl", region: "US", currency: "USD"), SearchModel(securityName: "aaple inc", symbol: "aapl", region: "US", currency: "USD"), SearchModel(securityName: "aaple inc", symbol: "aapl", region: "US", currency: "USD"), SearchModel(securityName: "aaple inc", symbol: "aapl", region: "US", currency: "USD"), SearchModel(securityName: "aaple inc", symbol: "aapl", region: "US", currency: "USD")])
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LazyBear/Views/Search/Helpers/CompanyRow.swift	Sat Apr 03 17:46:05 2021 +0200
@@ -0,0 +1,39 @@
+//
+//  CompanyRow.swift
+//  LazyBear
+//
+//  Created by Dennis Concepción Martín on 3/4/21.
+//
+
+import SwiftUI
+
+struct CompanyRow: View {
+    var company: SearchModel
+    
+    var body: some View {
+        HStack {
+            VStack(alignment: .leading) {
+                Text(company.symbol.uppercased())
+                    .fontWeight(.semibold)
+
+                Text(company.securityName.capitalized)
+                    .lineLimit(1)
+            }
+            
+            Spacer()
+            
+            VStack(alignment: .trailing) {
+                Text(company.currency)
+                    .fontWeight(.semibold)
+                
+                Text(company.region)
+            }
+        }
+    }
+}
+
+struct CompanyRow_Previews: PreviewProvider {
+    static var previews: some View {
+        CompanyRow(company: SearchModel(securityName: "apple inc", symbol: "aapl", region: "US", currency: "USD"))
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LazyBear/Views/Search/Helpers/HelpSheet.swift	Sat Apr 03 17:46:05 2021 +0200
@@ -0,0 +1,91 @@
+//
+//  HelpSheet.swift
+//  LazyBear
+//
+//  Created by Dennis Concepción Martín on 3/4/21.
+//
+
+import SwiftUI
+
+struct HelpSheet: View {
+    @Environment(\.colorScheme) var colorScheme
+    @EnvironmentObject var hudManager: HudManager
+    
+    var body: some View {
+        VStack {
+            HStack {
+                Spacer()
+                Button(action: { hudManager.showSearchHelper = false }) {
+                    Image(systemName: "multiply.circle")
+                        .imageScale(.large)
+                }
+            }
+            
+            Group {
+                Text("How to search a company?")
+                    .font(.headline)
+                
+                Text("Just tap on the search bar and type the company name or stock symbol. You'll see rows like this: ")
+                    .multilineTextAlignment(.leading)
+                
+                TutorialRow()
+                
+                let explanation = "The left side shows you the stock symbol, and the company name. The right side shows you the quote currency, and in what region the stock is trading."
+                
+                Text(explanation)
+                    .multilineTextAlignment(.leading)
+            }
+            .padding(.bottom)
+
+        }
+        .padding()
+        .background(
+            ZStack {
+                BlurBackground(style: .systemMaterial)
+                    .clipShape(RoundedRectangle(cornerRadius: 25))
+                
+                RoundedRectangle(cornerRadius: 25)
+                    .foregroundColor(colorScheme == .dark ? Color(.secondarySystemBackground): .white)
+                    .shadow(color: Color.black.opacity(0.2), radius: 10, x: 0.0, y: 5)
+            }
+        )
+    }
+}
+
+struct HelpSheet_Previews: PreviewProvider {
+    static var previews: some View {
+        HelpSheet()
+            .environmentObject(HudManager())
+    }
+}
+
+
+struct TutorialRow: View {
+    @Environment(\.colorScheme) var colorScheme
+    
+    var body: some View {
+        RoundedRectangle(cornerRadius: 10)
+            .frame(height: 55)
+            .foregroundColor(colorScheme == .dark ? Color(.tertiarySystemBackground): Color(.secondarySystemBackground))
+            .overlay(
+                HStack {
+                    VStack {
+                        Text("AAPL")
+                            .fontWeight(.semibold)
+                        
+                        Text("Apple Inc")
+                    }
+                    
+                    Spacer()
+                    
+                    VStack {
+                        Text("USD")
+                            .fontWeight(.semibold)
+                        
+                        Text("US")
+                    }
+                }
+                .padding()
+            )
+    }
+}
--- a/LazyBear/Views/Search/Helpers/PopularCompanyHelper.swift	Sat Apr 03 13:02:40 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-//
-//  PopularCompanyHelper.swift
-//  LazyBear
-//
-//  Created by Dennis Concepción Martín on 1/4/21.
-//
-
-import SwiftUI
-
-struct PopularCompanyHelper: View {
-    var company: CompanyQuoteModel
-    
-    var body: some View {
-        RoundedRectangle(cornerRadius: 20)
-            .foregroundColor(Color(.secondarySystemBackground))
-            .frame(height: 100)
-            .overlay(
-                HStack {
-                     Rectangle()
-                         .frame(width: 15)
-                         .foregroundColor(Color("default"))
-                    
-                    VStack {
-                        Text(company.companyName)
-                        Text(company.symbol)
-                    }
-                    
-                    Spacer()
-                    
-                    PriceView(latestPrice: company.latestPrice, changePercent: company.changePercent)
-                }
-                .clipShape(RoundedRectangle(cornerRadius: 20))
-            )
-    }
-}
-
-struct PopularCompanyHelper_Previews: PreviewProvider {
-    static var previews: some View {
-        PopularCompanyHelper(company: CompanyQuoteModel(companyName: "apple inc", symbol: "aapl", latestPrice: 120.30, changePercent: 0.03))
-    }
-}
--- a/LazyBear/Views/Search/Networking/BatchCompanyQuoteModel.swift	Sat Apr 03 13:02:40 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-//
-//  BatchCompanyQuoteModel.swift
-//  LazyBear
-//
-//  Created by Dennis Concepción Martín on 3/4/21.
-//
-
-import SwiftUI
-
-struct BatchCompanyQuoteModel: Codable {
-        var quote: CompanyQuoteModel
-}
--- a/LazyBear/Views/Search/Networking/PopularCompanyModel.swift	Sat Apr 03 13:02:40 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-//
-//  PopularCompanyModel.swift
-//  LazyBear
-//
-//  Created by Dennis Concepción Martín on 3/4/21.
-//
-
-import SwiftUI
-
-struct PopularCompanyModel: Codable, Hashable {
-    var symbol: String
-}
--- a/LazyBear/Views/Search/Networking/SearchData.swift	Sat Apr 03 13:02:40 2021 +0200
+++ b/LazyBear/Views/Search/Networking/SearchData.swift	Sat Apr 03 17:46:05 2021 +0200
@@ -8,34 +8,16 @@
 import SwiftUI
 
 class SearchData: ObservableObject {
-    @Published var companies = [CompanyQuoteModel]()
+    @Published var searchResult = [SearchModel]()
     
     private let baseUrl = Bundle.main.infoDictionary?["IEX_URL"] as? String ?? "Empty url"
     private let apiKey = Bundle.main.infoDictionary?["IEX_API"] as? String ?? "Empty key"
-    private let symbols = popularCompanies.map { $0.symbol }
     
-    func request() {
-        var url = "\(baseUrl)/stock/market/batch?symbols="
+    func request(_ searchedText: String) {
+        let url = "\(baseUrl)/search/\(searchedText)?token=\(apiKey)"
         
-        // Contruct url appending symbols
-        for symbol in self.symbols {
-            let index = self.symbols.firstIndex(of: symbol)
-            if index == 0 {
-                url += symbol
-            } else {
-                url += ",\(symbol)"
-            }
-        }
-        
-        // Append final part of the url
-        url += "&types=quote&token=\(apiKey)"
-
-        genericRequest(url: url, model: [String:BatchCompanyQuoteModel].self) { dict in
-            for key in dict.keys {
-                if let company = dict[key] {
-                    self.companies.append(company.quote)
-                }
-            }
+        genericRequest(url: url, model: [SearchModel].self) {
+            self.searchResult = $0
         }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LazyBear/Views/Search/Networking/SearchModel.swift	Sat Apr 03 17:46:05 2021 +0200
@@ -0,0 +1,15 @@
+//
+//  SearchModel.swift
+//  LazyBear
+//
+//  Created by Dennis Concepción Martín on 3/4/21.
+//
+
+import SwiftUI
+
+struct SearchModel: Codable, Hashable {
+    var securityName: String
+    var symbol: String
+    var region: String
+    var currency: String
+}
--- a/LazyBear/Views/Search/SearchView.swift	Sat Apr 03 13:02:40 2021 +0200
+++ b/LazyBear/Views/Search/SearchView.swift	Sat Apr 03 17:46:05 2021 +0200
@@ -10,23 +10,40 @@
 
 struct SearchView: View {
     @ObservedObject var searchData = SearchData()
-    @State private var searchedText = String()
+    @State private var searchedText: String = ""
+    @State private var showingSearchList = false
+    @EnvironmentObject var hudManager: HudManager
     
     var body: some View {
         NavigationView {
-            VStack {
-                ScrollView {
-                    VStack(spacing: 20) {
-                        ForEach(searchData.companies, id: \.self) { company in
-                            PopularCompanyHelper(company: company)
-                        }
+            VStack(alignment: .leading) {
+                if showingSearchList {
+                    CompanyList(searchResult: searchData.searchResult)
+                } else {
+                    Text("Are you looking for something? 👀")
+                        .fontWeight(.semibold)
+                    
+                    Text("Use the search bar to find a company")
+                    Text(searchedText)
+                }
+            }
+            .onDisappear { self.searchedText = ""; self.showingSearchList = false }
+            .navigationTitle("Search")
+            .navigationBarTitleDisplayMode(.inline)
+            .navigationBarSearch($searchedText)
+            .onChange(of: searchedText, perform: { searchedText in
+                if !searchedText.isEmpty {
+                    searchData.request(searchedText)
+                    self.showingSearchList = true
+                }
+            })
+            .toolbar {
+                ToolbarItem(placement: .navigationBarTrailing) {
+                    Button(action: { self.hudManager.showSearchHelper = true }) {
+                        Image(systemName: "questionmark.circle")
                     }
                 }
             }
-            .onAppear { searchData.request() }
-            .navigationTitle("Search")
-            .navigationBarTitleDisplayMode(.inline)
-            .navigationBarSearch($searchedText)
         }
     }
 }