Change status bar text color SwiftUI

Good afternoon!

Can you tell me how I can solve the problem? In my app there are 4 color themes of the background (like in the standard Books app). In the standard mode is the status bar according to the system color scheme, which is not suitable for white background and white status bar and vice versa with black background. At this point, the best I could think of and find is:

.onChange(of: store.colorStatusBar) { newValue in
           UIApplication.shared.statusBarStyle = store.colorStatusBar
}

But Xcode writes that this code is out of date and displays a warning:

'statusBarStyle' was deprecated in iOS 13.0: Use the statusBarManager property of the window scene instead.

I haven't found a working example with statusBarManager. Can you tell me how to redo it or fix it?

Change status bar text color SwiftUI
 
 
Q