How to detect device orientation in swiftUI ?

To check current device orientation in iOS application 1. NotificationCenter.default.publisher for detecting device orientation 2. .onReceive(… receive live values from the element on 3. getColor will return the color based on device orientation