summaryrefslogtreecommitdiff
path: root/Xmission/Code/Home/Screens
diff options
context:
space:
mode:
Diffstat (limited to 'Xmission/Code/Home/Screens')
-rw-r--r--Xmission/Code/Home/Screens/HomeScreen.swift89
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()
+ }
+}