UIDeviceProviderType

public protocol UIDeviceProviderType : ObservableObject

The interface of the UIDeviceProvider which can be used to inject different implementations. Normally code should not be directly dependent upon the UIDevice because that might break UnitTests when running the tests on a device / simulator which differs from the test’s expectations. Therefore, code should get the UIDevice instance being injected and for tests it should be mocked. To make this possible this protocol provides the interface to the user interface idiom and the device orientation while the UIDeviceProvider provides an implementation which can be injected when running the code in the app and UIDeviceProviderMock a mock which can then be configured and injected in UnitTests. It’s expected that the implementation informs the ObservableObject of any value changes.

  • The style of interface to use on the current device.

    Declaration

    Swift

    @MainActor
    var userInterfaceIdiom: UIUserInterfaceIdiom { get }
  • Returns true if this code currently runs on the simulator, false when on a physical device.

    Declaration

    Swift

    var isSimulator: Bool { get }
  • The physical orientation of the device.

    Declaration

    Swift

    @MainActor
    var deviceOrientation: UIDeviceOrientation { get }