Mercurial > public > lazybear
changeset 342:a6c49f1409f3
Implementing Watchlists
line wrap: on
line diff
--- a/LazyBear.xcodeproj/project.pbxproj Sun Apr 04 13:20:14 2021 +0200 +++ b/LazyBear.xcodeproj/project.pbxproj Mon Apr 05 20:08:19 2021 +0200 @@ -29,7 +29,7 @@ 9550444326111E7A000E0BCB /* SectorRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9550444226111E7A000E0BCB /* SectorRow.swift */; }; 9550444626111EE5000E0BCB /* SectorItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9550444526111EE5000E0BCB /* SectorItem.swift */; }; 9550444926111FC9000E0BCB /* TopStockRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9550444826111FC9000E0BCB /* TopStockRow.swift */; }; - 9550444C26111FED000E0BCB /* TopStockItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9550444B26111FED000E0BCB /* TopStockItem.swift */; }; + 9550444C26111FED000E0BCB /* StockItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9550444B26111FED000E0BCB /* StockItem.swift */; }; 95672B8F25DDA54700DCBE4A /* LazyBearApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95672B8E25DDA54700DCBE4A /* LazyBearApp.swift */; }; 95672B9325DDA54700DCBE4A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 95672B9225DDA54700DCBE4A /* Assets.xcassets */; }; 95672B9625DDA54700DCBE4A /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 95672B9525DDA54700DCBE4A /* Preview Assets.xcassets */; }; @@ -49,9 +49,6 @@ 95ECCA5D2612169200A67EFA /* LineShape.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95ECCA5C2612169200A67EFA /* LineShape.swift */; }; 95ECCA60261216D500A67EFA /* LineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95ECCA5F261216D500A67EFA /* LineView.swift */; }; 95FBE0DC2619CA7200440386 /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95FBE0DB2619CA7200440386 /* ProfileView.swift */; }; - 95FBE0E32619CBE500440386 /* UserProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95FBE0E22619CBE500440386 /* UserProfile.swift */; }; - 95FBE0E72619CC8700440386 /* ImagePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95FBE0E62619CC8700440386 /* ImagePicker.swift */; }; - 95FBE0EB2619D31100440386 /* EditProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95FBE0EA2619D31100440386 /* EditProfile.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -78,7 +75,7 @@ 9550444226111E7A000E0BCB /* SectorRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectorRow.swift; sourceTree = "<group>"; }; 9550444526111EE5000E0BCB /* SectorItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectorItem.swift; sourceTree = "<group>"; }; 9550444826111FC9000E0BCB /* TopStockRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopStockRow.swift; sourceTree = "<group>"; }; - 9550444B26111FED000E0BCB /* TopStockItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopStockItem.swift; sourceTree = "<group>"; }; + 9550444B26111FED000E0BCB /* StockItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StockItem.swift; sourceTree = "<group>"; }; 95672B8B25DDA54700DCBE4A /* LazyBear.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LazyBear.app; sourceTree = BUILT_PRODUCTS_DIR; }; 95672B8E25DDA54700DCBE4A /* LazyBearApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LazyBearApp.swift; sourceTree = "<group>"; }; 95672B9225DDA54700DCBE4A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; @@ -101,9 +98,6 @@ 95ECCA5C2612169200A67EFA /* LineShape.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineShape.swift; sourceTree = "<group>"; }; 95ECCA5F261216D500A67EFA /* LineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineView.swift; sourceTree = "<group>"; }; 95FBE0DB2619CA7200440386 /* ProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = "<group>"; }; - 95FBE0E22619CBE500440386 /* UserProfile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserProfile.swift; sourceTree = "<group>"; }; - 95FBE0E62619CC8700440386 /* ImagePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePicker.swift; sourceTree = "<group>"; }; - 95FBE0EA2619D31100440386 /* EditProfile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditProfile.swift; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -173,8 +167,10 @@ 954D7E9D260BBA5200A13C50 /* Global Models */ = { isa = PBXGroup; children = ( + 95893DCD2613C46B003698C5 /* CompanyQuoteModel.swift */, 954D7EA5260BBA6600A13C50 /* WatchlistCompany+CoreDataClass.swift */, 954D7EA6260BBA6600A13C50 /* WatchlistCompany+CoreDataProperties.swift */, + 95A5187626186C830002D27C /* IntradayPricesModel.swift */, ); path = "Global Models"; sourceTree = "<group>"; @@ -196,7 +192,6 @@ 9550444226111E7A000E0BCB /* SectorRow.swift */, 9550444526111EE5000E0BCB /* SectorItem.swift */, 9550444826111FC9000E0BCB /* TopStockRow.swift */, - 9550444B26111FED000E0BCB /* TopStockItem.swift */, 951566E92613A37C007C0F36 /* TradingDatesItem.swift */, ); path = Helpers; @@ -256,9 +251,7 @@ isa = PBXGroup; children = ( 9523ED532615CB7F006D3D6F /* HomeData.swift */, - 95893DCD2613C46B003698C5 /* CompanyQuoteModel.swift */, 95A5187926186C960002D27C /* TradingDatesModel.swift */, - 95A5187626186C830002D27C /* IntradayPricesModel.swift */, 95A5187326186C680002D27C /* SectorPerformanceModel.swift */, ); path = Networking; @@ -272,6 +265,7 @@ 95A5188526186F590002D27C /* PriceView.swift */, 950D0E2F2618B34600D17AD7 /* BlurBackground.swift */, 950D0E352618B61000D17AD7 /* BackgroundShadow.swift */, + 9550444B26111FED000E0BCB /* StockItem.swift */, ); path = "Global Helpers"; sourceTree = "<group>"; @@ -327,21 +321,10 @@ isa = PBXGroup; children = ( 95FBE0DB2619CA7200440386 /* ProfileView.swift */, - 95FBE0E12619CBD600440386 /* Helpers */, ); path = Profile; sourceTree = "<group>"; }; - 95FBE0E12619CBD600440386 /* Helpers */ = { - isa = PBXGroup; - children = ( - 95FBE0E22619CBE500440386 /* UserProfile.swift */, - 95FBE0EA2619D31100440386 /* EditProfile.swift */, - 95FBE0E62619CC8700440386 /* ImagePicker.swift */, - ); - path = Helpers; - sourceTree = "<group>"; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -418,17 +401,14 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 95FBE0E72619CC8700440386 /* ImagePicker.swift in Sources */, 950C36E3260FB6180081CF53 /* HapticsManager.swift in Sources */, 95FBE0DC2619CA7200440386 /* ProfileView.swift in Sources */, - 95FBE0EB2619D31100440386 /* EditProfile.swift in Sources */, 95A5186A26185AAB0002D27C /* GenericRequest.swift in Sources */, 95E745DA2614624500744A1E /* HomeDataPreview.swift in Sources */, 95A5187726186C830002D27C /* IntradayPricesModel.swift in Sources */, 95A5188626186F590002D27C /* PriceView.swift in Sources */, 9550444926111FC9000E0BCB /* TopStockRow.swift in Sources */, 9523ED542615CB7F006D3D6F /* HomeData.swift in Sources */, - 95FBE0E32619CBE500440386 /* UserProfile.swift in Sources */, 9550444326111E7A000E0BCB /* SectorRow.swift in Sources */, 950D0E302618B34600D17AD7 /* BlurBackground.swift in Sources */, 95ECCA60261216D500A67EFA /* LineView.swift in Sources */, @@ -445,7 +425,7 @@ 950D0E222618AD4A00D17AD7 /* SearchModel.swift in Sources */, 95A7C066261639E0003E2EC1 /* SearchView.swift in Sources */, 95ECCA5D2612169200A67EFA /* LineShape.swift in Sources */, - 9550444C26111FED000E0BCB /* TopStockItem.swift in Sources */, + 9550444C26111FED000E0BCB /* StockItem.swift in Sources */, 950D0E192618AA4900D17AD7 /* CompanyList.swift in Sources */, 950D0E362618B61000D17AD7 /* BackgroundShadow.swift in Sources */, 950D0E292618AEC800D17AD7 /* CompanyRow.swift in Sources */,
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/LazyBear.xcodeproj/xcshareddata/xcschemes/LazyBear.xcscheme Sun Apr 04 13:20:14 2021 +0200 +++ b/LazyBear.xcodeproj/xcshareddata/xcschemes/LazyBear.xcscheme Mon Apr 05 20:08:19 2021 +0200 @@ -31,7 +31,7 @@ </Testables> </TestAction> <LaunchAction - buildConfiguration = "Debug" + buildConfiguration = "Release" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Global Models/CompanyQuoteModel.swift Mon Apr 05 20:08:19 2021 +0200 @@ -0,0 +1,15 @@ +// +// CompanyQuoteModel.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 30/3/21. +// + +import SwiftUI + +struct CompanyQuoteModel: Codable, Hashable { + var companyName: String + var symbol: String + var latestPrice: Double + var changePercent: Double +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Global Models/IntradayPricesModel.swift Mon Apr 05 20:08:19 2021 +0200 @@ -0,0 +1,12 @@ +// +// IntradayPricesModel.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 3/4/21. +// + +import SwiftUI + +struct IntradayPricesModel: Codable { + var open: Double? +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Views/Global Helpers/StockItem.swift Mon Apr 05 20:08:19 2021 +0200 @@ -0,0 +1,75 @@ +// +// StockItem.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 28/3/21. +// + +import SwiftUI + +struct StockItem: View { + var company: CompanyQuoteModel + @State private var intradayPrices = [IntradayPricesModel]() + + private let baseUrl = Bundle.main.infoDictionary?["IEX_URL"] as? String ?? "Empty url" + private let apiKey = Bundle.main.infoDictionary?["IEX_API"] as? String ?? "Empty key" + + var body: some View { + RoundedRectangle(cornerRadius: 20) + .foregroundColor(Color(.secondarySystemBackground)) + .aspectRatio(0.8, contentMode: .fit) + .clipShape(RoundedRectangle(cornerRadius: 20)) + .overlay( + VStack(alignment: .leading) { + Group { + Text(company.symbol.uppercased()) + .fontWeight(.semibold) + .padding(.top) + + Text(company.companyName.capitalized) + .font(.callout) + .fontWeight(.semibold) + .opacity(0.6) + .lineLimit(1) + + PriceView(latestPrice: company.latestPrice, changePercent: company.changePercent) + + } + .padding(.horizontal) + + Spacer() + + let prices = intradayPrices.compactMap { $0.open } + if prices.isEmpty { + Text("No data available") + .font(.caption) + .opacity(0.6) + + Spacer() + } else { + LineView(data: prices) + .foregroundColor(company.changePercent < 0 ? .red: .green) + .padding(.vertical) + .clipped() + } + + } + ,alignment: .leading + ) + .onAppear { requestIntradayPrices(company.symbol) } + } + + private func requestIntradayPrices(_ symbol: String) { + let url = "\(baseUrl)/stock/\(symbol)/intraday-prices?token=\(apiKey)" + genericRequest(url: url, model: [IntradayPricesModel].self) { + self.intradayPrices = $0 + } + } +} + +struct StockItem_Previews: PreviewProvider { + static var previews: some View { + StockItem(company: CompanyQuoteModel(companyName: "Akumin Inc", symbol: "AKU", latestPrice: 120.30, changePercent: 0.03)) + + } +}
--- a/LazyBear/Views/Home/Helpers/TopStockItem.swift Sun Apr 04 13:20:14 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -// -// TopStockItem.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 28/3/21. -// - -import SwiftUI - -struct TopStockItem: View { - var company: CompanyQuoteModel - @State private var intradayPrices = [IntradayPricesModel]() - - private let baseUrl = Bundle.main.infoDictionary?["IEX_URL"] as? String ?? "Empty url" - private let apiKey = Bundle.main.infoDictionary?["IEX_API"] as? String ?? "Empty key" - - var body: some View { - RoundedRectangle(cornerRadius: 20) - .foregroundColor(Color(.secondarySystemBackground)) - .aspectRatio(0.8, contentMode: .fit) - .clipShape(RoundedRectangle(cornerRadius: 20)) - .overlay( - VStack(alignment: .leading) { - Group { - Text(company.symbol.uppercased()) - .fontWeight(.semibold) - .padding(.top) - - Text(company.companyName.capitalized) - .font(.callout) - .fontWeight(.semibold) - .opacity(0.6) - .lineLimit(1) - - PriceView(latestPrice: company.latestPrice, changePercent: company.changePercent) - - } - .padding(.horizontal) - - Spacer() - - let prices = intradayPrices.compactMap { $0.open } - if prices.isEmpty { - Text("No data available") - .font(.caption) - .opacity(0.6) - } else { - LineView(data: prices) - .foregroundColor(company.changePercent < 0 ? .red: .green) - .padding(.vertical) - .clipped() - } - - } - ,alignment: .leading - ) - .onAppear { requestIntradayPrices(company.symbol) } - } - - private func requestIntradayPrices(_ symbol: String) { - let url = "\(baseUrl)/stock/\(symbol)/intraday-prices?token=\(apiKey)" - genericRequest(url: url, model: [IntradayPricesModel].self) { - self.intradayPrices = $0 - } - } -} - -struct TopStockItem_Previews: PreviewProvider { - static var previews: some View { - TopStockItem(company: CompanyQuoteModel(companyName: "Akumin Inc", symbol: "AKU", latestPrice: 120.30, changePercent: 0.03)) - - } -}
--- a/LazyBear/Views/Home/Helpers/TopStockRow.swift Sun Apr 04 13:20:14 2021 +0200 +++ b/LazyBear/Views/Home/Helpers/TopStockRow.swift Mon Apr 05 20:08:19 2021 +0200 @@ -21,7 +21,7 @@ ScrollView(.horizontal, showsIndicators: false) { HStack(spacing: 20) { ForEach(list, id: \.self) { company in - TopStockItem(company: company) + StockItem(company: company) } } .padding() @@ -44,6 +44,6 @@ struct TopStockRow_Previews: PreviewProvider { static var previews: some View { - TopStockRow(listType: "gainers", list: [CompanyQuoteModel(companyName: "apple inc", symbol: "aapl", latestPrice: 120.30, changePercent: 0.03)]) + TopStockRow(listType: "gainers", list: [CompanyQuoteModel(companyName: "apple inc", symbol: "aapl", latestPrice: 120.30, changePercent: 0.034)]) } }
--- a/LazyBear/Views/Home/HomeView.swift Sun Apr 04 13:20:14 2021 +0200 +++ b/LazyBear/Views/Home/HomeView.swift Mon Apr 05 20:08:19 2021 +0200 @@ -36,7 +36,7 @@ } .listRowInsets(EdgeInsets()) } - .onReceive(timer) { _ in homeData.request() } + .onReceive(timer) { _ in homeData.get() } .onDisappear { self.timer.upstream.connect().cancel() } // Stop timer .navigationTitle("\(dueDate, formatter: Self.taskDateFormat)") .navigationBarTitleDisplayMode(.inline) @@ -55,7 +55,7 @@ } else { ProgressView() .onAppear { - homeData.request() + homeData.get() // Restart timer self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() }
--- a/LazyBear/Views/Home/Networking/CompanyQuoteModel.swift Sun Apr 04 13:20:14 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -// -// CompanyQuoteModel.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 30/3/21. -// - -import SwiftUI - -struct CompanyQuoteModel: Codable, Hashable { - var companyName: String - var symbol: String - var latestPrice: Double - var changePercent: Double -}
--- a/LazyBear/Views/Home/Networking/HomeData.swift Sun Apr 04 13:20:14 2021 +0200 +++ b/LazyBear/Views/Home/Networking/HomeData.swift Mon Apr 05 20:08:19 2021 +0200 @@ -20,7 +20,7 @@ private let apiKey = Bundle.main.infoDictionary?["IEX_API"] as? String ?? "Empty key" - func request() { + func get() { let dispatchGroup = DispatchGroup() var url = String()
--- a/LazyBear/Views/Home/Networking/IntradayPricesModel.swift Sun Apr 04 13:20:14 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -// -// IntradayPricesModel.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 3/4/21. -// - -import SwiftUI - -struct IntradayPricesModel: Codable { - var open: Double? -}
--- a/LazyBear/Views/Profile/Helpers/EditProfile.swift Sun Apr 04 13:20:14 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -// -// EditProfile.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 4/4/21. -// - -import SwiftUI - -struct EditProfile: View { - var body: some View { - NavigationView { - Form { - let footer = "This could be your first name or nickname. Let you creativity flow." - Section(header: Text("Name"), footer: Text(footer)) { - Text("Hello") - } - - Section(header: Text("Country")) { - Text("Country") - } - } - .navigationTitle("Edit your profile") - .navigationBarTitleDisplayMode(.inline) - } - } -} - -struct EditProfile_Previews: PreviewProvider { - static var previews: some View { - EditProfile() - } -}
--- a/LazyBear/Views/Profile/Helpers/ImagePicker.swift Sun Apr 04 13:20:14 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -// -// ImagePicker.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 4/4/21. -// - -import SwiftUI - -struct ImagePicker: UIViewControllerRepresentable { - @Environment(\.presentationMode) var presentationMode - @Binding var image: UIImage? - - func makeUIViewController(context: UIViewControllerRepresentableContext<ImagePicker>) -> UIImagePickerController { - let picker = UIImagePickerController() - picker.delegate = context.coordinator - return picker - } - - func updateUIViewController(_ uiViewController: UIImagePickerController, context: UIViewControllerRepresentableContext<ImagePicker>) { - - } - - class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate { - let parent: ImagePicker - - init(_ parent: ImagePicker) { - self.parent = parent - } - - func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) { - if let uiImage = info[.originalImage] as? UIImage { - parent.image = uiImage - } - - parent.presentationMode.wrappedValue.dismiss() - } - } - - func makeCoordinator() -> Coordinator { - Coordinator(self) - - } -} -
--- a/LazyBear/Views/Profile/Helpers/UserProfile.swift Sun Apr 04 13:20:14 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -// -// UserProfile.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 4/4/21. -// - -import SwiftUI - -struct UserProfile: View { - @State private var showingImagePicker = false - @State private var inputImage: UIImage? - @State private var userImage = Image("") - - var body: some View { - VStack { - Circle() - .frame(width: 200, height: 200) - .overlay( - userImage - .resizable() - .clipShape(Circle()) - - ) - .onTapGesture { self.showingImagePicker = true } - - } - .sheet(isPresented: $showingImagePicker, onDismiss: loadImage) { - ImagePicker(image: self.$inputImage) - } - } - - private func loadImage() { - guard let inputImage = inputImage else { return } - userImage = Image(uiImage: inputImage) - - } -} - -struct UserProfile_Previews: PreviewProvider { - static var previews: some View { - UserProfile() - } -}
--- a/LazyBear/Views/Profile/ProfileView.swift Sun Apr 04 13:20:14 2021 +0200 +++ b/LazyBear/Views/Profile/ProfileView.swift Mon Apr 05 20:08:19 2021 +0200 @@ -8,9 +8,18 @@ import SwiftUI struct ProfileView: View { + @FetchRequest(entity: WatchlistCompany.entity(), sortDescriptors: []) + var watchlistCompanies: FetchedResults<WatchlistCompany> + var body: some View { NavigationView { - UserProfile() + List { + ForEach(watchlistCompanies, id: \.self) { company in + Text("Hello company") + } + } + .navigationTitle("My profile") + .navigationBarTitleDisplayMode(.inline) } } }
--- a/LazyBear/Views/Search/Networking/SearchData.swift Sun Apr 04 13:20:14 2021 +0200 +++ b/LazyBear/Views/Search/Networking/SearchData.swift Mon Apr 05 20:08:19 2021 +0200 @@ -13,7 +13,7 @@ private let baseUrl = Bundle.main.infoDictionary?["IEX_URL"] as? String ?? "Empty url" private let apiKey = Bundle.main.infoDictionary?["IEX_API"] as? String ?? "Empty key" - func request(_ searchedText: String) { + func get(_ searchedText: String) { let url = "\(baseUrl)/search/\(searchedText)?token=\(apiKey)" genericRequest(url: url, model: [SearchModel].self) {
--- a/LazyBear/Views/Search/SearchView.swift Sun Apr 04 13:20:14 2021 +0200 +++ b/LazyBear/Views/Search/SearchView.swift Mon Apr 05 20:08:19 2021 +0200 @@ -48,7 +48,7 @@ if !searchedText.isEmpty { // Encode string with spaces let encodedSearchedText = searchedText.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) - searchData.request(encodedSearchedText!) + searchData.get(encodedSearchedText!) self.showingSearchList = true } }