@MainActor
struct SomeTip: Tip {
@Parameter
static var haveSome: Bool = false
static let eventOneHappened = Event(id: "eventOneHappened")
nonisolated var title: Text {
MainActor.assumeIsolated {
Text("xxx")
}
}
nonisolated var image: Image? {
MainActor.assumeIsolated {
Image(systemName: "heart")
}
}
nonisolated var options: [TipOption] {
MainActor.assumeIsolated {
[Tip.MaxDisplayCount(1)]
}
}
nonisolated var rules: [Rule] {
MainActor.assumeIsolated {
[
#Rule(Self.$haveSome) { $0 == true },
#Rule(Self.eventOneHappened) { $0.donations.count >= 1 }
]
}
}
}
I wrote it like this at the beginning. Although there is no warning now, it looks strange. However, my rules are pretty simple, all it takes is control through Event.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: