Compare commits
6 Commits
f4bb4e50e3
...
cfe804522f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cfe804522f | ||
|
|
1f501d8276 | ||
|
|
de42152b9f | ||
|
|
c3265592a7 | ||
|
|
895f74440b | ||
|
|
af7ddfa161 |
54
Modules/BusX/BusUI/src/BusUI.ManyTextField.swift
Normal file
54
Modules/BusX/BusUI/src/BusUI.ManyTextField.swift
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import Combine
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
extension BusUI {
|
||||||
|
public final class ManyTextField: ObservableObject {
|
||||||
|
let textApp: String
|
||||||
|
let textUI: String
|
||||||
|
@Published public var id: String?
|
||||||
|
@Published public var v = "a:"
|
||||||
|
var subscriptions = [AnyCancellable]()
|
||||||
|
var sub = [AnyCancellable]()
|
||||||
|
|
||||||
|
public init(
|
||||||
|
_ textApp: String,
|
||||||
|
_ textUI: String
|
||||||
|
) {
|
||||||
|
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) }
|
||||||
|
.store(in: &sub)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setup(_ id: String?) {
|
||||||
|
/**/print("ИГР BusUTF(\(Unmanaged.passUnretained(self).toOpaque())).setup id: '\(id)'")
|
||||||
|
|
||||||
|
subscriptions = []
|
||||||
|
|
||||||
|
Bus.sendSync(
|
||||||
|
textUI,
|
||||||
|
$v
|
||||||
|
.removeDuplicates()
|
||||||
|
.compactMap(onlyUIText)
|
||||||
|
.compactMap { v in
|
||||||
|
if let id {
|
||||||
|
return "\(id):\(v)"
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
.eraseToAnyPublisher(),
|
||||||
|
&subscriptions
|
||||||
|
)
|
||||||
|
|
||||||
|
Bus.receiveSync(
|
||||||
|
[textApp],
|
||||||
|
{ [weak self] (_, v: String) in self?.v = "a:\(v)" },
|
||||||
|
&subscriptions
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,9 @@ public extension MeetupId {
|
|||||||
static let M = "MeetupId"
|
static let M = "MeetupId"
|
||||||
static let textApp = "MeetupId.textApp"
|
static let textApp = "MeetupId.textApp"
|
||||||
static let textUI = "MeetupId.textUI"
|
static let textUI = "MeetupId.textUI"
|
||||||
|
|
||||||
|
static let testTextApp = "MeetupId.testTextApp"
|
||||||
|
static let testTextUI = "MeetupId.testTextUI"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
Modules/MeetupIdX/src/MeetupId.TV.swift
Normal file
27
Modules/MeetupIdX/src/MeetupId.TV.swift
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import BusX
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
extension MeetupId {
|
||||||
|
public struct TV: View {
|
||||||
|
let id: String
|
||||||
|
@StateObject var vm = VM()
|
||||||
|
|
||||||
|
public init(_ id: String) {
|
||||||
|
self.id = id
|
||||||
|
}
|
||||||
|
|
||||||
|
public var body: some View {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
18
Modules/MeetupIdX/src/MeetupId.TVM.swift
Normal file
18
Modules/MeetupIdX/src/MeetupId.TVM.swift
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import BusX
|
||||||
|
import Combine
|
||||||
|
|
||||||
|
extension MeetupId {
|
||||||
|
public final class VM: ObservableObject {
|
||||||
|
@Published public var id: String?
|
||||||
|
@Published var textField = BusUI.TextField(K.testTextApp, K.testTextUI)
|
||||||
|
var subscriptions = [AnyCancellable]()
|
||||||
|
|
||||||
|
public init() { }
|
||||||
|
|
||||||
|
public func setup(_ id: String) {
|
||||||
|
/**/print("ИГР MeetupIV(\(Unmanaged.passUnretained(self).toOpaque())).setup id: '\(id)'")
|
||||||
|
textField.id = id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -4,8 +4,10 @@ import UIKit
|
|||||||
|
|
||||||
struct Content: View {
|
struct Content: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
MeetupId.V()
|
//MeetupId.V()
|
||||||
|
MeetupId.TV("uuid-1")
|
||||||
Divider()
|
Divider()
|
||||||
|
MeetupId.TV("uuid-2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user