# HG changeset patch # User Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> # Date 1611142377 -3600 # Node ID c9ee25555f211506e7e5b148e7e2d0dbe86e74ce # Parent fa7df6b161f45b0b46cdd72d41e33969fe10fc42 Update insiders PieChart, add hide-show button diff -r fa7df6b161f4 -r c9ee25555f21 LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate Binary file LazyBear.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed diff -r fa7df6b161f4 -r c9ee25555f21 lazybear/Insiders.swift --- 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) } diff -r fa7df6b161f4 -r c9ee25555f21 lazybear/Main.swift --- 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) } }