Move diagnostics into settings, remove the app-local notification module, unify the global theme switcher, refine privacy copy and the instance detail experience, and rebuild the app icon.
71 lines
2.2 KiB
Swift
71 lines
2.2 KiB
Swift
import Foundation
|
|
|
|
enum DefaultContainer {
|
|
private static let credentials: any CredentialStore = FileCredentialStore(
|
|
location: documentFileURL("credentials.json")
|
|
)
|
|
|
|
private static let logStore: any LogStore = FileLogStore(
|
|
location: documentFileURL("log-center.json")
|
|
)
|
|
|
|
static func documentFileURL(_ name: String) -> URL {
|
|
let directory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
|
return directory.appendingPathComponent(name)
|
|
}
|
|
|
|
@MainActor
|
|
static func makeFleetModel() -> FleetViewModel {
|
|
FleetViewModel(
|
|
repository: FileInstanceRepository(location: documentFileURL("instances.json")),
|
|
probe: ConnectionProbe(client: SimAdminClient()),
|
|
credentials: credentials
|
|
)
|
|
}
|
|
|
|
@MainActor
|
|
static func makeMessagesModel() -> MessagesViewModel {
|
|
MessagesViewModel(
|
|
repository: FileInstanceRepository(location: documentFileURL("instances.json")),
|
|
service: MessageService(
|
|
client: SimAdminClient(),
|
|
sessions: InstanceSessionStore(),
|
|
credentials: credentials
|
|
)
|
|
)
|
|
}
|
|
|
|
@MainActor
|
|
static func makeLogsModel(autoRefreshOnAppear: Bool = true) -> LogsViewModel {
|
|
let store = logStore
|
|
return LogsViewModel(
|
|
repository: FileInstanceRepository(location: documentFileURL("instances.json")),
|
|
service: LogCenterService(
|
|
client: SimAdminClient(),
|
|
sessions: InstanceSessionStore(),
|
|
credentials: credentials,
|
|
store: store
|
|
),
|
|
store: store,
|
|
autoRefreshOnAppear: autoRefreshOnAppear
|
|
)
|
|
}
|
|
|
|
@MainActor
|
|
static func makeSettingsModel() -> SettingsViewModel {
|
|
SettingsViewModel(store: logStore)
|
|
}
|
|
|
|
@MainActor
|
|
static func makeDeviceModel(instance: Instance) -> DeviceViewModel {
|
|
DeviceViewModel(
|
|
instance: instance,
|
|
service: DeviceService(
|
|
client: SimAdminClient(),
|
|
sessions: InstanceSessionStore(),
|
|
credentials: credentials
|
|
)
|
|
)
|
|
}
|
|
}
|