Accessing Environment's value outside of being installed on a View. This will always read the default value and will not update.
So we shouldn't use @Environment var inside a non-View struct. We need to find a way to listen to color scheme changes and then re-render AvatarPickerProfileView so it updates its colors. I am not sure if this is the best solution so let's discuss other ideas if you have any.
Testing Steps
Check AvatarPickerProfileView previews "Empty", "Empty & Loading" in both light & dark appearance. Observe: Colors are adapting.
Run the SwiftUI demo app and open the avatar picker. Observe: The above warning has disappeared. ☝️
Closes #
Description
Fixes the issue:
So we shouldn't use
@Environment
var inside a non-View struct. We need to find a way to listen to color scheme changes and then re-renderAvatarPickerProfileView
so it updates its colors. I am not sure if this is the best solution so let's discuss other ideas if you have any.Testing Steps
Check
AvatarPickerProfileView
previews "Empty", "Empty & Loading" in both light & dark appearance. Observe: Colors are adapting.Run the SwiftUI demo app and open the avatar picker. Observe: The above warning has disappeared. ☝️