Михаил Капелько 10 个月前
父节点
当前提交
1a731e2fad
共有 3 个文件被更改,包括 28 次插入2 次删除
  1. +13
    -0
      Modules/MicX/MicItem/src/MicItem.Shoulds.swift
  2. +2
    -2
      Modules/MicX/MicItem/src/MicItem.V.swift
  3. +13
    -0
      Modules/MicX/MicItem/src/MicItem.WillBe.swift

+ 13
- 0
Modules/MicX/MicItem/src/MicItem.Shoulds.swift 查看文件

@@ -0,0 +1,13 @@
public extension MicItem {
static func shouldResetActivity(_ c: MicItemContext) -> Bool? {
if
c.activityDate.isRecent,
let end = c.activityDate.value,
let now = Date()
{
return now < end
}

return nil
}
}

+ 2
- 2
Modules/MicX/MicItem/src/MicItem.V.swift 查看文件

@@ -5,13 +5,13 @@ extension MicItem {
public struct V: View {
var id: String?
@StateObject var isActive = BusUI.Value(K.isActive, false)
let ctrl = MicItem.Controller()
let processors: [Any]
public init(_ id: String? = nil) {
self.id = id
self.processors = [
//Bus.Sync(shouldResetActivity, K.MI, K.isActive),
Bus.Sync(shouldResetActivity, K.MI, K.isActive),
MicItem.Controller()
]
}


+ 13
- 0
Modules/MicX/MicItem/src/MicItem.WillBe.swift 查看文件

@@ -9,7 +9,9 @@ extension MicItem {
public struct Model: MicItemContext {
public var activityDate: MPAK.Recent<Date?> = .init(nil)
}
}

extension MicItem {
final class Controller: MPAK.Controller<MicItem.Model> {
init() {
/**/print("MicIC.init")
@@ -24,6 +26,17 @@ extension MicItem {
m
.sink { v in Bus.send(K.MI, v) }
.store(in: &subscriptions)

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

正在加载...
取消
保存