d
This commit is contained in:
@@ -3,6 +3,7 @@ import UIKit
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate
|
||||
{
|
||||
let bus = Bus.Service()
|
||||
var window: UIWindow?
|
||||
|
||||
func application(
|
||||
@@ -89,63 +90,4 @@ public extension Bus {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BusSlot.swift
|
||||
var busHolder = Bus.Service()
|
||||
|
||||
// ========================================
|
||||
// MARK: - MeetupX module
|
||||
// ========================================
|
||||
|
||||
enum MeetupId {
|
||||
enum Keys: String, RawRepresentable {
|
||||
case meetupIdTextApp
|
||||
case meetupIdTextUI
|
||||
}
|
||||
|
||||
static func shouldFormat(_ s: String) -> String? {
|
||||
return s.components(separatedBy: NSCharacterSet.decimalDigits.inverted).reduce("") { $0 + $1 }
|
||||
}
|
||||
|
||||
final class MeetupIdFormatter {
|
||||
var subscriptions = [AnyCancellable]()
|
||||
|
||||
deinit {
|
||||
/**/dbg("ИГР MeetupIF.DEinit")
|
||||
}
|
||||
|
||||
init() {
|
||||
Bus.receive(
|
||||
&subscriptions,
|
||||
[Keys.meetupIdTextUI.rawValue],
|
||||
{ [weak self] k, v in self?.handleFormatting(k, v) }
|
||||
)
|
||||
/**/dbg("ИГР MeetupIF.init")
|
||||
}
|
||||
|
||||
func handleFormatting(_: String, _ value: String) {
|
||||
let out = MeetupId.shouldFormat(value)
|
||||
/**/dbg("ИГР MeetupIF.handleF out/dt: '\(out)'/'\(Date())'")
|
||||
Bus.Service.singleton?.send(Keys.meetupIdTextApp.rawValue, out)
|
||||
}
|
||||
}
|
||||
|
||||
struct V: View {
|
||||
/*@StateObject*/ var fmt = MeetupIdFormatter()
|
||||
@StateObject var txt = Bus.BindingPipe("", Keys.meetupIdTextApp.rawValue, Keys.meetupIdTextUI.rawValue)
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Text("Hi, the text is: '\(txt.value)'")
|
||||
.fontWeight(.bold)
|
||||
TextField("Placeholder", text: $txt.value)
|
||||
.padding(8)
|
||||
.border(Color.blue, width: 2)
|
||||
}
|
||||
.frame(width: 320)
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user