提交 18c697e2 编写于 作者: Y yixiangboy

Alert功能 从toast中抽出来

上级 03e48408
//
// DoraemonAlertUtil.h
// AFNetworking
//
// Created by didi on 2019/8/27.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef void (^DoraemonAlertOKActionBlock)(void);
typedef void (^DoraemonAlertCancleActionBlock)(void);
@interface DoraemonAlertUtil : NSObject
+ (void)handleAlertActionWithVC:(UIViewController *)vc
okBlock:(DoraemonAlertOKActionBlock)okBlock
cancleBlock:(DoraemonAlertCancleActionBlock)cancleBlock;
+ (void)handleAlertActionWithVC:(UIViewController *)vc
text:(NSString *)text
okBlock:(DoraemonAlertOKActionBlock)okBlock
cancleBlock:(DoraemonAlertCancleActionBlock)cancleBlock;
@end
NS_ASSUME_NONNULL_END
//
// DoraemonAlertUtil.m
// AFNetworking
//
// Created by didi on 2019/8/27.
//
#import "DoraemonAlertUtil.h"
#import "Doraemoni18NUtil.h"
@implementation DoraemonAlertUtil
+ (void)handleAlertActionWithVC:(UIViewController *)vc
okBlock:(DoraemonAlertOKActionBlock)okBlock
cancleBlock:(DoraemonAlertCancleActionBlock)cancleBlock {
[self handleAlertActionWithVC:vc text:DoraemonLocalizedString(@"该功能需要重启App才能生效") okBlock:okBlock cancleBlock:cancleBlock];
}
+ (void)handleAlertActionWithVC:(UIViewController *)vc
text:(NSString *)text
okBlock:(DoraemonAlertOKActionBlock)okBlock
cancleBlock:(DoraemonAlertCancleActionBlock)cancleBlock {
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:DoraemonLocalizedString(@"提示") message:text preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:DoraemonLocalizedString(@"取消") style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
cancleBlock ? cancleBlock():nil;
}];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:DoraemonLocalizedString(@"确定") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
okBlock ? okBlock():nil;
}];
[alertController addAction:cancelAction];
[alertController addAction:okAction];
[vc presentViewController:alertController animated:YES completion:nil];
}
@end
......@@ -7,22 +7,8 @@
#import <Foundation/Foundation.h>
typedef void (^DoraemonHandleRestartActionBlock)(void);
typedef void (^DoraemonHandleRestartCancleActionBlock)(void);
@interface DoraemonToastUtil : NSObject
+ (void)showToast:(NSString *)text inView:(UIView *)superView;
+ (void)handleRestartActionWithVC:(UIViewController *)vc
restartBlock:(DoraemonHandleRestartActionBlock)restartBlock
cancleBlock:(DoraemonHandleRestartCancleActionBlock)cancleBlock;
+ (void)handleRestartActionWithVC:(UIViewController *)vc
text:(NSString *)text
restartBlock:(DoraemonHandleRestartActionBlock)restartBlock
cancleBlock:(DoraemonHandleRestartCancleActionBlock)cancleBlock;
@end
......@@ -9,9 +9,6 @@
#import "UIColor+Doraemon.h"
#import "UIView+Doraemon.h"
#import "Doraemoni18NUtil.h"
#import "DoraemonCellSwitch.h"
@implementation DoraemonToastUtil
......@@ -34,27 +31,4 @@
}
+ (void)handleRestartActionWithVC:(UIViewController *)vc
restartBlock:(DoraemonHandleRestartActionBlock)restartBlock
cancleBlock:(DoraemonHandleRestartCancleActionBlock)cancleBlock
{
[self handleRestartActionWithVC:vc text:DoraemonLocalizedString(@"该功能需要重启App才能生效") restartBlock:restartBlock cancleBlock:cancleBlock];
}
+ (void)handleRestartActionWithVC:(UIViewController *)vc
text:(NSString *)text
restartBlock:(DoraemonHandleRestartActionBlock)restartBlock
cancleBlock:(DoraemonHandleRestartCancleActionBlock)cancleBlock{
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:DoraemonLocalizedString(@"提示") message:text preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:DoraemonLocalizedString(@"取消") style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
cancleBlock ? cancleBlock():nil;
}];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:DoraemonLocalizedString(@"确定") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
restartBlock ? restartBlock():nil;
}];
[alertController addAction:cancelAction];
[alertController addAction:okAction];
[vc presentViewController:alertController animated:YES completion:nil];
}
@end
......@@ -15,6 +15,7 @@
#import "UIImage+Doraemon.h"
#import "Doraemoni18NUtil.h"
#import "DoraemonToastUtil.h"
#import "DoraemonAlertUtil.h"
#define DoraemonScreenWidth [UIScreen mainScreen].bounds.size.width
#define DoraemonScreenHeight [UIScreen mainScreen].bounds.size.height
......
......@@ -88,7 +88,7 @@
- (void)okBtnClick{
__weak typeof(self) weakSelf = self;
[DoraemonToastUtil handleRestartActionWithVC:self text:@"是否确认" restartBlock:^{
[DoraemonAlertUtil handleAlertActionWithVC:self text:@"是否确认" okBlock:^{
weakSelf.okBtnStatus = !weakSelf.okBtnStatus;
[DoraemonAllTestManager shareInstance].startTestOn = weakSelf.okBtnStatus;
if (weakSelf.okBtnStatus) {
......
......@@ -66,7 +66,7 @@
- (void)changeSwitchOn:(BOOL)on sender:(id)sender{
__weak typeof(self) weakSelf = self;
[DoraemonToastUtil handleRestartActionWithVC:self restartBlock:^{
[DoraemonAlertUtil handleAlertActionWithVC:self okBlock:^{
[[DoraemonCacheManager sharedInstance] saveCrashSwitch:on];
exit(0);
} cancleBlock:^{
......
......@@ -47,7 +47,7 @@
#pragma mark -- DoraemonSwitchViewDelegate
- (void)changeSwitchOn:(BOOL)on sender:(id)sender{
__weak typeof(self) weakSelf = self;
[DoraemonToastUtil handleRestartActionWithVC:self restartBlock:^{
[DoraemonAlertUtil handleAlertActionWithVC:self okBlock:^{
[[DoraemonCacheManager sharedInstance] saveNSLogSwitch:on];
exit(0);
} cancleBlock:^{
......
......@@ -76,7 +76,7 @@ static NSTimeInterval endTime;
#pragma mark -- DoraemonSwitchViewDelegate
- (void)changeSwitchOn:(BOOL)on sender:(id)sender{
__weak typeof(self) weakSelf = self;
[DoraemonToastUtil handleRestartActionWithVC:self restartBlock:^{
[DoraemonAlertUtil handleAlertActionWithVC:self okBlock:^{
[[DoraemonCacheManager sharedInstance] saveStartTimeSwitch:on];
exit(0);
} cancleBlock:^{
......
......@@ -48,7 +48,7 @@
#pragma mark -- DoraemonSwitchViewDelegate
- (void)changeSwitchOn:(BOOL)on sender:(id)sender{
__weak typeof(self) weakSelf = self;
[DoraemonToastUtil handleRestartActionWithVC:self restartBlock:^{
[DoraemonAlertUtil handleAlertActionWithVC:self okBlock:^{
[[DoraemonCacheManager sharedInstance] saveSubThreadUICheckSwitch:on];
exit(0);
} cancleBlock:^{
......
......@@ -47,7 +47,7 @@
#pragma mark -- DoraemonSwitchViewDelegate
- (void)changeSwitchOn:(BOOL)on sender:(id)sender{
__weak typeof(self) weakSelf = self;
[DoraemonToastUtil handleRestartActionWithVC:self restartBlock:^{
[DoraemonAlertUtil handleAlertActionWithVC:self okBlock:^{
[[DoraemonCacheManager sharedInstance] saveLoggerSwitch:on];
exit(0);
} cancleBlock:^{
......
......@@ -47,7 +47,7 @@
#pragma mark -- DoraemonSwitchViewDelegate
- (void)changeSwitchOn:(BOOL)on sender:(id)sender{
__weak typeof(self) weakSelf = self;
[DoraemonToastUtil handleRestartActionWithVC:self restartBlock:^{
[DoraemonAlertUtil handleAlertActionWithVC:self okBlock:^{
[DoraemonMethodUseTimeManager sharedInstance].on = on;
exit(0);
} cancleBlock:^{
......
......@@ -24,33 +24,33 @@ PODS:
- CocoaLumberjack (3.5.3):
- CocoaLumberjack/Core (= 3.5.3)
- CocoaLumberjack/Core (3.5.3)
- DoraemonKit/Core (1.2.1):
- DoraemonKit/Core (1.2.2):
- BSBacktraceLogger
- fishhook
- PNChart
- DoraemonKit/WithDatabase (1.2.1):
- DoraemonKit/WithDatabase (1.2.2):
- BSBacktraceLogger
- DoraemonKit/Core
- fishhook
- PNChart
- YYDebugDatabase
- DoraemonKit/WithGPS (1.2.1):
- DoraemonKit/WithGPS (1.2.2):
- BSBacktraceLogger
- DoraemonKit/Core
- fishhook
- PNChart
- DoraemonKit/WithLoad (1.2.1):
- DoraemonKit/WithLoad (1.2.2):
- BSBacktraceLogger
- DoraemonKit/Core
- fishhook
- PNChart
- DoraemonKit/WithLogger (1.2.1):
- DoraemonKit/WithLogger (1.2.2):
- BSBacktraceLogger
- CocoaLumberjack
- DoraemonKit/Core
- fishhook
- PNChart
- DoraemonKit/WithWeex (1.2.1):
- DoraemonKit/WithWeex (1.2.2):
- BSBacktraceLogger
- DoraemonKit/Core
- fishhook
......@@ -113,7 +113,7 @@ SPEC CHECKSUMS:
AFNetworking: cb8d14a848e831097108418f5d49217339d4eb60
BSBacktraceLogger: 06b983ee93a9f87d957960e9c73d660d5966b447
CocoaLumberjack: 2f44e60eb91c176d471fdba43b9e3eae6a721947
DoraemonKit: 2d0d3bf18a5181f750d5bfead5030403ba3fbb2e
DoraemonKit: ea50d30db95bd7ce978e964b2bb90c588a19a2a3
fishhook: ea19933abfe8f2f52c55fd8b6e2718467d3ebc89
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
GCDWebServer: ead88cd14596dd4eae4f5830b8877c87c8728990
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册