mirror of
https://github.com/insidegui/VirtualBuddy.git
synced 2026-12-02 12:49:40 +08:00
* Raise deployment target to macOS 14, bump version * Integrate Liquid Glass compatibility components * Fix onChange(of:) deprecation warnings * Update project settings * Improve styling of setup and configuration UI components * Fix fatal error in VMSavedStatesController.preview * Tweak session UI * Do not use prominent button style in VM configuration sheet so it matches overall setup wizard style * Fix incorrectly sized buttons in grouped lists
96 lines
3.3 KiB
Swift
96 lines
3.3 KiB
Swift
//
|
|
// VMSessionConfigurationView.swift
|
|
// VirtualBuddy
|
|
//
|
|
// Created by Guilherme Rambo on 07/04/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
import VirtualCore
|
|
|
|
struct VMSessionConfigurationView: View {
|
|
@EnvironmentObject var controller: VMController
|
|
|
|
@State private var isShowingVMSettings = false
|
|
|
|
private var vm: VBVirtualMachine { controller.virtualMachineModel }
|
|
|
|
private var resolvedRestoreImage: ResolvedRestoreImage? {
|
|
let catalog = SoftwareCatalog.current(for: vm.configuration.systemType)
|
|
|
|
if let remoteURL = vm.metadata.remoteInstallImageURL,
|
|
let resolved = catalog.resolvedRestoreImage(matching: remoteURL, guestType: vm.configuration.systemType) {
|
|
return resolved
|
|
}
|
|
|
|
if let localURL = vm.metadata.installImageURL,
|
|
let resolved = catalog.resolvedRestoreImage(matching: localURL, guestType: vm.configuration.systemType) {
|
|
return resolved
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
var body: some View {
|
|
SelfSizingGroupedForm(minHeight: 100) {
|
|
if showSavedStatePicker {
|
|
SavedStatePicker(selectedStateURL: $controller.options.stateRestorationPackageURL)
|
|
.environmentObject(controller.savedStatesController)
|
|
}
|
|
|
|
if showInstallDeviceOption {
|
|
Toggle("Boot on install drive", isOn: $controller.options.bootOnInstallDevice)
|
|
}
|
|
|
|
if showRecoveryModeOption {
|
|
Toggle("Boot in recovery mode", isOn: $controller.options.bootInRecoveryMode)
|
|
.disabled(controller.options.bootInDFUMode)
|
|
}
|
|
|
|
if showDFUOption {
|
|
Toggle("Boot in DFU mode", isOn: $controller.options.bootInDFUMode)
|
|
.disabled(controller.options.bootInRecoveryMode)
|
|
}
|
|
|
|
Toggle("Capture system keyboard shortcuts", isOn: $controller.virtualMachineModel.configuration.captureSystemKeys)
|
|
|
|
Button("Virtual Machine Settings…") {
|
|
isShowingVMSettings.toggle()
|
|
}
|
|
.frame(maxWidth: .infinity, alignment: .trailing)
|
|
}
|
|
.padding(-12)
|
|
.clipShape(shape)
|
|
.airMaterialBackground(visualEffect: .hudWindow, glassEffect: .clear, in: shape)
|
|
.sheet(isPresented: $isShowingVMSettings) {
|
|
VMConfigurationSheet(
|
|
configuration: $controller.virtualMachineModel.configuration
|
|
)
|
|
.environmentObject(VMConfigurationViewModel(vm, resolvedRestoreImage: resolvedRestoreImage))
|
|
}
|
|
}
|
|
|
|
private var shape: RoundedRectangle {
|
|
RoundedRectangle(cornerRadius: 18)
|
|
}
|
|
|
|
private var showInstallDeviceOption: Bool { vm.configuration.systemType == .linux && vm.metadata.installImageURL != nil }
|
|
|
|
private var showRecoveryModeOption: Bool { vm.configuration.systemType == .mac }
|
|
|
|
private var showDFUOption: Bool { VBMacConfiguration.appBuildAllowsDFUMode && vm.configuration.systemType == .mac }
|
|
|
|
private var showSavedStatePicker: Bool { vm.configuration.systemType.supportsStateRestoration }
|
|
}
|
|
|
|
#if DEBUG
|
|
#Preview("Glass") {
|
|
VirtualMachineSessionViewPreview()
|
|
}
|
|
|
|
#Preview("No Glass") {
|
|
VirtualMachineSessionViewPreview()
|
|
.environment(\.preview_overrideLiquidGlassSupported, false)
|
|
}
|
|
#endif
|