Mercurial > public > lazybear
comparison LazyBear/Views/Company/Helpers/TransactionList.swift @ 412:a7c9dd0c5822
Main insider view implemented
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Tue, 08 Jun 2021 11:46:58 +0200 |
parents | 681fb377235e |
children | 5f21f7c23c5e |
comparison
equal
deleted
inserted
replaced
411:681fb377235e | 412:a7c9dd0c5822 |
---|---|
6 // | 6 // |
7 | 7 |
8 import SwiftUI | 8 import SwiftUI |
9 | 9 |
10 struct TransactionList: View { | 10 struct TransactionList: View { |
11 var transactions: [InsiderTransactionModel] | |
12 @State private var showFullList = false | |
13 | |
11 var body: some View { | 14 var body: some View { |
12 Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) | 15 VStack(alignment: .leading) { |
16 HStack { | |
17 Text("Latest transactions") | |
18 .font(.title3) | |
19 .fontWeight(.semibold) | |
20 | |
21 Spacer() | |
22 Button("See all", action: { showFullList = true }) | |
23 } | |
24 | |
25 VStack(alignment: .leading, spacing: 20) { | |
26 ForEach(transactions.prefix(3), id: \.self) { transaction in | |
27 TransactionRow(transaction: transaction) | |
28 } | |
29 } | |
30 } | |
31 .sheet(isPresented: $showFullList) { | |
32 TransactionFullList(transactions: transactions) | |
33 } | |
13 } | 34 } |
14 } | 35 } |
15 | 36 |
16 struct TransactionList_Previews: PreviewProvider { | 37 struct TransactionList_Previews: PreviewProvider { |
17 static var previews: some View { | 38 static var previews: some View { |
18 TransactionList() | 39 TransactionList(transactions: |
40 [ | |
41 InsiderTransactionModel(filingDate: "2020-01-01", | |
42 fullName: "Dennis Concepcion", | |
43 postShares: 1234, | |
44 reportedTitle: "Director", | |
45 transactionCode: "S", | |
46 transactionPrice: 20.08, | |
47 transactionShares: 12345, | |
48 transactionValue: 1234567.0 | |
49 ) | |
50 ] | |
51 ) | |
19 } | 52 } |
20 } | 53 } |
54 | |
55 struct TransactionFullList: View { | |
56 var transactions: [InsiderTransactionModel] | |
57 @Environment(\.presentationMode) private var presentationTransactionFullList | |
58 | |
59 var body: some View { | |
60 NavigationView { | |
61 ScrollView { | |
62 VStack(alignment: .leading, spacing: 20) { | |
63 ForEach(transactions, id: \.self) { transaction in | |
64 TransactionRow(transaction: transaction) | |
65 } | |
66 } | |
67 .padding() | |
68 } | |
69 .navigationTitle("Latest transactions") | |
70 .navigationBarTitleDisplayMode(.inline) | |
71 .toolbar { | |
72 ToolbarItem(placement: .navigationBarLeading) { | |
73 Button(action: { presentationTransactionFullList.wrappedValue.dismiss() }) { | |
74 Image(systemName: "multiply") | |
75 .imageScale(.large) | |
76 } | |
77 } | |
78 } | |
79 } | |
80 } | |
81 } |