Compare commits
26 Commits
cfe804522f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb527c2154 | ||
|
|
0309ab67b4 | ||
|
|
3bb8d453c4 | ||
|
|
46d2602ef7 | ||
|
|
8f2ed4ae51 | ||
|
|
d2a948e7c7 | ||
|
|
567d322516 | ||
|
|
e032918bf3 | ||
|
|
00a9a25997 | ||
|
|
a35ffcfbd4 | ||
|
|
e8f330ad2a | ||
|
|
aa203c2337 | ||
|
|
27fb18c484 | ||
|
|
2758b24ef7 | ||
|
|
e7975f151c | ||
|
|
65977e902f | ||
|
|
7f7a27f4e0 | ||
|
|
92e89bb0cf | ||
|
|
dbcf2a17a6 | ||
|
|
7faab99ad2 | ||
|
|
27865e97b3 | ||
|
|
f605fdbf52 | ||
|
|
95f66ab82c | ||
|
|
005621eccc | ||
|
|
336aa98fd2 | ||
|
|
da24b42515 |
36
Modules/BusX/BusUI/src/BusUI.ManyButton.swift
Normal file
36
Modules/BusX/BusUI/src/BusUI.ManyButton.swift
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import Combine
|
||||||
|
import MPAKX
|
||||||
|
|
||||||
|
extension BusUI {
|
||||||
|
public final class ManyButton: ObservableObject {
|
||||||
|
let key: String
|
||||||
|
public let v = PassthroughSubject<Void, Never>()
|
||||||
|
@Published public var id: String?
|
||||||
|
var sub = [AnyCancellable]()
|
||||||
|
var subscriptions = [AnyCancellable]()
|
||||||
|
|
||||||
|
public init(_ key: String) {
|
||||||
|
self.key = key
|
||||||
|
|
||||||
|
$id
|
||||||
|
.sink { [weak self] id in self?.setup(id) }
|
||||||
|
.store(in: &sub)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setup(_ id: String?) {
|
||||||
|
subscriptions = []
|
||||||
|
|
||||||
|
Bus.sendSync(
|
||||||
|
key,
|
||||||
|
v
|
||||||
|
.compactMap { v -> Any? in
|
||||||
|
guard let id else { return nil }
|
||||||
|
var d = [String: Bool]()
|
||||||
|
return MPAK.Many([id], d)
|
||||||
|
}
|
||||||
|
.eraseToAnyPublisher(),
|
||||||
|
&subscriptions
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import Combine
|
import Combine
|
||||||
|
import MPAKX
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
extension BusUI {
|
extension BusUI {
|
||||||
@@ -7,8 +8,8 @@ extension BusUI {
|
|||||||
let textUI: String
|
let textUI: String
|
||||||
@Published public var id: String?
|
@Published public var id: String?
|
||||||
@Published public var v = "a:"
|
@Published public var v = "a:"
|
||||||
var subscriptions = [AnyCancellable]()
|
|
||||||
var sub = [AnyCancellable]()
|
var sub = [AnyCancellable]()
|
||||||
|
var subscriptions = [AnyCancellable]()
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
_ textApp: String,
|
_ textApp: String,
|
||||||
@@ -17,28 +18,28 @@ extension BusUI {
|
|||||||
self.textApp = textApp
|
self.textApp = textApp
|
||||||
self.textUI = textUI
|
self.textUI = textUI
|
||||||
|
|
||||||
/**///print("ИГР BusUTF(\(Unmanaged.passUnretained(self).toOpaque())).init textA/textU: '\(textApp)'/'\(textUI)'")
|
|
||||||
|
|
||||||
$id
|
$id
|
||||||
.sink { [weak self] v in self?.setup(v) }
|
.sink { [weak self] id in self?.setup(id) }
|
||||||
.store(in: &sub)
|
.store(in: &sub)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setup(_ id: String?) {
|
private func setup(_ id: String?) {
|
||||||
/**/print("ИГР BusUTF(\(Unmanaged.passUnretained(self).toOpaque())).setup id: '\(id)'")
|
|
||||||
|
|
||||||
subscriptions = []
|
subscriptions = []
|
||||||
|
|
||||||
Bus.sendSync(
|
Bus.sendSync(
|
||||||
textUI,
|
textUI,
|
||||||
$v
|
$v
|
||||||
.removeDuplicates()
|
.removeDuplicates()
|
||||||
.compactMap(onlyUIText)
|
.compactMap { v -> Any? in
|
||||||
.compactMap { v in
|
guard
|
||||||
if let id {
|
let id,
|
||||||
return "\(id):\(v)"
|
let text = onlyUIText(v)
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return v
|
var d = [String: String]()
|
||||||
|
d[id] = text
|
||||||
|
return MPAK.Many([id], d)
|
||||||
}
|
}
|
||||||
.eraseToAnyPublisher(),
|
.eraseToAnyPublisher(),
|
||||||
&subscriptions
|
&subscriptions
|
||||||
@@ -46,7 +47,16 @@ extension BusUI {
|
|||||||
|
|
||||||
Bus.receiveSync(
|
Bus.receiveSync(
|
||||||
[textApp],
|
[textApp],
|
||||||
{ [weak self] (_, v: String) in self?.v = "a:\(v)" },
|
{ [weak self] (_, m: MPAK.Many<String>) in
|
||||||
|
guard
|
||||||
|
let id,
|
||||||
|
m.keys.contains(id),
|
||||||
|
let text = m.dict[id]
|
||||||
|
else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self?.v = "a:\(text)"
|
||||||
|
},
|
||||||
&subscriptions
|
&subscriptions
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
43
Modules/BusX/BusUI/src/BusUI.ManyValue.swift
Normal file
43
Modules/BusX/BusUI/src/BusUI.ManyValue.swift
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import Combine
|
||||||
|
import MPAKX
|
||||||
|
|
||||||
|
extension BusUI {
|
||||||
|
public final class ManyValue<T>: ObservableObject {
|
||||||
|
let key: String
|
||||||
|
@Published public var id: String?
|
||||||
|
@Published public var v: T
|
||||||
|
var sub = [AnyCancellable]()
|
||||||
|
var subscriptions = [AnyCancellable]()
|
||||||
|
|
||||||
|
public init(
|
||||||
|
_ key: String,
|
||||||
|
_ defaultValue: T
|
||||||
|
) {
|
||||||
|
self.key = key
|
||||||
|
v = defaultValue
|
||||||
|
|
||||||
|
$id
|
||||||
|
.sink { [weak self] id in self?.setup(id) }
|
||||||
|
.store(in: &sub)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setup(_ id: String?) {
|
||||||
|
subscriptions = []
|
||||||
|
|
||||||
|
Bus.receiveSync(
|
||||||
|
[key],
|
||||||
|
{ [weak self] (_, m: MPAK.Many<T>) in
|
||||||
|
guard
|
||||||
|
let id,
|
||||||
|
m.keys.contains(id),
|
||||||
|
let v = m.dict[id]
|
||||||
|
else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self?.v = v
|
||||||
|
},
|
||||||
|
&subscriptions
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,5 +10,6 @@ s.source = { :git => 'https://fake.com/FAKE.git', :tag => s.versi
|
|||||||
s.source_files = '**/**/*.swift'
|
s.source_files = '**/**/*.swift'
|
||||||
s.swift_version = '5.2'
|
s.swift_version = '5.2'
|
||||||
s.ios.deployment_target = '14.0'
|
s.ios.deployment_target = '14.0'
|
||||||
|
s.dependency 'MPAKX'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
extension MPAK {
|
extension MPAK {
|
||||||
public struct Many<T> {
|
public struct Many<T> {
|
||||||
public var keys = Set<String>()
|
public var keys: Set<String>
|
||||||
public var dict = [String: T]()
|
public var dict: [String: T]
|
||||||
|
|
||||||
public init() { }
|
public var isRecent: Bool { !keys.isEmpty }
|
||||||
|
|
||||||
|
public init(
|
||||||
|
_ keys: Set<String> = [],
|
||||||
|
_ dict: [String: T] = [:]
|
||||||
|
) {
|
||||||
|
self.keys = keys
|
||||||
|
self.dict = dict
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,14 +5,16 @@ model:
|
|||||||
isLoading: [Bool, false]
|
isLoading: [Bool, false]
|
||||||
join: [Bool, false]
|
join: [Bool, false]
|
||||||
textUI: [String, ""]
|
textUI: [String, ""]
|
||||||
|
testTextUI: [String, ""]
|
||||||
|
|
||||||
service:
|
service:
|
||||||
actions:
|
actions:
|
||||||
busModel
|
busModel
|
||||||
pipes:
|
pipes:
|
||||||
finishLoading: [toggle, K.finishLoading]
|
finishLoading: [toggle, K.finishLoading]
|
||||||
isLoading: [recent, K.isLoading]
|
isLoading: [many, K.isLoading]
|
||||||
join: [toggle, K.join]
|
join: [toggle, K.join]
|
||||||
textUI: [recent, K.textUI]
|
textUI: [many, K.textUI]
|
||||||
|
testTextUI: [many, K.testTextUI]
|
||||||
|
|
||||||
world:
|
world:
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public protocol MeetupIdContext {
|
|||||||
var isLoading: MPAK.Recent<Bool> { get }
|
var isLoading: MPAK.Recent<Bool> { get }
|
||||||
var join: Bool { get }
|
var join: Bool { get }
|
||||||
var textUI: MPAK.Recent<String> { get }
|
var textUI: MPAK.Recent<String> { get }
|
||||||
|
var testTextUI: MPAK.Many<String> { get }
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Controller
|
// MARK: - Controller
|
||||||
@@ -39,6 +40,7 @@ extension MeetupId {
|
|||||||
public var isLoading: MPAK.Recent<Bool> = .init(false)
|
public var isLoading: MPAK.Recent<Bool> = .init(false)
|
||||||
public var join: Bool = false
|
public var join: Bool = false
|
||||||
public var textUI: MPAK.Recent<String> = .init("")
|
public var textUI: MPAK.Recent<String> = .init("")
|
||||||
|
public var testTextUI: MPAK.Many<String> = .init()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Service
|
// MARK: - Service
|
||||||
@@ -143,6 +145,18 @@ extension MeetupId {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ctrl.pipeValue(
|
||||||
|
dbg: "testTUI",
|
||||||
|
sub: nil,
|
||||||
|
Bus.events.compactMap { Bus.convertKeyValue(K.testTextUI, $0) }.map { (k: String, v: MPAK.Many<String>) in v }.eraseToAnyPublisher(),
|
||||||
|
{
|
||||||
|
$0.testTextUI = $1
|
||||||
|
},
|
||||||
|
{ m, _ in m.testTextUI.keys = [] }
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,16 @@ extension MeetupId {
|
|||||||
_ world: World
|
_ world: World
|
||||||
) {
|
) {
|
||||||
service.any.append(contentsOf: [
|
service.any.append(contentsOf: [
|
||||||
Bus.Debounce(shouldResetText, 0.2, K.M, K.textApp),
|
//Bus.Debounce(shouldResetText, 0.2, K.M, K.textApp),
|
||||||
Bus.Delay(shouldFinishLoading, 5, K.M, K.finishLoading),
|
Bus.Debounce(shouldManyResetText, 0.2, K.M, K.textApp),
|
||||||
Bus.Sync(shouldEnableJoin, K.M, K.isJoinAvailable),
|
//Bus.Delay(shouldFinishLoading, 5, K.M, K.finishLoading),
|
||||||
Bus.Sync(shouldResetLoading, K.M, K.isLoading)
|
Bus.Delay(shouldManyFinishLoading, 5, K.M, K.finishLoading),
|
||||||
|
//Bus.Sync(shouldEnableJoin, K.M, K.isJoinAvailable),
|
||||||
|
Bus.Sync(shouldManyJoin, K.M, K.isJoinAvailable),
|
||||||
|
//Bus.Sync(shouldResetLoading, K.M, K.isLoading),
|
||||||
|
Bus.Sync(shouldManyResetLoading, K.M, K.isLoading),
|
||||||
|
|
||||||
|
Bus.Debounce(shouldManyTestResetText, 0.2, K.M, K.testTextApp),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
import MPAKX
|
||||||
|
|
||||||
public extension MeetupId {
|
public extension MeetupId {
|
||||||
|
/*
|
||||||
static func shouldEnableJoin(_ c: MeetupIdContext) -> Bool? {
|
static func shouldEnableJoin(_ c: MeetupIdContext) -> Bool? {
|
||||||
guard !c.isLoading.value else { return nil }
|
guard !c.isLoading.value else { return nil }
|
||||||
|
|
||||||
@@ -24,7 +26,49 @@ public extension MeetupId {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
static func shouldManyEnableJoin(_ c: MeetupIdContext) -> MPAK.Many<Bool>? {
|
||||||
|
var d = [String: Bool]()
|
||||||
|
|
||||||
|
// TODO: Когда копировать dict isLoading?
|
||||||
|
|
||||||
|
if c.textUI.isRecent {
|
||||||
|
for id in c.textUI.keys {
|
||||||
|
guard
|
||||||
|
c.isLoading.dict[id] == nil
|
||||||
|
let text = c.testTextUI.dict[id]
|
||||||
|
else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
let sid = formatId(text)
|
||||||
|
d[id] = sid.count > 2
|
||||||
|
}
|
||||||
|
if !d.isEmpty {
|
||||||
|
return .init(Set(d.keys), d)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
|
||||||
|
if c.join,
|
||||||
|
!c.isLoading.value
|
||||||
|
{
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if
|
||||||
|
c.isLoading.isRecent,
|
||||||
|
!c.isLoading.value
|
||||||
|
!c.isLoading.value
|
||||||
|
{
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
static func shouldFinishLoading(_ c: MeetupIdContext) -> Bool? {
|
static func shouldFinishLoading(_ c: MeetupIdContext) -> Bool? {
|
||||||
guard
|
guard
|
||||||
c.isLoading.isRecent,
|
c.isLoading.isRecent,
|
||||||
@@ -34,6 +78,11 @@ public extension MeetupId {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
это ещё конвертнуть надо в Many
|
||||||
|
|
||||||
static func shouldResetLoading(_ c: MeetupIdContext) -> Bool? {
|
static func shouldResetLoading(_ c: MeetupIdContext) -> Bool? {
|
||||||
if
|
if
|
||||||
@@ -52,9 +101,48 @@ public extension MeetupId {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
static func shouldResetText(_ c: MeetupIdContext) -> String? {
|
static func shouldResetText(_ c: MeetupIdContext) -> String? {
|
||||||
guard c.textUI.isRecent else { return nil }
|
guard c.textUI.isRecent else { return nil }
|
||||||
return formatId(c.textUI.value)
|
return formatId(c.textUI.value)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
static func shouldManyFinishLoading(_ c: MeetupIdContext) -> MPAK.Many<Bool>? {
|
||||||
|
guard c.isLoading.isRecent else { return nil }
|
||||||
|
var keys = Set<String>()
|
||||||
|
for id in c.isLoading.keys {
|
||||||
|
if
|
||||||
|
let isLoading = c.isLoading.dict[id],
|
||||||
|
isLoading
|
||||||
|
{
|
||||||
|
keys.insert(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let d = [String: Bool]()
|
||||||
|
return MPAK.Many(keys, d)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func shouldManyResetText(_ c: MeetupIdContext) -> MPAK.Many<String>? {
|
||||||
|
guard !c.textUI.keys.isEmpty else { return nil }
|
||||||
|
var d = [String: String]()
|
||||||
|
for id in c.textUI.keys {
|
||||||
|
let text = c.textUI.dict[id] ?? ""
|
||||||
|
d[id] = formatId(text)
|
||||||
|
}
|
||||||
|
return MPAK.Many(c.textUI.keys, d)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func shouldManyTestResetText(_ c: MeetupIdContext) -> MPAK.Many<String>? {
|
||||||
|
guard !c.testTextUI.keys.isEmpty else { return nil }
|
||||||
|
var d = [String: String]()
|
||||||
|
for id in c.testTextUI.keys {
|
||||||
|
let text = c.testTextUI.dict[id] ?? ""
|
||||||
|
d[id] = formatId(text)
|
||||||
|
}
|
||||||
|
return MPAK.Many(c.testTextUI.keys, d)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,22 +4,22 @@ import SwiftUI
|
|||||||
extension MeetupId {
|
extension MeetupId {
|
||||||
public struct TV: View {
|
public struct TV: View {
|
||||||
let id: String
|
let id: String
|
||||||
@StateObject var vm = VM()
|
@StateObject var textField = BusUI.ManyTextField(K.testTextApp, K.testTextUI)
|
||||||
|
|
||||||
public init(_ id: String) {
|
public init(_ id: String) {
|
||||||
self.id = id
|
self.id = id
|
||||||
}
|
}
|
||||||
|
|
||||||
public var body: some View {
|
public var body: some View {
|
||||||
TextField("TV", value: $vm.textField.v, formatter: BusUI.TextFieldSource())
|
TextField("TV", value: $textField.v, formatter: BusUI.TextFieldSource())
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.border(Color.blue)
|
.border(Color.blue)
|
||||||
.animation(.easeInOut(duration: 0.3))
|
.animation(.easeInOut(duration: 0.3))
|
||||||
.onAppear {
|
.onAppear {
|
||||||
vm.setup(id)
|
textField.id = id
|
||||||
}
|
}
|
||||||
.onChange(of: id) { newValue in
|
.onChange(of: id) { newValue in
|
||||||
vm.setup(newValue)
|
textField.id = newValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -3,18 +3,20 @@ import SwiftUI
|
|||||||
|
|
||||||
extension MeetupId {
|
extension MeetupId {
|
||||||
public struct V: View {
|
public struct V: View {
|
||||||
@StateObject var isJoinAvailable = BusUI.Value(K.isJoinAvailable, false)
|
let id: String
|
||||||
@StateObject var isLoading = BusUI.Value(K.isLoading, false)
|
@StateObject var isJoinAvailable = BusUI.ManyValue(K.isJoinAvailable, false)
|
||||||
@StateObject var join = BusUI.Button(K.join)
|
@StateObject var isLoading = BusUI.ManyValue(K.isLoading, false)
|
||||||
@StateObject var textField = BusUI.TextField(K.textApp, K.textUI)
|
@StateObject var join = BusUI.ManyButton(K.join)
|
||||||
|
@StateObject var textField = BusUI.ManyTextField(K.textApp, K.textUI)
|
||||||
|
|
||||||
public init() {
|
public init(_ id: String) {
|
||||||
|
self.id = id
|
||||||
}
|
}
|
||||||
|
|
||||||
public var body: some View {
|
public var body: some View {
|
||||||
VStack(spacing: 8) {
|
VStack(spacing: 8) {
|
||||||
HStack {
|
HStack {
|
||||||
TextField("Binding-3", value: $textField.v, formatter: BusUI.TextFieldSource())
|
ManyTextField("Binding-3", value: $textField.v, formatter: BusUI.TextFieldSource())
|
||||||
.disabled(isLoading.v)
|
.disabled(isLoading.v)
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.border(
|
.border(
|
||||||
@@ -27,7 +29,7 @@ extension MeetupId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Button(action: join.v.send) {
|
ManyButton(action: join.v.send) {
|
||||||
Text("Join")
|
Text("Join")
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.border(
|
.border(
|
||||||
@@ -40,6 +42,18 @@ extension MeetupId {
|
|||||||
.frame(width: 320)
|
.frame(width: 320)
|
||||||
.padding()
|
.padding()
|
||||||
.animation(.easeInOut(duration: 0.3))
|
.animation(.easeInOut(duration: 0.3))
|
||||||
|
.onAppear {
|
||||||
|
isJoinAvailable.id = id
|
||||||
|
isLoading.id = id
|
||||||
|
join.id = id
|
||||||
|
textField.id = id
|
||||||
|
}
|
||||||
|
.onChange(of: id) { newValue in
|
||||||
|
isJoinAvailable.id = newValue
|
||||||
|
isLoading.id = newValue
|
||||||
|
join.id = newValue
|
||||||
|
textField.id = newValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
|
from generation.isPipeMany import *
|
||||||
from generation.isPipeRecent import *
|
from generation.isPipeRecent import *
|
||||||
|
|
||||||
def fieldFormat(fmtPlain, fmtRecent, name, structure):
|
def fieldFormat(fmtMany, fmtPlain, fmtRecent, name, structure):
|
||||||
fmt = fmtPlain
|
fmt = fmtPlain
|
||||||
if (
|
if (
|
||||||
isPipeRecent(name, structure.core) or
|
isPipeRecent(name, structure.core) or
|
||||||
isPipeRecent(name, structure.service)
|
isPipeRecent(name, structure.service)
|
||||||
):
|
):
|
||||||
fmt = fmtRecent
|
fmt = fmtRecent
|
||||||
|
|
||||||
|
if (
|
||||||
|
isPipeMany(name, structure.core) or
|
||||||
|
isPipeMany(name, structure.service)
|
||||||
|
):
|
||||||
|
fmt = fmtMany
|
||||||
return fmt
|
return fmt
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ def generateContextFields(c):
|
|||||||
lines = c.readFile(fileName)
|
lines = c.readFile(fileName)
|
||||||
fmtPlain = lines[0]
|
fmtPlain = lines[0]
|
||||||
fmtRecent = lines[1]
|
fmtRecent = lines[1]
|
||||||
|
fmtMany = lines[2]
|
||||||
fields = []
|
fields = []
|
||||||
|
|
||||||
for key in c.structure.model.fields:
|
for key in c.structure.model.fields:
|
||||||
values = c.structure.model.fields[key]
|
values = c.structure.model.fields[key]
|
||||||
fmt = fieldFormat(fmtPlain, fmtRecent, key, c.structure)
|
fmt = fieldFormat(fmtMany, fmtPlain, fmtRecent, key, c.structure)
|
||||||
ln = fmt \
|
ln = fmt \
|
||||||
.replace("%NAME%", key) \
|
.replace("%NAME%", key) \
|
||||||
.replace("%TYPE%", values[0])
|
.replace("%TYPE%", values[0])
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ def generateModelFields(c):
|
|||||||
lines = c.readFile(fileName)
|
lines = c.readFile(fileName)
|
||||||
fmtPlain = lines[0]
|
fmtPlain = lines[0]
|
||||||
fmtRecent = lines[1]
|
fmtRecent = lines[1]
|
||||||
|
fmtMany = lines[2]
|
||||||
fields = []
|
fields = []
|
||||||
|
|
||||||
for key in c.structure.model.fields:
|
for key in c.structure.model.fields:
|
||||||
values = c.structure.model.fields[key]
|
values = c.structure.model.fields[key]
|
||||||
fmt = fieldFormat(fmtPlain, fmtRecent, key, c.structure)
|
fmt = fieldFormat(fmtMany, fmtPlain, fmtRecent, key, c.structure)
|
||||||
ln = fmt \
|
ln = fmt \
|
||||||
.replace("%NAME%", key) \
|
.replace("%NAME%", key) \
|
||||||
.replace("%TYPE%", values[0]) \
|
.replace("%TYPE%", values[0]) \
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
def isNotKeyword(str):
|
def isNotKeyword(str):
|
||||||
keywords = [
|
keywords = [
|
||||||
"ex",
|
"ex",
|
||||||
|
"many",
|
||||||
"recent",
|
"recent",
|
||||||
"set",
|
"set",
|
||||||
"toggle",
|
"toggle",
|
||||||
|
|||||||
5
Utilities/platform/2/generation/isPipeMany.py
Normal file
5
Utilities/platform/2/generation/isPipeMany.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
def isPipeMany(name, entity):
|
||||||
|
if name in entity.pipes:
|
||||||
|
props = entity.pipes[name]
|
||||||
|
return "many" in props
|
||||||
|
return False
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
|
from generation.isPipeMany import *
|
||||||
|
|
||||||
def pipeBusSource(name, entity, busKey, structure, fmt):
|
def pipeBusSource(name, entity, busKey, structure, fmt):
|
||||||
valueType = structure.model.fields[name][0]
|
valueType = structure.model.fields[name][0]
|
||||||
|
print(f"pipeBS-1 name: '{name}'")
|
||||||
|
if isPipeMany(name, entity):
|
||||||
|
valueType = f"MPAK.Many<{valueType}>"
|
||||||
|
|
||||||
return fmt \
|
return fmt \
|
||||||
.replace("%BUS_KEY%", busKey) \
|
.replace("%BUS_KEY%", busKey) \
|
||||||
.replace("%BUS_VALUE_TYPE%", valueType)
|
.replace("%BUS_VALUE_TYPE%", valueType)
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
def pipeFormat(fmtExRecent, fmtRecent, fmtSet, fmtToggle, fmtToggleNil, name, entity):
|
def pipeFormat(fmtExRecent, fmtMany, fmtRecent, fmtSet, fmtToggle, fmtToggleNil, name, entity):
|
||||||
props = entity.pipes[name]
|
props = entity.pipes[name]
|
||||||
if "recent" and "ex" in props:
|
if "many" in props:
|
||||||
|
return fmtMany
|
||||||
|
elif "recent" and "ex" in props:
|
||||||
return fmtExRecent
|
return fmtExRecent
|
||||||
elif "recent" in props:
|
elif "recent" in props:
|
||||||
return fmtRecent
|
return fmtRecent
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from generation.pipeSource import *
|
|||||||
def sectionGeneratedPipes(entity, sub, c):
|
def sectionGeneratedPipes(entity, sub, c):
|
||||||
fmtBusPipe = c.readFile(f"{c.dir}/templates/section-generated-pipe-src-bus")[0]
|
fmtBusPipe = c.readFile(f"{c.dir}/templates/section-generated-pipe-src-bus")[0]
|
||||||
fmtExRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-ex-recent")
|
fmtExRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-ex-recent")
|
||||||
|
fmtMany = c.readFile(f"{c.dir}/templates/section-generated-pipe-many")
|
||||||
fmtRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-recent")
|
fmtRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-recent")
|
||||||
fmtSet = c.readFile(f"{c.dir}/templates/section-generated-pipe-set")
|
fmtSet = c.readFile(f"{c.dir}/templates/section-generated-pipe-set")
|
||||||
fmtToggle = c.readFile(f"{c.dir}/templates/section-generated-pipe-toggle")
|
fmtToggle = c.readFile(f"{c.dir}/templates/section-generated-pipe-toggle")
|
||||||
@@ -14,6 +15,7 @@ def sectionGeneratedPipes(entity, sub, c):
|
|||||||
|
|
||||||
for key in entity.pipes:
|
for key in entity.pipes:
|
||||||
values = entity.pipes[key]
|
values = entity.pipes[key]
|
||||||
|
print(f"sectionGP-1 key/values: '{key}'/'{values}'")
|
||||||
|
|
||||||
# EX_NAME.
|
# EX_NAME.
|
||||||
firstLetter = key[:1].capitalize()
|
firstLetter = key[:1].capitalize()
|
||||||
@@ -29,11 +31,13 @@ def sectionGeneratedPipes(entity, sub, c):
|
|||||||
|
|
||||||
# SRC.
|
# SRC.
|
||||||
src = pipeSource(key, entity)
|
src = pipeSource(key, entity)
|
||||||
|
print(f"sectionGP-2 key/src: '{key}'/'{src}'")
|
||||||
# Bus.
|
# Bus.
|
||||||
if src.startswith("K."):
|
if src.startswith("K."):
|
||||||
|
print(f"sectionGP-3 key: '{key}' bus")
|
||||||
src = pipeBusSource(key, entity, src, c.structure, fmtBusPipe)
|
src = pipeBusSource(key, entity, src, c.structure, fmtBusPipe)
|
||||||
|
|
||||||
fmtPipe = pipeFormat(fmtExRecent, fmtRecent, fmtSet, fmtToggle, fmtToggleNil, key, entity)
|
fmtPipe = pipeFormat(fmtExRecent, fmtMany, fmtRecent, fmtSet, fmtToggle, fmtToggleNil, key, entity)
|
||||||
for fmt in fmtPipe:
|
for fmt in fmtPipe:
|
||||||
ln = fmt \
|
ln = fmt \
|
||||||
.replace("%EX_NAME%", exName) \
|
.replace("%EX_NAME%", exName) \
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
var %NAME%: %TYPE% { get }
|
var %NAME%: %TYPE% { get }
|
||||||
var %NAME%: MPAK.Recent<%TYPE%> { get }
|
var %NAME%: MPAK.Recent<%TYPE%> { get }
|
||||||
|
var %NAME%: MPAK.Many<%TYPE%> { get }
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
public var %NAME%: %TYPE% = %DEFAULT%
|
public var %NAME%: %TYPE% = %DEFAULT%
|
||||||
public var %NAME%: MPAK.Recent<%TYPE%> = .init(%DEFAULT%)
|
public var %NAME%: MPAK.Recent<%TYPE%> = .init(%DEFAULT%)
|
||||||
|
public var %NAME%: MPAK.Many<%TYPE%> = .init()
|
||||||
|
|||||||
12
Utilities/platform/2/templates/section-generated-pipe-many
Normal file
12
Utilities/platform/2/templates/section-generated-pipe-many
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
ctrl.%PIPE%(
|
||||||
|
dbg: "%SHORT_SRC%",
|
||||||
|
sub: %SUB%,
|
||||||
|
%SRC%.eraseToAnyPublisher(),
|
||||||
|
{
|
||||||
|
$0.%NAME% = $1
|
||||||
|
},
|
||||||
|
{ m, _ in m.%NAME%.keys = [] }
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,6 +1 @@
|
|||||||
Bus.events.compactMap { Bus.convertKeyValue(%BUS_KEY%, $0) }.map { (k: String, v: %BUS_VALUE_TYPE%) in v }
|
Bus.events.compactMap { Bus.convertKeyValue(%BUS_KEY%, $0) }.map { (k: String, v: %BUS_VALUE_TYPE%) in v }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
PODS:
|
PODS:
|
||||||
- AELog (0.6.3)
|
- AELog (0.6.3)
|
||||||
- BusX (2023.12.30)
|
- BusX (2023.12.30):
|
||||||
|
- MPAKX
|
||||||
- MeetupIdX (2023.12.31):
|
- MeetupIdX (2023.12.31):
|
||||||
- AELog
|
- AELog
|
||||||
- BusX
|
- BusX
|
||||||
@@ -27,7 +28,7 @@ EXTERNAL SOURCES:
|
|||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
AELog: f732b70f7a9d1b4c6a3676304192b3908f362133
|
AELog: f732b70f7a9d1b4c6a3676304192b3908f362133
|
||||||
BusX: d11e857e9cb762f649ee9f88fd5a4f8fbf5bf96b
|
BusX: eff20bdef75eb529d679d6a710f9531135c263fb
|
||||||
MeetupIdX: 2fa9fb27717aa8878ff495c1abe960c96e524308
|
MeetupIdX: 2fa9fb27717aa8878ff495c1abe960c96e524308
|
||||||
MPAKX: dc592434f55edf34709f6e4f37c9ec90dcd95185
|
MPAKX: dc592434f55edf34709f6e4f37c9ec90dcd95185
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,12 @@ import UIKit
|
|||||||
|
|
||||||
struct Content: View {
|
struct Content: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
//MeetupId.V()
|
MeetupId.V("w1")
|
||||||
|
Divider()
|
||||||
|
MeetupId.V("w2")
|
||||||
|
Divider()
|
||||||
|
Divider()
|
||||||
|
Divider()
|
||||||
MeetupId.TV("uuid-1")
|
MeetupId.TV("uuid-1")
|
||||||
Divider()
|
Divider()
|
||||||
MeetupId.TV("uuid-2")
|
MeetupId.TV("uuid-2")
|
||||||
|
|||||||
Reference in New Issue
Block a user