aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Application.swift
blob: 2e35e3c5843da423e2fbf7db97d369feb1bb1e5e (plain)
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
41
42
43
44
45
46
import SwiftUI
import SwiftData

@main
struct Application: App {
  #if os(iOS)
  private var model = Hotline(trackerClient: HotlineTrackerClient(), client: HotlineClient())
  #endif
  
  var body: some Scene {
    #if os(iOS)
    WindowGroup {
      TrackerView()
        .environment(model)
    }
    #elseif os(macOS)
    Window("Servers", id: "servers") {
      TrackerView()
        .frame(minWidth: 250, minHeight: 250)
        .toolbar {
          ToolbarItem(placement: .navigation) {
            Image("Hotline")
              .resizable()
              .renderingMode(.template)
              .scaledToFit()
              .foregroundColor(Color(hex: 0xE10000))
              .frame(width: 9)
          }
        }
    }
    .defaultSize(width: 700, height: 600)
    .defaultPosition(.center)
    
    WindowGroup(for: Server.self) { $server in
      if let s = server {
        ServerView(server: s)
          .frame(minWidth: 400, minHeight: 300)
          .environment(Hotline(trackerClient: HotlineTrackerClient(), client: HotlineClient()))
      }
    }
    .defaultSize(width: 700, height: 800)
    .defaultPosition(.center)

    #endif
  }
}