|
- import BusX
- import Combine
- import MeetupIdX
- import MicX
- import SwiftUI
- import UIKit
-
- struct Content: View {
- @State private var selectedId = "1"
- var ids = ["1", "2", "3", "4"]
-
- @StateObject var adates = BusUI.Value(Mic.K.activityDates, [String: Date]())
-
- func val(_ k: String) -> String {
- if let dt = adates.v[k] {
- return String(describing: Int(dt.timeIntervalSince1970))
- }
- return "N/A"
- }
-
- var body: some View {
- VStack {
- HStack {
- Text("MicItem id:")
- Picker("", selection: $selectedId) {
- ForEach(ids, id: \.self) {
- Text($0)
- }
- }
- }
- .pickerStyle(.segmented)
- Divider()
- .padding()
- MicItem.V(selectedId)
- Divider()
- .padding()
- List {
- ForEach(ids, id: \.self) {
- Text("\($0): \(val($0))")
- }
- }
- }
- .padding()
- }
- }
-
- @UIApplicationMain
- class AppDelegate: UIResponder, UIApplicationDelegate
- {
- let meetupIS = MeetupId.Service(.init())
- let micS = Mic.Service(.init())
- var window: UIWindow?
-
- func application(
- _ application: UIApplication,
- didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
- ) -> Bool {
- window = UIWindow(frame: UIScreen.main.bounds)
- let vc = UIViewController()
- addSwiftUIViewAsChild(swiftUIView: Content(), parent: vc.view)
- vc.view.backgroundColor = .white
- window?.rootViewController = vc
- window?.backgroundColor = UIColor.white
- window?.makeKeyAndVisible()
-
- print("ИГР App.didFLWO")
-
-
-
-
-
- testMic4()
- return true
- }
-
- func testMic1() {
- DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
- Bus.send(Mic.K.isActive, true)
- }
- DispatchQueue.main.asyncAfter(deadline: .now() + 4) {
- Bus.send(Mic.K.isActive, false)
- }
- }
-
- func testMic2() {
- DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
- Bus.send(Mic.K.activityDate, Date() + 2)
- }
-
- DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
- Bus.send(Mic.K.activityDate, Date() + 2)
- }
- DispatchQueue.main.asyncAfter(deadline: .now() + 6) {
- Bus.send(Mic.K.activityDate, Date() + 7)
- }
- }
-
- var subscriptions = [AnyCancellable]()
- func testMic2_id(_ id: String) {
- DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
- Bus.send(Bus.keyId(Mic.K.activityDate, id), Date() + 2)
- }
-
- DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
- Bus.send(Bus.keyId(Mic.K.activityDate, id), Date() + 2)
- }
- DispatchQueue.main.asyncAfter(deadline: .now() + 6) {
- Bus.send(Bus.keyId(Mic.K.activityDate, id), Date() + 3)
- }
- }
-
- func testMic4() {
- delayedSend(2, Mic.K.activeIds, ["1"])
- delayedSend(5, Mic.K.activeIds, ["1", "4"])
- delayedSend(11, Mic.K.activeIds, ["3", "4"])
- }
-
- func delayedSend(
- _ delay: TimeInterval,
- _ key: String,
- _ value: Any
- ) {
- DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
- Bus.send(key, value)
- }
- }
- }
|