Mercurial > public > lazybear
changeset 443:ffbb1dbab531
InsiderRosterHelper implemented
line wrap: on
line diff
--- a/LazyBear.xcodeproj/project.pbxproj Mon Jun 21 13:28:45 2021 +0200 +++ b/LazyBear.xcodeproj/project.pbxproj Mon Jun 21 20:17:46 2021 +0200 @@ -31,7 +31,7 @@ 95131D47267A03020055C6DE /* WatchlistCompany+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95131D44267A02FC0055C6DE /* WatchlistCompany+CoreDataClass.swift */; }; 95131D4B267A15490055C6DE /* WatchlistSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95131D4A267A15490055C6DE /* WatchlistSheet.swift */; }; 951490552610BD2B00BDEEB5 /* WelcomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951490542610BD2B00BDEEB5 /* WelcomeView.swift */; }; - 951566E72613A2B6007C0F36 /* TradingDates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951566E62613A2B6007C0F36 /* TradingDates.swift */; }; + 951566E72613A2B6007C0F36 /* TradingDatesSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951566E62613A2B6007C0F36 /* TradingDatesSheet.swift */; }; 951566EA2613A37C007C0F36 /* TradingDatesItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951566E92613A37C007C0F36 /* TradingDatesItem.swift */; }; 9519BE06267E5EC3009C6015 /* ProfileStockRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9519BE05267E5EC3009C6015 /* ProfileStockRow.swift */; }; 952045152610C7C600A76362 /* ConvertEpoch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952045142610C7C600A76362 /* ConvertEpoch.swift */; }; @@ -71,6 +71,9 @@ 95672B9825DDA54700DCBE4A /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95672B9725DDA54700DCBE4A /* Persistence.swift */; }; 95672B9B25DDA54800DCBE4A /* LazyBear.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 95672B9925DDA54800DCBE4A /* LazyBear.xcdatamodeld */; }; 95721DA6262761E700EC527B /* CurrencyRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95721DA5262761E700EC527B /* CurrencyRow.swift */; }; + 9576BFEB26810661002BCAC6 /* InsiderRosterHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9576BFEA26810661002BCAC6 /* InsiderRosterHelper.swift */; }; + 9576BFED26810713002BCAC6 /* InsiderRosterList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9576BFEC26810713002BCAC6 /* InsiderRosterList.swift */; }; + 9576BFEF26810719002BCAC6 /* InsiderRosterRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9576BFEE26810719002BCAC6 /* InsiderRosterRow.swift */; }; 958A735225E0170900FD7ECA /* CloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 958A735125E0170900FD7ECA /* CloudKit.framework */; }; 9594331326691789004A0339 /* Bazooka in Frameworks */ = {isa = PBXBuildFile; productRef = 9594331226691789004A0339 /* Bazooka */; }; 9594F0402651355B00CFA8D4 /* HistoricalPricesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9594F03F2651355B00CFA8D4 /* HistoricalPricesModel.swift */; }; @@ -97,7 +100,6 @@ 95E2DBF82673752F007FCCB4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 95E2DBF72673752F007FCCB4 /* LaunchScreen.storyboard */; }; 95E4A2D7268091F900A6FEB9 /* NewsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95E4A2D6268091F900A6FEB9 /* NewsHelper.swift */; }; 95E4A2D92680931300A6FEB9 /* NewsRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95E4A2D82680931300A6FEB9 /* NewsRow.swift */; }; - 95E4A2DC2680971A00A6FEB9 /* SDWebImageSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 95E4A2DB2680971A00A6FEB9 /* SDWebImageSwiftUI */; }; 95E4A2E02680A70000A6FEB9 /* NewsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95E4A2DF2680A70000A6FEB9 /* NewsList.swift */; }; 95E4A2E22680AD7C00A6FEB9 /* SFSafariViewWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95E4A2E12680AD7C00A6FEB9 /* SFSafariViewWrapper.swift */; }; 95E8BAA32656D86E0016AE72 /* RequestType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95E8BAA22656D86E0016AE72 /* RequestType.swift */; }; @@ -203,7 +205,7 @@ 95131D45267A02FC0055C6DE /* WatchlistCompany+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WatchlistCompany+CoreDataProperties.swift"; sourceTree = "<group>"; }; 95131D4A267A15490055C6DE /* WatchlistSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WatchlistSheet.swift; sourceTree = "<group>"; }; 951490542610BD2B00BDEEB5 /* WelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeView.swift; sourceTree = "<group>"; }; - 951566E62613A2B6007C0F36 /* TradingDates.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TradingDates.swift; sourceTree = "<group>"; }; + 951566E62613A2B6007C0F36 /* TradingDatesSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TradingDatesSheet.swift; sourceTree = "<group>"; }; 951566E92613A37C007C0F36 /* TradingDatesItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TradingDatesItem.swift; sourceTree = "<group>"; }; 9519BE05267E5EC3009C6015 /* ProfileStockRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileStockRow.swift; sourceTree = "<group>"; }; 952045142610C7C600A76362 /* ConvertEpoch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConvertEpoch.swift; sourceTree = "<group>"; }; @@ -251,6 +253,9 @@ 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>"; }; 95721DA5262761E700EC527B /* CurrencyRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrencyRow.swift; sourceTree = "<group>"; }; + 9576BFEA26810661002BCAC6 /* InsiderRosterHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InsiderRosterHelper.swift; sourceTree = "<group>"; }; + 9576BFEC26810713002BCAC6 /* InsiderRosterList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InsiderRosterList.swift; sourceTree = "<group>"; }; + 9576BFEE26810719002BCAC6 /* InsiderRosterRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InsiderRosterRow.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; }; 9594F03F2651355B00CFA8D4 /* HistoricalPricesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoricalPricesModel.swift; sourceTree = "<group>"; }; @@ -324,7 +329,6 @@ files = ( 958A735225E0170900FD7ECA /* CloudKit.framework in Frameworks */, 950B6F3F267643640029E447 /* StoreKit.framework in Frameworks */, - 95E4A2DC2680971A00A6FEB9 /* SDWebImageSwiftUI in Frameworks */, 9594331326691789004A0339 /* Bazooka in Frameworks */, 954572EC267A3D6A00C33A20 /* StockCharts in Frameworks */, 95A4B933263E9F810056F036 /* Introspect in Frameworks */, @@ -483,7 +487,6 @@ isa = PBXGroup; children = ( 9550443926111B2B000E0BCB /* HomeView.swift */, - 951566E62613A2B6007C0F36 /* TradingDates.swift */, 954D7EAF260BBBD500A13C50 /* Helpers */, 95893DC72613C410003698C5 /* Networking */, ); @@ -493,13 +496,14 @@ 954D7EAF260BBBD500A13C50 /* Helpers */ = { isa = PBXGroup; children = ( + 951566E92613A37C007C0F36 /* TradingDatesItem.swift */, + 951566E62613A2B6007C0F36 /* TradingDatesSheet.swift */, 9550444226111E7A000E0BCB /* SectorRow.swift */, 9550444526111EE5000E0BCB /* SectorItem.swift */, 9550444826111FC9000E0BCB /* StockRow.swift */, 95123ABF26767370001BFAF3 /* StockItem.swift */, 95721DA5262761E700EC527B /* CurrencyRow.swift */, 95D308F72624B3A400A39F77 /* CurrencyItem.swift */, - 951566E92613A37C007C0F36 /* TradingDatesItem.swift */, 95123AB726766497001BFAF3 /* CurrencySheet.swift */, 95123ABB2676676B001BFAF3 /* CurrencySheetRow.swift */, 95123AB92676658E001BFAF3 /* StockSheet.swift */, @@ -653,9 +657,12 @@ 9502BBFE267F6454003B0A59 /* KeyStatsHelper.swift */, 9502BC00267F8771003B0A59 /* KeyStatsList.swift */, 95E4A2D6268091F900A6FEB9 /* NewsHelper.swift */, + 95E4A2D82680931300A6FEB9 /* NewsRow.swift */, 95E4A2DF2680A70000A6FEB9 /* NewsList.swift */, - 95E4A2D82680931300A6FEB9 /* NewsRow.swift */, 95E4A2E12680AD7C00A6FEB9 /* SFSafariViewWrapper.swift */, + 9576BFEA26810661002BCAC6 /* InsiderRosterHelper.swift */, + 9576BFEE26810719002BCAC6 /* InsiderRosterRow.swift */, + 9576BFEC26810713002BCAC6 /* InsiderRosterList.swift */, ); path = Helpers; sourceTree = "<group>"; @@ -809,7 +816,6 @@ 9594331226691789004A0339 /* Bazooka */, 950B6F3C267643460029E447 /* Purchases */, 954572EB267A3D6A00C33A20 /* StockCharts */, - 95E4A2DB2680971A00A6FEB9 /* SDWebImageSwiftUI */, ); productName = LazyBear; productReference = 95672B8B25DDA54700DCBE4A /* LazyBear.app */; @@ -866,7 +872,6 @@ 9594331126691789004A0339 /* XCRemoteSwiftPackageReference "Bazooka" */, 950B6F3B267643460029E447 /* XCRemoteSwiftPackageReference "purchases-ios" */, 954572EA267A3D6A00C33A20 /* XCRemoteSwiftPackageReference "StockCharts" */, - 95E4A2DA2680971A00A6FEB9 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */, ); productRefGroup = 95672B8C25DDA54700DCBE4A /* Products */; projectDirPath = ""; @@ -995,6 +1000,7 @@ 95602704265ABB990046F97E /* InsiderRosterModel.swift in Sources */, 95E4A2D92680931300A6FEB9 /* NewsRow.swift in Sources */, 95131D46267A03020055C6DE /* WatchlistCompany+CoreDataProperties.swift in Sources */, + 9576BFEF26810719002BCAC6 /* InsiderRosterRow.swift in Sources */, 950C36E3260FB6180081CF53 /* HapticsManager.swift in Sources */, 95FBE0DC2619CA7200440386 /* ProfileView.swift in Sources */, 95131D4B267A15490055C6DE /* WatchlistSheet.swift in Sources */, @@ -1007,9 +1013,10 @@ 95123ABC2676676B001BFAF3 /* CurrencySheetRow.swift in Sources */, 95A7C0742616409D003E2EC1 /* ParseJSON.swift in Sources */, 95E4A2D7268091F900A6FEB9 /* NewsHelper.swift in Sources */, + 9576BFED26810713002BCAC6 /* InsiderRosterList.swift in Sources */, 95E8BAA32656D86E0016AE72 /* RequestType.swift in Sources */, 95CCFB56266E7A0F00C384A1 /* InsiderTransactionModel.swift in Sources */, - 951566E72613A2B6007C0F36 /* TradingDates.swift in Sources */, + 951566E72613A2B6007C0F36 /* TradingDatesSheet.swift in Sources */, 9502BBF5267F5194003B0A59 /* CompanyView.swift in Sources */, 955E73392623568F005652FF /* Home.swift in Sources */, 95721DA6262761E700EC527B /* CurrencyRow.swift in Sources */, @@ -1038,6 +1045,7 @@ 95A07F7126305AD5009865AA /* SectorPerformanceModel.swift in Sources */, 9594F0402651355B00CFA8D4 /* HistoricalPricesModel.swift in Sources */, 95123AC026767370001BFAF3 /* StockItem.swift in Sources */, + 9576BFEB26810661002BCAC6 /* InsiderRosterHelper.swift in Sources */, 9502BBFF267F6454003B0A59 /* KeyStatsHelper.swift in Sources */, 9519BE06267E5EC3009C6015 /* ProfileStockRow.swift in Sources */, 9550444626111EE5000E0BCB /* SectorItem.swift in Sources */, @@ -1647,14 +1655,6 @@ minimumVersion = 0.1.3; }; }; - 95E4A2DA2680971A00A6FEB9 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/SDWebImage/SDWebImageSwiftUI.git"; - requirement = { - kind = upToNextMajorVersion; - minimumVersion = 2.0.2; - }; - }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -1683,11 +1683,6 @@ package = 95A4B931263E9F810056F036 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */; productName = Introspect; }; - 95E4A2DB2680971A00A6FEB9 /* SDWebImageSwiftUI */ = { - isa = XCSwiftPackageProductDependency; - package = 95E4A2DA2680971A00A6FEB9 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */; - productName = SDWebImageSwiftUI; - }; /* End XCSwiftPackageProductDependency section */ /* Begin XCVersionGroup section */
--- a/LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved Mon Jun 21 13:28:45 2021 +0200 +++ b/LazyBear.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved Mon Jun 21 20:17:46 2021 +0200 @@ -20,24 +20,6 @@ } }, { - "package": "SDWebImage", - "repositoryURL": "https://github.com/SDWebImage/SDWebImage.git", - "state": { - "branch": null, - "revision": "76dd4b49110b8624317fc128e7fa0d8a252018bc", - "version": "5.11.1" - } - }, - { - "package": "SDWebImageSwiftUI", - "repositoryURL": "https://github.com/SDWebImage/SDWebImageSwiftUI.git", - "state": { - "branch": null, - "revision": "cd8625b7cf11a97698e180d28bb7d5d357196678", - "version": "2.0.2" - } - }, - { "package": "StockCharts", "repositoryURL": "https://github.com/denniscm190/StockCharts.git", "state": {
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/LazyBear/Views/Company/CompanyView.swift Mon Jun 21 13:28:45 2021 +0200 +++ b/LazyBear/Views/Company/CompanyView.swift Mon Jun 21 20:17:46 2021 +0200 @@ -16,46 +16,48 @@ var body: some View { if company.showView { - NavigationView { - ScrollView { - VStack { - HStack { - Text(name.capitalized) - .font(.title) - .fontWeight(.semibold) - .lineLimit(1) - - Spacer() - } - .padding(.horizontal) + ScrollView(showsIndicators: false) { + VStack { + HStack { + Text(name.capitalized) + .font(.title) + .fontWeight(.semibold) + .lineLimit(1) - Picker("Select a range", selection: $selectedRange) { - ForEach(ranges, id: \.self) { - Text($0) - } - } - .pickerStyle(SegmentedPickerStyle()) - .padding(.horizontal) - .onChange(of: selectedRange, perform: { range in - let url = "https://api.lazybear.app/company/symbol=\(symbol)/type=refresh/range=\(range.lowercased())" - company.request(url, .refresh) - }) - - ChartHelper(company: company) - KeyStatsHelper(keyStats: company.data.keyStats) - if let latestNews = company.data.latestNews { - NewsHelper(latestNews: latestNews) - .padding([.horizontal, .bottom]) + Spacer() + } + .padding(.horizontal) + + Picker("Select a range", selection: $selectedRange) { + ForEach(ranges, id: \.self) { + Text($0) } } + .pickerStyle(SegmentedPickerStyle()) + .padding(.horizontal) + .onChange(of: selectedRange, perform: { range in + let url = "https://api.lazybear.app/company/symbol=\(symbol)/type=refresh/range=\(range.lowercased())" + company.request(url, .refresh) + }) + + ChartHelper(company: company) + KeyStatsHelper(keyStats: company.data.keyStats) + if let latestNews = company.data.latestNews { + NewsHelper(latestNews: latestNews) + .padding([.horizontal, .bottom]) + } + + if let insiderRoster = company.data.insiderRoster { + InsiderRosterHelper(insiderRoster: insiderRoster) + .padding([.horizontal, .bottom]) + } } - .background(Color("customBackground").edgesIgnoringSafeArea(.all)) - .navigationTitle(symbol.uppercased()) } + .background(Color("customBackground").edgesIgnoringSafeArea(.all)) } else { ProgressView() .onAppear { - company.request("https://api.lazybear.app/company/symbol=aapl", .initial) + company.request("https://api.lazybear.app/company/symbol=\(symbol)", .initial) } } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Views/Company/Helpers/InsiderRosterHelper.swift Mon Jun 21 20:17:46 2021 +0200 @@ -0,0 +1,56 @@ +// +// InsiderRosterHelper.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 21/6/21. +// + +import SwiftUI + +struct InsiderRosterHelper: View { + var insiderRoster: [InsiderRosterModel] + @State private var showList = false + + var body: some View { + VStack(alignment: .leading) { + HStack { + Text("Top 10 Insiders") + .font(.title) + .fontWeight(.semibold) + + Spacer() + Button("See all", action: { showList = true } ) + } + .padding(.bottom) + + let totalPositions = insiderRoster.map { $0.position ?? 0 }.reduce(0, +) /// Get total shares owned by top 10 insiders + ForEach(insiderRoster.prefix(4), id: \.self) { insider in + let percentageOfWidth = Double(insider.position ?? 0) / Double(totalPositions) /// Compute percentage of ownership for each insider + InsiderRosterRow(insider: insider, percentageOfWidth: CGFloat(percentageOfWidth)) + Divider() + } + } + .padding() + .background( + CustomRectangleBox() + ) + .sheet(isPresented: $showList) { + InsiderRosterList(insiderRoster: insiderRoster) + } + } +} + +struct InsiderRosterHelper_Previews: PreviewProvider { + static var previews: some View { + InsiderRosterHelper( + insiderRoster: + [ + InsiderRosterModel( + entityName: "Tim Cook", + position: 12345, + reportDate: 12345 + ) + ] + ) + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Views/Company/Helpers/InsiderRosterList.swift Mon Jun 21 20:17:46 2021 +0200 @@ -0,0 +1,52 @@ +// +// InsiderRosterList.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 21/6/21. +// + +import SwiftUI + +struct InsiderRosterList: View { + var insiderRoster: [InsiderRosterModel] + @Environment(\.presentationMode) private var insiderRosterListPresentation + + var body: some View { + NavigationView { + ScrollView(showsIndicators: false) { + VStack { + let totalPositions = insiderRoster.map { $0.position ?? 0 }.reduce(0, +) /// Get total shares owned by top 10 insiders + ForEach(insiderRoster, id: \.self) { insider in + let percentageOfWidth = Double(insider.position ?? 0) / Double(totalPositions) /// Compute percentage of ownership for each insider + InsiderRosterRow(insider: insider, percentageOfWidth: CGFloat(percentageOfWidth)) + Divider() + } + } + .padding() + } + .navigationTitle("Top 10 Insiders") + .toolbar { + ToolbarItem(placement: .cancellationAction) { + Button(action: { insiderRosterListPresentation.wrappedValue.dismiss() }) { + Image(systemName: "multiply") + } + } + } + } + } +} + +struct InsiderRosterList_Previews: PreviewProvider { + static var previews: some View { + InsiderRosterList( + insiderRoster: + [ + InsiderRosterModel( + entityName: "Tim Cook", + position: 12345, + reportDate: 12345 + ) + ] + ) + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Views/Company/Helpers/InsiderRosterRow.swift Mon Jun 21 20:17:46 2021 +0200 @@ -0,0 +1,49 @@ +// +// InsiderRosterRow.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 21/6/21. +// + +import SwiftUI +import StockCharts + +struct InsiderRosterRow: View { + var insider: InsiderRosterModel + var percentageOfWidth: CGFloat + + var body: some View { + VStack(alignment: .leading) { + Text(insider.entityName.capitalized) + .lineLimit(1) + .font(.headline) + + Text("Last updated: \(convertEpoch(insider.reportDate, false))") + .opacity(0.5) + .font(.subheadline) + + HStack { + Spacer() + Text("\(insider.position ?? 0) shares owned") + .font(.caption) + .opacity(0.5) + } + + CapsuleChartView(percentageOfWidth: percentageOfWidth) + } + } +} + +struct InsiderRosterRow_Previews: PreviewProvider { + static var previews: some View { + InsiderRosterRow( + insider: + InsiderRosterModel( + entityName: "Tim Cook", + position: 12345, + reportDate: 12345 + ), + percentageOfWidth: 0.6 + ) + } +}
--- a/LazyBear/Views/Company/Helpers/KeyStatsList.swift Mon Jun 21 13:28:45 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/KeyStatsList.swift Mon Jun 21 20:17:46 2021 +0200 @@ -35,7 +35,6 @@ } } .navigationTitle("Key Stats") - .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarLeading) { Button(action: { keyStatsListPresentation.wrappedValue.dismiss() }) {
--- a/LazyBear/Views/Company/Helpers/NewsHelper.swift Mon Jun 21 13:28:45 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/NewsHelper.swift Mon Jun 21 20:17:46 2021 +0200 @@ -24,12 +24,11 @@ } .padding(.bottom) - ForEach(latestNews.prefix(4), id: \.self) { new in + let latestNewsPrefixed = latestNews.prefix(4) + ForEach(latestNewsPrefixed, id: \.self) { new in if !new.headline.isEmpty { NewsRow(new: new) Divider() - .padding(.leading, 80) - } } }
--- a/LazyBear/Views/Company/Helpers/NewsList.swift Mon Jun 21 13:28:45 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/NewsList.swift Mon Jun 21 20:17:46 2021 +0200 @@ -13,13 +13,13 @@ var body: some View { NavigationView { - ScrollView { + ScrollView(showsIndicators: false) { VStack { ForEach(latestNews, id: \.self) { new in if !new.headline.isEmpty { NewsRow(new: new) Divider() - .padding(.leading, 80) + .padding() } }
--- a/LazyBear/Views/Company/Helpers/NewsRow.swift Mon Jun 21 13:28:45 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/NewsRow.swift Mon Jun 21 20:17:46 2021 +0200 @@ -6,7 +6,6 @@ // import SwiftUI -import SDWebImageSwiftUI struct NewsRow: View { var new: LatestNewsModel @@ -14,28 +13,20 @@ var body: some View { HStack { - RoundedRectangle(cornerRadius: 10) - .frame(width: 65, height: 65, alignment: .center) - .overlay( - WebImage(url: URL(string: new.image)) - .resizable() - .placeholder { - Rectangle() - .foregroundColor(.gray) - } - .indicator(.activity) - .scaledToFill() - ) - .clipShape(RoundedRectangle(cornerRadius: 10)) - VStack(alignment: .leading) { - Text(new.headline) + Text("\(convertEpoch(new.datetime, true)) ago") + .font(.caption2) + .opacity(0.5) + + Text(new.headline.capitalized) .font(.callout) .fontWeight(.semibold) .fixedSize(horizontal: false, vertical: true) /// I need to add this to make lineLimit works correctly .lineLimit(3) } - .padding(.horizontal, 5) +// .padding(.horizontal, 5) + + Spacer() Button(action: { showWebArticle = true }) { Capsule()
--- a/LazyBear/Views/Home/Helpers/CurrencySheet.swift Mon Jun 21 13:28:45 2021 +0200 +++ b/LazyBear/Views/Home/Helpers/CurrencySheet.swift Mon Jun 21 20:17:46 2021 +0200 @@ -19,7 +19,6 @@ } } .navigationTitle("Currencies") - .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarLeading) { Button(action: {currencySheetPresentation.wrappedValue.dismiss()}) {
--- a/LazyBear/Views/Home/Helpers/StockRow.swift Mon Jun 21 13:28:45 2021 +0200 +++ b/LazyBear/Views/Home/Helpers/StockRow.swift Mon Jun 21 20:17:46 2021 +0200 @@ -39,7 +39,13 @@ ScrollView(.horizontal, showsIndicators: false) { HStack(spacing: 20) { ForEach(companies, id: \.self) { company in - StockItem(company: company) + NavigationLink(destination: + CompanyView(symbol: company.symbol, name: company.companyName) + .navigationTitle(company.symbol.uppercased()) + ) { + StockItem(company: company) + } + .buttonStyle(PlainButtonStyle()) } } .padding()
--- a/LazyBear/Views/Home/Helpers/StockSheet.swift Mon Jun 21 13:28:45 2021 +0200 +++ b/LazyBear/Views/Home/Helpers/StockSheet.swift Mon Jun 21 20:17:46 2021 +0200 @@ -17,11 +17,15 @@ NavigationView { VStack { List(companies, id: \.self) { company in - StockSheetRow(company: company) + NavigationLink(destination: + CompanyView(symbol: company.symbol, name: company.companyName) + .navigationTitle(company.symbol.uppercased()) + ) { + StockSheetRow(company: company) + } } } .navigationTitle(listName) - .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarLeading) { Button(action: {stockSheetPresentation.wrappedValue.dismiss()}) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Views/Home/Helpers/TradingDatesSheet.swift Mon Jun 21 20:17:46 2021 +0200 @@ -0,0 +1,45 @@ +// +// TradingDateSheet.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 30/3/21. +// + +import SwiftUI + + +struct TradingDatesSheet: View { + var dates: [String] + @Environment(\.presentationMode) private var tradingDatesPresentation + + let columns = [GridItem(.adaptive(minimum: 100))] + + var body: some View { + NavigationView { + ScrollView { + LazyVGrid(columns: columns, spacing: 20) { + ForEach(dates, id: \.self) { date in + TradingDatesItem(date: convertStringToDate(date)) + } + } + .padding() + } + .navigationTitle("Holiday dates") + .toolbar { + ToolbarItem(placement: .navigationBarLeading) { + Button(action: { tradingDatesPresentation.wrappedValue.dismiss() }) { + Image(systemName: "multiply") + .imageScale(.large) + } + } + } + } + } +} + +struct TradingDate_Previews: PreviewProvider { + static var previews: some View { + // Format is YYYY-MM-DD + TradingDatesSheet(dates: ["2021-01-01"]) + } +}
--- a/LazyBear/Views/Home/HomeView.swift Mon Jun 21 13:28:45 2021 +0200 +++ b/LazyBear/Views/Home/HomeView.swift Mon Jun 21 20:17:46 2021 +0200 @@ -61,7 +61,7 @@ .navigationViewStyle(StackNavigationViewStyle()) .sheet(isPresented: $showTradingDates) { if let dates = home.data.tradingDates { - TradingDates(dates: dates) + TradingDatesSheet(dates: dates) } } } else {
--- a/LazyBear/Views/Home/TradingDates.swift Mon Jun 21 13:28:45 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -// -// TradingDate.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 30/3/21. -// - -import SwiftUI - - -struct TradingDates: View { - var dates: [String] - @Environment(\.presentationMode) private var tradingDatesPresentation - - let columns = [GridItem(.adaptive(minimum: 100))] - - var body: some View { - NavigationView { - ScrollView { - LazyVGrid(columns: columns, spacing: 20) { - ForEach(dates, id: \.self) { date in - TradingDatesItem(date: convertStringToDate(date)) - } - } - .padding() - } - .navigationTitle("Holiday dates") - .navigationBarTitleDisplayMode(.inline) - .toolbar { - ToolbarItem(placement: .navigationBarLeading) { - Button(action: { tradingDatesPresentation.wrappedValue.dismiss() }) { - Image(systemName: "multiply") - .imageScale(.large) - } - } - } - } - } -} - -struct TradingDate_Previews: PreviewProvider { - static var previews: some View { - // Format is YYYY-MM-DD - TradingDates(dates: ["2021-01-01"]) - } -}
--- a/LazyBear/Views/Profile/Helpers/WatchlistSheet.swift Mon Jun 21 13:28:45 2021 +0200 +++ b/LazyBear/Views/Profile/Helpers/WatchlistSheet.swift Mon Jun 21 20:17:46 2021 +0200 @@ -31,7 +31,6 @@ } } .navigationTitle(listName) - .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarLeading) { Button(action: { willRenameWatchlist = false; watchlistSheetPresentation.wrappedValue.dismiss()} ) {
--- a/LazyBear/Views/Search/CompanyList.swift Mon Jun 21 13:28:45 2021 +0200 +++ b/LazyBear/Views/Search/CompanyList.swift Mon Jun 21 20:17:46 2021 +0200 @@ -12,9 +12,12 @@ var body: some View { List(searchResult, id: \.self) { company in -// NavigationLink(destination: CompanyView(symbol: company.symbol!)) { + NavigationLink(destination: + CompanyView(symbol: company.symbol!, name: company.securityName!) + .navigationTitle(company.symbol!.uppercased()) + ) { SearchedCompanyItem(company: company) -// } + } } } }