Remaining Flight Time Widget - dji-sdk/Mobile-UXSDK-Beta-iOS GitHub Wiki
The widget shows the remaining flight time graphically. Data displayed includes:
- Battery charge remaining in percentage
- Battery required for the drone to return home
- Battery required for the drone to land
- Remaining flight time
- Serious low battery threshold level
- Low battery threshold level
When the product is disconnected the widget is hidden.
When the aircraft hasn't taken off yet, the flight time, battery needed to return to home, and battery needed to land indicators are unavailable.
When the aircraft has taken off, then landed, only the flight time text is unavailable.
The graphical representation of the widget demonstrates the reduction in the battery level.
If creating the remaining flight time widget through code, it can be added using the convenience method:
- (void)installInViewController:(nullable UIViewController *)viewController
If creating the widget through storyboard, use the object library to drag a container view controller into the desired view controller like so:
Following this, make sure to change the class of the child view controller to DUXBetaRemainingFlightTimeWidget
. From here, you can create the constraints on the container view using the remaining flight time widget's widgetSizeHint
property.
Note that remaining flight time widget does not set its aspect ratio internally so it needs both width and height constraints. This applies to initialization through code or storyboard.
The remaining flight time widget can be customized to match the style of the user's application.
To get this effect we would use the following code:
remainingFlightTimeWidget.homeIndicatorColor = UIColor.systemBlue
remainingFlightTimeWidget.remainingBatteryBarColor = UIColor.white
remainingFlightTimeWidget.lowBatteryWarningBarColor = UIColor.orange
remainingFlightTimeWidget.lowBatteryIndicatorColor = UIColor.systemBlue
remainingFlightTimeWidget.seriouslyLowBatteryIndicatorColor = UIColor.systemBlue
remainingFlightTimeWidget.remainingTimeLabelBackgroundColor = UIColor.systemBlue
remainingFlightTimeWidget.remainingTimeLabelTextColor = UIColor.white
remainingFlightTimeWidget.seriouslyLowBatteryWarningBarColor = UIColor.systemRed
remainingFlightTimeWidget.homeIndicatorColor = [UIColor systemBlueColor];
remainingFlightTimeWidget.remainingBatteryBarColor = [UIColor whiteColor];
remainingFlightTimeWidget.lowBatteryWarningBarColor = [UIColor orangeColor];
remainingFlightTimeWidget.lowBatteryIndicatorColor = [UIColor systemBlueColor];
remainingFlightTimeWidget.seriouslyLowBatteryIndicatorColor = [UIColor systemBlueColor];
remainingFlightTimeWidget.remainingTimeLabelBackgroundColor = [UIColor systemBlueColor];
remainingFlightTimeWidget.remainingTimeLabelTextColor = [UIColor whiteColor];
remainingFlightTimeWidget.seriouslyLowBatteryWarningBarColor = [UIColor systemRedColor];
List of customization methods and properties
-
@property (nonatomic, strong) UIFont *remainingTimeFont;
The font for the remaining flight time text. -
@property (nonatomic, strong) UIColor *remainingTimeLabelBackgroundColor;
The background color of the remaining time label. -
@property (nonatomic, strong) UIColor *remainingTimeLabelTextColor;
The color of the remaining flight time text. -
@property (nonatomic, strong) UIColor *remainingBatteryBarColor;
The color of the remaining battery battery bar (default green). -
@property (nonatomic, strong) UIColor *lowBatteryWarningBarColor;
The color of the low battery warning bar (default yellow). -
@property (nonatomic, strong) UIColor *seriouslyLowBatteryWarningBarColor;
The color of the seriously low battery warning bar (default red). -
@property (nonatomic, strong) UIColor *seriouslyLowBatteryIndicatorColor;
The tint color of the seriously low battery indicator(default white dot). -
@property (nonatomic, strong) UIColor *lowBatteryIndicatorColor;
The tint color of the low battery indicator(default white dot). -
@property (nonatomic, strong) UIColor *homeIndicatorColor;
The tint color of the home indicator icon. -
@property (nonatomic, strong) UIImage *lowBatteryIndicatorImage;
The low battery indicator image. -
@property (nonatomic, strong) UIImage *seriouslyLowBatteryIndicatorImage;
The seriously low battery indicator image. -
@property (nonatomic, strong) UIImage *homeIndicatorImage;
The return home indicator image.
The widget provides hooks for users to add functionality based on state changes in the widget. The remaining flight time widget provides the following hooks:
-
RemainingFlightTimeModelState
- Provides hooks for events received by the widget from the widget model.
-
+ (instancetype)productConnected:(BOOL)isConnected;
- Event when product is connected or disconnected. -
+ (instancetype)flightTimeDataUpdated:(DUXBetaRemainingFlightTimeData *)flightTimeData;
- Event when remaining flight time data is updated. -
+ (instancetype)isAircraftFlyingUpdated:(BOOL)isAircraftFlying;
- Event when aircraft toggles between flying and not flying state.