Mercurial > public > lazybear
diff LazyBear/Views/Company/Helpers/InsiderList.swift @ 417:5f21f7c23c5e
Add comments and clean code
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Fri, 11 Jun 2021 11:37:42 +0200 |
parents | 2984d8946342 |
children | c78d5b5b3bda |
line wrap: on
line diff
--- a/LazyBear/Views/Company/Helpers/InsiderList.swift Wed Jun 09 20:26:28 2021 +0200 +++ b/LazyBear/Views/Company/Helpers/InsiderList.swift Fri Jun 11 11:37:42 2021 +0200 @@ -22,14 +22,10 @@ Button("See all", action: { showFullList = true }) } - // Get total shares owned by the top 10 insiders - let totalPositions = insiderSummary.map { $0.position ?? 0 }.reduce(0, +) + let totalPositions = insiderSummary.map { $0.position ?? 0 }.reduce(0, +) /// Get total shares owned by the top 10 insiders VStack(alignment: .leading, spacing: 20) { ForEach(insiderSummary.prefix(3), id: \.self) { insider in - - // Compute percentage of ownership for each insider - let percentage = Double(insider.position ?? 0) / Double(totalPositions) - + let percentage = Double(insider.position ?? 0) / Double(totalPositions) /// Compute percentage of ownership for each insider InsiderRow(percentageOfWidth: CGFloat(percentage), insiderRoster: insider) } } @@ -43,7 +39,13 @@ struct InsiderList_Previews: PreviewProvider { static var previews: some View { InsiderList(insiderSummary: - [InsiderRosterModel(entityName: "Dennis Concepcion", position: 1234, reportDate: 1234567)] + [ + InsiderRosterModel( + entityName: "Dennis Concepcion", + position: 1234, + reportDate: 1234567 + ) + ] ) } } @@ -55,14 +57,10 @@ var body: some View { NavigationView { ScrollView { - // Get total shares owned by the top 10 insiders - let totalPositions = insiderSummary.map { $0.position ?? 0 }.reduce(0, +) + let totalPositions = insiderSummary.map { $0.position ?? 0 }.reduce(0, +) /// Get total shares owned by the top 10 insiders VStack(alignment: .leading, spacing: 20) { ForEach(insiderSummary, id: \.self) { insider in - - // Compute percentage of ownership for each insider - let percentage = Double(insider.position ?? 0) / Double(totalPositions) - + let percentage = Double(insider.position ?? 0) / Double(totalPositions) /// Compute percentage of ownership for each insider InsiderRow(percentageOfWidth: CGFloat(percentage), insiderRoster: insider) } }