I try to change view's backgorund color by networking state.
enum NetworkConnectivityLevel: Int {
case none
case low
case medium
case high
var color: UIColor {
switch self {
case .none: return .gray
case .low: return .red
case .medium: return .yellow
case .high: return .mintyGreen
}
}
}
ViewController and body in buildView
@UState var connectiviyLevel: NetworkConnectivityLevel = .medium
...
body {
connectivtyStatusView.background($connectiviyLevel.map { $0.color } )
// not working :(
connectivtyStatusView.background($connectiviyLevel.map {
if $0 == .none { return UIColor.gray }
else if $0 == .low { return UIColor.red}
else if $0 == .medium { return UIColor.yellow }
else { return UIColor.mintyGreen} }
// also not working :(
}
There is no effect on background color on the connectivtyStatusView. if I change to basic operator, it is okay.
I try to change view's backgorund color by networking state.
ViewController
andbody in buildView
There is no effect on background color on the connectivtyStatusView. if I change to basic operator, it is okay.
I don't know what is correct way to use UState property wrapper.