comparison LazyBear/Views/Company/Helpers/InsiderRosterHelper.swift @ 447:8621ba6fd457

Fixes #48
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Wed, 23 Jun 2021 10:54:47 +0200
parents 9cc0455bc46f
children c6913f0ce46e
comparison
equal deleted inserted replaced
446:9cc0455bc46f 447:8621ba6fd457
7 7
8 import SwiftUI 8 import SwiftUI
9 9
10 struct InsiderRosterHelper: View { 10 struct InsiderRosterHelper: View {
11 var insiderRoster: [InsiderRosterModel] 11 var insiderRoster: [InsiderRosterModel]
12 @State private var showList = false
13 12
14 var body: some View { 13 var body: some View {
15 VStack(alignment: .leading) { 14 VStack(alignment: .leading) {
16 HStack { 15 HStack {
17 Text("Top Insiders") 16 Text("Top Insiders")
18 .font(.title) 17 .font(.title)
19 .fontWeight(.semibold) 18 .fontWeight(.semibold)
20 19
21 Spacer() 20 Spacer()
22 Button("See all", action: { showList = true } ) 21 NavigationLink(destination: InsiderRosterList(insiderRoster: insiderRoster)
22 .navigationTitle("Top Insiders")
23 ) {
24 Text("See all")
25 .accentColor(Color(.systemBlue))
26 }
23 } 27 }
24 .padding(.bottom) 28 .padding(.bottom)
25 29
26 let totalPositions = insiderRoster.map { $0.position ?? 0 }.reduce(0, +) /// Get total shares owned by top 10 insiders 30 let totalPositions = insiderRoster.map { $0.position ?? 0 }.reduce(0, +) /// Get total shares owned by top 10 insiders
27 ForEach(insiderRoster.prefix(4), id: \.self) { insider in 31 ForEach(insiderRoster.prefix(4), id: \.self) { insider in
32 } 36 }
33 .padding() 37 .padding()
34 .background( 38 .background(
35 CustomRectangleBox() 39 CustomRectangleBox()
36 ) 40 )
37 .sheet(isPresented: $showList) {
38 InsiderRosterList(insiderRoster: insiderRoster, isPresented: $showList)
39 }
40 } 41 }
41 } 42 }
42 43
43 struct InsiderRosterHelper_Previews: PreviewProvider { 44 struct InsiderRosterHelper_Previews: PreviewProvider {
44 static var previews: some View { 45 static var previews: some View {