# HG changeset patch # User Dennis Concepción Martín # Date 1624438487 -7200 # Node ID 8621ba6fd457939211461b463add40dafa213c64 # Parent 9cc0455bc46fa639d8c597d16dc5bed06f708409 Fixes #48 diff -r 9cc0455bc46f -r 8621ba6fd457 LazyBear.xcodeproj/project.pbxproj --- a/LazyBear.xcodeproj/project.pbxproj Tue Jun 22 19:57:08 2021 +0200 +++ b/LazyBear.xcodeproj/project.pbxproj Wed Jun 23 10:54:47 2021 +0200 @@ -80,6 +80,10 @@ 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 */; }; + 9595DC342682849E00DC8104 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9595DC332682849E00DC8104 /* HomeView.swift */; }; + 9595DC36268284B100DC8104 /* CompanyRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9595DC35268284B100DC8104 /* CompanyRow.swift */; }; + 9595DC37268284FA00DC8104 /* WatchlistCompany+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95131D44267A02FC0055C6DE /* WatchlistCompany+CoreDataClass.swift */; }; + 9595DC382682850000DC8104 /* WatchlistCompany+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95131D45267A02FC0055C6DE /* WatchlistCompany+CoreDataProperties.swift */; }; 95A07F6226305A9B009865AA /* CurrencyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A07F6126305A9B009865AA /* CurrencyModel.swift */; }; 95A07F6C26305AC6009865AA /* QuoteModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A07F6B26305AC6009865AA /* QuoteModel.swift */; }; 95A07F7126305AD5009865AA /* SectorPerformanceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95A07F7026305AD5009865AA /* SectorPerformanceModel.swift */; }; @@ -265,6 +269,8 @@ 958A734E25E016FD00FD7ECA /* LazyBear.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = LazyBear.entitlements; sourceTree = ""; }; 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 = ""; }; + 9595DC332682849E00DC8104 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = ""; }; + 9595DC35268284B100DC8104 /* CompanyRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompanyRow.swift; sourceTree = ""; }; 95A07F6126305A9B009865AA /* CurrencyModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrencyModel.swift; sourceTree = ""; }; 95A07F6B26305AC6009865AA /* QuoteModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuoteModel.swift; sourceTree = ""; }; 95A07F7026305AD5009865AA /* SectorPerformanceModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectorPerformanceModel.swift; sourceTree = ""; }; @@ -426,6 +432,7 @@ 952457E7267E339C00D5BBCB /* NotificationController.swift */, 952457E9267E339C00D5BBCB /* NotificationView.swift */, 952457EB267E339C00D5BBCB /* ComplicationController.swift */, + 9595DC2E2682840C00DC8104 /* Views */, 952457ED267E339C00D5BBCB /* Assets.xcassets */, 952457F2267E339C00D5BBCB /* Info.plist */, 952457F3267E339C00D5BBCB /* PushNotificationPayload.apns */, @@ -597,6 +604,39 @@ name = Frameworks; sourceTree = ""; }; + 9595DC2E2682840C00DC8104 /* Views */ = { + isa = PBXGroup; + children = ( + 9595DC312682845500DC8104 /* Home */, + ); + path = Views; + sourceTree = ""; + }; + 9595DC312682845500DC8104 /* Home */ = { + isa = PBXGroup; + children = ( + 9595DC332682849E00DC8104 /* HomeView.swift */, + 9595DC322682848B00DC8104 /* Helpers */, + 9595DC392682858D00DC8104 /* Networking */, + ); + path = Home; + sourceTree = ""; + }; + 9595DC322682848B00DC8104 /* Helpers */ = { + isa = PBXGroup; + children = ( + 9595DC35268284B100DC8104 /* CompanyRow.swift */, + ); + path = Helpers; + sourceTree = ""; + }; + 9595DC392682858D00DC8104 /* Networking */ = { + isa = PBXGroup; + children = ( + ); + path = Networking; + sourceTree = ""; + }; 95A7C06126163943003E2EC1 /* Search */ = { isa = PBXGroup; children = ( @@ -981,8 +1021,12 @@ 952457E8267E339C00D5BBCB /* NotificationController.swift in Sources */, 952457E6267E339C00D5BBCB /* ContentView.swift in Sources */, 952457EC267E339C00D5BBCB /* ComplicationController.swift in Sources */, + 9595DC342682849E00DC8104 /* HomeView.swift in Sources */, + 9595DC382682850000DC8104 /* WatchlistCompany+CoreDataProperties.swift in Sources */, 952457E4267E339C00D5BBCB /* LazyBearApp.swift in Sources */, + 9595DC37268284FA00DC8104 /* WatchlistCompany+CoreDataClass.swift in Sources */, 952457EA267E339C00D5BBCB /* NotificationView.swift in Sources */, + 9595DC36268284B100DC8104 /* CompanyRow.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff -r 9cc0455bc46f -r 8621ba6fd457 LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed diff -r 9cc0455bc46f -r 8621ba6fd457 LazyBear/Views/Company/CompanyView.swift --- a/LazyBear/Views/Company/CompanyView.swift Tue Jun 22 19:57:08 2021 +0200 +++ b/LazyBear/Views/Company/CompanyView.swift Wed Jun 23 10:54:47 2021 +0200 @@ -56,7 +56,7 @@ InsiderRosterHelper(insiderRoster: insiderRoster) .padding([.horizontal, .bottom]) } - + if let insiderTransactions = company.data.insiderTransactions { InsiderTransactionsHelper(insiderTransactions: insiderTransactions) .padding([.horizontal, .bottom]) diff -r 9cc0455bc46f -r 8621ba6fd457 LazyBear/Views/Company/Helpers/InsiderRosterHelper.swift --- a/LazyBear/Views/Company/Helpers/InsiderRosterHelper.swift Tue Jun 22 19:57:08 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/InsiderRosterHelper.swift Wed Jun 23 10:54:47 2021 +0200 @@ -9,7 +9,6 @@ struct InsiderRosterHelper: View { var insiderRoster: [InsiderRosterModel] - @State private var showList = false var body: some View { VStack(alignment: .leading) { @@ -19,7 +18,12 @@ .fontWeight(.semibold) Spacer() - Button("See all", action: { showList = true } ) + NavigationLink(destination: InsiderRosterList(insiderRoster: insiderRoster) + .navigationTitle("Top Insiders") + ) { + Text("See all") + .accentColor(Color(.systemBlue)) + } } .padding(.bottom) @@ -34,9 +38,6 @@ .background( CustomRectangleBox() ) - .sheet(isPresented: $showList) { - InsiderRosterList(insiderRoster: insiderRoster, isPresented: $showList) - } } } diff -r 9cc0455bc46f -r 8621ba6fd457 LazyBear/Views/Company/Helpers/InsiderRosterList.swift --- a/LazyBear/Views/Company/Helpers/InsiderRosterList.swift Tue Jun 22 19:57:08 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/InsiderRosterList.swift Wed Jun 23 10:54:47 2021 +0200 @@ -9,29 +9,18 @@ struct InsiderRosterList: View { var insiderRoster: [InsiderRosterModel] - @Binding var isPresented: Bool 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: { self.isPresented.toggle() }) { - Image(systemName: "multiply") - } + 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() } } } @@ -47,7 +36,6 @@ reportDate: 12345 ) ] - , isPresented: .constant(true) ) } } diff -r 9cc0455bc46f -r 8621ba6fd457 LazyBear/Views/Company/Helpers/InsiderTransactionsHelper.swift --- a/LazyBear/Views/Company/Helpers/InsiderTransactionsHelper.swift Tue Jun 22 19:57:08 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/InsiderTransactionsHelper.swift Wed Jun 23 10:54:47 2021 +0200 @@ -19,7 +19,13 @@ .fontWeight(.semibold) Spacer() - Button("See all", action: { showList = true } ) + NavigationLink(destination: InsiderTransactionsList(insiderTransactions: insiderTransactions) + .navigationTitle("Insider Transactions") + .navigationBarTitleDisplayMode(.large) + ) { + Text("See all") + .accentColor(Color(.systemBlue)) + } } .padding(.bottom) @@ -32,9 +38,6 @@ .background( CustomRectangleBox() ) - .sheet(isPresented: $showList) { - InsiderTransactionsList(insiderTransactions: insiderTransactions, isPresented: $showList) - } } } diff -r 9cc0455bc46f -r 8621ba6fd457 LazyBear/Views/Company/Helpers/InsiderTransactionsList.swift --- a/LazyBear/Views/Company/Helpers/InsiderTransactionsList.swift Tue Jun 22 19:57:08 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/InsiderTransactionsList.swift Wed Jun 23 10:54:47 2021 +0200 @@ -9,27 +9,16 @@ struct InsiderTransactionsList: View { var insiderTransactions: [InsiderTransactionModel] - @Binding var isPresented: Bool var body: some View { - NavigationView { - ScrollView(showsIndicators: false) { - VStack { - ForEach(insiderTransactions, id: \.self) { insiderTransaction in - InsiderTransactionsRow(insiderTransaction: insiderTransaction) - Divider() - } - } - .padding() - } - .navigationTitle("Insider Transactions") - .toolbar { - ToolbarItem(placement: .cancellationAction) { - Button(action: { self.isPresented.toggle() }) { - Image(systemName: "multiply") - } + ScrollView(showsIndicators: false) { + VStack { + ForEach(insiderTransactions, id: \.self) { insiderTransaction in + InsiderTransactionsRow(insiderTransaction: insiderTransaction) + Divider() } } + .padding() } } } @@ -50,7 +39,6 @@ transactionValue: 1234567.0 ) ] - , isPresented: .constant(true) ) } } diff -r 9cc0455bc46f -r 8621ba6fd457 LazyBear/Views/Company/Helpers/KeyStatsHelper.swift --- a/LazyBear/Views/Company/Helpers/KeyStatsHelper.swift Tue Jun 22 19:57:08 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/KeyStatsHelper.swift Wed Jun 23 10:54:47 2021 +0200 @@ -10,7 +10,6 @@ struct KeyStatsHelper: View { var keyStats: KeyStatsModel? let displayWords: DisplayWordsModel = parseJSON("DisplayWords.json") - @State private var showList = false @Environment(\.colorScheme) private var colorScheme var body: some View { @@ -24,7 +23,9 @@ if let unwrappedValue = unwrapAnyOptional(value: child.value) { let label = String(child.label!) - Button(action: { showList = true }) { + NavigationLink(destination: KeyStatsList(keyStats: keyStats) + .navigationTitle("Key Stats") + ) { Capsule() .frame(width: 250, height: 40) .foregroundColor(Color("customSecondaryBackground")) @@ -53,9 +54,6 @@ .frame(height: 70) .padding(.horizontal) } - .sheet(isPresented: $showList) { - KeyStatsList(keyStats: keyStats, isPresented: $showList) - } } } diff -r 9cc0455bc46f -r 8621ba6fd457 LazyBear/Views/Company/Helpers/KeyStatsList.swift --- a/LazyBear/Views/Company/Helpers/KeyStatsList.swift Tue Jun 22 19:57:08 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/KeyStatsList.swift Wed Jun 23 10:54:47 2021 +0200 @@ -9,39 +9,27 @@ struct KeyStatsList: View { var keyStats: KeyStatsModel - @Binding var isPresented: Bool let displayWords: DisplayWordsModel = parseJSON("DisplayWords.json") var body: some View { - NavigationView { - Form { - let mirror = Mirror(reflecting: keyStats) - ForEach(Array(mirror.children), id: \.label) { child in /// Iterate over each variable within the class - if let unwrappedValue = unwrapAnyOptional(value: child.value) { - let label = String(child.label!) - HStack { - Text("\(displayWords.keyStats[label]!):") - .font(.callout) - .fontWeight(.semibold) - .lineLimit(1) - - Spacer() - Text(unwrappedValue) - .font(.callout) - .lineLimit(1) - } + Form { + let mirror = Mirror(reflecting: keyStats) + ForEach(Array(mirror.children), id: \.label) { child in /// Iterate over each variable within the class + if let unwrappedValue = unwrapAnyOptional(value: child.value) { + let label = String(child.label!) + HStack { + Text("\(displayWords.keyStats[label]!):") + .font(.callout) + .fontWeight(.semibold) + .lineLimit(1) + + Spacer() + Text(unwrappedValue) + .font(.callout) + .lineLimit(1) } } } - .navigationTitle("Key Stats") - .toolbar { - ToolbarItem(placement: .navigationBarLeading) { - Button(action: { self.isPresented.toggle() }) { - Image(systemName: "multiply") - } - - } - } } } @@ -96,7 +84,6 @@ nextDividendDate: "2020-01-01", nextEarningsDate: "2020-01-01" ) - , isPresented: .constant(true) ) } } diff -r 9cc0455bc46f -r 8621ba6fd457 LazyBear/Views/Company/Helpers/NewsHelper.swift --- a/LazyBear/Views/Company/Helpers/NewsHelper.swift Tue Jun 22 19:57:08 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/NewsHelper.swift Wed Jun 23 10:54:47 2021 +0200 @@ -10,8 +10,6 @@ struct NewsHelper: View { var latestNews: [LatestNewsModel] - @State private var showList = false - var body: some View { VStack(alignment: .leading) { HStack { @@ -20,7 +18,13 @@ .fontWeight(.semibold) Spacer() - Button("See all", action: { showList = true } ) + + NavigationLink(destination: NewsList(latestNews: latestNews) + .navigationTitle("Latest news") + ) { + Text("See all") + .accentColor(Color(.systemBlue)) + } } .padding(.bottom) @@ -36,9 +40,6 @@ .background( CustomRectangleBox() ) - .sheet(isPresented: $showList) { - NewsList(latestNews: latestNews, isPresented: $showList) - } } } diff -r 9cc0455bc46f -r 8621ba6fd457 LazyBear/Views/Company/Helpers/NewsList.swift --- a/LazyBear/Views/Company/Helpers/NewsList.swift Tue Jun 22 19:57:08 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/NewsList.swift Wed Jun 23 10:54:47 2021 +0200 @@ -9,31 +9,20 @@ struct NewsList: View { var latestNews: [LatestNewsModel] - @Binding var isPresented: Bool var body: some View { - NavigationView { - ScrollView(showsIndicators: false) { - VStack { - ForEach(latestNews, id: \.self) { new in - if !new.headline.isEmpty { - NewsRow(new: new) - Divider() - .padding() - - } - } - } - .padding() - } - .navigationTitle("Latest news") - .toolbar { - ToolbarItem(placement: .cancellationAction) { - Button(action: { self.isPresented.toggle() }) { - Image(systemName: "multiply") + ScrollView(showsIndicators: false) { + VStack { + ForEach(latestNews, id: \.self) { new in + if !new.headline.isEmpty { + NewsRow(new: new) + Divider() + .padding() + } } } + .padding() } } } @@ -50,7 +39,6 @@ summary: "https://www.investing.com/news/stock-market-news", url: "https://cloud.iexapis.com/v1/news/article/99abeb99-6d9e-47c8-ae7b-53404eacccec") ] - , isPresented: .constant(true) ) } } diff -r 9cc0455bc46f -r 8621ba6fd457 LazyBear/Views/Company/Helpers/NewsRow.swift --- a/LazyBear/Views/Company/Helpers/NewsRow.swift Tue Jun 22 19:57:08 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/NewsRow.swift Wed Jun 23 10:54:47 2021 +0200 @@ -19,12 +19,11 @@ .opacity(0.5) Text(new.headline.capitalized) - .font(.callout) + .font(.headline) .fontWeight(.semibold) .fixedSize(horizontal: false, vertical: true) /// I need to add this to make lineLimit works correctly .lineLimit(3) } -// .padding(.horizontal, 5) Spacer() diff -r 9cc0455bc46f -r 8621ba6fd457 LazyBearWatchOS Extension/ContentView.swift --- a/LazyBearWatchOS Extension/ContentView.swift Tue Jun 22 19:57:08 2021 +0200 +++ b/LazyBearWatchOS Extension/ContentView.swift Wed Jun 23 10:54:47 2021 +0200 @@ -9,8 +9,12 @@ struct ContentView: View { var body: some View { - Text("Hello, World!") - .padding() + VStack { + ForEach((1..<4)) { _ in + Text("Hello") + } + .navigationTitle("Lazybear") + } } } diff -r 9cc0455bc46f -r 8621ba6fd457 LazyBearWatchOS Extension/Views/Home/Helpers/CompanyRow.swift --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBearWatchOS Extension/Views/Home/Helpers/CompanyRow.swift Wed Jun 23 10:54:47 2021 +0200 @@ -0,0 +1,20 @@ +// +// CompanyRow.swift +// LazyBearWatchOS Extension +// +// Created by Dennis Concepción Martín on 22/6/21. +// + +import SwiftUI + +struct CompanyRow: View { + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } +} + +struct CompanyRow_Previews: PreviewProvider { + static var previews: some View { + CompanyRow() + } +} diff -r 9cc0455bc46f -r 8621ba6fd457 LazyBearWatchOS Extension/Views/Home/HomeView.swift --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBearWatchOS Extension/Views/Home/HomeView.swift Wed Jun 23 10:54:47 2021 +0200 @@ -0,0 +1,26 @@ +// +// HomeView.swift +// LazyBearWatchOS Extension +// +// Created by Dennis Concepción Martín on 22/6/21. +// + +import SwiftUI +import CoreData + +struct HomeView: View { + @FetchRequest(entity: WatchlistCompany.entity(), sortDescriptors: []) + var watchlistCompanies: FetchedResults + + var body: some View { + VStack { + + } + } +} + +struct HomeView_Previews: PreviewProvider { + static var previews: some View { + HomeView() + } +}