As the shell of AntUI, AntUIShell is mainly used to implement third-party protocols in AntUI. It can be embedded to an mPaaS app and reduce external dependencies of AntUI.
API description
AntUIShellObject.h
//
// AntUIShellObject.h
// AntUIShell
//
#import <Foundation/Foundation.h>
#import <AntUI/AntUI.h>
@interface AntUIShellObject : NSObject<AUThirdPartyAdapter>
@end
Code sample
//
// AntUIShellObject.m
// AntUIShell
//
#import "AntUIShellObject.h"
#import <APMonitor/APMonitor.h>
#import <APMultimedia/APMultimedia.h>
#import <MPBadgeService/MPBadgeService.h>
@implementation AntUIShellObject
#pragma mark ----AUThirdPartyAdapter
/***********************************************************/
// The image protocol APMultimedia.
/*
API adaptation for third-party to download image.
It wraps mulimedia APIs and is implemented by a third party.
*/
- (NSString *)thirdPartyGetImage:(NSString *)identifier
business:(NSString *)business
zoom:(CGSize)size
originalSize:(CGSize)originSize
progress:(void (^)(double percentage,long long partialBytes,long long totalBytes))progress
completion:(void (^)(UIImage *image, NSError *error))complete
{
return [[APImageManager manager] getImage:identifier business:business zoom:size originalSize:originSize progress:progress completion:complete];
}
/*
API adaptation for third-party to download UIImageView image.
It is implemented by a third party.
*/
- (void)thirdPartypFromImageView:(UIImageView *)fromImgView
setImageWithKey:(NSString *)key
business:(NSString *)business
placeholderImage:(UIImage *)placeholder
zoom:(CGSize)zoom
originalSize:(CGSize)originalSize
progress:(void (^)(double percentage,long long partialBytes,long long totalBytes))progress
completion:(void (^)(UIImage *image, NSError *error))complete
{
if(fromImgView && [fromImgView isKindOfClass:[UIImageView class]]) {
[fromImgView setImageWithKey:key business:business placeholderImage:placeholder zoom:zoom originalSize:originalSize progress:progress completion:complete];
}
}
/***********************************************************/
// The badge protocol MPBadgeService.
/*
Initialize the badge view.
*/
- (UIView *) thirdPartyBadgeViewWithFrame:(CGRect)frame
{
return [[MPBadgeView alloc] initWithFrame:frame];
}
/*
Set widgetId for the badge.
*/
- (void) thirdPartyBadgeViewWith:(UIView *)badgeView
widgetId:(NSString *) widgetId
{
if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
tmpBadgeView.widgetId = widgetId;
}
}
/*
Register the badge view to MPBadgeManager.
*/
- (void) thirdPartyBadgeViewReg:(UIView *)badgeView
{
if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
[[MPBadgeManager sharedInstance] registerBadgeView:tmpBadgeView];
}
}
/**
* Update the badge style.
* @param badgeView The badge view.
* @param badgeValue: @"." Display a red dot.
* @"new" Display "new".
* @"Number" Display a number. For a number greater than 99, display the more icon (...).
* @"hui" Display "hui".
* @"xin" Display "xin".
* nil Clear the currently displayed content.
*
* @return There is no return value.
*/
- (void) thirdPartyBadgeViewWith:(UIView *)badgeView
updateValue:(NSString *)badgeValue
{
if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
[tmpBadgeView updateBadgeValue:badgeValue];
}
}
/*
Provide business personnel with an API for monitoring badge control updates.
The type of widgetInfo is MPWidgetInfo.
*/
- (void) thirdPartyBadgeViewWith:(UIView *)badgeView
updateBlock:(void(^)(id widgetInfo, BOOL isShow)) updateBlock
{
if(badgeView && [badgeView isKindOfClass:[MPBadgeView class]]) {
MPBadgeView * tmpBadgeView =(MPBadgeView *)badgeView;
if(updateBlock) {
tmpBadgeView.updateBlock = updateBlock;
}
}
}
/*
The tracking protocol APMonitor.
*/
// The tracking protocol of actionName of the button.
- (void) thirdPartySetButtonActionLog:(UIButton *)button
actionNameLog:(NSString *)actionName
{
if(button && [button isKindOfClass:[UIButton class]]) {
button.actionName = actionName;
}
}
/*
The notification protocol AUCardMenu/AUFloatMenu.
*/
/*
AUCardMenu registers the logout notification, ensuring that AUCardMenu is destroyed upon logout in a timely manner.
*/
- (NSString *) thirdPartyCardMenuDismissNotiName
{
return @"SAAccountDidExitNotification";
}
/*
AUFloatMenu registers alerView kShareTokenAlertViewShownNotification.
*/
- (NSString *) thirdPartyFloatMenuDismissFromAlertNotiName
{
return @"kShareTokenAlertViewShownNotification";
}
/*
AUFloatMenu registers alerView SALoginAppWillStartNotification.
*/
- (NSString *) thirdPartyFloatMenuDismissFromLoginNotiName
{
return @"SALoginAppWillStartNotification";
}
@end