Files
xcodesApp-mirror/Xcodes/Frontend/Preferences/DownloadPreferencePane.swift
Anand Biligiri 6e64db26fb Disallow changes to managed preferences
- Define enumerations for preferences that can be managed in an enterprise environment using MDM
- Add methods in AppState to check for managed preferences
- Update Advanced, Download, Experiments and Update preference panes to disable controls
  to modify any of the managed preferences
- Update Xcode category list button to be disabled if preference is managed
2024-06-21 07:17:18 +05:30

65 lines
2.2 KiB
Swift

import AppleAPI
import SwiftUI
struct DownloadPreferencePane: View {
@EnvironmentObject var appState: AppState
@AppStorage("dataSource") var dataSource: DataSource = .xcodeReleases
@AppStorage("downloader") var downloader: Downloader = .aria2
var body: some View {
VStack(alignment: .leading) {
GroupBox(label: Text("DataSource")) {
VStack(alignment: .leading) {
Picker("DataSource", selection: $dataSource) {
ForEach(DataSource.allCases) { dataSource in
Text(dataSource.description)
.tag(dataSource)
}
}
.labelsHidden()
.fixedSize()
Text("DataSourceDescription")
.font(.footnote)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
}
}
.groupBoxStyle(PreferencesGroupBoxStyle())
.disabled(dataSource.isManaged)
GroupBox(label: Text("Downloader")) {
VStack(alignment: .leading) {
Picker("Downloader", selection: $downloader) {
ForEach(Downloader.allCases) { downloader in
Text(downloader.description)
.tag(downloader)
}
}
.labelsHidden()
.fixedSize()
Text("DownloaderDescription")
.font(.footnote)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
}
}
.groupBoxStyle(PreferencesGroupBoxStyle())
.disabled(downloader.isManaged)
}
}
}
struct DownloadPreferencePane_Previews: PreviewProvider {
static var previews: some View {
Group {
DownloadPreferencePane()
.environmentObject(AppState())
.frame(maxWidth: 600)
.frame(minHeight: 300)
}
}
}