diff --git a/Modules/BusX/BusUI/src/BusUI.TextField.swift b/Modules/BusX/BusUI/src/BusUI.TextField.swift index c610e00..93996e8 100644 --- a/Modules/BusX/BusUI/src/BusUI.TextField.swift +++ b/Modules/BusX/BusUI/src/BusUI.TextField.swift @@ -16,6 +16,8 @@ extension BusUI { ) { self.textApp = textApp self.textUI = textUI + + /**/print("ИГР BusUTF(\(Unmanaged.passUnretained(self).toOpaque())).init textA/textU: '\(textApp)'/'\(textUI)'") $id .sink { [weak self] v in self?.setup(v) } diff --git a/Modules/MeetupIdX/src/MeetupId.TV.swift b/Modules/MeetupIdX/src/MeetupId.TV.swift index 695aca8..d4f628c 100644 --- a/Modules/MeetupIdX/src/MeetupId.TV.swift +++ b/Modules/MeetupIdX/src/MeetupId.TV.swift @@ -3,17 +3,25 @@ import SwiftUI extension MeetupId { public struct TV: View { - @StateObject var textField = BusUI.TextField(K.testTextApp, K.testTextUI) + let id: String + @StateObject var vm = TVM() public init(_ id: String) { - textField.id = id + self.id = id } public var body: some View { - TextField("TV", value: $textField.v, formatter: BusUI.TextFieldSource()) + TextField("TV", value: vm.$textField.v, formatter: BusUI.TextFieldSource()) .padding(8) .border(Color.blue) .animation(.easeInOut(duration: 0.3)) + .onAppear { + vm.setup(id) + } + .onChange(of: id) { newValue in + vm.setup(newValue) + } } + } } diff --git a/Modules/MeetupIdX/src/MeetupId.TVM.swift b/Modules/MeetupIdX/src/MeetupId.TVM.swift new file mode 100644 index 0000000..25c4106 --- /dev/null +++ b/Modules/MeetupIdX/src/MeetupId.TVM.swift @@ -0,0 +1,17 @@ +import BusX + +extension MeetupId { + public final class VM: ObservableObject { + let textField = BusUI.TextField(K.testTextApp, K.testTextUI) + @Published public var id: String? + var subscriptions = [AnyCancellable]() + + public init() { } + + public setup(_ id: String) { + /**/print("ИГР MeetupIV(\(Unmanaged.passUnretained(self).toOpaque())).setup id: '\(id)'") + textField.id = id + } + } +} + diff --git a/src/App.swift b/src/App.swift index 0f71d39..5870186 100644 --- a/src/App.swift +++ b/src/App.swift @@ -4,8 +4,7 @@ import UIKit struct Content: View { var body: some View { - MeetupId.V() - Divider() + //MeetupId.V() MeetupId.TV("uuid-1") Divider() MeetupId.TV("uuid-2")