aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Application.swift
blob: 93bf0255d7b928b39685de9e2124d608acbcaa22 (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
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)
    WindowGroup {
      TrackerView()
        .frame(minWidth: 250, minHeight: 250)
    }
    .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
  }
}