Skip to content

Travel Mode List Item Widget

Cristina Suciu edited this page Dec 23, 2020 · 1 revision

The Travel Mode List Item Widget is a widget of type DUXBetaListItemLabelButtonWidget and is used to put DJI Inspire series aircraft into and out of travel mode with the landing gear extended and locked for transportation.

Following are examples of the widget states

Disconnected

Travel Mode Deactivated

Travel Mode Activated

The users will be presented with instructions in a confirmation dialog when they try to put the drone in travel mode.

Usage

To add the travel mode list item widget to your DUXBetaSmartListModel class, override buildModelLists and include DUXBetaTravelModeListItemWidget.duxbeta_className() or [DUXBetaTravelModeListItemWidget duxbeta_className] in your modelClassnameList. This widget is a good example of using the smart model to display only appropriate items in a list. The travel mode widget is only appropriate for DJI Inspire aircraft, and the smart model can prevent it from being shown for non-Inspire devices.

Swift Example

@objc open class MySmartListModel : DUXBetaSmartListModel {
    @objc open override func buildModelLists() {
        super.buildModelLists()
        if isInspire {
            modelClassnameList.append(DUXBetaTravelModeListItemWidget.duxbeta_className())
        }
    }
}

ObjC Example

@interface DUXBetaTestSmartListModel : DUXBetaSmartListModel
@end

@implementation DUXBetaTestSmartListModel
- (void)buildModelLists {
    [super buildModelLists];
    if (isInspire) {
        [self.modelClassnameList append:[DUXBetaTravelModeListItemWidget duxbeta_className]];
    }
}
@end

Customizations

The following are examples of simple instantiation and customizations of the confirmation dialog colors.

Swift

travelModeWidget.confirmTravelModeDialogAppearance.imageTintColor = UIColor.blue
travelModeWidget.confirmTravelModeDialogAppearance.backgroundColor = UIColor.lightGray

Objective-C

travelModeWidget.confirmTravelModeDialogAppearance.imageTintColor = [UIColor blueColor];
travelModeWidget.confirmTravelModeDialogAppearance.backgroundColor = [UIColor lightGrayColor];

The standard customizations for the DUXBetaListItemButtonLabelWidget are supported as well as customizations for the three dialogs shown by the travel mode widget as well as the icons for the on and off states for travel mode.

Customization APIs

List of the travel mode customization APIs
  • confirmTravelModeDialogAppearance - An instance of DUXBetaAlertViewAppearance pre-customized for list item dialog display.
  • enterTravelModeDialogAppearance - An instance of DUXBetaAlertViewAppearance pre-customized for list item dialog display.
  • travelModeErrorDialogAppearance - An instance of DUXBetaAlertViewAppearance pre-customized for list item dialog display.
  • travelModeActiveIcon - A UIImage which holds the icon for the travel mode activated state.
  • travelModeInactiveIcon - A UIImage which holds the icon for the travel mode deactivated state.

Hooks

The widget provides hooks for the users to add functionality based on the state changes in the widget. The unit mode list item widget provides the following hooks:

  1. TravelModeItemUIState - Provides the hooks from ListItemLabelButtonUIState but does not add any new hooks.

  2. TravelModeItemModelState - Provides hooks for events received by the widget from user interactions. It inherits from ListItemLabelButtonModelState and adds the following hooks:

  • + (instancetype)travelModeStateUpdated:(BOOL)isInTravelMode; - Event when the aircraft changes into travel mode (send YES as an NSNumber) or out of travel mode (sends NO as an NSNumber.)
Clone this wiki locally