Михаил Капелько 10 months ago
parent
commit
ea09967ab6
13 changed files with 74 additions and 38 deletions
  1. +1
    -0
      app/Podfile
  2. +7
    -1
      app/Podfile.lock
  3. +15
    -0
      mod/CordX/CordX.podspec
  4. +3
    -3
      mod/CordX/src/Cord.Button.swift
  5. +9
    -0
      mod/CordX/src/Cord.Onlys.swift
  6. +3
    -3
      mod/CordX/src/Cord.Receive.swift
  7. +7
    -4
      mod/CordX/src/Cord.TextField.swift
  8. +19
    -0
      mod/CordX/src/Cord.TextFieldValueOwner.swift
  9. +0
    -1
      mod/CordX/src/Cord.swift
  10. +0
    -8
      src/Cord.Aux.swift
  11. +8
    -0
      src/MeetupId.swift
  12. +0
    -17
      src/TextFieldValueOwner.swift
  13. +2
    -1
      src/V.swift

+ 1
- 0
app/Podfile View File

@@ -4,6 +4,7 @@ platform :ios, '14.0'


# Source. # Source.
pod 'BusX', :path => '../mod/BusX' pod 'BusX', :path => '../mod/BusX'
pod 'CordX', :path => '../mod/CordX'


target 'pesochnicza' do target 'pesochnicza' do
use_frameworks! use_frameworks!


+ 7
- 1
app/Podfile.lock View File

@@ -1,16 +1,22 @@
PODS: PODS:
- BusX (2023.12.28) - BusX (2023.12.28)
- CordX (2023.12.28):
- BusX


DEPENDENCIES: DEPENDENCIES:
- BusX (from `../mod/BusX`) - BusX (from `../mod/BusX`)
- CordX (from `../mod/CordX`)


EXTERNAL SOURCES: EXTERNAL SOURCES:
BusX: BusX:
:path: "../mod/BusX" :path: "../mod/BusX"
CordX:
:path: "../mod/CordX"


SPEC CHECKSUMS: SPEC CHECKSUMS:
BusX: fd22c04ad544d131e66315c1a33d87d85b19712e BusX: fd22c04ad544d131e66315c1a33d87d85b19712e
CordX: 63515d366b217366b9562edcfef34630a7be1171


PODFILE CHECKSUM: c4bbd7cc826ceee472b0bbb53eb2d5dc7dd1f97e
PODFILE CHECKSUM: 1091fc5c43b2a3881ee63b88848d7ed4f2ede026


COCOAPODS: 1.13.0 COCOAPODS: 1.13.0

+ 15
- 0
mod/CordX/CordX.podspec View File

@@ -0,0 +1,15 @@
Pod::Spec.new do |s|

s.name = 'CordX'
s.version = '2023.12.28'
s.license = 'IVCS'
s.summary = 'Упрощённое общение с шиной из SwiftUI'
s.homepage = 'IVCS'
s.author = 'IVCS'
s.source = { :git => 'https://fake.com/FAKE.git', :tag => s.version }
s.source_files = 'src/**/*.swift'
s.swift_version = '5.2'
s.ios.deployment_target = '14.0'
s.dependency 'BusX'

end

src/Cord.Button.swift → mod/CordX/src/Cord.Button.swift View File

@@ -2,11 +2,11 @@ import BusX
import Combine import Combine


extension Cord { extension Cord {
final class Button: ObservableObject {
let press = PassthroughSubject<Void, Never>()
public final class Button: ObservableObject {
public let press = PassthroughSubject<Void, Never>()
var subscriptions = [AnyCancellable]() var subscriptions = [AnyCancellable]()
init(_ key: String) {
public init(_ key: String) {
Bus.send( Bus.send(
key, key,
press.eraseToAnyPublisher(), press.eraseToAnyPublisher(),

+ 9
- 0
mod/CordX/src/Cord.Onlys.swift View File

@@ -0,0 +1,9 @@
extension Cord {
/// Пропускаем лишь значения от UI
///
/// - Returns: Значение без префиксов "a:"/"u:"
static func onlyUIText(_ s: String) -> String? {
guard s.hasPrefix("u:") else { return nil }
return String(s.dropFirst(2))
}
}

src/Cord.Receive.swift → mod/CordX/src/Cord.Receive.swift View File

@@ -2,11 +2,11 @@ import BusX
import Combine import Combine


extension Cord { extension Cord {
final class Receive<T>: ObservableObject {
@Published var value: T
public final class Receive<T>: ObservableObject {
@Published public var value: T
var subscriptions = [AnyCancellable]() var subscriptions = [AnyCancellable]()
init(
public init(
_ key: String, _ key: String,
_ defaultValue: T _ defaultValue: T
) { ) {

src/Cord.TextField.swift → mod/CordX/src/Cord.TextField.swift View File

@@ -3,17 +3,20 @@ import Combine
import SwiftUI import SwiftUI


extension Cord { extension Cord {
final class TextField: ObservableObject {
@Published var value = "a:"
public final class TextField: ObservableObject {
@Published public var value = "a:"
var subscriptions = [AnyCancellable]() var subscriptions = [AnyCancellable]()
init(
public init(
_ textApp: String, _ textApp: String,
_ textUI: String _ textUI: String
) { ) {
Bus.send( Bus.send(
textUI, textUI,
$value.removeDuplicates().compactMap(onlyUIText).eraseToAnyPublisher(),
$value
.removeDuplicates()
.compactMap(onlyUIText)
.eraseToAnyPublisher(),
sub: &subscriptions sub: &subscriptions
) )

+ 19
- 0
mod/CordX/src/Cord.TextFieldValueOwner.swift View File

@@ -0,0 +1,19 @@
import Foundation

extension Cord {
public final class TextFieldValueOwner: Formatter {
public override func string(for obj: Any?) -> String? {
guard let str = obj as? String else { return nil }
return String(str.dropFirst(2))
}

public override func getObjectValue(
_ obj: AutoreleasingUnsafeMutablePointer<AnyObject?>?,
for string: String,
errorDescription error: AutoreleasingUnsafeMutablePointer<NSString?>?
) -> Bool {
obj?.pointee = "u:\(string)" as AnyObject
return true
}
}
}

src/Cord.swift → mod/CordX/src/Cord.swift View File

@@ -1,2 +1 @@

public enum Cord { } public enum Cord { }

+ 0
- 8
src/Cord.Aux.swift View File

@@ -1,8 +0,0 @@

/// Пропускаем лишь значения от UI
///
/// - Returns: Значение без префиксов "a:"/"u:"
func onlyUIText(_ s: String) -> String? {
guard s.hasPrefix("u:") else { return nil }
return String(s.dropFirst(2))
}

+ 8
- 0
src/MeetupId.swift View File

@@ -29,6 +29,14 @@ enum MeetupId {
} }
return r return r
} }

/// Пропускаем лишь значения от UI
///
/// - Returns: Значение без префиксов "a:"/"u:"
func onlyUIText(_ s: String) -> String? {
guard s.hasPrefix("u:") else { return nil }
return String(s.dropFirst(2))
}
} }





+ 0
- 17
src/TextFieldValueOwner.swift View File

@@ -1,17 +0,0 @@
import Foundation

class TextFieldValueOwner: Formatter {
override func string(for obj: Any?) -> String? {
guard let str = obj as? String else { return nil }
return String(str.dropFirst(2))
}

override func getObjectValue(
_ obj: AutoreleasingUnsafeMutablePointer<AnyObject?>?,
for string: String,
errorDescription error: AutoreleasingUnsafeMutablePointer<NSString?>?
) -> Bool {
obj?.pointee = "u:\(string)" as AnyObject
return true
}
}

+ 2
- 1
src/V.swift View File

@@ -1,4 +1,5 @@
import BusX import BusX
import CordX
import SwiftUI import SwiftUI


struct V: View { struct V: View {
@@ -15,7 +16,7 @@ struct V: View {
.fontWeight(.bold) .fontWeight(.bold)
} }


TextField("Binding-3", value: $textF.value, formatter: TextFieldValueOwner())
TextField("Binding-3", value: $textF.value, formatter: Cord.TextFieldValueOwner())
.padding(8) .padding(8)
.border(Color.blue, width: 2) .border(Color.blue, width: 2)




Loading…
Cancel
Save