changeset 58:c9ee25555f21

Update insiders PieChart, add hide-show button
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Wed, 20 Jan 2021 12:32:57 +0100
parents fa7df6b161f4
children 8a32a0e965be
files LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate lazybear/Insiders.swift lazybear/Main.swift
diffstat 3 files changed, 24 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/lazybear/Insiders.swift	Wed Jan 20 12:08:07 2021 +0100
+++ b/lazybear/Insiders.swift	Wed Jan 20 12:32:57 2021 +0100
@@ -14,6 +14,7 @@
     var name: String
     
     @ObservedObject var transaction = InsiderTransaction()
+    @State private var chartsAreShowing = true
     
     // Picker
     var dateFormatter: DateFormatter {
@@ -29,14 +30,30 @@
             GeometryReader { geo in
                 VStack {
                     let width = geo.size.height*0.6
-                    InsiderCharts(transaction: transaction, width: width)
+                    if chartsAreShowing {
+                        InsiderCharts(transaction: transaction, width: width)
+                    }
+                    
+                    HStack {
+                        Button(action: { self.chartsAreShowing.toggle() }) {
+                            if chartsAreShowing {
+                                Text("Hide chart")
+                            }
+                            else {
+                                Text("Show chart")
+                            }
+                        }
+                            Spacer()
+                    }
+                    .padding([.leading, .top, .trailing])
+                    
                     
                     DatePicker(selection: $selectedDate, in: ...Date(), displayedComponents: .date) { Text("Transactions since").font(.headline) }
-                        .padding([.leading, .top, .trailing])
+                        .padding([.leading, .trailing])
                         .onChange(of: self.selectedDate, perform: { date in
                             transaction.request(cik: String(cik), date: dateFormatter.string(from: selectedDate))
                         })
-
+                    
                     TransactionList(transaction: transaction)
                         .offset(y: 10)
                 }
--- a/lazybear/Main.swift	Wed Jan 20 12:08:07 2021 +0100
+++ b/lazybear/Main.swift	Wed Jan 20 12:32:57 2021 +0100
@@ -21,7 +21,7 @@
                 HStack {
                     Button(action: { self.showingSettings.toggle() }) {
                         Image(systemName: "gear")
-                            .imageIconModifier()
+                            .imageIconModifier(maxWidth: 30)
                         
                     }.sheet(isPresented: $showingSettings) {
                         About()
@@ -31,7 +31,7 @@
                     Spacer()
                     Button(action: { self.showingUser.toggle() }) {
                         Image(systemName: "person")
-                            .imageIconModifier()
+                            .imageIconModifier(maxWidth: 30)
                         
                     }
                     .sheet(isPresented: $showingUser) {
@@ -60,11 +60,11 @@
     }
 }
 extension Image {
-    func imageIconModifier() -> some View {
+    func imageIconModifier(maxWidth: CGFloat) -> some View {
         self
             .resizable()
             .aspectRatio(contentMode: .fit)
-            .frame(maxWidth: 30)
+            .frame(maxWidth: maxWidth)
     }
 }