Files
VirtualBuddy/VirtualUI/Source/Session/Configuration/VMSessionConfigurationView.swift
Guilherme Rambo e19a74866c Liquid glass adoption (#677)
* 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
2026-05-22 09:47:01 -03:00

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