|
@@ -0,0 +1,265 @@
|
|
|
+//
|
|
|
+// clearCacheAlretViewController.m
|
|
|
+// 双子星云手机
|
|
|
+//
|
|
|
+// Created by xd h on 2024/3/29.
|
|
|
+//
|
|
|
+
|
|
|
+#import "clearCacheAlretViewController.h"
|
|
|
+
|
|
|
+@interface clearCacheAlretViewController (){
|
|
|
+ NSString *titleStr;
|
|
|
+ NSString *msgStr;
|
|
|
+ NSString *imageStr;
|
|
|
+ NSString *cancelTitleStr;
|
|
|
+ NSString *okTitleStr;
|
|
|
+ BOOL isOkBtnHighlight;
|
|
|
+
|
|
|
+ clearCacheAlert_ClickOkBtn didClickOkBtn;
|
|
|
+ CommonAlert_ClickCancelBtn didClickCanaelBtn;
|
|
|
+
|
|
|
+ UIButton *selectBut;
|
|
|
+}
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation clearCacheAlretViewController
|
|
|
+
|
|
|
+- (id)initWithTiTle:(NSString *)title msg:(NSString *)msg imageStr:(NSString *)image cancelTitle:(NSString *)cancelTitle okTitle:(NSString *)okTitle isOkBtnHighlight:(BOOL)okBtnHighlight didClickOk:(clearCacheAlert_ClickOkBtn)ok didClickCancel:(CommonAlert_ClickCancelBtn)Cancel{
|
|
|
+ self = [super init];
|
|
|
+
|
|
|
+ titleStr = title;
|
|
|
+ msgStr = msg;
|
|
|
+ imageStr = image;
|
|
|
+ cancelTitleStr = cancelTitle;
|
|
|
+ okTitleStr = okTitle;
|
|
|
+ isOkBtnHighlight = okBtnHighlight;
|
|
|
+
|
|
|
+ didClickOkBtn = ok;
|
|
|
+ didClickCanaelBtn = Cancel;
|
|
|
+ return self;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)viewDidLoad {
|
|
|
+ [super viewDidLoad];
|
|
|
+ // Do any additional setup after loading the view.
|
|
|
+
|
|
|
+ [self drawAnyView];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)drawAnyView{
|
|
|
+ [self.view setBackgroundColor:HW000000Color60];
|
|
|
+
|
|
|
+ [self.toolBar setHidden:YES];
|
|
|
+ [self.navigationBar setHidden:YES];
|
|
|
+
|
|
|
+ UIView *bgView = [[UIView alloc] init];
|
|
|
+ [bgView setBackgroundColor:[UIColor whiteColor]];
|
|
|
+ [bgView.layer setCornerRadius:8.f];
|
|
|
+
|
|
|
+ [self.view addSubview:bgView];
|
|
|
+
|
|
|
+ [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerY.equalTo(self.view.mas_centerY).offset(10*HAUTOSCALE);
|
|
|
+ make.centerX.equalTo(self.view.mas_centerX);
|
|
|
+ make.width.mas_equalTo(300.f);
|
|
|
+ }];
|
|
|
+
|
|
|
+ CGFloat curTop = 30.0;
|
|
|
+
|
|
|
+ //图片
|
|
|
+ UIImageView *topImageView = [[UIImageView alloc] init];
|
|
|
+ //topImageView.backgroundColor = [UIColor redColor];
|
|
|
+
|
|
|
+ if(imageStr && imageStr.length > 0){
|
|
|
+ topImageView.image = [UIImage imageNamed:imageStr];
|
|
|
+ [bgView addSubview:topImageView];
|
|
|
+ [topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.width.mas_equalTo(80.f);
|
|
|
+ make.height.mas_equalTo(80.f);
|
|
|
+ make.centerX.equalTo(bgView.mas_centerX);;
|
|
|
+ make.top.mas_equalTo(curTop);
|
|
|
+ }];
|
|
|
+
|
|
|
+ curTop = 30 + 80 + 10.0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*主标题*/
|
|
|
+ UILabel *titleLabel = [[UILabel alloc] init];
|
|
|
+ [titleLabel setTextColor:HW0A132BColor];
|
|
|
+ [titleLabel setFont:[UIFont boldSystemFontOfSize:16.f]];
|
|
|
+ [titleLabel setTextAlignment:(NSTextAlignmentCenter)];
|
|
|
+ [titleLabel setText:titleStr];
|
|
|
+ [titleLabel setNumberOfLines:0];
|
|
|
+
|
|
|
+ if (titleStr.length > 0){
|
|
|
+ [bgView addSubview:titleLabel];
|
|
|
+ [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(8.f);
|
|
|
+ make.right.mas_equalTo(-8.f);
|
|
|
+ make.top.mas_equalTo(curTop);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+
|
|
|
+ /*副标题*/
|
|
|
+ UILabel *msgLabel = [[UILabel alloc] init];
|
|
|
+ [msgLabel setTextColor:HW333333Color];
|
|
|
+ [msgLabel setFont:[UIFont systemFontOfSize:15.f]];
|
|
|
+ [msgLabel setTextAlignment:(NSTextAlignmentCenter)];
|
|
|
+ [msgLabel setText:msgStr];
|
|
|
+ [msgLabel setNumberOfLines:0];
|
|
|
+
|
|
|
+ if (msgStr.length > 0){
|
|
|
+ [bgView addSubview:msgLabel];
|
|
|
+ [msgLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(8.f);
|
|
|
+ make.right.mas_equalTo(-8.f);
|
|
|
+ if (titleStr.length > 0){
|
|
|
+ make.top.equalTo(titleLabel.mas_bottom).offset(15.f);
|
|
|
+ }else{
|
|
|
+ make.top.mas_equalTo(curTop);
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //清理缓存中间添加另外的按钮
|
|
|
+ selectBut = [[UIButton alloc] init];
|
|
|
+ [selectBut setImage:[UIImage imageNamed:@"common_did_check"] forState:UIControlStateSelected];
|
|
|
+ [selectBut setImage:[UIImage imageNamed:@"common_un_check"] forState:UIControlStateNormal];
|
|
|
+ [selectBut setTitle:NSLocalizedString(@"clear_cache_include_file_Transfer",nil) forState:UIControlStateNormal];
|
|
|
+ selectBut.titleLabel.font = [UIFont systemFontOfSize:12.0];
|
|
|
+ [selectBut setTitleColor:[UIColor hwColor:@"#151515" alpha:1.0] forState:UIControlStateNormal];
|
|
|
+ [selectBut addTarget:self action:@selector(didClickSelectButtonFun:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+
|
|
|
+ [bgView addSubview:selectBut];
|
|
|
+ [selectBut mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(8.f);
|
|
|
+ make.right.mas_equalTo(-8.f);
|
|
|
+ if (msgStr.length > 0){
|
|
|
+ make.top.equalTo(msgLabel.mas_bottom).offset(15.f);
|
|
|
+ }else{
|
|
|
+ make.top.equalTo(titleLabel.mas_bottom).offset(25.f);
|
|
|
+ }
|
|
|
+ make.height.mas_equalTo(20);
|
|
|
+ }];
|
|
|
+
|
|
|
+ /*双按钮*/
|
|
|
+ /*取消*/
|
|
|
+
|
|
|
+ /*取消按钮*/
|
|
|
+ UIButton *cancelBtn = [[UIButton alloc] init];
|
|
|
+ cancelBtn.frame = CGRectMake(0, 0, 115, 48.f);
|
|
|
+ CGFloat w_btn = 200;
|
|
|
+ if (okTitleStr.length > 0){
|
|
|
+ w_btn = 115;
|
|
|
+ }
|
|
|
+
|
|
|
+ // gradient
|
|
|
+ CAGradientLayer *gl = [CAGradientLayer layer];
|
|
|
+ gl.frame = CGRectMake(0,0,w_btn,48.f);
|
|
|
+ gl.startPoint = CGPointMake(0, 0.5);
|
|
|
+ gl.endPoint = CGPointMake(1, 0.5);
|
|
|
+ gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
|
|
|
+ gl.locations = @[@(0), @(1.0f)];
|
|
|
+
|
|
|
+
|
|
|
+ if(!isOkBtnHighlight){
|
|
|
+ [cancelBtn.layer addSublayer:gl];
|
|
|
+ [cancelBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ [cancelBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
|
|
|
+ [cancelBtn setBackgroundColor:HWE3E8F1Color];
|
|
|
+ }
|
|
|
+
|
|
|
+ [cancelBtn addTarget:self action:@selector(cancelBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
|
|
|
+ [cancelBtn setTitle:cancelTitleStr forState:(UIControlStateNormal)];
|
|
|
+ [cancelBtn.titleLabel setFont:[UIFont systemFontOfSize:16.f]];
|
|
|
+ [cancelBtn.layer setCornerRadius:8.f];
|
|
|
+ cancelBtn.clipsToBounds = YES;
|
|
|
+ cancelBtn.tag = 999;
|
|
|
+ [bgView addSubview:cancelBtn];
|
|
|
+ [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ if (okTitleStr.length > 0){
|
|
|
+ make.left.mas_equalTo(24);
|
|
|
+ }else{
|
|
|
+ make.centerX.equalTo(bgView.mas_centerX);
|
|
|
+ }
|
|
|
+// if (msgStr.length > 0){
|
|
|
+// make.top.equalTo(msgLabel.mas_bottom).offset(15.f);
|
|
|
+// }else{
|
|
|
+// make.top.equalTo(titleLabel.mas_bottom).offset(25.f);
|
|
|
+// }
|
|
|
+
|
|
|
+ make.top.equalTo(selectBut.mas_bottom).offset(25.f);
|
|
|
+
|
|
|
+ make.width.mas_equalTo(w_btn);
|
|
|
+ make.bottom.equalTo(bgView.mas_bottom).offset(-30.f);
|
|
|
+ make.height.mas_equalTo(48.f);
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+ if (okTitleStr.length > 0){
|
|
|
+ /*残忍拒绝*/
|
|
|
+ UIButton *okBtn = [[UIButton alloc] init];
|
|
|
+
|
|
|
+ if(!isOkBtnHighlight){
|
|
|
+ [okBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
|
|
|
+ [okBtn setBackgroundColor:HWE3E8F1Color];
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ [okBtn.layer addSublayer:gl];
|
|
|
+ [okBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
|
|
|
+ }
|
|
|
+
|
|
|
+ [okBtn addTarget:self action:@selector(okBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
|
|
|
+ [okBtn setTitle:okTitleStr forState:(UIControlStateNormal)];
|
|
|
+ //[okBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
|
|
|
+ [okBtn.titleLabel setFont:[UIFont systemFontOfSize:16.f]];
|
|
|
+ [okBtn.layer setCornerRadius:8.f];
|
|
|
+ //[okBtn setBackgroundColor:HWE3E8F1Color];
|
|
|
+ okBtn.clipsToBounds = YES;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [bgView addSubview:okBtn];
|
|
|
+ [okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.right.mas_equalTo(-24.f);
|
|
|
+ make.width.mas_equalTo(w_btn);
|
|
|
+ make.top.equalTo(cancelBtn.mas_top);
|
|
|
+ make.height.mas_equalTo(48.f);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+- (void)cancelBtnClick{
|
|
|
+ [self dismissViewControllerAnimated:YES completion:^{
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+
|
|
|
+
|
|
|
+ if(self->didClickCanaelBtn){
|
|
|
+ self->didClickCanaelBtn();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)okBtnClick{
|
|
|
+ [self dismissViewControllerAnimated:YES completion:^{
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+
|
|
|
+ if(self->didClickOkBtn){
|
|
|
+ self->didClickOkBtn(self->selectBut.selected);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)didClickSelectButtonFun:(UIButton*)but
|
|
|
+{
|
|
|
+ but.selected = !but.selected;
|
|
|
+}
|
|
|
+@end
|