Проверка шаблона шины для iOS
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

53 wiersze
1.5KB

  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. public init() {
  11. processors = [
  12. Bus.Debounce(shouldResetText, 0.2, K.M, K.textApp),
  13. Bus.Delay(shouldFinishLoading, 5, K.M, K.finishLoading),
  14. Bus.Sync(shouldEnableJoin, K.M, K.isJoinAvailable),
  15. Bus.Sync(shouldResetLoading, K.M, K.isLoading)
  16. ]
  17. }
  18. public var body: some View {
  19. VStack(spacing: 8) {
  20. HStack {
  21. TextField("Binding-3", value: $textField.v, formatter: BusUI.TextFieldSource())
  22. .disabled(isLoading.v)
  23. .padding(8)
  24. .border(
  25. !isLoading.v ? Color.black : Color.gray,
  26. width: !isLoading.v ? 2 : 1
  27. )
  28. if isLoading.v {
  29. ProgressView()
  30. .padding(8)
  31. }
  32. }
  33. Button(action: join.v.send) {
  34. Text("Join")
  35. .padding(8)
  36. .border(
  37. isJoinAvailable.v ? Color.green : Color.gray,
  38. width: isJoinAvailable.v ? 2 : 1
  39. )
  40. }
  41. .disabled(!isJoinAvailable.v)
  42. }
  43. .frame(width: 320)
  44. .padding()
  45. .animation(.easeInOut(duration: 0.3))
  46. }
  47. }
  48. }