// // MvpViewController.m // YUMI // // Created by admin on 2023/3/9. // #import "MvpViewController.h" #import "BaseMvpProtocol.h" #import "BaseMvpPresenter.h" #import "BaseNavigationController.h" //Tool #import "TTPopup.h" #import "PLTimeUtil.h" #import "DJDKMIMOMColor.h" #import "YUMIMacroUitls.h" #import "YUMIHtmlUrl.h" #import "BSRealTimeView.h" @interface MvpViewController () @property (nonatomic, copy) void(^backAction)(void); @property (nonatomic, strong) UILabel *mvpTitleLabel; @property (nonatomic, strong) UIButton *backButton; @end @implementation MvpViewController - (__kindof id)presenter { if (_presenter == nil) { _presenter = [self createPresenter]; [_presenter attatchView:self]; } return _presenter; } - (__kindof id)createPresenter { return [[BaseMvpPresenter alloc] init]; } - (void)setupTopTheme { } - (void)setupCustomNavigationBar:(void(^)(void))backAction title:(NSString *)title titleColor:(UIColor *)color { UILabel *titleLabel = [self mvpTitleLabel]; titleLabel.text = title; titleLabel.textColor = color; [self.view addSubview:titleLabel]; [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self.view); make.top.mas_equalTo(self.view).offset(kStatusBarHeight); make.height.mas_equalTo(22); }]; UIButton *backButton = [self mvpBackButton]; [self.view addSubview:backButton]; [backButton mas_makeConstraints:^(MASConstraintMaker *make) { make.leading.mas_equalTo(self.view).offset(16); make.centerY.mas_equalTo(titleLabel); make.size.mas_equalTo(CGSizeMake(22, 22)); }]; self.backAction = backAction; } - (void)setupCustonNavigationRightButtons:(NSArray *)array sizes:(NSArray *)sizes { if (array.count > 0 && self->_mvpTitleLabel) { CGFloat trailing = -16; for (UIButton *b in array) { NSInteger index = [array indexOfObject:b]; NSValue *sizeValue = [sizes xpSafeObjectAtIndex:index]; [self.view addSubview:b]; [b mas_makeConstraints:^(MASConstraintMaker *make) { make.trailing.mas_equalTo(self.view).offset(trailing); make.centerY.mas_equalTo(self.mvpTitleLabel); make.size.mas_equalTo([sizeValue CGSizeValue]); }]; trailing -= 14 + [sizeValue CGSizeValue].width; } } } - (void)didTapBack { if (self.backAction) { self.backAction(); } [self.navigationController popViewControllerAnimated:YES]; } - (void)viewDidLoad { [super viewDidLoad]; #ifdef DEBUG for (id obj in kWindow.subviews) { if([obj isKindOfClass:[BSRealTimeView class]]){ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ BSRealTimeView *timeView = (BSRealTimeView *)obj; [timeView removeFromSuperview]; [kWindow addSubview:timeView]; }); break; } } #else #endif } - (void)accountCanceled:(NSDictionary *)data { NSString *date = [NSString stringWithFormat:@"%.0f",[[data objectForKey:@"cancelDate"] doubleValue]]; NSString *dateDes = [NSString stringWithFormat:YMLocalizedString(@"MvpViewController0"), [PLTimeUtil getDateWithYYMMDD:date]]; NSString *msg = [NSString stringWithFormat:YMLocalizedString(@"MvpViewController1.1"), dateDes]; if ([[data objectForKey:@"cancelDate"] doubleValue] == 0) { dateDes = @""; msg = YMLocalizedString(@"MvpViewController1.2"); } TTAlertMessageAttributedConfig *dateAttrConfig = [[TTAlertMessageAttributedConfig alloc] init]; dateAttrConfig.text = dateDes; dateAttrConfig.color = DJDKMIMOMColor.appMainColor; TTAlertConfig *config = [[TTAlertConfig alloc] init]; config.actionStyle = 0; config.title = YMLocalizedString(@"MvpViewController2"); config.message = msg; config.messageAttributedConfig = @[dateAttrConfig]; [TTPopup alertWithConfig:config confirmHandler:^{ } cancelHandler:^{ }]; } - (void)completeUserInfo { } ///实名认证弹窗 - (void)showRealNameAuthenticationTipsAlertView { TTAlertConfig *config = [[TTAlertConfig alloc] init]; config.message = YMLocalizedString(@"MvpViewController3"); config.messageLineSpacing = 4; config.confirmButtonConfig.title = YMLocalizedString(@"TTAlertConfig0"); config.confirmButtonConfig.titleColor = UIColor.whiteColor; config.confirmButtonConfig.backgroundColor = [DJDKMIMOMColor appMainColor]; TTAlertMessageAttributedConfig *nameAttrConf = [[TTAlertMessageAttributedConfig alloc] init]; nameAttrConf.text = YMLocalizedString(@"MvpViewController5"); nameAttrConf.color = [DJDKMIMOMColor appMainColor]; config.messageAttributedConfig = @[nameAttrConf]; [TTPopup alertWithConfig:config confirmHandler:^{ } cancelHandler:^{ }]; } /////封禁账号 //- (void)accountBanned:(BaseModel *)data { // TTAlertConfig * config = [[TTAlertConfig alloc] init]; // config.title = YMLocalizedString(@"MvpViewController6"); // NSString *dateDes = [PLTimeUtil getDateWithYYMMDD:data.date]; // NSString * title = [NSString stringWithFormat:YMLocalizedString(@"MvpViewController7"), data.reason,dateDes]; // TTAlertMessageAttributedConfig * inviteAlertConfig = [[TTAlertMessageAttributedConfig alloc] init]; // inviteAlertConfig.text = dateDes; // inviteAlertConfig.color = [DJDKMIMOMColor appMainColor]; // inviteAlertConfig.font = [UIFont systemFontOfSize:15]; // config.message = title; // config.messageAttributedConfig = @[inviteAlertConfig]; // [TTPopup alertWithConfig:config confirmHandler:^{ // // } cancelHandler:^{ // // }]; //} - (UILabel *)mvpTitleLabel { if (!_mvpTitleLabel) { UILabel *label = [[UILabel alloc] init]; label.textAlignment = NSTextAlignmentCenter; label.font = kFontMedium(17); label.textColor = UIColorFromRGB(0xD9E7F7); _mvpTitleLabel = label; } return _mvpTitleLabel; } - (UIButton *)mvpBackButton { if (!_backButton) { UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom]; [b setImage:kImage(@"common_nav_back_white") forState:UIControlStateNormal]; [b addTarget:self action:@selector(didTapBack) forControlEvents:UIControlEventTouchUpInside]; _backButton = b; } return _backButton; } @end