-
Notifications
You must be signed in to change notification settings - Fork 15
System Status Widget
This widget shows the system status of the aircraft. The color of the text changes depending on the severity of the status. There is no widget background by default, but if one is added using setSystemStatusBackgroundDrawable
, then the background also blinks when the incoming message is urgent.
This widget receives the system status as an object of the WarningStatusItem
class which contains the message to be displayed, and the warning level and urgency of the message. The default colors for the warning levels are as follows:
-
DUXBetaSystemStatusWarningLevelDisconnected
-
DUXBetaSystemStatusWarningLevelGood
-
DUXBetaSystemStatusWarningLevelWarning
-
DUXBetaSystemStatusWarningLevelError
The text scrolls in a marquee if the text is too long to fit inside the widget. Additionally, if the message is "Height Limited Zone" or "Special Unlock", the maximum flight altitude is appended to the end of the message.
If creating the system status 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 be DUXBetaSystemStatusWidget
. From here you can create the constraints on the container view using the System Status Widget's widgetSizeHint
property.
The System Status Widget supports customization of its icon as well as text. An example of a customized system status widget showing the product is in a good state could look something like this:
To get this effect we would use the following code:
let gradientPatternColor = UIColor(patternImage: UIImage.init(named: "gradientBackground")!)
systemStatusWidget.setBackgroundColor(gradientPatternColor, for: DUXBetaSystemStatusWarningLevel.safe)
systemStatusWidget.setTextColor(UIColor.white, for: DUXBetaSystemStatusWarningLevel.safe)
UIImage *gradientImage = [UIImage imageNamed:@"gradientBackground"];
UIColor *gradientPatternColor = [[UIColor alloc] initWithPatternImage:gradientImage];
[systemStatusWidget setBackgroundColor:gradientPatternColor forSystemStatusWarningLevel:DUXBetaSystemStatusWarningLevelSafe];
The widget can be customized by the user to serve their purpose and theme with the following methods and properties:
List of customization methods and properties
-
@property (nonatomic, strong) UIFont *messageFont;
The font of the pre-flight status message. Default point size = 16, scales with widget. -
- (void)setBackgroundColor:(UIColor *)color forSystemStatusWarningLevel:(DUXBetaSystemStatusWarningLevel)systemStatusWarningLevel;
Set the background color of the widget for the warning level. -
- (UIColor *)backgroundColorForSystemStatusWarningLevel:(DUXBetaSystemStatusWarningLevel)systemStatusWarningLevel;
Get the background color of the widget when messages with a certain warning level are displayed. -
- (void)setTextColor:(UIColor *)color forSystemStatusWarningLevel (DUXBetaSystemStatusWarningLevel)systemStatusWarningLevel;
Set the text color of messages with the warning level. -
- (UIColor *)textColorForSystemStatusWarningLevel:(DUXBetaSystemStatusWarningLevel)systemStatusWarningLevel;
Get the text color of messages with the warning level.
The widget provides hooks for users to add functionality based on state changes in the widget. The System Status Widget provides the following hooks:
-
DUXBetaSystemStatusWidgetModelState
- Provides hooks for events received by the widget from the widget model.
-
+ (instancetype)productConnected:(BOOL)isConnected;
- Event when product is connected or disconnected. -
+ (instancetype)systemStatusUpdated:(NSString *)systemStatusMessage;
- Event when the system status message changes.
-
DUXBetaSystemStatusWidgetUIState
- Provides hooks for events received by the widget from user interactions.
-
+ (instancetype)widgetTapped;
- Event when user taps the widget.
DJI UX SDK Version 5 Beta 4.1