diff options
author | Christian Segundo | 2023-07-24 10:45:15 +0200 |
---|---|---|
committer | Christian Segundo | 2023-07-24 10:45:15 +0200 |
commit | 01ce93653d86f2a47eda58d2e74c3926981b22cf (patch) | |
tree | def1c1599a0a044ab9c64d48b89c704f4cbb0938 /Xmission/Code/Home/Screens/HomeScreen.swift | |
parent | 864b644e8ecafccaf84b40168524e47351a6d111 (diff) | |
download | xmission-ios-01ce93653d86f2a47eda58d2e74c3926981b22cf.tar.gz |
Diffstat (limited to 'Xmission/Code/Home/Screens/HomeScreen.swift')
-rw-r--r-- | Xmission/Code/Home/Screens/HomeScreen.swift | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/Xmission/Code/Home/Screens/HomeScreen.swift b/Xmission/Code/Home/Screens/HomeScreen.swift new file mode 100644 index 0000000..dac8a20 --- /dev/null +++ b/Xmission/Code/Home/Screens/HomeScreen.swift @@ -0,0 +1,89 @@ +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() + } +} |