|
|
@@ -4,14 +4,25 @@ import SwiftUI |
|
|
|
extension MicItem { |
|
|
|
public struct V: View { |
|
|
|
var id: String? |
|
|
|
@StateObject var h = BusUI.Holder() |
|
|
|
@StateObject var holder = BusUI.Holder() |
|
|
|
@StateObject var isActive = BusUI.Value(K.isActive, false) |
|
|
|
|
|
|
|
public init(_ id: String? = nil) { |
|
|
|
self.id = id |
|
|
|
/**/print("ИГР MicIV.init id: '\(id)'") |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func config(_ id: String? = nil) { |
|
|
|
/**/print("ИГР MicIV.config id: '\(id)'") |
|
|
|
isActive.id = id |
|
|
|
holder.items = [ |
|
|
|
Bus.Delay(shouldResetTimeout, K.MI, K.timeout, id), |
|
|
|
Bus.Sync(shouldResetActivity, K.MI, K.isActive, id), |
|
|
|
MicItem.Controller(id) |
|
|
|
] |
|
|
|
// Запрашиваем актуальные данные при (пере)создании. |
|
|
|
Bus.send(K.requestActivityDate, id) |
|
|
|
} |
|
|
|
|
|
|
|
public var body: some View { |
|
|
|
Text("Mic activity") |
|
|
|
.padding(8) |
|
|
@@ -20,28 +31,8 @@ extension MicItem { |
|
|
|
width: isActive.v ? 3 : 1 |
|
|
|
) |
|
|
|
.animation(.easeInOut(duration: 0.3)) |
|
|
|
.onAppear { |
|
|
|
/**/print("ИГР MicIV.onA id: '\(id)'") |
|
|
|
isActive.id = id |
|
|
|
h.items = [ |
|
|
|
Bus.Delay(shouldResetTimeout, K.MI, K.timeout, id), |
|
|
|
Bus.Sync(shouldResetActivity, K.MI, K.isActive, id), |
|
|
|
MicItem.Controller(id) |
|
|
|
] |
|
|
|
|
|
|
|
Bus.send(K.requestActivityDate, id) |
|
|
|
} |
|
|
|
.onChange(of: id) { newValue in |
|
|
|
let id = newValue |
|
|
|
isActive.id = id |
|
|
|
h.items = [ |
|
|
|
Bus.Delay(shouldResetTimeout, K.MI, K.timeout, id), |
|
|
|
Bus.Sync(shouldResetActivity, K.MI, K.isActive, id), |
|
|
|
MicItem.Controller(id) |
|
|
|
] |
|
|
|
|
|
|
|
Bus.send(K.requestActivityDate, id) |
|
|
|
} |
|
|
|
.onAppear { self.config(id) } |
|
|
|
.onChange(of: id) { id in self.config(id) } |
|
|
|
} |
|
|
|
} |
|
|
|
} |