Проверка шаблона шины для iOS

50 строки
1.4KB

  1. import BusX
  2. import SwiftUI
  3. extension MeetupId {
  4. public struct V: View {
  5. @StateObject var isJoinAvailable = BusUI.Value(K.isJoinAvailable, false)
  6. @StateObject var isLoading = BusUI.Value(K.isLoading, false)
  7. @StateObject var join = BusUI.Button(K.join)
  8. @StateObject var textField = BusUI.TextField(K.textApp, K.textUI)
  9. let processors: [Any] = [
  10. Bus.Processor(shouldEnableJoin, K.M, K.isJoinAvailable),
  11. MeetupId.Debounce(0.2, formatId, K.textUI, K.textApp),
  12. MeetupId.Delay(5, finishLoading, K.isLoading, K.finishLoading),
  13. ]
  14. public init() { }
  15. public var body: some View {
  16. VStack(spacing: 8) {
  17. HStack {
  18. TextField("Binding-3", value: $textField.v, formatter: BusUI.TextFieldSource())
  19. .disabled(isLoading.v)
  20. .padding(8)
  21. .border(
  22. !isLoading.v ? Color.black : Color.gray,
  23. width: !isLoading.v ? 2 : 1
  24. )
  25. if isLoading.v {
  26. ProgressView()
  27. .padding(8)
  28. }
  29. }
  30. Button(action: join.v.send) {
  31. Text("Join")
  32. .padding(8)
  33. .border(
  34. isJoinAvailable.v ? Color.green : Color.gray,
  35. width: isJoinAvailable.v ? 2 : 1
  36. )
  37. }
  38. .disabled(!isJoinAvailable.v)
  39. }
  40. .frame(width: 320)
  41. .padding()
  42. .animation(.easeInOut(duration: 0.3))
  43. }
  44. }
  45. }