Skip to content

Camera Settings Indicator Widget

Cristina Suciu edited this page Feb 25, 2021 · 1 revision

(Updated widget in develop branch)

This widget displays the camera exposure mode. The exposure modes are listed below:

Icon Description
Auto/Program Exposure Mode
Aperture Priority Mode
Shutter Priority Mode
Manual Mode
Unknown Exposure Mode

Usage

If creating the Camera Settings Indicator widget through code it can be added using the convenience method:

- (void)installInViewController:(nullable UIViewController *)viewController

which adds the widget the method is called on as a subview of the ViewController that is passed in as an argument. Following this add constraints to the widget using its widgetSizeHint property to determine width, height and aspect ratio constraints.

If creating the widget through storyboard use the object library to drag a container view controller into the desired view controller like so:

Following this make sure to change the class of the child view controller to be DUXBetaCameraSettingsIndicatorWidget. From here you can create the constraints on the container view using the widget's widgetSizeHint property.

Customizations

The widget can be customized by the user to serve their purpose and theme.

Example

Icon Description
Auto/Program Exposure Mode
Aperture Priority Mode
Shutter Priority Mode
Manual Mode
Unknown Exposure Mode

Swift Example

widget.backgroundColor = UIColor.white
widget.set(tintColor: UIColor.black, for: .manual)
widget.set(tintColor: UIColor.black, for: .program)
widget.set(tintColor: UIColor.black, for: .unknown)
widget.set(tintColor: UIColor.black, for: .shutterPriority)
widget.set(tintColor: UIColor.black, for: .aperturePriority)

Objective-C Example

widget.backgroundColor = [UIColor whiteColor];
[widget setTintColor:[UIColor blackColor] for:DJICameraExposureModeManual];
[widget setTintColor:[UIColor blackColor] for:DJICameraExposureModeProgram];
[widget setTintColor:[UIColor blackColor] for:DJICameraExposureModeUnknown];
[widget setTintColor:[UIColor blackColor] for:DJICameraExposureModeShutterPriority];
[widget setTintColor:[UIColor blackColor] for:DJICameraExposureModeAperturePriority];

APIs

List of the customization APIs
  • var cameraIndex: Int - The camera index for which the widget should react.
  • var disconnectedImage: UIImage - The image for the product or camera disconnected state.
  • var disconnectedTintColor: UIColor - The image tint color for the product or camera disconnected state.
  • var backgroundColor: UIColor - The background color of the widget.
  • func setImage(_ image: UIImage?, for exposureMode: DJICameraExposureMode) - Set the image to be displayed for the given exposure mode.
  • getImage(for exposureMode: DJICameraExposureMode) -> UIImage? - Get the image for the given exposure mode.
  • setTintColor(_ tintColor: UIColor?, for exposureMode: DJICameraExposureMode) - Set the tint color to be displayed for the given exposure mode image.
  • getTintColor(for exposureMode: DJICameraExposureMode) -> UIColor? - Get the tint color for the given exposure mode.

Hooks

The widget provides hooks for users to add functionality based on state changes in the widget. The Camera Settings Indicator widget provides two types of hooks

  1. CameraSettingsIndicatorModelState - Provides hooks in events received by the widget from the widget model.

    • func productConnected(_ isConnected: Bool) - Event when product is connected or disconnected.
    • func cameraSettingsIndicatorStateUpdated(_ state: DUXBetaCameraSettingsIndicatorState) - Event when camera settings state is updated.
  2. CameraSettingsIndicatorUIState - Provides hooks in events related to user interaction with the widget.

    • func widgetTapped() - Event when widget is tapped.
Clone this wiki locally