# HG changeset patch # User Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> # Date 1615112742 -3600 # Node ID 724916624385aedc8dcd75682ede9333badb5d81 # Parent 46b503fcb0f90692bce0345d776dfe9ec16b0ab8 Implement Insider View diff -r 46b503fcb0f9 -r 724916624385 LazyBear.xcodeproj/project.pbxproj --- a/LazyBear.xcodeproj/project.pbxproj Fri Mar 05 20:44:09 2021 +0000 +++ b/LazyBear.xcodeproj/project.pbxproj Sun Mar 07 11:25:42 2021 +0100 @@ -19,6 +19,7 @@ 950B674F25E9A0AE00BF8593 /* IconModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 950B674E25E9A0AE00BF8593 /* IconModel.swift */; }; 9517626025EEB37E00733235 /* PriceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9517625F25EEB37E00733235 /* PriceModel.swift */; }; 9517626325EEBD3800733235 /* IexAttribution.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9517626225EEBD3800733235 /* IexAttribution.swift */; }; + 9520C26F25F4D43D0070DD71 /* TranDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9520C26E25F4D43D0070DD71 /* TranDetail.swift */; }; 9549D63325E1903F0085C3CD /* Charts in Frameworks */ = {isa = PBXBuildFile; productRef = 9549D63225E1903F0085C3CD /* Charts */; }; 9549D63625E191520085C3CD /* Normalize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9549D63525E191520085C3CD /* Normalize.swift */; }; 95672B8F25DDA54700DCBE4A /* LazyBearApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95672B8E25DDA54700DCBE4A /* LazyBearApp.swift */; }; @@ -85,6 +86,7 @@ 950BA46C25E944FC00D065EF /* Sandbox.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Sandbox.xcconfig; sourceTree = ""; }; 9517625F25EEB37E00733235 /* PriceModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PriceModel.swift; sourceTree = ""; }; 9517626225EEBD3800733235 /* IexAttribution.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IexAttribution.swift; sourceTree = ""; }; + 9520C26E25F4D43D0070DD71 /* TranDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TranDetail.swift; sourceTree = ""; }; 9549D63525E191520085C3CD /* Normalize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Normalize.swift; sourceTree = ""; }; 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 = ""; }; @@ -267,6 +269,7 @@ 95BFAE4A25E2AEA000A70EC3 /* HUD.swift */, 95F90AB725F280190023A4B0 /* InsiderTrans.swift */, 957B816C25F2A35D0005E5C0 /* TransRow.swift */, + 9520C26E25F4D43D0070DD71 /* TranDetail.swift */, 95DED9DA25F2B268000DFCBA /* InsiderSum.swift */, ); path = UI; @@ -422,6 +425,7 @@ 957B816D25F2A35D0005E5C0 /* TransRow.swift in Sources */, 95ACB5A925E0397B00A3CCC8 /* CompanyView.swift in Sources */, 958A734225E00C9900FD7ECA /* Watchlist.swift in Sources */, + 9520C26F25F4D43D0070DD71 /* TranDetail.swift in Sources */, 95BB43C025EA667700B6C965 /* DateSelection.swift in Sources */, 957B817025F2A4290005E5C0 /* SideColor.swift in Sources */, 95DED9D825F2B1EF000DFCBA /* TopInsiderModel.swift in Sources */, @@ -557,7 +561,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = LazyBear/LazyBear.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 14; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_ASSET_PATHS = "\"LazyBear/Preview Content\""; DEVELOPMENT_TEAM = MTX83R5H8X; ENABLE_PREVIEWS = YES; @@ -567,7 +571,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.0; + MARKETING_VERSION = 3.1; PRODUCT_BUNDLE_IDENTIFIER = dennis.LazyBear; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -582,7 +586,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = LazyBear/LazyBear.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 14; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_ASSET_PATHS = "\"LazyBear/Preview Content\""; DEVELOPMENT_TEAM = MTX83R5H8X; ENABLE_PREVIEWS = YES; @@ -592,7 +596,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.0; + MARKETING_VERSION = 3.1; PRODUCT_BUNDLE_IDENTIFIER = dennis.LazyBear; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; diff -r 46b503fcb0f9 -r 724916624385 LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed diff -r 46b503fcb0f9 -r 724916624385 LazyBear.xcodeproj/xcshareddata/xcschemes/LazyBear.xcscheme --- a/LazyBear.xcodeproj/xcshareddata/xcschemes/LazyBear.xcscheme Fri Mar 05 20:44:09 2021 +0000 +++ b/LazyBear.xcodeproj/xcshareddata/xcschemes/LazyBear.xcscheme Sun Mar 07 11:25:42 2021 +0100 @@ -31,7 +31,7 @@ diff -r 46b503fcb0f9 -r 724916624385 LazyBear/UI/InsiderSum.swift --- a/LazyBear/UI/InsiderSum.swift Fri Mar 05 20:44:09 2021 +0000 +++ b/LazyBear/UI/InsiderSum.swift Sun Mar 07 11:25:42 2021 +0100 @@ -17,16 +17,18 @@ var body: some View { VStack(alignment: .leading) { - HStack { - Image(systemName: "star.fill") - .renderingMode(.original) - .imageScale(.large) - - Text("Top 10 insiders") - .font(.title2) - .fontWeight(.semibold) - - Spacer() + if !dataPoints.isEmpty { + HStack { + Image(systemName: "star.fill") + .renderingMode(.original) + .imageScale(.large) + + Text("Top 10 insiders") + .font(.title2) + .fontWeight(.semibold) + + Spacer() + } } HorizontalBarChartView(dataPoints: dataPoints) diff -r 46b503fcb0f9 -r 724916624385 LazyBear/UI/InsiderTrans.swift --- a/LazyBear/UI/InsiderTrans.swift Fri Mar 05 20:44:09 2021 +0000 +++ b/LazyBear/UI/InsiderTrans.swift Sun Mar 07 11:25:42 2021 +0100 @@ -13,31 +13,25 @@ var body: some View { VStack(alignment: .leading) { - HStack { - Image(systemName: "dollarsign.circle.fill") - .foregroundColor(Color(.systemGreen)) - .imageScale(.large) - - Text("Latest transactions") - .font(.title2) - .fontWeight(.semibold) - .padding(.horizontal) - - Spacer() + if !transactions.isEmpty { + HStack { + Image(systemName: "dollarsign.circle.fill") + .foregroundColor(Color(.systemGreen)) + .imageScale(.large) + + Text("Latest transactions") + .font(.title2) + .fontWeight(.semibold) + .padding(.horizontal) + + Spacer() + } + .padding(.horizontal) } - .padding(.horizontal) Divider() - if transactions.isEmpty { - HStack { - Spacer() - ProgressView() - Spacer() - } - } - - ForEach(transactions, id: \.self) { trans in + ForEach(transactions.reversed(), id: \.self) { trans in TransRow(transaction: trans) .padding(.horizontal) .padding(.vertical, 5) diff -r 46b503fcb0f9 -r 724916624385 LazyBear/UI/NewsView.swift --- a/LazyBear/UI/NewsView.swift Fri Mar 05 20:44:09 2021 +0000 +++ b/LazyBear/UI/NewsView.swift Sun Mar 07 11:25:42 2021 +0100 @@ -14,18 +14,20 @@ var body: some View { VStack(alignment: .leading) { - HStack { - Image(systemName: "newspaper.fill") - .foregroundColor(Color(.systemYellow)) - .imageScale(.large) - - Text("Recent news") - .font(.title2) - .fontWeight(.semibold) - - Spacer() + if !news.isEmpty { + HStack { + Image(systemName: "newspaper.fill") + .foregroundColor(Color(.systemYellow)) + .imageScale(.large) + + Text("Recent news") + .font(.title2) + .fontWeight(.semibold) + + Spacer() + } + .padding() } - .padding() let language = userSettings.first?.newsLanguage ?? "en" ForEach(news, id: \.self) { new in diff -r 46b503fcb0f9 -r 724916624385 LazyBear/UI/TranDetail.swift --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/UI/TranDetail.swift Sun Mar 07 11:25:42 2021 +0100 @@ -0,0 +1,71 @@ +// +// TranDetail.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 7/3/21. +// + +import SwiftUI + +struct TranDetail: View { + var transaction: InsiderTranModel + + var body: some View { + NavigationView { + Form { + Section(header: Text("Insider information")) { + HStack { + Image(systemName: "person.fill") + Text(transaction.fullName?.capitalized ?? "-") + } + + if let postShares = transaction.postShares { + HStack { + Image(systemName: "number") + Text("\(postShares) shares owned") + } + } + } + + Section(header: Text("Transaction information")) { + HStack { + Image(systemName: "calendar") + Text(transaction.transactionDate ?? "-") + } + + let direcIndirect = transaction.directIndirect ?? "-" + if direcIndirect == "D" { + Text("Direct transaction") + } else if direcIndirect == "I" { + Text("Indirect transaction") + } + + if let tranPrice = transaction.transactionPrice { + Text(String(format: "Price per share: $%.2f", tranPrice)) + } + + if let tranShares = transaction.transactionShares { + Text("Shares transacted: \(tranShares)") + } + + if let tranValue = transaction.transactionValue { + Text(String(format: "Transaction value: $%.2f", tranValue)) + } + } + + if let tranType = transactionCodes[transaction.transactionCode ?? "-"] { + Section(header: Text("Transaction type")) { + Text(tranType) + } + } + } + .navigationTitle("Transaction detail") + } + } +} + +struct TranDetail_Previews: PreviewProvider { + static var previews: some View { + TranDetail(transaction: InsiderTranModel(directIndirect: "D", transactionDate: "2020-02-04", fullName: "WAGNER SUSAN", postShares: 886126, transactionCode: "M", transactionPrice: 13.20, transactionShares: 12345, transactionValue: 123456.50)) + } +} diff -r 46b503fcb0f9 -r 724916624385 LazyBear/UI/TransRow.swift --- a/LazyBear/UI/TransRow.swift Fri Mar 05 20:44:09 2021 +0000 +++ b/LazyBear/UI/TransRow.swift Sun Mar 07 11:25:42 2021 +0100 @@ -9,24 +9,31 @@ struct TransRow: View { var transaction: InsiderTranModel + @State private var showingDetail = false var body: some View { - HStack(alignment: .top) { - VStack(alignment: .leading) { - Text(transaction.fullName?.capitalized ?? "-") - .fontWeight(.semibold) + Button(action: { self.showingDetail = true }) { + HStack(alignment: .top) { + VStack(alignment: .leading) { + Text(transaction.fullName?.capitalized ?? "-") + .fontWeight(.semibold) + + if let date = transaction.transactionDate { + Text(date) + } + } - if let date = transaction.transactionDate { - Text(date) + Spacer() + if let shares = transaction.transactionShares ?? 0 { + Text("\(shares)") + .foregroundColor(shares < 0 ? Color(.systemRed): Color(.systemGreen)) + .fontWeight(.semibold) } } - - Spacer() - if let shares = transaction.transactionShares ?? 0 { - Text("\(shares)") - .foregroundColor(shares < 0 ? Color(.systemRed): Color(.systemGreen)) - .fontWeight(.semibold) - } + } + .buttonStyle(PlainButtonStyle()) + .sheet(isPresented: $showingDetail) { + TranDetail(transaction: transaction) } } }