-
Notifications
You must be signed in to change notification settings - Fork 15
Flight Mode List Item Widget
Flight Mode List Item Widget is a DUXBetaListItemLabelOnly type of widget which will display the current FlightMode. Following are examples of the widget states:
Disconnected
Sport
Opti
Atti
To add the flight mode widget to your DUXBetaSmartListModel class, override buildModelLists and include DUXBetaFlightModeListItemWidget.duxbeta_className() or [DUXBetaFlightModeWidget duxbeta_className] in your modelClassnameList:
@objc open class MySmartListModel : DUXBetaSmartListModel {
@objc open override func buildModelLists() {
super.buildModelLists()
self.modelClassnameList.append(DUXBetaFlightModeListItemWidget.duxbeta_className())
}
}
@interface DUXBetaTestSmartListModel : DUXBetaSmartListModel
@end
@implementation DUXBetaTestSmartListModel
- (void)buildModelLists {
[super buildModelLists];
[self.modelClassnameList append:[DUXBetaFlightModeListItemWidget duxbeta_className]];
}
@end
The UI elements can be customized to match the style of the user's application. The widget supports all the customizations that its parent, DUXBetaListItemLabelOnly, supports. An example of a customized flight mode list item widget showing various flight modes could look something like this:
Disconnected
Sport
Opti
Atti
To get this effect we would use the following code:
flightModeListWidget.backgroundColor = .gray
flightModeListWidget.iconImage = UIImage.init(named: "CustomFlightModeIconImage")!
flightModeListWidget.labelTextColorNormal = .green
flightModeListWidget.labelTextColorDisconnected = .red
flightModeListWidget.backgroundColor = UIColor.grayColor;
flightModeListWidget.iconImage = [UIImage imageNamed:@"CustomFlightModeIconImage"];
flightModeListWidget.labelTextColorNormal = UIColor.greenColor;
flightModeListWidget.labelTextColorDisconnected = UIColor.redColor;
The widget provides hooks for the users to add functionality based on the state changes in the widget. The FlightModeListItemStateWidget provides the following hooks
-
FlightModeListItemModelState
- Provides hooks for events received by the widget from the widget model. It inherits from ListItemLabelButtonModelState and adds the following hooks:
-
+ (instancetype)flightModeUpdated:(NSString*)newMode;
- Event when the flight mode is updated.
-
FlightModeListItemUIState
- Provides hooks for events received by the widget from the user interface interactions. It inherits from ListItemLabelButtonUIState and adds no other hooks.
DJI UX SDK Version 5 Beta 4.1