Mercurial > public > lazybear
changeset 348:0abb8d5c12ec
Merge pull request #12 from DennisTechnologies/dennis
Implementing Prop API
committer: GitHub <noreply@github.com>
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Sun, 11 Apr 2021 19:56:04 +0200 |
parents | 2132a211820d (current diff) 80bfa88c6b0f (diff) |
children | 5ccceb527178 284ca0328c60 |
files | LazyBear/Global Models/QuoteModel.swift LazyBear/Global Models/SectorPerformanceModel.swift LazyBear/Global Models/TradingDatesModel.swift |
diffstat | 29 files changed, 373 insertions(+), 575 deletions(-) [+] |
line wrap: on
line diff
--- a/LazyBear.xcodeproj/project.pbxproj Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear.xcodeproj/project.pbxproj Sun Apr 11 19:56:04 2021 +0200 @@ -9,8 +9,6 @@ /* Begin PBXBuildFile section */ 950C36E3260FB6180081CF53 /* HapticsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950C36E2260FB6180081CF53 /* HapticsManager.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 */; }; @@ -21,7 +19,6 @@ 951566EA2613A37C007C0F36 /* TradingDatesItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951566E92613A37C007C0F36 /* TradingDatesItem.swift */; }; 952045152610C7C600A76362 /* ConvertEpoch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952045142610C7C600A76362 /* ConvertEpoch.swift */; }; 9523ED422615BDB2006D3D6F /* phrases.json in Resources */ = {isa = PBXBuildFile; fileRef = 9523ED412615BDB2006D3D6F /* phrases.json */; }; - 9523ED542615CB7F006D3D6F /* HomeData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9523ED532615CB7F006D3D6F /* HomeData.swift */; }; 954D7EA7260BBA6600A13C50 /* WatchlistCompany+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954D7EA5260BBA6600A13C50 /* WatchlistCompany+CoreDataClass.swift */; }; 954D7EA8260BBA6600A13C50 /* WatchlistCompany+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954D7EA6260BBA6600A13C50 /* WatchlistCompany+CoreDataProperties.swift */; }; 954D7EC2260BE70C00A13C50 /* SwiftlySearch in Frameworks */ = {isa = PBXBuildFile; productRef = 954D7EC1260BE70C00A13C50 /* SwiftlySearch */; }; @@ -30,17 +27,19 @@ 9550444626111EE5000E0BCB /* SectorItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9550444526111EE5000E0BCB /* SectorItem.swift */; }; 9550444926111FC9000E0BCB /* StockRectangleRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9550444826111FC9000E0BCB /* StockRectangleRow.swift */; }; 9550444C26111FED000E0BCB /* StockItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9550444B26111FED000E0BCB /* StockItem.swift */; }; + 955E732D26235561005652FF /* QuoteModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955E732C26235561005652FF /* QuoteModel.swift */; }; + 955E7330262355FD005652FF /* SectorPerformanceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955E732F262355FD005652FF /* SectorPerformanceModel.swift */; }; + 955E733326235633005652FF /* IntradayPricesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955E733226235633005652FF /* IntradayPricesModel.swift */; }; + 955E73362623565F005652FF /* TradingDatesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955E73352623565F005652FF /* TradingDatesModel.swift */; }; + 955E73392623568F005652FF /* Home.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955E73382623568F005652FF /* Home.swift */; }; + 955E733C262356F3005652FF /* HomeResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955E733B262356F3005652FF /* HomeResponse.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 */; }; 95672B9825DDA54700DCBE4A /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95672B9725DDA54700DCBE4A /* Persistence.swift */; }; 95672B9B25DDA54800DCBE4A /* LazyBear.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 95672B9925DDA54800DCBE4A /* LazyBear.xcdatamodeld */; }; - 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 */; }; - 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 */; }; 95A5188626186F590002D27C /* PriceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A5188526186F590002D27C /* PriceView.swift */; }; 95A7C066261639E0003E2EC1 /* SearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A7C065261639DF003E2EC1 /* SearchView.swift */; }; 95A7C0742616409D003E2EC1 /* ParseJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A7C0732616409D003E2EC1 /* ParseJSON.swift */; }; @@ -49,16 +48,11 @@ 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 */; }; - 95FD09CB261BA13800393042 /* ProfileData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95FD09CA261BA13800393042 /* ProfileData.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 950BA46B25E944F500D065EF /* Production.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Production.xcconfig; sourceTree = "<group>"; }; - 950BA46C25E944FC00D065EF /* Sandbox.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Sandbox.xcconfig; sourceTree = "<group>"; }; 950C36E2260FB6180081CF53 /* HapticsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HapticsManager.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>"; }; @@ -69,7 +63,6 @@ 951566E92613A37C007C0F36 /* TradingDatesItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TradingDatesItem.swift; sourceTree = "<group>"; }; 952045142610C7C600A76362 /* ConvertEpoch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConvertEpoch.swift; sourceTree = "<group>"; }; 9523ED412615BDB2006D3D6F /* phrases.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = phrases.json; sourceTree = "<group>"; }; - 9523ED532615CB7F006D3D6F /* HomeData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeData.swift; sourceTree = "<group>"; }; 954D7EA5260BBA6600A13C50 /* WatchlistCompany+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WatchlistCompany+CoreDataClass.swift"; sourceTree = "<group>"; }; 954D7EA6260BBA6600A13C50 /* WatchlistCompany+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WatchlistCompany+CoreDataProperties.swift"; sourceTree = "<group>"; }; 9550443926111B2B000E0BCB /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; }; @@ -77,6 +70,12 @@ 9550444526111EE5000E0BCB /* SectorItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectorItem.swift; sourceTree = "<group>"; }; 9550444826111FC9000E0BCB /* StockRectangleRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StockRectangleRow.swift; sourceTree = "<group>"; }; 9550444B26111FED000E0BCB /* StockItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StockItem.swift; sourceTree = "<group>"; }; + 955E732C26235561005652FF /* QuoteModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuoteModel.swift; sourceTree = "<group>"; }; + 955E732F262355FD005652FF /* SectorPerformanceModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectorPerformanceModel.swift; sourceTree = "<group>"; }; + 955E733226235633005652FF /* IntradayPricesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntradayPricesModel.swift; sourceTree = "<group>"; }; + 955E73352623565F005652FF /* TradingDatesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TradingDatesModel.swift; sourceTree = "<group>"; }; + 955E73382623568F005652FF /* Home.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Home.swift; sourceTree = "<group>"; }; + 955E733B262356F3005652FF /* HomeResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeResponse.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>"; }; @@ -84,13 +83,9 @@ 95672B9725DDA54700DCBE4A /* Persistence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Persistence.swift; sourceTree = "<group>"; }; 95672B9A25DDA54800DCBE4A /* LazyBear.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = LazyBear.xcdatamodel; sourceTree = "<group>"; }; 95672B9C25DDA54800DCBE4A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; - 95893DCD2613C46B003698C5 /* CompanyQuoteModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompanyQuoteModel.swift; sourceTree = "<group>"; }; 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>"; }; - 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>"; }; 95A5188526186F590002D27C /* PriceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PriceView.swift; sourceTree = "<group>"; }; 95A7C065261639DF003E2EC1 /* SearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchView.swift; sourceTree = "<group>"; }; 95A7C0732616409D003E2EC1 /* ParseJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParseJSON.swift; sourceTree = "<group>"; }; @@ -99,7 +94,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>"; }; - 95FD09CA261BA13800393042 /* ProfileData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileData.swift; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -118,8 +112,6 @@ 950D0E202618AD3D00D17AD7 /* Networking */ = { isa = PBXGroup; children = ( - 950D0E242618ADD000D17AD7 /* SearchData.swift */, - 950D0E212618AD4A00D17AD7 /* SearchModel.swift */, ); path = Networking; sourceTree = "<group>"; @@ -171,8 +163,10 @@ children = ( 954D7EA5260BBA6600A13C50 /* WatchlistCompany+CoreDataClass.swift */, 954D7EA6260BBA6600A13C50 /* WatchlistCompany+CoreDataProperties.swift */, - 95893DCD2613C46B003698C5 /* CompanyQuoteModel.swift */, - 95A5187626186C830002D27C /* IntradayPricesModel.swift */, + 955E732C26235561005652FF /* QuoteModel.swift */, + 955E732F262355FD005652FF /* SectorPerformanceModel.swift */, + 955E733226235633005652FF /* IntradayPricesModel.swift */, + 955E73352623565F005652FF /* TradingDatesModel.swift */, ); path = "Global Models"; sourceTree = "<group>"; @@ -221,8 +215,6 @@ 958A734E25E016FD00FD7ECA /* LazyBear.entitlements */, 95672B9C25DDA54800DCBE4A /* Info.plist */, 95672B9925DDA54800DCBE4A /* LazyBear.xcdatamodeld */, - 950BA46B25E944F500D065EF /* Production.xcconfig */, - 950BA46C25E944FC00D065EF /* Sandbox.xcconfig */, 95672B9225DDA54700DCBE4A /* Assets.xcassets */, 95672B8E25DDA54700DCBE4A /* LazyBearApp.swift */, 95AD4A2C26078C1400498079 /* ContentView.swift */, @@ -230,7 +222,6 @@ 950C36E2260FB6180081CF53 /* HapticsManager.swift */, 950D0E322618B44800D17AD7 /* HudManager.swift */, 95B1874925DDAC4D0068A364 /* Views */, - 95CD32E2261C5B0600901250 /* Secondary Views */, 952045132610C7A200A76362 /* Global functions */, 954D7E9D260BBA5200A13C50 /* Global Models */, 9523ED402615BD93006D3D6F /* Resources */, @@ -252,9 +243,8 @@ 95893DC72613C410003698C5 /* Networking */ = { isa = PBXGroup; children = ( - 9523ED532615CB7F006D3D6F /* HomeData.swift */, - 95A5187926186C960002D27C /* TradingDatesModel.swift */, - 95A5187326186C680002D27C /* SectorPerformanceModel.swift */, + 955E73382623568F005652FF /* Home.swift */, + 955E733B262356F3005652FF /* HomeResponse.swift */, ); path = Networking; sourceTree = "<group>"; @@ -304,21 +294,6 @@ path = Views; sourceTree = "<group>"; }; - 95CD32E2261C5B0600901250 /* Secondary Views */ = { - isa = PBXGroup; - children = ( - 95CD32E3261C5B2200901250 /* Company */, - ); - path = "Secondary Views"; - sourceTree = "<group>"; - }; - 95CD32E3261C5B2200901250 /* Company */ = { - isa = PBXGroup; - children = ( - ); - path = Company; - sourceTree = "<group>"; - }; 95E745D72614622C00744A1E /* Home */ = { isa = PBXGroup; children = ( @@ -347,7 +322,6 @@ 95FD09C9261BA12800393042 /* Networking */ = { isa = PBXGroup; children = ( - 95FD09CA261BA13800393042 /* ProfileData.swift */, ); path = Networking; sourceTree = "<group>"; @@ -432,39 +406,37 @@ 95FBE0DC2619CA7200440386 /* ProfileView.swift in Sources */, 95A5186A26185AAB0002D27C /* GenericRequest.swift in Sources */, 95E745DA2614624500744A1E /* HomeDataPreview.swift in Sources */, - 95A5187726186C830002D27C /* IntradayPricesModel.swift in Sources */, 95A5188626186F590002D27C /* PriceView.swift in Sources */, 9550444926111FC9000E0BCB /* StockRectangleRow.swift in Sources */, - 9523ED542615CB7F006D3D6F /* HomeData.swift in Sources */, 9550444326111E7A000E0BCB /* SectorRow.swift in Sources */, - 95FD09CB261BA13800393042 /* ProfileData.swift in Sources */, + 955E7330262355FD005652FF /* SectorPerformanceModel.swift in Sources */, 950D0E302618B34600D17AD7 /* BlurBackground.swift in Sources */, 95ECCA60261216D500A67EFA /* LineView.swift in Sources */, 9550443A26111B2B000E0BCB /* HomeView.swift in Sources */, - 95A5187426186C680002D27C /* SectorPerformanceModel.swift in Sources */, 95672B9825DDA54700DCBE4A /* Persistence.swift in Sources */, 95A7C0742616409D003E2EC1 /* ParseJSON.swift in Sources */, 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 */, + 955E73392623568F005652FF /* Home.swift in Sources */, 95672B8F25DDA54700DCBE4A /* LazyBearApp.swift in Sources */, - 950D0E222618AD4A00D17AD7 /* SearchModel.swift in Sources */, 95A7C066261639E0003E2EC1 /* SearchView.swift in Sources */, 95ECCA5D2612169200A67EFA /* LineShape.swift in Sources */, 9550444C26111FED000E0BCB /* StockItem.swift in Sources */, 950D0E192618AA4900D17AD7 /* CompanyList.swift in Sources */, 950D0E362618B61000D17AD7 /* BackgroundShadow.swift in Sources */, + 955E732D26235561005652FF /* QuoteModel.swift in Sources */, 950D0E292618AEC800D17AD7 /* CompanyRow.swift in Sources */, + 955E733C262356F3005652FF /* HomeResponse.swift in Sources */, + 955E733326235633005652FF /* IntradayPricesModel.swift in Sources */, 951566EA2613A37C007C0F36 /* TradingDatesItem.swift in Sources */, - 950D0E252618ADD000D17AD7 /* SearchData.swift in Sources */, 951490552610BD2B00BDEEB5 /* WelcomeView.swift in Sources */, - 95A5187A26186C960002D27C /* TradingDatesModel.swift in Sources */, 9550444626111EE5000E0BCB /* SectorItem.swift in Sources */, 954D7EA7260BBA6600A13C50 /* WatchlistCompany+CoreDataClass.swift in Sources */, 95672B9B25DDA54800DCBE4A /* LazyBear.xcdatamodeld in Sources */, 95AD4A2D26078C1400498079 /* ContentView.swift in Sources */, + 955E73362623565F005652FF /* TradingDatesModel.swift in Sources */, 952045152610C7C600A76362 /* ConvertEpoch.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -474,7 +446,6 @@ /* Begin XCBuildConfiguration section */ 95672B9D25DDA54800DCBE4A /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 950BA46C25E944FC00D065EF /* Sandbox.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -536,7 +507,6 @@ }; 95672B9E25DDA54800DCBE4A /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 950BA46B25E944F500D065EF /* Production.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES;
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/LazyBear.xcodeproj/xcshareddata/xcschemes/LazyBear.xcscheme Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear.xcodeproj/xcshareddata/xcschemes/LazyBear.xcscheme Sun Apr 11 19:56:04 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 Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear/ContentView.swift Sun Apr 11 19:56:04 2021 +0200 @@ -19,21 +19,21 @@ Image(systemName: "house") Text("Home") } - SearchView() - .tabItem { - Image(systemName: "magnifyingglass") - Text("Search") - } - ProfileView() - .tabItem { - Image(systemName: "person") - Text("Profile") - } - Text("The Last Tab") - .tabItem { - Image(systemName: "4.square.fill") - Text("Forth") - } +// SearchView() +// .tabItem { +// Image(systemName: "magnifyingglass") +// Text("Search") +// } +// ProfileView() +// .tabItem { +// Image(systemName: "person") +// Text("Profile") +// } +// Text("The Last Tab") +// .tabItem { +// Image(systemName: "4.square.fill") +// Text("Forth") +// } } // .onAppear { isAppAlreadyLaunchedOnce() } .sheet(isPresented: $showWelcome) {
--- a/LazyBear/Global Models/CompanyQuoteModel.swift Sun Apr 11 00:34:30 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/Global Models/IntradayPricesModel.swift Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear/Global Models/IntradayPricesModel.swift Sun Apr 11 19:56:04 2021 +0200 @@ -2,15 +2,11 @@ // IntradayPricesModel.swift // LazyBear // -// Created by Dennis Concepción Martín on 3/4/21. +// Created by Dennis Concepción Martín on 11/4/21. // import SwiftUI -struct IntradayPricesBatch: Codable { - var intradayprices: [IntradayPricesResult] +struct IntradayPricesModel: Codable { + var marketOpen: Double? } - -struct IntradayPricesResult: Codable { - var open: Double? -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Global Models/QuoteModel.swift Sun Apr 11 19:56:04 2021 +0200 @@ -0,0 +1,15 @@ +// +// QuoteModel.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 11/4/21. +// + +import SwiftUI + +struct QuoteModel: 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/SectorPerformanceModel.swift Sun Apr 11 19:56:04 2021 +0200 @@ -0,0 +1,13 @@ +// +// SectorPerformanceModel.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 11/4/21. +// + +import SwiftUI + +struct SectorPerformanceModel: Codable, Hashable { + var name: String + var performance: Double +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Global Models/TradingDatesModel.swift Sun Apr 11 19:56:04 2021 +0200 @@ -0,0 +1,12 @@ +// +// TradingDatesModel.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 11/4/21. +// + +import SwiftUI + +struct TradingDatesModel: Codable { + var date: String +}
--- a/LazyBear/Info.plist Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear/Info.plist Sun Apr 11 19:56:04 2021 +0200 @@ -176,10 +176,6 @@ <string>$(MARKETING_VERSION)</string> <key>CFBundleVersion</key> <string>$(CURRENT_PROJECT_VERSION)</string> - <key>IEX_API</key> - <string>$(IEX_API)</string> - <key>IEX_URL</key> - <string>$(IEX_URL)</string> <key>LSRequiresIPhoneOS</key> <true/> <key>UIApplicationSceneManifest</key>
--- a/LazyBear/Preview Content/Home/Networking/HomeDataPreview.swift Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear/Preview Content/Home/Networking/HomeDataPreview.swift Sun Apr 11 19:56:04 2021 +0200 @@ -5,23 +5,23 @@ // Created by Dennis Concepción Martín on 31/3/21. // -import SwiftUI - -class HomeDataPreview: ObservableObject { - @Published var sectorPerformance = [ - SectorPerformanceModel(name: "Communication Services", performance: 0.043, lastUpdated: 1617177387000), - SectorPerformanceModel(name: "Consumer Discretionary", performance: 0.043, lastUpdated: 1617177387000), - SectorPerformanceModel(name: "Consumer Staples", performance: 0.043, lastUpdated: 1617177387000), - SectorPerformanceModel(name: "Energy", performance: 0.043, lastUpdated: 1617177387000), - SectorPerformanceModel(name: "Financials", performance: 0.043, lastUpdated: 1617177387000), - SectorPerformanceModel(name: "Health Care", performance: 0.043, lastUpdated: 1617177387000), - SectorPerformanceModel(name: "Industrials", performance: 0.043, lastUpdated: 1617177387000), - SectorPerformanceModel(name: "Materials", performance: 0.043, lastUpdated: 1617177387000), - SectorPerformanceModel(name: "Real Estate", performance: 0.043, lastUpdated: 1617177387000), - SectorPerformanceModel(name: "Technology", performance: 0.043, lastUpdated: 1617177387000), - SectorPerformanceModel(name: "Utilities", performance: 0.043, lastUpdated: 1617177387000), - ] - - - -} +//import SwiftUI +// +//class HomeDataPreview: ObservableObject { +// @Published var sectorPerformance = [ +// SectorPerformanceModel(name: "Communication Services", performance: 0.043, lastUpdated: 1617177387000), +// SectorPerformanceModel(name: "Consumer Discretionary", performance: 0.043, lastUpdated: 1617177387000), +// SectorPerformanceModel(name: "Consumer Staples", performance: 0.043, lastUpdated: 1617177387000), +// SectorPerformanceModel(name: "Energy", performance: 0.043, lastUpdated: 1617177387000), +// SectorPerformanceModel(name: "Financials", performance: 0.043, lastUpdated: 1617177387000), +// SectorPerformanceModel(name: "Health Care", performance: 0.043, lastUpdated: 1617177387000), +// SectorPerformanceModel(name: "Industrials", performance: 0.043, lastUpdated: 1617177387000), +// SectorPerformanceModel(name: "Materials", performance: 0.043, lastUpdated: 1617177387000), +// SectorPerformanceModel(name: "Real Estate", performance: 0.043, lastUpdated: 1617177387000), +// SectorPerformanceModel(name: "Technology", performance: 0.043, lastUpdated: 1617177387000), +// SectorPerformanceModel(name: "Utilities", performance: 0.043, lastUpdated: 1617177387000), +// ] +// +// +// +//}
--- a/LazyBear/Views/Global Helpers/StockItem.swift Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear/Views/Global Helpers/StockItem.swift Sun Apr 11 19:56:04 2021 +0200 @@ -8,8 +8,8 @@ import SwiftUI struct StockItem: View { - var company: CompanyQuoteModel - var intradayPrices: [IntradayPricesResult] + var company: QuoteModel + 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" @@ -39,14 +39,7 @@ Spacer() - let prices = intradayPrices.compactMap { $0.open } - if prices.isEmpty { - Text("No data available") - .font(.caption) - .opacity(0.6) - - Spacer() - } else { + if let prices = intradayPrices?.compactMap { $0.marketOpen } { LineView(data: prices) .foregroundColor(company.changePercent < 0 ? .red: .green) .padding(.vertical) @@ -56,13 +49,14 @@ } ,alignment: .leading ) - .onAppear { } } } struct StockItem_Previews: PreviewProvider { static var previews: some View { - StockItem(company: CompanyQuoteModel(companyName: "Akumin Inc", symbol: "AKU", latestPrice: 120.30, changePercent: 0.03), intradayPrices: [IntradayPricesResult(open: 130.3)]) - + StockItem( + company: QuoteModel(companyName: "apple inc", symbol: "aapl", latestPrice: 130.3, changePercent: 0.03), + intradayPrices: [IntradayPricesModel(marketOpen: 130.3)] + ) } }
--- a/LazyBear/Views/Global Helpers/StockRectangleRow.swift Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear/Views/Global Helpers/StockRectangleRow.swift Sun Apr 11 19:56:04 2021 +0200 @@ -9,13 +9,13 @@ struct StockRectangleRow: View { - var listType: String - var list: [CompanyQuoteModel] - var intradayPrices: [String: [IntradayPricesResult]] + var listName: String + var list: [QuoteModel] + var nestedIntradayPrices: [String: NestedIntradayPricesModel]? var body: some View { VStack(alignment: .leading) { - Text(adaptTitle(listType)) + Text(adaptTitle(listName)) .font(.title3) .fontWeight(.semibold) .padding([.top, .horizontal]) @@ -23,7 +23,11 @@ ScrollView(.horizontal, showsIndicators: false) { HStack(spacing: 20) { ForEach(list, id: \.self) { company in - StockItem(company: company, intradayPrices: self.intradayPrices[company.symbol]!) + if let intradayPrices = nestedIntradayPrices?[company.symbol.uppercased()] { + StockItem(company: company, intradayPrices: intradayPrices.nestedIntradayPrices) + } else { + StockItem(company: company, intradayPrices: nil) + } } } .padding() @@ -32,6 +36,12 @@ } .padding(.bottom) } + + private func testPrint(_ test: Any) -> Text { + print(test) + + return Text("") + } } private func adaptTitle(_ listType: String) -> String { @@ -45,6 +55,10 @@ struct StockRectangleRow_Previews: PreviewProvider { static var previews: some View { - StockRectangleRow(listType: "gainers", list: [CompanyQuoteModel(companyName: "apple inc", symbol: "aapl", latestPrice: 120.30, changePercent: 0.034)], intradayPrices: ["aapl": [IntradayPricesResult(open: 130.3)]]) + StockRectangleRow( + listName: "mostactive", + list: [QuoteModel(companyName: "apple inc", symbol: "aapl", latestPrice: 130.3, changePercent: 0.03)], + nestedIntradayPrices: ["AAPL": NestedIntradayPricesModel(nestedIntradayPrices: [IntradayPricesModel(marketOpen: 130.3)])] + ) } }
--- a/LazyBear/Views/Home/Helpers/SectorItem.swift Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear/Views/Home/Helpers/SectorItem.swift Sun Apr 11 19:56:04 2021 +0200 @@ -39,6 +39,6 @@ struct SectorItem_Previews: PreviewProvider { static var previews: some View { - SectorItem(sector: SectorPerformanceModel(name: "Technology", performance: 0.04, lastUpdated: 1617137138)) + SectorItem(sector: SectorPerformanceModel(name: "Technology", performance: 0.04)) } }
--- a/LazyBear/Views/Home/Helpers/SectorRow.swift Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear/Views/Home/Helpers/SectorRow.swift Sun Apr 11 19:56:04 2021 +0200 @@ -33,6 +33,6 @@ struct SectorRow_Previews: PreviewProvider { static var previews: some View { - SectorRow(sectorPerformance: [SectorPerformanceModel(name: "Technology", performance: 0.04, lastUpdated: 1617137138)]) + SectorRow(sectorPerformance: [SectorPerformanceModel(name: "Technology", performance: 0.04)]) } }
--- a/LazyBear/Views/Home/HomeView.swift Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear/Views/Home/HomeView.swift Sun Apr 11 19:56:04 2021 +0200 @@ -8,7 +8,7 @@ import SwiftUI struct HomeView: View { - @ObservedObject var homeData = HomeData() + @ObservedObject var home = Home() @State private var showTradingDates = false // Set recurrent price request @@ -23,23 +23,26 @@ let dueDate = Date() var body: some View { - if homeData.showView { + if home.showView { NavigationView { List { - SectorRow(sectorPerformance: homeData.sectorPerformance) + if let sectorPerformance = home.data.sectorPerformance { + SectorRow(sectorPerformance: sectorPerformance) + .listRowInsets(EdgeInsets()) + } + + if let lists = home.data.lists { + ForEach(Array(lists.keys.sorted()), id: \.self) { listName in + if let intradayPrices = home.data.intradayPrices { + StockRectangleRow(listName: listName, list: lists[listName]!, nestedIntradayPrices: intradayPrices) + } else { + StockRectangleRow(listName: listName, list: lists[listName]!, nestedIntradayPrices: nil) + } + } .listRowInsets(EdgeInsets()) - - // Get keys of the dictionary list - let listTypes = ["mostactive", "losers", "gainers"] - ForEach(listTypes.sorted(), id: \.self) { listType in - if let list = homeData.topLists[listType] { - StockRectangleRow(listType: listType, list: list, intradayPrices: homeData.intradayPrices) - - } } - .listRowInsets(EdgeInsets()) } - .onReceive(timer) { _ in homeData.get() } + .onReceive(timer) { _ in home.request("https://api.lazybear.app/home/streaming") } .onDisappear { self.timer.upstream.connect().cancel() } // Stop timer .navigationTitle("\(dueDate, formatter: Self.taskDateFormat)") .navigationBarTitleDisplayMode(.inline) @@ -53,12 +56,14 @@ } } .sheet(isPresented: $showTradingDates) { - TradingDates() + if let dates = home.data.tradingDates { + TradingDates(dates: dates) + } } } else { ProgressView() .onAppear { - homeData.get() + home.request("https://api.lazybear.app/home/init") // Restart timer self.timer = Timer.publish(every: 10, on: .main, in: .common).autoconnect() }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Views/Home/Networking/Home.swift Sun Apr 11 19:56:04 2021 +0200 @@ -0,0 +1,27 @@ +// +// Home.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 11/4/21. +// + +import SwiftUI + +class Home: ObservableObject { + @Published var showView = false + @Published var data = HomeResponse() + + func request(_ url: String) { + genericRequest(url: url, model: HomeResponse.self) { response in + // Is intradayPrices is empty -> request all data + if self.data.intradayPrices == nil { + self.data = response + } else { + // If not, request streaming data (without intradayPrices) + self.data.lists = response.lists + self.data.sectorPerformance = response.sectorPerformance + } + self.showView = true + } + } +}
--- a/LazyBear/Views/Home/Networking/HomeData.swift Sun Apr 11 00:34:30 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -// -// HomeData.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 1/4/21. -// - -import SwiftUI - -class HomeData: ObservableObject { - @Published var showView = false - - // Data - @Published var sectorPerformance = [SectorPerformanceModel]() - @Published var topLists = [String(): [CompanyQuoteModel]()] - @Published var intradayPrices = [String(): [IntradayPricesResult]()] - - private var symbolsInLists = [String()] - 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 get() { - let dispatchGroup = DispatchGroup() - var url = String() - - // 1. SECTOR PERFORMANCE REQUEST - url = "\(baseUrl)/stock/market/sector-performance?token=\(apiKey)" - dispatchGroup.enter() - - genericRequest(url: url, model: [SectorPerformanceModel].self) { - self.sectorPerformance = $0 - dispatchGroup.leave() - } - - // 2. STOCK LISTS REQUEST - let listTypes = ["mostactive", "losers", "gainers"] - for listType in listTypes { - url = "\(baseUrl)/stock/market/list/\(listType)?token=\(apiKey)" - dispatchGroup.enter() - - genericRequest(url: url, model: [CompanyQuoteModel].self) { list in - self.topLists[listType] = list - // Append symbols in list to array - for company in list { - self.symbolsInLists.append(company.symbol) - } - - dispatchGroup.leave() - } - } - - dispatchGroup.notify(queue: .main) { - if self.intradayPrices.count == 1 { - self.getIntradayPrices() - } else { - self.showView = true - } - } - } - - // 3. INTRADAY PRICES REQUEST - func getIntradayPrices() { - var url = "\(baseUrl)/stock/market/batch?symbols=" - - var counter = 0 - for symbol in symbolsInLists { - counter += 1 - if counter == 1 { - url += symbol - } else { - url += ",\(symbol)" - } - } - - url += "&types=intradayprices&token=\(apiKey)" - - genericRequest(url: url, model: [String: IntradayPricesBatch].self) { dict in - for symbol in dict.keys { - self.intradayPrices[symbol] = dict[symbol]?.intradayprices - } - - self.showView = true - } - } -} - -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Views/Home/Networking/HomeResponse.swift Sun Apr 11 19:56:04 2021 +0200 @@ -0,0 +1,31 @@ +// +// HomeResponse.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 11/4/21. +// + +import SwiftUI + +struct HomeResponse: Codable { + var lists: [String: [QuoteModel]]? // String is the list type; gainers, losers ... + var sectorPerformance: [SectorPerformanceModel]? + var tradingDates: [TradingDatesModel]? + var intradayPrices: [String: NestedIntradayPricesModel]? // String is each company symbol + + private enum CodingKeys : String, CodingKey { + case lists + case sectorPerformance = "sector_performance" + case tradingDates = "trading_dates" + case intradayPrices = "intraday_prices" + } +} + + +struct NestedIntradayPricesModel: Codable { + var nestedIntradayPrices: [IntradayPricesModel] + + private enum CodingKeys : String, CodingKey { + case nestedIntradayPrices = "intradayprices" + } +}
--- a/LazyBear/Views/Home/Networking/SectorPerformanceModel.swift Sun Apr 11 00:34:30 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -// -// SectorPerformanceModel.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 3/4/21. -// - -import SwiftUI - -struct SectorPerformanceModel: Codable, Hashable { - var name: String - var performance: Double - var lastUpdated: Int -}
--- a/LazyBear/Views/Home/Networking/TradingDatesModel.swift Sun Apr 11 00:34:30 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -// -// TradingDatesModel.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 3/4/21. -// - -import SwiftUI - -struct TradingDatesModel: Codable { - var date: String - -}
--- a/LazyBear/Views/Home/TradingDates.swift Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear/Views/Home/TradingDates.swift Sun Apr 11 19:56:04 2021 +0200 @@ -7,16 +7,9 @@ import SwiftUI -enum DateType { - case holidays, trading -} struct TradingDates: View { - @State private var dates = [TradingDatesModel]() - @State private var showingView = false - - 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 dates: [TradingDatesModel] var body: some View { NavigationView { @@ -28,29 +21,11 @@ } .padding() } - .onAppear { requestDates(.holidays) } .navigationTitle("Holiday dates") .navigationBarTitleDisplayMode(.inline) } } - private func requestDates(_ dateType: DateType) { - switch dateType { - case .trading: - let tradingUrl = "\(baseUrl)/ref-data/us/dates/trade/next/10?token=\(apiKey)" - genericRequest(url: tradingUrl, model: [TradingDatesModel].self) { - self.dates = $0 - self.showingView = true - } - case.holidays: - let holidaysUrl = "\(baseUrl)/ref-data/us/dates/holiday/next/10?token=\(apiKey)" - genericRequest(url: holidaysUrl, model: [TradingDatesModel].self) { - self.dates = $0 - self.showingView = true - } - } - } - private func getArrayOfDates() -> [Date] { // Get array of the string dates let stringDates = self.dates.map { $0.date } @@ -71,7 +46,7 @@ struct TradingDate_Previews: PreviewProvider { static var previews: some View { - // Format is YYY-MM-DD - TradingDates() + // Format is YYYY-MM-DD + TradingDates(dates: [TradingDatesModel(date: "2021-01-01")]) } }
--- a/LazyBear/Views/Profile/Networking/ProfileData.swift Sun Apr 11 00:34:30 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -// -// ProfileData.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 5/4/21. -// - -import SwiftUI - -class ProfileData: ObservableObject { - @Published var showView = false - - @Published var watchlists = [String(): [CompanyQuoteModel]()] - @Published var intradayPrices = [String(): [IntradayPricesResult]()] - - 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 get(_ watchlistCompanies: FetchedResults<WatchlistCompany>) { - let dispatchGroup = DispatchGroup() - var url = String() - - let watchlistSymbols = watchlistCompanies.map { $0.symbol } // Map watchlist symbols - - // 1. REQUEST LATEST PRICE OF THE COMPANIES IN THE WATCHLIST CORE DATA - url = "\(baseUrl)/stock/market/batch?symbols=" - - // If there are no companies in Core Data, do not request - if !watchlistCompanies.isEmpty { - var counter = 0 - for symbol in watchlistSymbols { // Iterate watchlist symbols - counter += 1 - - // Append symbols to the URL to make the batch request - if counter == 1 { - url += symbol - } else { - url += ",\(symbol)" - } - } - - url += "&types=quote&token=\(apiKey)" - genericRequest(url: url, model: [String: CompanyQuoteBatch].self) { dict in - // Iterate symbols in the Batch request (Keys of the dictionary response) - for symbol in dict.keys { - // Get index of the requested symbol in the watchlist symbol array - let index = watchlistSymbols.firstIndex(of: symbol) - - // Get watchlist name of that symbol - let watchlistName = watchlistCompanies[index!].watchlist - - // Append the CompanyQuote response to a dictionary with key as the watchlist name. Not trivial - // First create a object of the company I want to add to the dict - let newCompany = dict[symbol]?.quote - - // Second, get an array of the values in the watchlist key - if var companiesInWatchlist = self.watchlists[watchlistName] { - // Third, append the new value to that array - companiesInWatchlist.append(newCompany!) - - // Finally, append the updated array to the key dict - self.watchlists[watchlistName] = companiesInWatchlist - } else { - // If it's nil create the array and add it to dict - let initCompanyArray: [CompanyQuoteModel] = [newCompany!] - self.watchlists[watchlistName] = initCompanyArray - } - - print(self.watchlists) - - } - } - } else { - self.showView = true - } - } -} - - -struct CompanyQuoteBatch: Codable { - var quote: CompanyQuoteModel -}
--- a/LazyBear/Views/Profile/ProfileView.swift Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear/Views/Profile/ProfileView.swift Sun Apr 11 19:56:04 2021 +0200 @@ -7,56 +7,56 @@ import SwiftUI -struct ProfileView: View { - @ObservedObject var profileData = ProfileData() - @Environment(\.managedObjectContext) private var moc - @FetchRequest(entity: WatchlistCompany.entity(), sortDescriptors: []) - var watchlistCompanies: FetchedResults<WatchlistCompany> - - var body: some View { - NavigationView { - List { - Text("Hello World") - Button("Save company", action: addCompany) - Button("Delete company", action: removeCompany) - Button("Request", action: {profileData.get(watchlistCompanies)}) - Button("Print watchlist", action: {print(watchlistCompanies.map {$0.symbol})}) - } - .navigationTitle("My profile") - .navigationBarTitleDisplayMode(.inline) - } - } - - // REMOVE IN PRODUCTION - private func addCompany() { - let watchlistCompany = WatchlistCompany(context: moc) - watchlistCompany.symbol = "FB" - watchlistCompany.name = "Facebook Inc" - watchlistCompany.watchlist = "MyWatchlist" - do { - try moc.save() - print("Company saved") - } catch { - print(error.localizedDescription) - } - } - - private func removeCompany() { - let symbols = watchlistCompanies.map { $0.symbol } - let index = symbols.firstIndex(of: "aapl") - let company = watchlistCompanies[index!] - moc.delete(company) - do { - try moc.save() - print("Company deleted") - } catch { - // Error - } - } -} - -struct ProfileView_Previews: PreviewProvider { - static var previews: some View { - ProfileView() - } -} +//struct ProfileView: View { +// @ObservedObject var profileData = ProfileData() +// @Environment(\.managedObjectContext) private var moc +// @FetchRequest(entity: WatchlistCompany.entity(), sortDescriptors: []) +// var watchlistCompanies: FetchedResults<WatchlistCompany> +// +// var body: some View { +// NavigationView { +// List { +// Text("Hello World") +// Button("Save company", action: addCompany) +// Button("Delete company", action: removeCompany) +// Button("Request", action: {profileData.get(watchlistCompanies)}) +// Button("Print watchlist", action: {print(watchlistCompanies.map {$0.symbol})}) +// } +// .navigationTitle("My profile") +// .navigationBarTitleDisplayMode(.inline) +// } +// } +// +// // REMOVE IN PRODUCTION +// private func addCompany() { +// let watchlistCompany = WatchlistCompany(context: moc) +// watchlistCompany.symbol = "FB" +// watchlistCompany.name = "Facebook Inc" +// watchlistCompany.watchlist = "MyWatchlist" +// do { +// try moc.save() +// print("Company saved") +// } catch { +// print(error.localizedDescription) +// } +// } +// +// private func removeCompany() { +// let symbols = watchlistCompanies.map { $0.symbol } +// let index = symbols.firstIndex(of: "aapl") +// let company = watchlistCompanies[index!] +// moc.delete(company) +// do { +// try moc.save() +// print("Company deleted") +// } catch { +// // Error +// } +// } +//} +// +//struct ProfileView_Previews: PreviewProvider { +// static var previews: some View { +// ProfileView() +// } +//}
--- a/LazyBear/Views/Search/CompanyList.swift Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear/Views/Search/CompanyList.swift Sun Apr 11 19:56:04 2021 +0200 @@ -7,19 +7,19 @@ 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")]) - } -} +//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")]) +// } +//}
--- a/LazyBear/Views/Search/Helpers/CompanyRow.swift Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear/Views/Search/Helpers/CompanyRow.swift Sun Apr 11 19:56:04 2021 +0200 @@ -7,33 +7,33 @@ 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")) - } -} +//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")) +// } +//}
--- a/LazyBear/Views/Search/Networking/SearchData.swift Sun Apr 11 00:34:30 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -// -// SearchData.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 3/4/21. -// - -import SwiftUI - -class SearchData: ObservableObject { - @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" - - func get(_ searchedText: String) { - let url = "\(baseUrl)/search/\(searchedText)?token=\(apiKey)" - - genericRequest(url: url, model: [SearchModel].self) { - self.searchResult = $0 - } - } -}
--- a/LazyBear/Views/Search/Networking/SearchModel.swift Sun Apr 11 00:34:30 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -// -// 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 Sun Apr 11 00:34:30 2021 +0200 +++ b/LazyBear/Views/Search/SearchView.swift Sun Apr 11 19:56:04 2021 +0200 @@ -8,64 +8,64 @@ import SwiftUI import SwiftlySearch -struct SearchView: View { - @ObservedObject var searchData = SearchData() - @State private var searchedText: String = "" - @State private var showingSearchList = false - @EnvironmentObject var hudManager: HudManager - - var body: some View { - NavigationView { - VStack(alignment: .leading) { - if showingSearchList { - CompanyList(searchResult: searchData.searchResult) - } else { - VStack(alignment: .center) { - Image("bearSleeping") - .resizable() - .scaledToFit() - - Text("Are you looking for something?") - .font(.title2) - .fontWeight(.semibold) - .multilineTextAlignment(.center) - .padding(.bottom) - - Text("Use the search bar to find your favourite company. Type the stock symbol or name, we'll find it!") - .multilineTextAlignment(.center) - } - .padding(.horizontal) - } - } - .onDisappear { self.searchedText = ""; self.showingSearchList = false } - .navigationTitle("Search") - .navigationBarTitleDisplayMode(.inline) - .navigationBarSearch($searchedText) - .onChange(of: searchedText, perform: { searchedText in - showSearchList(searchedText) - }) - .toolbar { - ToolbarItem(placement: .navigationBarTrailing) { - Button(action: { self.hudManager.showSearchHelper = true }) { - Image(systemName: "questionmark.circle") - } - } - } - } - } - - private func showSearchList(_ searchedText: String) { - if !searchedText.isEmpty { - // Encode string with spaces - let encodedSearchedText = searchedText.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) - searchData.get(encodedSearchedText!) - self.showingSearchList = true - } - } -} - -struct SearchView_Previews: PreviewProvider { - static var previews: some View { - SearchView() - } -} +//struct SearchView: View { +// @ObservedObject var searchData = SearchData() +// @State private var searchedText: String = "" +// @State private var showingSearchList = false +// @EnvironmentObject var hudManager: HudManager +// +// var body: some View { +// NavigationView { +// VStack(alignment: .leading) { +// if showingSearchList { +// CompanyList(searchResult: searchData.searchResult) +// } else { +// VStack(alignment: .center) { +// Image("bearSleeping") +// .resizable() +// .scaledToFit() +// +// Text("Are you looking for something?") +// .font(.title2) +// .fontWeight(.semibold) +// .multilineTextAlignment(.center) +// .padding(.bottom) +// +// Text("Use the search bar to find your favourite company. Type the stock symbol or name, we'll find it!") +// .multilineTextAlignment(.center) +// } +// .padding(.horizontal) +// } +// } +// .onDisappear { self.searchedText = ""; self.showingSearchList = false } +// .navigationTitle("Search") +// .navigationBarTitleDisplayMode(.inline) +// .navigationBarSearch($searchedText) +// .onChange(of: searchedText, perform: { searchedText in +// showSearchList(searchedText) +// }) +// .toolbar { +// ToolbarItem(placement: .navigationBarTrailing) { +// Button(action: { self.hudManager.showSearchHelper = true }) { +// Image(systemName: "questionmark.circle") +// } +// } +// } +// } +// } +// +// private func showSearchList(_ searchedText: String) { +// if !searchedText.isEmpty { +// // Encode string with spaces +// let encodedSearchedText = searchedText.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) +// searchData.get(encodedSearchedText!) +// self.showingSearchList = true +// } +// } +//} +// +//struct SearchView_Previews: PreviewProvider { +// static var previews: some View { +// SearchView() +// } +//}