Skip to content

Photo Video Switch Widget

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

(Updated widget in develop branch)

This widget can be used to switch between Shoot Photo Mode and Record Video Mode. There are two states

Icon Description
Shoot Photo Mode
Record Video Mode

Usage

If creating the photo video switch 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 DUXBetaPhotoVideoSwitchWidget. From here you can create the constraints on the container view using the widgetSizeHint property.

Customizations

The UI elements can be customized to match the style of the user's application.

Example

Icon Description
Shoot Photo Mode
Record Video Mode

Swift Example

widget.backgroundColor = .yellow
widget.photoModeTintColor = .red
widget.videoModeTintColor = .blue
widget.disconnectedTintColor = .darkGray

Objective-C Example

widget.backgroundColor = [UIColor yellowColor];
widget.photoModeTintColor = [UIColor redColor];
widget.videoModeTintColor = [UIColor blueColor];
widget.disconnectedTintColor = [UIColor darkGrayColor];

DUXBetaPhotoVideoSwitchWidget APIs

List of the customization APIs
  • public var cameraIndex: Int - Index of the camera the widget model is communicating with.
  • public var disconnectedTintColor: UIColor - The tint color of the icon when product disconnected or camera disabled.
  • public var photoModeImage: UIImage? - The image of the icon when in photo mode.
  • public var photoModeTintColor: UIColor - The tint color of the icon when in video mode.
  • public var videoModeImage: UIImage? - The image of the icon when in video mode.
  • public var videoModeTintColor: UIColor - The tint color of the icon when in video mode.
  • public var backgroundColor: UIColor - The background color of the widget.

Hooks

The widget provides hooks for the users to add functionality based on the state changes in the widget. The DUXBetaPhotoVideoSwitchWidget provides the following hooks:

  1. PhotoVideoSwitchModelState - Provides hooks in events received by the widget from the widget model.
    • public static func productConnected(_ isConnected: Bool) -> PhotoVideoSwitchModelState - Event when the product is connected or disconnected.
    • public static func photoVideoStateUpdated(_ state: DUXBetaPhotoVideoSwitchState) -> PhotoVideoSwitchModelState - Event when the photo video switch widget state changes.
  2. PhotoVideoSwitchUIState - Provides hooks in events received by the widget from user interface interactions.
    • public static func widgetTapped() -> PhotoVideoSwitchUIState - Event when the widget is tapped.
Clone this wiki locally