Skip to content

Max Altitude List Item Widget

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

Max Altitude List Item Widget is a DUXBetaListItemOnlyEdit type widget which will display the current value of the maximum altitude that the drone is restricted to fly at. The widget also provides functionality to modify this value. The user can tap on the value and edit it in the permitted range. The permitted range is shown next to the edit field as a hint.

Following are examples of the widget states:

Disconnected

Normal

The modification of the maximum altitude value depends on the mode of the drone and flight restrictions at the current location.

  1. Flight Restriction - If there is no flight restriction at the location the maximum altitude value can be modified over 120m / 400ft. The user will, however, be shown a dialog to accept responsibility for flying above the FAA 400-foot flight ceiling.

If the user modifies the maximum altitude value to a value lower than the current Failsafe Return To Home Altitude, the Failsafe Return To Home Altitude will also be modified to that value. The user will be shown a dialog to confirm this action.

Usage

To add the max altitude list item widget to your DUXBetaSmartListModel class, override buildModelLists and include DUXBetaMaxAltitudeListItemWidget.duxbeta_className() or [DUXBetaMaxAltitudeListItemWidget duxbeta_className] in your modelClassnameList:

Swift Example

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

ObjC Example

@interface DUXBetaTestSmartListModel : DUXBetaSmartListModel
@end

@implementation DUXBetaTestSmartListModel
- (void)buildModelLists {
    [super buildModelLists];
    [self.modelClassnameList append:[DUXBetaMaxAltitudeListItemWidget 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, DUXBetaListItemOnlyEdit supports. An example of a customized max altitude list item widget in various states could look something like this:

To get this effect we would use the following code:

Swift Example

maxHeightWidget.backgroundColor = .darkGray
maxHeightWidget.titleColor = .black

ObjC Example

maxHeightWidget.backgroundColor = UIColor.darkGrayColor;
maxHeightWidget.titleColor = UIColor.blackColor;

Hooks

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

  1. MaxAltitudeListItemModelState - Provides hooks for events received by the widget from the widget model. It inherits from ListItemEditTextModelState and adds the following hooks:
  • + (instancetype)setMaxAltitudeSucceeded; - Event when setting the max altitude value is successful.
  • + (instancetype)setMaxAltitudeFailed:(NSInteger)maxAltitude; - Event when setting the max altitude value fails.
  • + (instancetype)maxAltitudeChanged:(NSInteger)maxAltitude; - Event when the max altitude level state is updated.
  1. MaxAltitudeListItemUIState - Provides hooks for events received by the widget from user interactions. It inherits from ListItemEditTextUIState and adds no aditional hooks.
Clone this wiki locally