changeset 244:724916624385

Implement Insider View
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Sun, 07 Mar 2021 11:25:42 +0100
parents 46b503fcb0f9
children 14f2f6ea69f8
files LazyBear.xcodeproj/project.pbxproj LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate LazyBear.xcodeproj/xcshareddata/xcschemes/LazyBear.xcscheme LazyBear/ContentView.swift LazyBear/UI/InsiderSum.swift LazyBear/UI/InsiderTrans.swift LazyBear/UI/NewsView.swift LazyBear/UI/TranDetail.swift LazyBear/UI/TransRow.swift
diffstat 9 files changed, 142 insertions(+), 61 deletions(-) [+]
line wrap: on
line diff
--- 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 = "<group>"; };
 		9517625F25EEB37E00733235 /* PriceModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PriceModel.swift; sourceTree = "<group>"; };
 		9517626225EEBD3800733235 /* IexAttribution.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IexAttribution.swift; sourceTree = "<group>"; };
+		9520C26E25F4D43D0070DD71 /* TranDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TranDetail.swift; sourceTree = "<group>"; };
 		9549D63525E191520085C3CD /* Normalize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Normalize.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>"; };
@@ -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;
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- 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 @@
       </Testables>
    </TestAction>
    <LaunchAction
-      buildConfiguration = "Release"
+      buildConfiguration = "Debug"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       launchStyle = "0"
--- a/LazyBear/ContentView.swift	Fri Mar 05 20:44:09 2021 +0000
+++ b/LazyBear/ContentView.swift	Sun Mar 07 11:25:42 2021 +0100
@@ -8,9 +8,10 @@
 import SwiftUI
 
 struct ContentView: View {
+    // Start ObservedObjects
     @ObservedObject var hudManager = HUDManager()
     
-    // Fetch user appearence settings (the last one made first)
+    // Fetch user appearence settings
     @FetchRequest(entity: UserSettings.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \UserSettings.changedAt, ascending: false)])
     var userSettings: FetchedResults<UserSettings>
     
--- 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)
--- 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)
--- 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
--- /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))
+    }
+}
--- 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)
         }
     }
 }