This commit is contained in:
Михаил Капелько
2023-12-28 13:33:20 +03:00
parent a1ec08f280
commit 16026a7b47
21 changed files with 26 additions and 16 deletions

View File

@@ -0,0 +1,16 @@
version: 2
model:
textApp: [String, ""]
textUI: [String, ""]
service:
actions:
modelBus
pipes:
textApp: [recent, K.meetupIdTextApp]
textUI: [recent, K.meetupIdTextUI]
world:
textApp: [ps]
textUI: [ps]

View File

@@ -0,0 +1,16 @@
Pod::Spec.new do |s|
s.name = 'MeetupIdX'
s.version = '2023.12.28'
s.license = 'IVCS'
s.summary = 'Окно ввода ID мероприятия'
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'
s.dependency 'CordX'
end

View File

@@ -0,0 +1,9 @@
public extension MeetupId {
enum K: String {
case meetupIdIsJoinAvailable
case meetupIdJoin
case meetupIdTextApp
case meetupIdTextUI
}
}

View File

@@ -0,0 +1,26 @@
import Foundation
public extension MeetupId {
static func onlyAllowJoin(_ s: String) -> Bool? {
s.hasPrefix("123")
}
static func onlyFormat(_ s: String) -> String? {
let digits = s.components(separatedBy: NSCharacterSet.decimalDigits.inverted).reduce("") { $0 + $1 }
var r = ""
var i = 0
// Делим каждые три цифры дефисом.
for v in digits {
r += String(v)
i = i + 1
if i % 3 == 0 {
r += "-"
}
}
// Исключаем дефис в конце.
if r.hasSuffix("-") {
r = String(r.dropLast(1))
}
return r
}
}

View File

@@ -0,0 +1 @@
public enum MeetupId { }

View File

@@ -0,0 +1,40 @@
import BusX
import CordX
import SwiftUI
extension MeetupId {
public struct V: View {
@StateObject var isJA = Cord.Receive(K.meetupIdIsJoinAvailable.rawValue, false)
@StateObject var join = Cord.Button(K.meetupIdJoin.rawValue)
@StateObject var txtF = Cord.TextField(K.meetupIdTextApp.rawValue, K.meetupIdTextUI.rawValue)
let test = Bus.Processor(K.meetupIdTextUI.rawValue, K.meetupIdIsJoinAvailable.rawValue, onlyAllowJoin)
public init() { }
public var body: some View {
VStack {
HStack {
Text("Check text field:")
Text("'\(txtF.value)'")
.fontWeight(.bold)
}
TextField("Binding-3", value: $txtF.value, formatter: Cord.TextFieldValueOwner())
.padding(8)
.border(Color.blue, width: 2)
Button(action: join.press.send) {
Text("Join")
.padding(8)
.border(
isJA.value ? Color.green : Color.gray,
width: isJA.value ? 4 : 1
)
}
.disabled(!isJA.value)
}
.frame(width: 320)
.padding()
}
}
}