mirror of
https://github.com/insidegui/VirtualBuddy.git
synced 2026-12-02 00:50:32 +08:00
* Fix duplicate name during setup overwriting existing VM * Move VirtualCore tests into a dedicated target
50 lines
1.3 KiB
Swift
50 lines
1.3 KiB
Swift
//
|
|
// VirtualMachineNameInputView.swift
|
|
// VirtualUI
|
|
//
|
|
// Created by Guilherme Rambo on 01/08/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
import VirtualCore
|
|
|
|
struct VirtualMachineNameInputView: View {
|
|
@Binding var name: String
|
|
var validationError: String?
|
|
|
|
var body: some View {
|
|
VirtualBuddyInstallerInputView {
|
|
VStack(alignment: .leading, spacing: 12) {
|
|
HStack {
|
|
TextField("Virtual Machine Name", text: $name)
|
|
|
|
Spacer()
|
|
|
|
Button {
|
|
name = RandomNameGenerator.shared.newName()
|
|
} label: {
|
|
Image(systemName: "arrow.clockwise")
|
|
.help("Generate new name")
|
|
}
|
|
.buttonStyle(.borderless)
|
|
.font(.system(size: 15, weight: .medium, design: .rounded))
|
|
.keyboardShortcut(.init("r", modifiers: .command))
|
|
}
|
|
|
|
if let validationError {
|
|
Text(validationError)
|
|
.font(.subheadline)
|
|
.foregroundStyle(.red)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
#Preview {
|
|
VMInstallationWizard.preview(step: .name)
|
|
}
|
|
#endif // DEBUG
|