d
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
|
|
||||||
s.name = 'CordX'
|
s.name = 'CordX'
|
||||||
s.version = '2023.12.28'
|
s.version = '2023.12.29'
|
||||||
s.license = 'IVCS'
|
s.license = 'IVCS'
|
||||||
s.summary = 'Упрощённое общение с шиной из SwiftUI'
|
s.summary = 'Упрощённое общение с шиной из SwiftUI'
|
||||||
s.homepage = 'IVCS'
|
s.homepage = 'IVCS'
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ import Combine
|
|||||||
|
|
||||||
extension Cord {
|
extension Cord {
|
||||||
public final class Button: ObservableObject {
|
public final class Button: ObservableObject {
|
||||||
public let press = PassthroughSubject<Void, Never>()
|
public let v = PassthroughSubject<Void, Never>()
|
||||||
var subscriptions = [AnyCancellable]()
|
var subscriptions = [AnyCancellable]()
|
||||||
|
|
||||||
public init(_ key: String) {
|
public init(_ key: String) {
|
||||||
Bus.send(
|
Bus.send(
|
||||||
key,
|
key,
|
||||||
press.eraseToAnyPublisher(),
|
v.eraseToAnyPublisher(),
|
||||||
sub: &subscriptions
|
sub: &subscriptions
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,17 +3,17 @@ import Combine
|
|||||||
|
|
||||||
extension Cord {
|
extension Cord {
|
||||||
public final class Receive<T>: ObservableObject {
|
public final class Receive<T>: ObservableObject {
|
||||||
@Published public var value: T
|
@Published public var v: T
|
||||||
var subscriptions = [AnyCancellable]()
|
var subscriptions = [AnyCancellable]()
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
_ key: String,
|
_ key: String,
|
||||||
_ defaultValue: T
|
_ defaultValue: T
|
||||||
) {
|
) {
|
||||||
value = defaultValue
|
v = defaultValue
|
||||||
Bus.receive(
|
Bus.receive(
|
||||||
[key],
|
[key],
|
||||||
{ [weak self] (_, v: T) in self?.value = v },
|
{ [weak self] (_, v: T) in self?.v = v },
|
||||||
sub: &subscriptions
|
sub: &subscriptions
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import SwiftUI
|
|||||||
|
|
||||||
extension Cord {
|
extension Cord {
|
||||||
public final class TextField: ObservableObject {
|
public final class TextField: ObservableObject {
|
||||||
@Published public var value = "a:"
|
@Published public var v = "a:"
|
||||||
var subscriptions = [AnyCancellable]()
|
var subscriptions = [AnyCancellable]()
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
@@ -13,7 +13,7 @@ extension Cord {
|
|||||||
) {
|
) {
|
||||||
Bus.send(
|
Bus.send(
|
||||||
textUI,
|
textUI,
|
||||||
$value
|
$v
|
||||||
.removeDuplicates()
|
.removeDuplicates()
|
||||||
.compactMap(onlyUIText)
|
.compactMap(onlyUIText)
|
||||||
.eraseToAnyPublisher(),
|
.eraseToAnyPublisher(),
|
||||||
@@ -22,7 +22,7 @@ extension Cord {
|
|||||||
|
|
||||||
Bus.receive(
|
Bus.receive(
|
||||||
[textApp],
|
[textApp],
|
||||||
{ [weak self] (_, v: String) in self?.value = "a:\(v)" },
|
{ [weak self] (_, v: String) in self?.v = "a:\(v)" },
|
||||||
sub: &subscriptions
|
sub: &subscriptions
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,35 +5,34 @@ import SwiftUI
|
|||||||
extension MeetupId {
|
extension MeetupId {
|
||||||
public struct V: View {
|
public struct V: View {
|
||||||
@StateObject var fmt = MeetupId.Formatter(K.textUI, K.textApp)
|
@StateObject var fmt = MeetupId.Formatter(K.textUI, K.textApp)
|
||||||
@StateObject var isJA = Cord.Receive(K.isJoinAvailable, false)
|
@StateObject var isJoinAvailable = Cord.Receive(K.isJoinAvailable, false)
|
||||||
@StateObject var isL = Cord.Receive(K.isLoading, false)
|
@StateObject var isLoading = Cord.Receive(K.isLoading, false)
|
||||||
@StateObject var join = Cord.Button(K.join)
|
@StateObject var join = Cord.Button(K.join)
|
||||||
@StateObject var txtF = Cord.TextField(K.textApp, K.textUI)
|
@StateObject var textField = Cord.TextField(K.textApp, K.textUI)
|
||||||
let pSEJ = Bus.Processor(shouldEnableJoin, K.M, K.isJoinAvailable)
|
let pSEJ = Bus.Processor(shouldEnableJoin, K.M, K.isJoinAvailable)
|
||||||
let pSRL = Bus.Processor(shouldResetLoading, K.M, K.isLoading)
|
|
||||||
|
|
||||||
public init() { }
|
public init() { }
|
||||||
|
|
||||||
public var body: some View {
|
public var body: some View {
|
||||||
VStack {
|
VStack(spacing: 8) {
|
||||||
HStack {
|
HStack {
|
||||||
TextField("Binding-3", value: $txtF.value, formatter: Cord.TextFieldValueOwner())
|
TextField("Binding-3", value: $textField.v, formatter: Cord.TextFieldValueOwner())
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.border(Color.blue, width: 2)
|
.border(Color.blue, width: 2)
|
||||||
if isL.value {
|
|
||||||
ProgressView()
|
ProgressView()
|
||||||
}
|
.padding(8)
|
||||||
|
.opacity(isLoading.v ? 1 : 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
Button(action: join.press.send) {
|
Button(action: join.v.send) {
|
||||||
Text("Join")
|
Text("Join")
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.border(
|
.border(
|
||||||
isJA.value ? Color.green : Color.gray,
|
isJoinAvailable.v ? Color.green : Color.gray,
|
||||||
width: isJA.value ? 4 : 1
|
width: isJoinAvailable.v ? 4 : 1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.disabled(!isJA.value)
|
.disabled(!isJoinAvailable.v)
|
||||||
}
|
}
|
||||||
.frame(width: 320)
|
.frame(width: 320)
|
||||||
.padding()
|
.padding()
|
||||||
|
|||||||
Reference in New Issue
Block a user