forked from github/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppInfoView.swift
More file actions
75 lines (66 loc) · 2.5 KB
/
AppInfoView.swift
File metadata and controls
75 lines (66 loc) · 2.5 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import ComposableArchitecture
import GitHubCopilotService
import GitHubCopilotViewModel
import SwiftUI
struct AppInfoView: View {
class Settings: ObservableObject {
@AppStorage(\.installPrereleases)
var installPrereleases
}
static var copilotAuthService: GitHubCopilotAuthServiceType?
@Environment(\.updateChecker) var updateChecker
@Environment(\.toast) var toast
@StateObject var settings = Settings()
@StateObject var viewModel: GitHubCopilotViewModel
@State var appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
@State var automaticallyCheckForUpdates: Bool?
let store: StoreOf<General>
var body: some View {
HStack(alignment: .center, spacing: 16) {
let appImage = if let nsImage = NSImage(named: "AppIcon") {
Image(nsImage: nsImage)
} else {
Image(systemName: "app")
}
appImage
.resizable()
.frame(width: 110, height: 110)
VStack(alignment: .leading, spacing: 8) {
HStack {
Text(Bundle.main.object(forInfoDictionaryKey: "HOST_APP_NAME") as? String ?? "GitHub Copilot for Xcode")
.font(.title)
Text("(\(appVersion ?? ""))")
.font(.title)
}
Text("Language Server Version: \(viewModel.version ?? "Loading...")")
Button(action: {
updateChecker.checkForUpdates()
}) {
HStack(spacing: 2) {
Text("Check for Updates")
}
}
HStack {
Toggle(isOn: .init(
get: { automaticallyCheckForUpdates ?? updateChecker.getAutomaticallyChecksForUpdates() },
set: { updateChecker.setAutomaticallyChecksForUpdates($0); automaticallyCheckForUpdates = $0 }
)) {
Text("Automatically Check for Updates")
}
Toggle(isOn: $settings.installPrereleases) {
Text("Install pre-releases")
}
}
}
Spacer()
}
.padding(.horizontal, 2)
.padding(.vertical, 15)
}
}
#Preview {
AppInfoView(
viewModel: GitHubCopilotViewModel.shared,
store: .init(initialState: .init(), reducer: { General() })
)
}