import SwiftUI struct HomeScreen: View { @ObservedObject var viewModel: HomeViewModel = .init() var body: some View { NavigationView { List { ForEach(viewModel.torrents, id: \.name) { torrent in TorrentRow(torrent: torrent) .swipeActions(edge: .trailing) { Button {} label: { Label("Delete", systemImage: "trash") } .tint(.red) } .listRowSeparator(.hidden) } } .listStyle(.plain) .navigationBarTitle(Text("192.168.0.2"), displayMode: .inline) .navigationBarItems( leading: Button( action: { print("Adding torrent") }, label: { Image(systemName: "plus") } ), trailing: Button( action: { print("Going to Settings") }, label: { Image(systemName: "gear") } ) ) } } } struct TorrentRow: View { let torrent: Torrent var body: some View { HStack { ProgressView( value: torrent.completionPercent, total: 100, label: { VStack { Text(torrent.name) HStack { // todo chips } } }, currentValueLabel: { HStack { Text("Ratio: " + String(torrent.ratio)).frame( maxWidth: .infinity, maxHeight: .infinity, alignment: .leading ) Text(String(torrent.completionPercent) + "%").frame( maxWidth: .infinity, maxHeight: .infinity, alignment: .center ) HStack { Image(systemName: "chevron.up", variableValue: 100) Text(String(torrent.rateUpload)) Image(systemName: "chevron.down") Text(String(torrent.rateDownload)) }.frame( maxWidth: .infinity, maxHeight: .infinity, alignment: .trailing ) } } ) } } } struct HomeScreen_Previews: PreviewProvider { static var previews: some View { HomeScreen() } }