VMConfigPortForwardForm.swift 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // Copyright © 2020 osy. All rights reserved.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. import SwiftUI
  17. struct VMConfigPortForwardForm: View {
  18. @Binding var forward: UTMQemuConfigurationPortForward
  19. var body: some View {
  20. Group {
  21. VMConfigConstantPicker("Protocol", selection: $forward.protocol)
  22. DefaultTextField("Guest Address", text: $forward.guestAddress.bound, prompt: "10.0.2.15")
  23. .help("Guest Address")
  24. NumberTextField("Guest Port", number: $forward.guestPort, prompt: "1234")
  25. .help("Guest Port")
  26. DefaultTextField("Host Address", text: $forward.hostAddress.bound, prompt: "0.0.0.0")
  27. .help("Host Address")
  28. NumberTextField("Host Port", number: $forward.hostPort, prompt: "1234")
  29. .help("Host Port")
  30. }.disableAutocorrection(true)
  31. .keyboardType(.decimalPad)
  32. }
  33. }
  34. struct VMConfigPortForwardForm_Previews: PreviewProvider {
  35. @State static private var forward = UTMQemuConfigurationPortForward()
  36. static var previews: some View {
  37. VStack {
  38. VStack {
  39. Form {
  40. VMConfigPortForwardForm(forward: $forward)
  41. }
  42. }
  43. }
  44. }
  45. }