Михаил Капелько 10 月之前
父節點
當前提交
860ac00106
共有 5 個檔案被更改,包括 44 行新增8 行删除
  1. +3
    -0
      Modules/MeetupIdX/MeetupId.yml
  2. +19
    -0
      Modules/MeetupIdX/src/MeetupId.Generated.swift
  3. +1
    -0
      Modules/MeetupIdX/src/MeetupId.K.swift
  4. +12
    -0
      Modules/MeetupIdX/src/MeetupId.Shoulds.swift
  5. +9
    -8
      Modules/MeetupIdX/src/MeetupId.V.swift

+ 3
- 0
Modules/MeetupIdX/MeetupId.yml 查看文件

@@ -1,13 +1,16 @@
version: 2

model:
isLoading: [Bool, false]
join: [Bool, false]
textUI: [String, ""]

service:
actions:
busModel
🚀shouldResetLoading: Bus.send(K.isLoading, v)
pipes:
isLoading: [recent, K.isLoading]
join: [toggle, K.join]
textUI: [recent, K.textUI]



+ 19
- 0
Modules/MeetupIdX/src/MeetupId.Generated.swift 查看文件

@@ -12,6 +12,7 @@ import UIKit
// MARK: - Context

public protocol MeetupIdContext {
var isLoading: MPAK.Recent<Bool> { get }
var join: Bool { get }
var textUI: MPAK.Recent<String> { get }
}
@@ -34,6 +35,7 @@ extension MeetupId {
// MARK: - Model

public struct Model: MeetupIdContext {
public var isLoading: MPAK.Recent<Bool> = .init(false)
public var join: Bool = false
public var textUI: MPAK.Recent<String> = .init("")
}
@@ -83,10 +85,27 @@ extension MeetupId {
ctrl.m
.sink { v in Bus.send("MeetupId", v) }
.store(in: &service.subscriptions)
ctrl.m
.compactMap { shouldResetLoading($0) }
.sink { v in Bus.send(K.isLoading, v) }
.store(in: &service.subscriptions)


// MARK: - SectionGenerated Service Pipes

ctrl.pipeValue(
dbg: "isL",
sub: nil,
Bus.events.compactMap { Bus.convertKeyValue(K.isLoading, $0) }.map { (k: String, v: Bool) in v }.eraseToAnyPublisher(),
{
$0.isLoading.value = $1
$0.isLoading.isRecent = true
},
{ m, _ in m.isLoading.isRecent = false }
)



ctrl.pipe(
dbg: "join",
sub: nil,


+ 1
- 0
Modules/MeetupIdX/src/MeetupId.K.swift 查看文件

@@ -1,6 +1,7 @@
public extension MeetupId {
enum K {
static let isJoinAvailable = "MeetupId.isJoinAvailable"
static let isLoading = "MeetupId.isLoading"
static let join = "MeetupId.join"
static let M = "MeetupId"
static let textApp = "MeetupId.textApp"


+ 12
- 0
Modules/MeetupIdX/src/MeetupId.Shoulds.swift 查看文件

@@ -15,4 +15,16 @@ public extension MeetupId {
return nil
}

static func shouldResetLoading(_ c: MeetupIdContext) -> Bool? {
if
c.join,
!c.isLoading.value
{
return true
}

return nil
}

}

+ 9
- 8
Modules/MeetupIdX/src/MeetupId.V.swift 查看文件

@@ -6,24 +6,25 @@ extension MeetupId {
public struct V: View {
@StateObject var fmt = MeetupId.Formatter(K.textUI, K.textApp)
@StateObject var isJA = Cord.Receive(K.isJoinAvailable, false)
@StateObject var isL = Cord.Receive(K.isLoading, false)
@StateObject var join = Cord.Button(K.join)
@StateObject var txtF = Cord.TextField(K.textApp, K.textUI)
let joinA = 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 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)
if isL.value {
ProgressView()
}
}

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)


Loading…
取消
儲存