-
Notifications
You must be signed in to change notification settings - Fork 15
Unit Mode List Item Widget
Unit Mode List Item Widget is a DUXBetaListItemRadioButtonWidget type of widget which displays the Unit System used. The currently enabled unit type will be highlighted. The widget provides functionality to change the unit type by tapping on any option. Changing the unit type will change the unit system used in all the widgets. For example, Max Altitude List Item Widget, Max Flight Distance List Item Widget, and telemetry widgets.
Following are examples of the widget states:
As you can see below, both hints and edit values update dynnamically
When switching to imperial units, a warning dialog is shown explaining that imperial units are approximations of the metric values used by the aircraft.
To add the unit mode list item widget to your DUXBetaSmartListModel
class, override buildModelLists
and include DUXBetaUnitModeListItemWidget.duxbeta_className()
or [DUXBetaUnitModeListItemWidget duxbeta_className]
in your modelClassnameList:
@objc open class MySmartListModel : DUXBetaSmartListModel {
@objc open override func buildModelLists() {
super.buildModelLists()
self.modelClassnameList.append(DUXBetaUnitModeListItemWidget.duxbeta_className())
}
}
@interface DUXBetaTestSmartListModel : DUXBetaSmartListModel
@end
@implementation DUXBetaTestSmartListModel
- (void)buildModelLists {
[super buildModelLists];
[self.modelClassnameList append:[DUXBetaUnitModeListItemWidget duxbeta_className]];
}
@end
The following customizations are available on the Unit Mode List Item Widget:
-
imperialModeOnAlertAppearance
- An instance of DUXBetaAlertView.systemAlertAppearance to customize all the standard aspects of the imperial approximations dialog -
imperialModeExampleTextFont
- Optional custom font to use for the example text in the imperial dialog -
imperialModeOnExampleTextColor
- Optional custom color to use for the example text in the imperial dialog -
imperialModeOnCheckboxTextFont
- Optional custom font to use for the "Don't Show Again" checkbox text in the imperial dialog -
imperialModeOnCheckboxTextColor
- Optional custom color to use for the "Don't Show Again" checkbox text in the imperial dialog -
imperialModeOnCheckboxTintColor
- Optional tint color to apply to the checkbox icon in the imperial dialog -
imperialModeCheckboxOnImage
- Optional checkbox "on" image to use for the "Don't Show Again" checkbox. It should be white for tint application -
imperialModeCheckboxOffImage
- Optional checkbox "off" image to use for the "Don't Show Again" checkbox. It should be white for tint application -
neverShowAgainCheckboxTitle
- Customizable string for the checkbox to prevent the imperial change dialog from being shown again
The dialog shown when switching to imperial mode can be customized in multiple ways. To achieve this customized dialog, use the following code:
unitWiget.imperialModeOnAlertAppearance.backgroundColor = .duxbeta_gray()
unitWiget.imperialModeExampleTextFont = UIFont(name: "Copperplate-Bold", size: 24.0)
unitWiget.imperialModeOnExampleTextColor = UIColor.blue
unitWiget.imperialModeOnCheckboxTextFont = UIFont(name: "Optima-ExtraBlack", size: 24.0)
unitWiget.imperialModeOnCheckboxTextColor = UIColor.yellow
unitWiget.imperialModeOnCheckboxTintColor = UIColor.blue
unitWiget.imperialModeOnAlertAppearance.backgroundColor = UIColor.duxbeta_gray();
unitWiget.imperialModeExampleTextFont = [UIFont fontWithName:@"Copperplate-Bold" size:24.0];
unitWiget.imperialModeOnExampleTextColor = [UIColor blueColor];
unitWiget.imperialModeOnCheckboxTextFont = [UIFont fontWithName:@"Optima-ExtraBlack" size: 24.0];
unitWiget.imperialModeOnCheckboxTextColor = [UIColor yellowColor];
unitWiget.imperialModeOnCheckboxTintColor = [UIColor blueColor];
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:
-
UnitModeItemModelState
- Provides hooks for events received by the widget from the widget model. It inherits from ListItemTitleModelState and adds the following hooks:
-
+ (instancetype)setUnitTypeSucceeded;
- Event with TRUE value when the unit mode has been successfully updated. -
+ (instancetype)setUnitTypeFailed;
- Event when setting the unit mode fails. -
+ (instancetype)unitTypeUpdated:(MeasureUnitType)newUnitsMode;
- Event when the units mode has changed, passing 1 for metric, 2 for imperial, 3 for unknown
-
UnitModeItemUIState
- Provides hooks for events received by the widget from user interactions. It inherits from ListItemTitleUIState and adds the following hooks:
-
+ (instancetype)neverShowAgainCheckChanged:(Bool)newCheckboxSetting;
- Event when the user toggles the "Don't Show Again" checkbox.
DJI UX SDK Version 5 Beta 4.1