Mercurial > public > lazybear
comparison LazyBear/Views/Company/Helpers/TransactionRow.swift @ 411:681fb377235e
Implementing insider transactions
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Mon, 07 Jun 2021 20:59:52 +0200 |
parents | |
children | a7c9dd0c5822 |
comparison
equal
deleted
inserted
replaced
410:e24c9ca71824 | 411:681fb377235e |
---|---|
1 // | |
2 // TransactionRow.swift | |
3 // LazyBear | |
4 // | |
5 // Created by Dennis Concepción Martín on 7/6/21. | |
6 // | |
7 | |
8 import SwiftUI | |
9 | |
10 struct TransactionRow: View { | |
11 var transaction: InsiderTransactionModel | |
12 | |
13 var body: some View { | |
14 RowShape() | |
15 .frame(height: 105) | |
16 .overlay( | |
17 HStack { | |
18 VStack { | |
19 let date = convertStringToDate(transaction.filingDate) | |
20 Text(getDateComponents(.month, date)) | |
21 .fontWeight(.semibold) | |
22 | |
23 Text(getDateComponents(.day, date)) | |
24 .font(.title) | |
25 .fontWeight(.semibold) | |
26 .foregroundColor(Color("default")) | |
27 | |
28 Text(getDateComponents(.year, date)) | |
29 .font(.caption) | |
30 .fontWeight(.semibold) | |
31 } | |
32 .padding(.trailing) | |
33 | |
34 VStack(alignment: .leading) { | |
35 Text(transaction.fullName.capitalized) | |
36 .lineLimit(1) | |
37 .font(.headline) | |
38 | |
39 Text(transaction.reportedTitle ?? "-") | |
40 } | |
41 | |
42 Spacer() | |
43 VStack(alignment: .trailing) { | |
44 Text("\(transaction.transactionShares)") | |
45 .foregroundColor(transaction.transactionShares < 0 ? Color(.systemRed): Color(.systemGreen)) | |
46 } | |
47 } | |
48 .padding() | |
49 ) | |
50 } | |
51 } | |
52 | |
53 struct TransactionRow_Previews: PreviewProvider { | |
54 static var previews: some View { | |
55 TransactionRow(transaction: | |
56 InsiderTransactionModel(filingDate: "2020-01-01", | |
57 fullName: "Dennis Concepcion", | |
58 postShares: 1234, | |
59 reportedTitle: "Director", | |
60 transactionCode: "S", | |
61 transactionPrice: 20.08, | |
62 transactionShares: 12345, | |
63 transactionValue: 1234567.0 | |
64 ) | |
65 ) | |
66 } | |
67 } |