Mercurial > public > lazybear
view LazyBear/Views/Company/Helpers/InsiderRosterList.swift @ 445:7d1c4dc8d1d8
Change presentationMode to Binding
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Tue, 22 Jun 2021 19:56:59 +0200 |
parents | ffbb1dbab531 |
children | 8621ba6fd457 |
line wrap: on
line source
// // InsiderRosterList.swift // LazyBear // // Created by Dennis Concepción Martín on 21/6/21. // import SwiftUI struct InsiderRosterList: View { var insiderRoster: [InsiderRosterModel] @Binding var isPresented: Bool var body: some View { NavigationView { ScrollView(showsIndicators: false) { VStack { let totalPositions = insiderRoster.map { $0.position ?? 0 }.reduce(0, +) /// Get total shares owned by top 10 insiders ForEach(insiderRoster, id: \.self) { insider in let percentageOfWidth = Double(insider.position ?? 0) / Double(totalPositions) /// Compute percentage of ownership for each insider InsiderRosterRow(insider: insider, percentageOfWidth: CGFloat(percentageOfWidth)) Divider() } } .padding() } .navigationTitle("Top 10 Insiders") .toolbar { ToolbarItem(placement: .cancellationAction) { Button(action: { self.isPresented.toggle() }) { Image(systemName: "multiply") } } } } } } struct InsiderRosterList_Previews: PreviewProvider { static var previews: some View { InsiderRosterList( insiderRoster: [ InsiderRosterModel( entityName: "Tim Cook", position: 12345, reportDate: 12345 ) ] , isPresented: .constant(true) ) } }