hi is there any way to UPDATE dropdown content Text or do anything when "@State" changes ? cuz in normal SwiftUI views everything rerenders when "@State" changes expect this new "MenuBarExtra"
code in "label:" part will update when "@State" change but where I added "ControlView()" it does not :/
example code:
@State var secounds = 0
@State var timerRunning = false
let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
var body: some Scene {
MenuBarExtra {
ControlView()
} label: {
Text("\(hours):\(minutes):\(secounds)")
.onReceive(timer) { _ in
}
}
}
.menuBarExtraStyle(.window)
}
@ViewBuilder
func ControlView()->some View {
Grid(horizontalSpacing: 12, verticalSpacing: 12) {
GridRow {
ZStack {
RoundedRectangle(cornerRadius: 12, style: .continuous)
.fill(.red)
.frame(height: 75)
Text("\(timerRunning ? "Pause" : "Play")")
.padding()
.onTapGesture {
timerRunning.toggle()
}
}
}
}
.padding(10)
}