|
@@ -0,0 +1,100 @@ |
|
|
|
|
|
// ВНИМАНИЕ Сгенерировано автоматом из файла Mic.yml |
|
|
|
|
|
// ВНИМАНИЕ Не менять руками! |
|
|
|
|
|
|
|
|
|
|
|
import AELog |
|
|
|
|
|
import BusX |
|
|
|
|
|
import Combine |
|
|
|
|
|
import Foundation |
|
|
|
|
|
import MPAKX |
|
|
|
|
|
import UIKit |
|
|
|
|
|
|
|
|
|
|
|
// MARK: - Context |
|
|
|
|
|
|
|
|
|
|
|
public protocol MicContext { |
|
|
|
|
|
var activityDates: MPAK.Recent<[String:Date]> { get } |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// MARK: - Controller |
|
|
|
|
|
|
|
|
|
|
|
extension Mic { |
|
|
|
|
|
final class Controller: MPAK.Controller<Mic.Model> { |
|
|
|
|
|
init() { |
|
|
|
|
|
super.init( |
|
|
|
|
|
Mic.Model(), |
|
|
|
|
|
debugClassName: "MicCtrl", |
|
|
|
|
|
debugLog: { aelog($0) } |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: - Model |
|
|
|
|
|
|
|
|
|
|
|
public struct Model: MicContext { |
|
|
|
|
|
public var activityDates: MPAK.Recent<[String:Date]> = .init([:]) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// MARK: - Service |
|
|
|
|
|
|
|
|
|
|
|
public final class Service { |
|
|
|
|
|
let ctrl = Controller() |
|
|
|
|
|
let world: World |
|
|
|
|
|
|
|
|
|
|
|
var subscriptions = [AnyCancellable]() |
|
|
|
|
|
static private(set) weak var singleton: Service? |
|
|
|
|
|
|
|
|
|
|
|
public init(_ world: World) { |
|
|
|
|
|
self.world = world |
|
|
|
|
|
Self.singleton = self |
|
|
|
|
|
SectionGenerated.setupPlatform(ctrl, self, world) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// MARK: - World |
|
|
|
|
|
|
|
|
|
|
|
public struct World { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public init( |
|
|
|
|
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
enum SectionGenerated { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: - SectionGenerated Service |
|
|
|
|
|
|
|
|
|
|
|
static func setupPlatform( |
|
|
|
|
|
_ ctrl: Controller, |
|
|
|
|
|
_ service: Service, |
|
|
|
|
|
_ world: World |
|
|
|
|
|
) { |
|
|
|
|
|
// MARK: - SectionGenerated Service Actions |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: - SectionGenerated Service Pipes |
|
|
|
|
|
|
|
|
|
|
|
ctrl.pipeValue( |
|
|
|
|
|
dbg: "activityD", |
|
|
|
|
|
sub: nil, |
|
|
|
|
|
Bus.events.compactMap { Bus.convertKeyValue(K.activityDates, $0) }.map { (k: String, v: [String:Date]) in v }.eraseToAnyPublisher(), |
|
|
|
|
|
{ |
|
|
|
|
|
$0.activityDates.value = $1 |
|
|
|
|
|
$0.activityDates.isRecent = true |
|
|
|
|
|
}, |
|
|
|
|
|
{ m, _ in m.activityDates.isRecent = false } |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |