Skip to content

eMMC Status List Item Widget

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

The eMMC Status List Item Widget is a DUXBetaListItemLabelAndButton type of widget which will display the remaining capacity of the internal storage (an SD Card) and SDCardOperationState. By default, this widget only shows in the System Status List when connected to aircraft with internal storage capability or if no aircraft is connected.

Following are examples of the widget states:

Disconnected

Current eMMC State: Normal

Current eMMC State: Formatting

Current eMMC State: Not Supported

It also provides an option to format the internal storage media. Tapping on the format button will show the format confirmation dialogs.

Format confirmation dialog

Format success dialog

Format error dialog

Usage

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

Swift Example

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

ObjC Example

@interface DUXBetaTestSmartListModel : DUXBetaSmartListModel
@end

@implementation DUXBetaTestSmartListModel
- (void)buildModelLists {
    [super buildModelLists];
    [self.modelClassnameList append:[DUXBetaEMMCStatusListItemWidget 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 eMMC status list item widget with a different background and button color could look something like this:

To get this effect we would use the following code:

Swift Example

emmcWidget.setButtonColor(.red, for: .normal)
emmcWidget.backgroundColor = .darkGray
emmcWidget.titleColor = .black

ObjC Example

[emmcWidget setButtonColor:UIColor.redColor forUIControlState:UIControlStateNormal];
emmcWidget.backgroundColor = UIColor.darkGrayColor;
emmcWidget.titleColor = UIColor.blackColor;

To customize the appearance of the dialogs presented when formatting the internal storage, 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
  • emmcConfirmFormatAlertAppearance - The customization object for the format confirmation dialog.
  • emmcFormattingSuccessAlertAppearance - The customization object for successful formatting completion dialog.
  • emmcFormattingErrorAlertAppearance - 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

emmcWidget.emmcConfirmFormatAlertAppearance.backgroundColor = .duxbeta_grayColor

ObjC Example

emmcWidget.emmcConfirmFormatAlertAppearance.backgroundColor = [UIColor duxbeta_grayColor];

Hooks

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

The EMCC Status List Item widget provides the following hooks:

  1. EMMCStatusListWidgetModelState - Provides hooks in events received by the widget from the widget model. It inherits from ListItemLabelButtonModelState and it adds the following hooks:
  • + (instancetype)emmcStatusCapacityChanged:(NSInteger)freeStorageChanged; - Event when the internal storage remaining capacity changes.
  • + (instancetype)emmcStateUpdated:(NSNumber *)operationState; - Event when the SDCardOperationState is updated.
  1. EMCCStatusListWidgetUIState - Provides hooks in events related to user interaction with the widget. It inherits from ListItemLabelButtonUIState and adds no other hooks.
Clone this wiki locally