Mercurial > public > lazybear
changeset 75:883cac235c16
Implementing API endpoints, request function finished
line wrap: on
line diff
--- a/LazyBear.xcodeproj/project.pbxproj Sat Jan 23 00:18:07 2021 +0100 +++ b/LazyBear.xcodeproj/project.pbxproj Sun Jan 24 16:15:17 2021 +0100 @@ -11,17 +11,16 @@ 950B79F625B1CB7A00E5DB5B /* CompanyList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950B79F525B1CB7A00E5DB5B /* CompanyList.swift */; }; 952498B325BB381300B00E22 /* CurrentPrice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952498B225BB381300B00E22 /* CurrentPrice.swift */; }; 952498B625BB47A700B00E22 /* LatestPriceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952498B525BB47A700B00E22 /* LatestPriceModel.swift */; }; - 952498B925BB481100B00E22 /* LatestPrice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952498B825BB481100B00E22 /* LatestPrice.swift */; }; - 95493BA425BB8C8100761301 /* IntradayPricesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95493BA325BB8C8100761301 /* IntradayPricesModel.swift */; }; 954D992225A2105F001F7F60 /* companies.json in Resources */ = {isa = PBXBuildFile; fileRef = 954D992125A2105F001F7F60 /* companies.json */; }; 954D992525A2123B001F7F60 /* HistoricalPricesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954D992425A2123B001F7F60 /* HistoricalPricesModel.swift */; }; 954D996D25A2461B001F7F60 /* SwiftUICharts in Frameworks */ = {isa = PBXBuildFile; productRef = 954D996C25A2461B001F7F60 /* SwiftUICharts */; }; 954D997125A253A9001F7F60 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954D997025A253A9001F7F60 /* Config.swift */; }; - 954D998325A27571001F7F60 /* HistoricalPrices.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954D998225A27571001F7F60 /* HistoricalPrices.swift */; }; 9552A61F25B06580001CD0C8 /* SampleConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9552A61E25B0657F001CD0C8 /* SampleConfig.swift */; }; 95612C512598D48200F7698F /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95612C4F2598D48200F7698F /* SearchBar.swift */; }; 956FAF7B25AF421E0002B2C1 /* FavCompany+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 956FAF7925AF421E0002B2C1 /* FavCompany+CoreDataClass.swift */; }; 956FAF7C25AF421E0002B2C1 /* FavCompany+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 956FAF7A25AF421E0002B2C1 /* FavCompany+CoreDataProperties.swift */; }; + 95700BC625BD9D12009CEEFE /* API.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95700BC525BD9D12009CEEFE /* API.swift */; }; + 95700BC925BDAF83009CEEFE /* Test2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95700BC825BDAF83009CEEFE /* Test2.swift */; }; 958E472B25B1CA8B0048E770 /* FavCompanyList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 958E472A25B1CA8B0048E770 /* FavCompanyList.swift */; }; 95AB4A7A259DCBAE0064C9C1 /* ReadJson.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95AB4A79259DCBAE0064C9C1 /* ReadJson.swift */; }; 95AB4A7D259DCC0C0064C9C1 /* CompanyDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95AB4A7C259DCC0C0064C9C1 /* CompanyDataModel.swift */; }; @@ -29,9 +28,12 @@ 95B04EB325212369000AD27F /* LazyBearApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95B04EB225212369000AD27F /* LazyBearApp.swift */; }; 95B04EB525212369000AD27F /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95B04EB425212369000AD27F /* ContentView.swift */; }; 95B04EB72521236A000AD27F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 95B04EB62521236A000AD27F /* Assets.xcassets */; }; + 95C28AB625BC45CF0033D16A /* ChartStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95C28AB525BC45CF0033D16A /* ChartStyle.swift */; }; + 95C28AB925BC46250033D16A /* ScalateChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95C28AB825BC46250033D16A /* ScalateChart.swift */; }; 95D1BF4925ADCF7700E5D063 /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95D1BF4825ADCF7700E5D063 /* Persistence.swift */; }; 95E0287825B88F0B00020CF2 /* formDescription.json in Resources */ = {isa = PBXBuildFile; fileRef = 95E0287725B88F0B00020CF2 /* formDescription.json */; }; 95E0287B25B88F3C00020CF2 /* FormDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95E0287A25B88F3C00020CF2 /* FormDescription.swift */; }; + 95E68FD625BCC2E4006468EF /* Test.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95E68FD525BCC2E4006468EF /* Test.swift */; }; 95F6C2DD25BAD394003CF389 /* FavCompanyRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F6C2DC25BAD394003CF389 /* FavCompanyRow.swift */; }; 95F6C2E425BAD529003CF389 /* RandomColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F6C2E325BAD529003CF389 /* RandomColor.swift */; }; 95F6C2F025BAE2ED003CF389 /* Company.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F6C2EF25BAE2ED003CF389 /* Company.swift */; }; @@ -40,7 +42,6 @@ 95F6C30125BAEC8B003CF389 /* ShowingCompany.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F6C30025BAEC8B003CF389 /* ShowingCompany.swift */; }; 95F6C30525BAF599003CF389 /* CompanyHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F6C30425BAF599003CF389 /* CompanyHeader.swift */; }; 95F6C30925BAF7C2003CF389 /* DateSelection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F6C30825BAF7C2003CF389 /* DateSelection.swift */; }; - 95F6C30C25BAFDF5003CF389 /* Insiders.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F6C30B25BAFDF5003CF389 /* Insiders.swift */; }; 95F6C31125BAFFB8003CF389 /* AddWatchlist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95F6C31025BAFFB8003CF389 /* AddWatchlist.swift */; }; 95F7CAF625ADC7B7009E0E7C /* LazyBear.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 95F7CAF425ADC7B7009E0E7C /* LazyBear.xcdatamodeld */; }; /* End PBXBuildFile section */ @@ -51,16 +52,15 @@ 950B79F525B1CB7A00E5DB5B /* CompanyList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompanyList.swift; sourceTree = "<group>"; }; 952498B225BB381300B00E22 /* CurrentPrice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentPrice.swift; sourceTree = "<group>"; }; 952498B525BB47A700B00E22 /* LatestPriceModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = LatestPriceModel.swift; path = lazybear/Models/LatestPriceModel.swift; sourceTree = SOURCE_ROOT; }; - 952498B825BB481100B00E22 /* LatestPrice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = LatestPrice.swift; path = lazybear/Functions/LatestPrice.swift; sourceTree = SOURCE_ROOT; }; - 95493BA325BB8C8100761301 /* IntradayPricesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = IntradayPricesModel.swift; path = lazybear/Models/IntradayPricesModel.swift; sourceTree = SOURCE_ROOT; }; 954D992125A2105F001F7F60 /* companies.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = companies.json; path = lazybear/Data/companies.json; sourceTree = SOURCE_ROOT; }; 954D992425A2123B001F7F60 /* HistoricalPricesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = HistoricalPricesModel.swift; path = lazybear/Models/HistoricalPricesModel.swift; sourceTree = SOURCE_ROOT; }; 954D997025A253A9001F7F60 /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Config.swift; path = lazybear/Config.swift; sourceTree = SOURCE_ROOT; }; - 954D998225A27571001F7F60 /* HistoricalPrices.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = HistoricalPrices.swift; path = lazybear/Functions/HistoricalPrices.swift; sourceTree = SOURCE_ROOT; }; 9552A61E25B0657F001CD0C8 /* SampleConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SampleConfig.swift; path = lazybear/SampleConfig.swift; sourceTree = SOURCE_ROOT; }; 95612C4F2598D48200F7698F /* SearchBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchBar.swift; sourceTree = "<group>"; }; 956FAF7925AF421E0002B2C1 /* FavCompany+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FavCompany+CoreDataClass.swift"; sourceTree = "<group>"; }; 956FAF7A25AF421E0002B2C1 /* FavCompany+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FavCompany+CoreDataProperties.swift"; sourceTree = "<group>"; }; + 95700BC525BD9D12009CEEFE /* API.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = API.swift; path = lazybear/API.swift; sourceTree = SOURCE_ROOT; }; + 95700BC825BDAF83009CEEFE /* Test2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Test2.swift; path = lazybear/Tests/Test2.swift; sourceTree = SOURCE_ROOT; }; 958E472A25B1CA8B0048E770 /* FavCompanyList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = FavCompanyList.swift; path = "lazybear/Supply views/FavCompanyList.swift"; sourceTree = SOURCE_ROOT; }; 95AB4A79259DCBAE0064C9C1 /* ReadJson.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ReadJson.swift; path = lazybear/Functions/ReadJson.swift; sourceTree = SOURCE_ROOT; }; 95AB4A7C259DCC0C0064C9C1 /* CompanyDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CompanyDataModel.swift; path = lazybear/Models/CompanyDataModel.swift; sourceTree = SOURCE_ROOT; }; @@ -70,18 +70,20 @@ 95B04EB425212369000AD27F /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; }; 95B04EB62521236A000AD27F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 95B04EBB2521236A000AD27F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; + 95C28AB525BC45CF0033D16A /* ChartStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ChartStyle.swift; path = lazybear/Functions/ChartStyle.swift; sourceTree = SOURCE_ROOT; }; + 95C28AB825BC46250033D16A /* ScalateChart.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ScalateChart.swift; path = lazybear/Functions/ScalateChart.swift; sourceTree = SOURCE_ROOT; }; 95D1BF4825ADCF7700E5D063 /* Persistence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Persistence.swift; path = "LazyBear/Core Data/Persistence.swift"; sourceTree = SOURCE_ROOT; }; 95E0287725B88F0B00020CF2 /* formDescription.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = formDescription.json; path = lazybear/Data/formDescription.json; sourceTree = SOURCE_ROOT; }; 95E0287A25B88F3C00020CF2 /* FormDescription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = FormDescription.swift; path = lazybear/Models/FormDescription.swift; sourceTree = SOURCE_ROOT; }; + 95E68FD525BCC2E4006468EF /* Test.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Test.swift; path = lazybear/Tests/Test.swift; sourceTree = SOURCE_ROOT; }; 95F6C2DC25BAD394003CF389 /* FavCompanyRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavCompanyRow.swift; sourceTree = "<group>"; }; 95F6C2E325BAD529003CF389 /* RandomColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = RandomColor.swift; path = lazybear/Functions/RandomColor.swift; sourceTree = SOURCE_ROOT; }; 95F6C2EF25BAE2ED003CF389 /* Company.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Company.swift; sourceTree = "<group>"; }; 95F6C2F225BAE3D1003CF389 /* Stock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stock.swift; sourceTree = "<group>"; }; 95F6C2FD25BAEBBD003CF389 /* HeaderWatchList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderWatchList.swift; sourceTree = "<group>"; }; - 95F6C30025BAEC8B003CF389 /* ShowingCompany.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ShowingCompany.swift; path = lazybear/Models/ShowingCompany.swift; sourceTree = SOURCE_ROOT; }; + 95F6C30025BAEC8B003CF389 /* ShowingCompany.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ShowingCompany.swift; path = "lazybear/Supply views/ShowingCompany.swift"; sourceTree = SOURCE_ROOT; }; 95F6C30425BAF599003CF389 /* CompanyHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompanyHeader.swift; sourceTree = "<group>"; }; 95F6C30825BAF7C2003CF389 /* DateSelection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateSelection.swift; sourceTree = "<group>"; }; - 95F6C30B25BAFDF5003CF389 /* Insiders.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Insiders.swift; sourceTree = "<group>"; }; 95F6C31025BAFFB8003CF389 /* AddWatchlist.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddWatchlist.swift; sourceTree = "<group>"; }; 95F7CAF525ADC7B7009E0E7C /* LazyBear.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = LazyBear.xcdatamodel; sourceTree = "<group>"; }; /* End PBXFileReference section */ @@ -110,6 +112,8 @@ 952F791C2598B1CD00FF929F /* Tests */ = { isa = PBXGroup; children = ( + 95E68FD525BCC2E4006468EF /* Test.swift */, + 95700BC825BDAF83009CEEFE /* Test2.swift */, ); path = Tests; sourceTree = "<group>"; @@ -117,6 +121,7 @@ 95612C4D2598D48200F7698F /* Supply views */ = { isa = PBXGroup; children = ( + 95F6C30025BAEC8B003CF389 /* ShowingCompany.swift */, 95612C4F2598D48200F7698F /* SearchBar.swift */, 958E472A25B1CA8B0048E770 /* FavCompanyList.swift */, 95F6C2DC25BAD394003CF389 /* FavCompanyRow.swift */, @@ -124,11 +129,9 @@ 950B79F525B1CB7A00E5DB5B /* CompanyList.swift */, 95AB4A8F259DD66D0064C9C1 /* CompanyRow.swift */, 95F6C30425BAF599003CF389 /* CompanyHeader.swift */, - 95F6C2F225BAE3D1003CF389 /* Stock.swift */, 952498B225BB381300B00E22 /* CurrentPrice.swift */, 95F6C30825BAF7C2003CF389 /* DateSelection.swift */, 95F6C31025BAFFB8003CF389 /* AddWatchlist.swift */, - 95F6C30B25BAFDF5003CF389 /* Insiders.swift */, ); name = "Supply views"; path = "lazybear/Supply views"; @@ -138,9 +141,9 @@ isa = PBXGroup; children = ( 95AB4A79259DCBAE0064C9C1 /* ReadJson.swift */, - 954D998225A27571001F7F60 /* HistoricalPrices.swift */, 95F6C2E325BAD529003CF389 /* RandomColor.swift */, - 952498B825BB481100B00E22 /* LatestPrice.swift */, + 95C28AB525BC45CF0033D16A /* ChartStyle.swift */, + 95C28AB825BC46250033D16A /* ScalateChart.swift */, ); path = Functions; sourceTree = "<group>"; @@ -151,9 +154,7 @@ 95AB4A7C259DCC0C0064C9C1 /* CompanyDataModel.swift */, 954D992425A2123B001F7F60 /* HistoricalPricesModel.swift */, 95E0287A25B88F3C00020CF2 /* FormDescription.swift */, - 95F6C30025BAEC8B003CF389 /* ShowingCompany.swift */, 952498B525BB47A700B00E22 /* LatestPriceModel.swift */, - 95493BA325BB8C8100761301 /* IntradayPricesModel.swift */, ); path = Models; sourceTree = "<group>"; @@ -195,10 +196,12 @@ 95002578256D1564008FFD28 /* Configuration.storekit */, 95F7CAF425ADC7B7009E0E7C /* LazyBear.xcdatamodeld */, 954D997025A253A9001F7F60 /* Config.swift */, + 95700BC525BD9D12009CEEFE /* API.swift */, 9552A61E25B0657F001CD0C8 /* SampleConfig.swift */, 95B04EB225212369000AD27F /* LazyBearApp.swift */, 95B04EB425212369000AD27F /* ContentView.swift */, 95F6C2EF25BAE2ED003CF389 /* Company.swift */, + 95F6C2F225BAE3D1003CF389 /* Stock.swift */, 95612C4D2598D48200F7698F /* Supply views */, 95855384259CD9800081CF24 /* Functions */, 9592F496259D29F1005AB6F1 /* Models */, @@ -293,7 +296,6 @@ buildActionMask = 2147483647; files = ( 95AB4A7A259DCBAE0064C9C1 /* ReadJson.swift in Sources */, - 95493BA425BB8C8100761301 /* IntradayPricesModel.swift in Sources */, 95E0287B25B88F3C00020CF2 /* FormDescription.swift in Sources */, 952498B625BB47A700B00E22 /* LatestPriceModel.swift in Sources */, 95F6C30525BAF599003CF389 /* CompanyHeader.swift in Sources */, @@ -309,17 +311,19 @@ 95F6C2F025BAE2ED003CF389 /* Company.swift in Sources */, 95D1BF4925ADCF7700E5D063 /* Persistence.swift in Sources */, 958E472B25B1CA8B0048E770 /* FavCompanyList.swift in Sources */, - 952498B925BB481100B00E22 /* LatestPrice.swift in Sources */, - 95F6C30C25BAFDF5003CF389 /* Insiders.swift in Sources */, 956FAF7B25AF421E0002B2C1 /* FavCompany+CoreDataClass.swift in Sources */, + 95E68FD625BCC2E4006468EF /* Test.swift in Sources */, 95F6C31125BAFFB8003CF389 /* AddWatchlist.swift in Sources */, 95B04EB325212369000AD27F /* LazyBearApp.swift in Sources */, 95F6C2F325BAE3D1003CF389 /* Stock.swift in Sources */, - 954D998325A27571001F7F60 /* HistoricalPrices.swift in Sources */, 95AB4A7D259DCC0C0064C9C1 /* CompanyDataModel.swift in Sources */, 95F6C2DD25BAD394003CF389 /* FavCompanyRow.swift in Sources */, + 95700BC625BD9D12009CEEFE /* API.swift in Sources */, + 95700BC925BDAF83009CEEFE /* Test2.swift in Sources */, 95F6C2E425BAD529003CF389 /* RandomColor.swift in Sources */, + 95C28AB625BC45CF0033D16A /* ChartStyle.swift in Sources */, 954D997125A253A9001F7F60 /* Config.swift in Sources */, + 95C28AB925BC46250033D16A /* ScalateChart.swift in Sources */, 9552A61F25B06580001CD0C8 /* SampleConfig.swift in Sources */, 954D992525A2123B001F7F60 /* HistoricalPricesModel.swift in Sources */, 95F7CAF625ADC7B7009E0E7C /* LazyBear.xcdatamodeld in Sources */,
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lazybear/API.swift Sun Jan 24 16:15:17 2021 +0100 @@ -0,0 +1,42 @@ +// +// API.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 24/1/21. +// + +import SwiftUI + + +enum Url { + case sandbox + case production + + var url: String { + switch self { + case .sandbox: + return "https://sandbox.iexapis.com" + case .production: + return "https://cloud.iexapis.com" + } + } +} + +enum Endpoints { + case historicalPrices(H) + enum H { + case range(R) + enum R { + + } + } +} + +struct SomeTest: View { + var body: some View { + Text("Hello world") + .onAppear { + + } + } +}
--- a/lazybear/Company.swift Sat Jan 23 00:18:07 2021 +0100 +++ b/lazybear/Company.swift Sun Jan 24 16:15:17 2021 +0100 @@ -15,9 +15,8 @@ CompanyHeader(name: self.name, symbol: self.symbol) ScrollView { VStack(alignment: .leading) { - Stock(name: self.name, symbol: self.symbol) + //Stock(name: self.name, symbol: self.symbol) Spacer() - //Insiders() } } }
--- a/lazybear/ContentView.swift Sat Jan 23 00:18:07 2021 +0100 +++ b/lazybear/ContentView.swift Sun Jan 24 16:15:17 2021 +0100 @@ -26,8 +26,8 @@ HeaderWatchlist() FavCompanyList() .environment(\.managedObjectContext, persistenceController.container.viewContext) - } - else { + + } else { if searchedCompany.count > 2 { CompanyList(searchedCompany: $searchedCompany) }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lazybear/Functions/ChartStyle.swift Sun Jan 24 16:15:17 2021 +0100 @@ -0,0 +1,22 @@ +// +// ChartStyle.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 23/1/21. +// + +import SwiftUI +import SwiftUICharts + +func chartStyle() -> ChartStyle { + let gradient = GradientColor(start: .green, end: .green) + let style = ChartStyle( + backgroundColor: .white, + accentColor: .green, + gradientColor: gradient, + textColor: .black, + legendTextColor: .black, + dropShadowColor: .white) + + return style +}
--- a/lazybear/Functions/HistoricalPrices.swift Sat Jan 23 00:18:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -// -// RequestPrices.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 3/1/21. -// - -import SwiftUI - -class HistoricalPrices: ObservableObject { - @Published var result = [HistoricalPricesModel]() - @Published var showingView = false - @Published var showingAlert = false - - func request(symbol: String, period: String, sandbox: Bool) { - guard let url = URL(string: historicalPricesUrl(symbol: symbol, period: period, sandbox: sandbox)) else { // Change sandbox when production - print("Invalid URL") - return - } - print(url) - let request = URLRequest(url: url) - URLSession.shared.dataTask(with: request) { data, response, error in - if let data = data { - if let decodedResponse = try? JSONDecoder().decode([HistoricalPricesModel].self, from: data) { - // we have good data – go back to the main thread - DispatchQueue.main.async { - // update our UI - self.result = decodedResponse - print("API request ok") - - // Check if data is empty - if self.result.isEmpty || self.result.count <= 1 { - print("Data is empty") - self.showingView = false - self.showingAlert = true - } else { - print("Showing view...") - self.showingView = true - } - - } - - // everything is good, so we can exit - return - } - - } - - // if we're still here it means there was a problem - print("Fetch failed: \(error?.localizedDescription ?? "Unknown error")") - }.resume() - } -}
--- a/lazybear/Functions/LatestPrice.swift Sat Jan 23 00:18:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -// -// LatestPrice.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 22/1/21. -// - -import SwiftUI - -class LatestPrice: ObservableObject { - @Published var latestPrice = Double() - @Published var changePercent = Double() - //@Published var isUSMarketOpen = Bool() - - @Published var showingView = false - @Published var showingAlert = false - - func request(symbol: String, sandbox: Bool) { - guard let url = URL(string: latestPriceUrl(symbol: symbol, sandbox: sandbox)) else { // Change sandbox when production - print("Invalid URL") - return - } - print(url) - let request = URLRequest(url: url) - URLSession.shared.dataTask(with: request) { data, response, error in - if let data = data { - if let decodedResponse = try? JSONDecoder().decode(LatestPriceModel.self, from: data) { - // we have good data – go back to the main thread - DispatchQueue.main.async { - // update our UI - self.latestPrice = decodedResponse.latestPrice - self.changePercent = decodedResponse.changePercent - //self.isUSMarketOpen = decodedResponse.isUSMarketOpen - self.showingView = true - print("API request ok") - print("Showing view...") - } - - // everything is good, so we can exit - return - } - } - - // if we're still here it means there was a problem - print("Fetch failed: \(error?.localizedDescription ?? "Unknown error")") - }.resume() - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lazybear/Functions/ScalateChart.swift Sun Jan 24 16:15:17 2021 +0100 @@ -0,0 +1,25 @@ +// +// ScalateChart.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 23/1/21. +// + +import SwiftUI + +func scalateChart(prices: [Double], selectedPeriod: Int) -> [Double] { + // Remove every two items to shorter the chart data points + var indexesToRemove = Set<Int>() + + if selectedPeriod >= 4 { + for index in 0..<prices.count { + indexesToRemove.insert(index*2) + } + } + let prices = prices + .enumerated() + .filter { !indexesToRemove.contains($0.offset) } + .map { $0.element } + + return prices +}
--- a/lazybear/LazyBearApp.swift Sat Jan 23 00:18:07 2021 +0100 +++ b/lazybear/LazyBearApp.swift Sun Jan 24 16:15:17 2021 +0100 @@ -13,7 +13,7 @@ var body: some Scene { WindowGroup { - ContentView() + SomeTest() .environment(\.managedObjectContext, persistenceController.container.viewContext) } }
--- a/lazybear/Models/IntradayPricesModel.swift Sat Jan 23 00:18:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -// -// IntradayPriceModel.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 22/1/21. -// - -import SwiftUI - -struct IntradayPricesModel: Codable { - var open: Double -}
--- a/lazybear/Models/ShowingCompany.swift Sat Jan 23 00:18:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -// -// ShowingCompany.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 22/1/21. -// - -import SwiftUI - -class ShowingCompany: ObservableObject { - @Published var isShowing: Bool = false { - didSet { - print("Company is showing -> " + String(isShowing)) - } - } -}
--- a/lazybear/SampleConfig.swift Sat Jan 23 00:18:07 2021 +0100 +++ b/lazybear/SampleConfig.swift Sun Jan 24 16:15:17 2021 +0100 @@ -5,27 +5,3 @@ // Created by Dennis Concepción Martín on 14/1/21. // -/* -import SwiftUI - -func samplePriceUrl(symbol: String, sandbox: Bool) -> String { - var token = "" - var url = "" - if sandbox { - token = "SANDBOX TOKEN" - url = "SANDBOX URL" - } - else { - token = "TOKEN" - url = "URL" - } - - return url -} - -func sampleTransactionUrl(cik: String, date: String) -> String { - let url = "URL" - - return url -} -*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lazybear/Stock.swift Sun Jan 24 16:15:17 2021 +0100 @@ -0,0 +1,67 @@ +// +// Price.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 22/1/21. +// + +import SwiftUI +import SwiftUICharts +/* +struct Stock: View { + @ObservedObject var historicalPrices = HistoricalPrices() + @ObservedObject var latestPrice = LatestPrice() + + var periods = ["1D", "1W", "1M", "3M", "6M", "1Y", "2Y", "5Y"] + @State var selectedPeriod = 3 + var name: String + var symbol: String + + var body: some View { + VStack { + Divider() + + let price = latestPrice.latestPrice + let change = latestPrice.changePercent*100 + //let marketIsOpen = latestPrice.isUSMarketOpen + + if latestPrice.showingView { + CurrentPrice(price: price, change: change, marketIsOpen: false) + } else { + HStack { + ProgressView() + .padding(.leading) + Spacer() + } + } + + Divider() + DateSelection(selectedperiod: $selectedPeriod) + .padding([.leading, .trailing]) + .onChange(of: selectedPeriod, perform: { value in + historicalPrices.showingView.toggle() + historicalPrices.request(symbol: self.symbol, period: periods[selectedPeriod], sandbox: true) + }) + + if historicalPrices.showingView { + let prices = historicalPrices.result.map { $0.close } + LineView(data: scalateChart(prices: prices, selectedPeriod: selectedPeriod), title: "", style: chartStyle()) + .padding([.leading, .trailing]) + .offset(y: -40) + } else { + ProgressView() + } + } + .onAppear { + historicalPrices.request(symbol: self.symbol, period: periods[selectedPeriod], sandbox: true) + latestPrice.request(symbol: self.symbol, sandbox: true) + } + } +} + +struct Price_Previews: PreviewProvider { + static var previews: some View { + Stock(name: "Apple Inc", symbol: "AAPL") + } +} +*/
--- a/lazybear/Supply views/DateSelection.swift Sat Jan 23 00:18:07 2021 +0100 +++ b/lazybear/Supply views/DateSelection.swift Sun Jan 24 16:15:17 2021 +0100 @@ -8,7 +8,7 @@ import SwiftUI struct DateSelection: View { - var period = ["1D", "1W", "1M", "3M", "6M", "1Y", "2Y", "5Y"] + var period = ["1W", "1M", "3M", "6M", "1Y", "2Y", "5Y"] @Binding var selectedperiod: Int var body: some View {
--- a/lazybear/Supply views/Insiders.swift Sat Jan 23 00:18:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -// -// Insiders.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 22/1/21. -// - -import SwiftUI - -struct Insiders: View { - var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) - } -} - -struct Insiders_Previews: PreviewProvider { - static var previews: some View { - Insiders() - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lazybear/Supply views/ShowingCompany.swift Sun Jan 24 16:15:17 2021 +0100 @@ -0,0 +1,16 @@ +// +// ShowingCompany.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 22/1/21. +// + +import SwiftUI + +class ShowingCompany: ObservableObject { + @Published var isShowing: Bool = false { + didSet { + print("Company is showing -> " + String(isShowing)) + } + } +}
--- a/lazybear/Supply views/Stock.swift Sat Jan 23 00:18:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -// -// Price.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 22/1/21. -// - -import SwiftUI -import SwiftUICharts - -struct Stock: View { - @ObservedObject var historicalPrices = HistoricalPrices() - @ObservedObject var latestPrice = LatestPrice() - - var periods = ["1D", "1W", "1M", "3M", "6M", "1Y", "2Y", "5Y"] - @State var selectedPeriod = 3 - var name: String - var symbol: String - - var body: some View { - VStack { - Divider() - - let price = latestPrice.latestPrice - let change = latestPrice.changePercent*100 - //let marketIsOpen = latestPrice.isUSMarketOpen - - if latestPrice.showingView { - CurrentPrice(price: price, change: change, marketIsOpen: false) - } else { - HStack { - ProgressView() - .padding(.leading) - Spacer() - } - } - Divider() - DateSelection(selectedperiod: $selectedPeriod) - .onChange(of: selectedPeriod, perform: { value in - historicalPrices.showingView.toggle() - historicalPrices.request(symbol: self.symbol, period: periods[selectedPeriod], sandbox: true) - }) - .padding([.leading, .trailing]) - - if historicalPrices.showingView { - let prices = historicalPrices.result.map { $0.close } - LineView(data: scalate(prices: prices), title: "", style: chartStyle()) - .padding([.leading, .trailing]) - .offset(y: -40) - } else { - ProgressView() - } - } - .onAppear { - historicalPrices.request(symbol: self.symbol, period: periods[selectedPeriod], sandbox: true) - latestPrice.request(symbol: self.symbol, sandbox: true) - } - } - - func chartStyle() -> ChartStyle { - let gradient = GradientColor(start: .green, end: .green) - let style = ChartStyle( - backgroundColor: .white, - accentColor: .green, - gradientColor: gradient, - textColor: .black, - legendTextColor: .black, - dropShadowColor: .white) - - return style - } - - func scalate(prices: [Double]) -> [Double] { - // Remove every two items to shorter the chart data points - var indexesToRemove = Set<Int>() - - if selectedPeriod >= 5 { - for index in 0..<prices.count { - indexesToRemove.insert(index*2) - } - } - let prices = prices - .enumerated() - .filter { !indexesToRemove.contains($0.offset) } - .map { $0.element } - - return prices - } -} - -struct Price_Previews: PreviewProvider { - static var previews: some View { - Stock(name: "Apple Inc", symbol: "AAPL") - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lazybear/Tests/File.swift Sun Jan 24 16:15:17 2021 +0100 @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Dennis Concepción Martín on 24/1/21. +// + +import Foundation
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lazybear/Tests/SomeTests.playground/Contents.swift Sun Jan 24 16:15:17 2021 +0100 @@ -0,0 +1,12 @@ +import UIKit + +func returnDouble() -> (String, String) { + let a = "Hello" + let b = "world" + + return (a, b) +} + +let (a, b) = returnDouble() +print(a) +print(b)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lazybear/Tests/SomeTests.playground/contents.xcplayground Sun Jan 24 16:15:17 2021 +0100 @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<playground version='5.0' target-platform='ios' buildActiveScheme='true'> + <timeline fileName='timeline.xctimeline'/> +</playground> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lazybear/Tests/Test.swift Sun Jan 24 16:15:17 2021 +0100 @@ -0,0 +1,47 @@ +// +// Test.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 23/1/21. +// + +import SwiftUI + +// We take some model data T.Type +func loadData<T: Decodable>(model: T.Type, completion: @escaping (T) -> Void) { + guard let url = URL(string: "") else { + print("Invalid URL") + return + } + let request = URLRequest(url: url) + URLSession.shared.dataTask(with: request) { data, response, error in + if let data = data { + do { + // Decode response with the model passed + let decodedResponse = try JSONDecoder().decode(model, from: data) + DispatchQueue.main.async { + print(decodedResponse) + completion(decodedResponse) + } + return + } catch { + print(error) + } + } + print("Fetch failed: \(error?.localizedDescription ?? "Unknown error")") + } + .resume() +} + + +struct Test: View { + @State var results = [HistoricalPricesModel]() + var body: some View { + Text("Hello world") + .onAppear { + loadData(model: [HistoricalPricesModel].self) { + self.results = $0 + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lazybear/Tests/Test2.swift Sun Jan 24 16:15:17 2021 +0100 @@ -0,0 +1,23 @@ +// +// Test2.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 24/1/21. +// + +import SwiftUI + +struct Test2: View { + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + .onAppear { + + } + } +} + +struct Test2_Previews: PreviewProvider { + static var previews: some View { + Test2() + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lazybear/Tests/Untitled.xcworkspace/contents.xcworkspacedata Sun Jan 24 16:15:17 2021 +0100 @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Workspace + version = "1.0"> + <FileRef + location = "group:File.swift"> + </FileRef> +</Workspace>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lazybear/Tests/Untitled.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist Sun Jan 24 16:15:17 2021 +0100 @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IDEDidComputeMac32BitWarning</key> + <true/> +</dict> +</plist>