Mercurial > public > lazybear
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Views/Company/Helpers/TransactionRow.swift Mon Jun 07 20:59:52 2021 +0200 @@ -0,0 +1,67 @@ +// +// TransactionRow.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 7/6/21. +// + +import SwiftUI + +struct TransactionRow: View { + var transaction: InsiderTransactionModel + + var body: some View { + RowShape() + .frame(height: 105) + .overlay( + HStack { + VStack { + let date = convertStringToDate(transaction.filingDate) + Text(getDateComponents(.month, date)) + .fontWeight(.semibold) + + Text(getDateComponents(.day, date)) + .font(.title) + .fontWeight(.semibold) + .foregroundColor(Color("default")) + + Text(getDateComponents(.year, date)) + .font(.caption) + .fontWeight(.semibold) + } + .padding(.trailing) + + VStack(alignment: .leading) { + Text(transaction.fullName.capitalized) + .lineLimit(1) + .font(.headline) + + Text(transaction.reportedTitle ?? "-") + } + + Spacer() + VStack(alignment: .trailing) { + Text("\(transaction.transactionShares)") + .foregroundColor(transaction.transactionShares < 0 ? Color(.systemRed): Color(.systemGreen)) + } + } + .padding() + ) + } +} + +struct TransactionRow_Previews: PreviewProvider { + static var previews: some View { + TransactionRow(transaction: + InsiderTransactionModel(filingDate: "2020-01-01", + fullName: "Dennis Concepcion", + postShares: 1234, + reportedTitle: "Director", + transactionCode: "S", + transactionPrice: 20.08, + transactionShares: 12345, + transactionValue: 1234567.0 + ) + ) + } +}