summaryrefslogtreecommitdiff
path: root/Sora/Views/Generic/GenericItemView.swift
blob: 21c5142c3edae95e73f2be20e7597a43625944d1 (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: GenericItem>: 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()
        }
      }
      .contextMenu {
        Button {
          removeAction(item.id)
        } label: {
          Label("Remove", systemImage: "trash")
        }
      }
    #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
  }
}