将HUD相关方法放到BaseMvpProtocol协议,所有的view都要实现BaseMvpProtocol协议
This commit is contained in:
@@ -19,7 +19,6 @@ typedef void(^HttpFail)(NSInteger code, NSString * _Nullable msg);
|
||||
|
||||
- (void)attatchView:(id)view;
|
||||
- (id)getView;
|
||||
- (BaseViewController *)getBaseVC;
|
||||
- (void)detatchView;
|
||||
- (HttpRequestHelperCompletion)createHttpCompletion:(HttpSuccess)success fail:(HttpFail)fail;
|
||||
- (HttpRequestHelperCompletion)createHttpCompletion:(HttpSuccess)success fail:(HttpFail)fail showLoading:(BOOL)loading;
|
||||
|
@@ -23,10 +23,6 @@
|
||||
return self.view;
|
||||
}
|
||||
|
||||
- (BaseViewController *)getBaseVC {
|
||||
return ((BaseViewController *) [self getView]);
|
||||
}
|
||||
|
||||
- (HttpRequestHelperCompletion)createHttpCompletion:(HttpSuccess)success fail:(HttpFail)fail {
|
||||
return [self createHttpCompletion:success fail:fail showLoading:NO errorToast:YES];
|
||||
}
|
||||
@@ -41,11 +37,11 @@
|
||||
|
||||
- (HttpRequestHelperCompletion)createHttpCompletion:(HttpSuccess)success fail:(HttpFail)fail showLoading:(BOOL)loading errorToast:(BOOL)toast {
|
||||
if (loading) {
|
||||
[[self getBaseVC] showLoading];
|
||||
[self.view showLoading];
|
||||
}
|
||||
return ^(BaseModel *data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (loading) {
|
||||
[[self getBaseVC] hideHUD];
|
||||
[self.view hideHUD];
|
||||
}
|
||||
if (code == 200) {
|
||||
success(data);
|
||||
@@ -62,7 +58,7 @@
|
||||
}
|
||||
|
||||
if (toast) {
|
||||
[[self getBaseVC] showErrorToast:msg];
|
||||
[self.view showErrorToast:msg];
|
||||
}
|
||||
fail(code, msg);
|
||||
};
|
||||
|
@@ -13,6 +13,25 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)tokenInvalid;
|
||||
- (void)completeUserInfo;
|
||||
/**
|
||||
成功 toast
|
||||
*/
|
||||
- (void)showSuccessToast:(NSString *)msg;
|
||||
|
||||
/**
|
||||
失败 toast
|
||||
*/
|
||||
- (void)showErrorToast:(NSString *)msg;
|
||||
|
||||
/**
|
||||
加载 loading
|
||||
*/
|
||||
- (void)showLoading;
|
||||
|
||||
/**
|
||||
隐藏 XCHUDTool
|
||||
*/
|
||||
- (void)hideHUD;
|
||||
|
||||
@end
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MvpViewController<T> : BaseViewController<BaseMvpProtocol>
|
||||
@interface MvpViewController<T> : BaseViewController
|
||||
|
||||
@property (nonatomic, strong) __kindof T presenter;
|
||||
|
||||
|
@@ -6,10 +6,11 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "BaseMvpProtocol.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface BaseViewController : UIViewController
|
||||
@interface BaseViewController : UIViewController<BaseMvpProtocol>
|
||||
|
||||
// 是否隐藏导航 默认是不隐藏的
|
||||
@property(nonatomic,assign,getter=isHiddenNavBar) BOOL hiddenNavBar;
|
||||
@@ -36,26 +37,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
- (void)hideStatusBar;
|
||||
|
||||
/**
|
||||
成功 toast
|
||||
*/
|
||||
- (void)showSuccessToast:(NSString *)msg;
|
||||
|
||||
/**
|
||||
失败 toast
|
||||
*/
|
||||
- (void)showErrorToast:(NSString *)msg;
|
||||
|
||||
/**
|
||||
加载 loading
|
||||
*/
|
||||
- (void)showLoading;
|
||||
|
||||
/**
|
||||
隐藏 XCHUDTool
|
||||
*/
|
||||
- (void)hideHUD;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -85,7 +85,7 @@
|
||||
[AccountInfoStorage instance].thirdUserInfo = userInfo;
|
||||
|
||||
[Api loginWithThirdPart:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
[[self getBaseVC] hideHUD];
|
||||
[[super getView] hideHUD];
|
||||
AccountModel * model = [AccountModel modelWithDictionary:data.data];
|
||||
if (model != nil) {
|
||||
[[AccountInfoStorage instance] saveAccountInfo:model];
|
||||
@@ -94,11 +94,11 @@
|
||||
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
||||
} showLoading:YES] openid:openid unionid:unionid access_token:access_token type:[NSString stringWithFormat:@"%lu", (unsigned long)type]];
|
||||
} else if(state == SSDKResponseStateCancel) {///取消
|
||||
[[self getBaseVC] hideHUD];
|
||||
[[self getBaseVC] showErrorToast:@"登录取消"];
|
||||
[[super getView] hideHUD];
|
||||
[[super getView] showErrorToast:@"登录取消"];
|
||||
} else if (state == SSDKResponseStateFail) {///失败
|
||||
[[self getBaseVC] hideHUD];
|
||||
[[self getBaseVC] showErrorToast:@"登录失败,请重试"];
|
||||
[[super getView] hideHUD];
|
||||
[[super getView] showErrorToast:@"登录失败,请重试"];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
@@ -136,7 +136,6 @@
|
||||
return nav;
|
||||
}
|
||||
|
||||
#pragma mark - 如果不实现的话 如果在main里面请求接口的时候 需要的话 就会导致方法找不到的错误
|
||||
- (void)showSuccessToast:(NSString *)msg {
|
||||
[XCHUDTool showSuccessWithMessage:msg];
|
||||
}
|
||||
|
Reference in New Issue
Block a user