Skip to content

SSD Status List Item Widget

Cristina Suciu edited this page Dec 23, 2020 · 1 revision

SSD Status List Item Widget is a DUXBetaListItemLabelAndButton type of widget which will display the remaining capacity of the SSD and SSDCardOperationState when an appropriate aircraft and camera combination is available.

Following are examples of the widget states:

Disconnected

Normal

Formatting

Not Inserted

It also provides an option to format the SSD. Tapping on the format button will show the format confirmation dialog.

Format confirmation dialog

Format success dialog

Format error dialog

Usage

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

Swift Example

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

ObjC Example

@interface DUXBetaTestSmartListModel : DUXBetaSmartListModel
@end

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

To get this effect we would use the following code:

Swift Example

ssdWidget.setButtonColor(.blue, for: .normal)
ssdWidget.backgroundColor = UIColor.lightGray
ssdWidget.imageTintColor = UIColor.cyanColor

ObjC Example

[ssdWidget setButtonBorderColor:UIColor.blueColor forUIControlState:UIControlStateNormal];
ssdWidget.backgroundColor = UIColor.lightGrayColor
ssdWidget.imageTintColor = UIColor.cyanColor

To customize the appearance of the dialogs presented when formatting the SSD, there are 3 different appearances of type DUXBetaAlertViewAppearance, one per dialog which can be customized.

Dialog Customization Properties

List of the dialog properties for customization
  • ssdConfirmFormatAlertAppearance - The customization object for the format confirmation dialog.
  • ssdFormattingSuccessAlertAppearance - The customization object for successful formatting completion dialog.
  • ssdFormattingErrorAlertAppearance - The customization object for the dialog shown when an error happens during formatting.

See Alerts Customization Overview for all the customizable properties.

To get this effect we would use the following code:

Swift Example

ssdWidget.ssdConfirmFormatAlertAppearance.backgroundColor = UIColor.lightGray;
ssdWidget.ssdConfirmFormatAlertAppearance.messageColor = UIColor.yellow;
ssdWidget.ssdConfirmFormatAlertAppearance.imageTintColor = UIColor.cyan;

ObjC Example

ssdWidget.ssdConfirmFormatAlertAppearance.backgroundColor = UIColor.lightGrayColor;
ssdWidget.ssdConfirmFormatAlertAppearance.messageColor = UIColor.yellowColor;
ssdWidget.ssdConfirmFormatAlertAppearance.imageTintColor = UIColor.cyanColor;

Hooks

The widget provides hooks for the users to add functionality based on the state changes in the widget.

The SSD Status List Item widget provides the following hooks:

  1. SSDStatusItemModelState - Provides hooks in events received by the widget from the widget model. It inherits from ListItemLabelButtonModelState and it adds the following hooks:
  • + (instancetype)ssdStatusCapacityChanged:(NSInteger)freeStorageChanged; - Event when the SSD's remaining capacity changes.
  • + (instancetype)ssdStateUpdated:(NSNumber *)operationState; - Event when the SSDOperationState is updated.
  1. SSDStatusItemUIState - Provides hooks in events related to user interaction with the widget. It inherits from ListItemLabelButtonUIState and adds no other hooks.
Clone this wiki locally