Skip to content

RC Stick Mode List Item Widget

Cristina Suciu edited this page Dec 23, 2020 · 2 revisions

RC Stick Mode List Item Widget is a DUXBetaListItemRadioButtonWidget which displays the RC Stick Modes also known as Aircraft Mapping Styles. The currently enabled mode will be highlighted. The widget provides functionality to change the mode by tapping on any option.

Following are examples of the widget states:

Disconnected

Mode 1

Mode 3

Usage

To add the RC Stick Mode List Item Widget to your DUXBetaSmartListModel class, override buildModelLists and include DUXBetaRCStickModeListItemWidget.duxbeta_className() or [DUXBetaRCStickModeListItemWidget duxbeta_className] in your modelClassnameList:

Swift Example

@objc open class MySmartListModel : DUXBetaSmartListModel {
    @objc open override func buildModelLists() {
        super.buildModelLists()
        self.modelClassnameList.append(DUXBetaRCStickModeListItemWidget.duxbeta_className())
    }
}

ObjC Example

@interface DUXBetaTestSmartListModel : DUXBetaSmartListModel
@end

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

Customizations

The UI elements can be customized to match the style of the user's application. The widget supports all the customizations that its parent, DUXBetaListItemRadioButtonWidget supports. An example of a customized RC stick mode list item widget in various states could look something like this:

To get this effect we would use the following code:

Swift Example

stickModeWidget.titleColor = .red
stickModeWidget.setTextColor(.gray, for: .normal)
stickModeWidget.setTextColor(.black, for: .disabled)

ObjC Example

stickModeWidget.titleColor = UIColor.redColor;
[stickModeWidget setTextColor:UIColor.grayColor forState:UIControlStateNormal];
[stickModeWidget setTextColor:UIColor.blackColor forState:UIControlStateDisabled];

Hooks

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

  1. RCModeListItemModelState - Provides hooks for events received by the widget from the widget model. It inherits from ListItemRadioButtonModelState and adds the following hooks:
  • + (instancetype)setRCStickModeSucceded; - Event when setting the RC stick mode succeeds.
  • + (instancetype)rcStickModeUpdateFailed:(NSError *)error; - Event when setting the RC stick mode fails.
  • + (instancetype)rcStickModeUpdated:(DJIRCAircraftMappingStyle)newMode; - Event when the RC stick mode is updated.
  1. RCModeListItemUIState - Provides hooks for events received by the widget from user interactions. It inherits from ListItemRadioButtonUIState and adds no additional hooks.
Clone this wiki locally