summaryrefslogtreecommitdiff
path: root/Sora/Views/GenericItemView.swift
blob: f2d70cbd66ee192f45fda44fc1648610e4b31ab4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import SwiftUI

struct GenericItemView<T: ItemViewModel>: View {
  @EnvironmentObject var settings: SettingsManager
  let item: T
  let removeAction: (UUID) -> Void

  var body: some View {
#if os(macOS)
    HStack {
      VStack(alignment: .leading) {
        Text(item.tags.joined(separator: ", ").lowercased())

        Spacer()

        Text("On \(item.date.formatted()) from \(item.provider.rawValue)")
          .font(.caption)
          .foregroundStyle(Color.secondary)
      }

      Spacer()

      Button {
        removeAction(item.id)
      } label: {
        Image(systemName: "trash")
      }
    }
    .padding()
#else
    VStack(alignment: .leading) {
      Text(item.tags.joined(separator: ", ").lowercased())

      Text("On \(item.date.formatted()) from \(item.provider.rawValue)")
        .font(.caption)
        .foregroundStyle(Color.secondary)
    }
#endif
  }
}