修复了更新弹框的样式问题

This commit is contained in:
fengshuo
2022-12-15 15:16:22 +08:00
parent 2beff3228b
commit 78d6a04f4e
3 changed files with 68 additions and 145 deletions

View File

@@ -159,7 +159,6 @@
XPVersionUpdateModel *model = [XPVersionUpdateModel modelWithDictionary:data.data];
[[self getView] getVersionUpdate:model];
} fail:^(NSInteger code, NSString * _Nullable msg) {
NSLog(@"%@", msg);
[[self getView] getVersionUpdateFail];
} errorToast:NO] appVersion:appVersion os:os channel:channel];
}

View File

@@ -299,24 +299,18 @@
return;
}
NSString *appVersion = [YYUtility appVersion];
NSArray *appVersionList = [appVersion componentsSeparatedByString:@"."];
int appVersionNum = 0;
if(appVersionList. count == 3){
appVersionNum = [appVersionList[0]intValue] * 100 + [appVersionList[1]intValue] * 10 + [appVersionList[2]intValue];
}
NSString *updateVersion = model.updateVersion;
NSArray *updateVersionList = [updateVersion componentsSeparatedByString:@"."];
int updateVersionNum = 0;
if(updateVersionList. count == 3){
updateVersionNum = [updateVersionList[0] intValue] * 100 + [updateVersionList[1] intValue] * 10 + [updateVersionList[2] intValue];
}
if(updateVersionNum <= appVersionNum){
NSComparisonResult result = [appVersion compare:updateVersion options:NSNumericSearch];
if(result == NSOrderedSame || result == NSOrderedDescending){
[self showErrorToast:@"目前已更新到最新版本"];
return;
}
XPUpgradeView *view = [[XPUpgradeView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
view.versionModel = model;
[[UIApplication sharedApplication].keyWindow addSubview:view];
TTPopupService * service = [[TTPopupService alloc] init];
service.contentView = view;
service.shouldDismissOnBackgroundTouch = NO;
[TTPopup popupWithConfig:service];
}
#pragma mark - Event Response

View File

@@ -7,19 +7,18 @@
#import "XPUpgradeView.h"
#import <Masonry/Masonry.h>
#import <SZTextView/SZTextView.h>
#import "UIImage+Utils.h"
#import "XPMacro.h"
#import "ThemeColor.h"
#import "UIView+Corner.h"
#import "TTPopup.h"
@interface XPUpgradeView()
@property (nonatomic,strong) UIImageView *bgImageView;
@property (nonatomic,strong) UIImageView *bgheadImageView;
@property (nonatomic,strong) UIImageView *bgFooderImageView;
@property (nonatomic,strong) UIView *titleBgView;
@property (nonatomic,strong) UILabel *titleView;
@property (nonatomic,strong) UILabel *versionView;
@property (nonatomic,strong) UILabel *textView;
@property (nonatomic,strong) SZTextView *textView;
///
@property (nonatomic,strong) UIStackView *stackView;
@property (nonatomic,strong) UIButton *updateBtn;
@property (nonatomic,strong) UIButton *cancelBtn;
@end
@@ -39,82 +38,45 @@
- (void)initSubViews {
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
[self addSubview:self.bgImageView];
[self.bgImageView addSubview:self.bgheadImageView];
[self.bgImageView addSubview:self.bgFooderImageView];
[self.bgImageView addSubview:self.titleBgView];
[self.bgImageView addSubview:self.titleView];
[self.bgImageView addSubview:self.versionView];
[self.bgImageView addSubview:self.textView];
[self.bgImageView addSubview:self.updateBtn];
[self.bgImageView addSubview:self.cancelBtn];
[self.bgImageView addSubview:self.stackView];
[self.stackView addArrangedSubview:self.cancelBtn];
[self.stackView addArrangedSubview:self.updateBtn];
}
- (void)initSubViewConstraints {
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self);
make.width.mas_equalTo(279);
make.height.mas_greaterThanOrEqualTo(348);
make.width.mas_equalTo(250);
make.height.mas_greaterThanOrEqualTo(311);
}];
[self.bgheadImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.right.equalTo(self.bgImageView);
make.height.mas_equalTo(125);
}];
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(99);
make.centerX.equalTo(self.bgImageView);
make.height.mas_equalTo(24);
}];
[self.versionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.titleView.mas_bottom).mas_offset(3);
make.height.mas_equalTo(21);
make.centerX.equalTo(self.bgImageView);
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(32);
make.centerX.mas_equalTo(self.bgImageView);
make.bottom.mas_equalTo(self.bgImageView).offset(-20);
}];
[self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.bgImageView);
make.width.mas_equalTo(50);
make.height.mas_equalTo(17);
make.bottom.equalTo(self.bgImageView.mas_bottom).mas_offset(-18);
make.width.mas_equalTo(106);
}];
[self.updateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(154);
make.height.mas_equalTo(34);
make.centerX.equalTo(self.bgImageView);
make.bottom.equalTo(self.bgImageView.mas_bottom).mas_offset(-43);
make.width.mas_equalTo(106);
}];
[self.bgFooderImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(18);
make.width.mas_equalTo(250);
make.height.mas_equalTo(227);
make.bottom.equalTo(self.bgImageView);
}];
[self.titleBgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.width.equalTo(self.bgFooderImageView);
make.width.mas_equalTo(279);
make.top.equalTo(self.bgheadImageView.mas_bottom);
make.height.greaterThanOrEqualTo(@20);
make.bottom.equalTo(self.textView);
}];
[self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.bgImageView.mas_bottom).mas_offset(-121);
make.left.mas_equalTo(39);
make.right.mas_equalTo(-40);
make.top.equalTo(self.versionView.mas_bottom).mas_equalTo(9);
make.top.equalTo(self.bgImageView.mas_top).mas_offset(136);
make.left.mas_equalTo(17);
make.right.mas_equalTo(-17);
make.bottom.equalTo(self.stackView.mas_top).offset(-5);
}];
}
-(void)setVersionModel:(XPVersionUpdateModel *)versionModel{
_versionModel = versionModel;
_versionView.text = _versionModel.updateVersion;
_textView.text = _versionModel.updateVersionDesc;
_cancelBtn.hidden = _versionModel.updateStatus == 3;
if(_versionModel.updateStatus == 3){
[self.updateBtn mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.bgImageView.mas_bottom).mas_offset(-21.5);
}];
}
}
-(void)updateAction{
@@ -122,92 +84,57 @@
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
if(self.versionModel.updateStatus != 3){
[self removeFromSuperview];
[TTPopup dismiss];
}
}];
}
}
-(void)cancelAction{
[self removeFromSuperview];
[TTPopup dismiss];
}
#pragma mark -
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisHorizontal;
_stackView.distribution = UIStackViewDistributionFill;
_stackView.alignment = UIStackViewAlignmentFill;
_stackView.spacing = 10;
}
return _stackView;
}
- (UIImageView *)bgImageView{
if (!_bgImageView){
_bgImageView = [UIImageView new];
_bgImageView.backgroundColor = [UIColor clearColor];
_bgImageView.userInteractionEnabled = YES;
_bgImageView.image = [UIImage imageNamed:@"version_update_bg"];
}
return _bgImageView;
}
- (UIImageView *)bgheadImageView{
if (!_bgheadImageView){
_bgheadImageView = [UIImageView new];
_bgheadImageView.image = [UIImage imageNamed:@"tab_upgrade_head_view"];
_bgheadImageView.userInteractionEnabled = YES;
}
return _bgheadImageView;
}
-(UIImageView *)bgFooderImageView{
if (!_bgFooderImageView){
_bgFooderImageView = [UIImageView new];
UIImage *image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFFFFFF),UIColorFromRGB(0xFFFFFF),UIColorFromRGB(0xE1FCFF)] gradientType:GradientTypeTopToBottom imgSize:CGSizeMake(250, 227)];
_bgFooderImageView.image = image;
_bgFooderImageView.userInteractionEnabled = YES;
[_bgFooderImageView setCornerWithLeftTopCorner:0 rightTopCorner:0 bottomLeftCorner:25 bottomRightCorner:25 size:CGSizeMake(250, 227)];
}
return _bgFooderImageView;
}
- (UIView *)titleBgView{
if (!_titleBgView){
_titleBgView = [UIView new];
_titleBgView.backgroundColor = [UIColor whiteColor];
}
return _titleBgView;
}
- (UILabel *)titleView{
if (!_titleView){
_titleView = [[UILabel alloc] init];
_titleView.text = @"";
_titleView.font = [UIFont systemFontOfSize:17 weight:UIFontWeightBold];
// _titleView.textColor = [ThemeColor inputTextColor];
// labelInitWithText:XCLocalizedString(@"XPUpgradeView0") font:[UIFont systemFontOfSize:17 weight:UIFontWeightBold] textColor:[ThemeColor inputTextColor]];
_titleView.textAlignment = NSTextAlignmentCenter;
}
return _titleView;
}
-(UILabel *)versionView{
if (!_versionView){
_versionView = [[UILabel alloc] init];
_versionView.text = @"";
_versionView.font = [UIFont systemFontOfSize:15 weight:UIFontWeightBold];
// _versionView = [UILabel labelInitWithText:@"" font:[UIFont systemFontOfSize:15 weight:UIFontWeightBold] textColor:[ThemeColor inputTextColor]];
_versionView.textAlignment = NSTextAlignmentCenter;
}
return _versionView;
}
-(UILabel *)textView{
- (SZTextView *)textView {
if (!_textView) {
_textView = [[UILabel alloc]init];
_textView.textColor = UIColorFromRGB(0x6D6B89);
_textView.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
_textView = [[SZTextView alloc] init];
_textView.textColor = [ThemeColor mainTextColor];
_textView.font = [UIFont systemFontOfSize:12];
_textView.backgroundColor = [UIColor clearColor];
_textView.numberOfLines = 0;
_textView.editable = NO;
}
return _textView;
}
-(UIButton *)updateBtn{
if (!_updateBtn){
UIImage *image = [UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor],[ThemeColor confirmButtonGradientStartColor],[ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(154, 34)];
_updateBtn = [[UIButton alloc] init];
[_updateBtn setTitle:@"" forState:UIControlStateNormal];
UIImage *image = [UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor],[ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
_updateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_updateBtn setTitle:@"记录更新" forState:UIControlStateNormal];
_updateBtn.titleLabel.font = [UIFont systemFontOfSize:14];
_updateBtn.titleLabel.textColor = [UIColor whiteColor];
_updateBtn.titleLabel.textColor = [ThemeColor confirmButtonTextColor];
[_updateBtn setBackgroundImage:image forState:UIControlStateNormal];
// _updateBtn = [UIButton buttonInitWithText:XCLocalizedString(@"XPUpgradeView1") font:kFontRegular(14) textColor:[UIColor whiteColor] image:nil bgImage:image];
_updateBtn.layer.cornerRadius = 34 / 2;
_updateBtn.layer.cornerRadius = 32 / 2;
_updateBtn.layer.masksToBounds = YES;
[_updateBtn addTarget:self action:@selector(updateAction) forControlEvents:UIControlEventTouchUpInside];
}
@@ -215,11 +142,14 @@
}
-(UIButton *)cancelBtn{
if (!_cancelBtn){
_cancelBtn = [[UIButton alloc] init];
[_cancelBtn setTitle:@"" forState:UIControlStateNormal];
_cancelBtn.titleLabel.font = [UIFont systemFontOfSize:12];
_cancelBtn.titleLabel.textColor = [ThemeColor disableButtonTextColor];
// _cancelBtn = [UIButton buttonInitWithText:XCLocalizedString(@"XPUpgradeView2") font:[UIFont systemFontOfSize:12 weight:UIFontWeightRegular] textColor:[ThemeColor disableButtonTextColor] image:nil bgImage:nil];
_cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *image = [UIImage gradientColorImageFromColors:@[[ThemeColor cancelButtonGradientStartColor],[ThemeColor cancelButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
[_cancelBtn setTitle:@"下次再说" forState:UIControlStateNormal];
_cancelBtn.titleLabel.font = [UIFont systemFontOfSize:14];
_cancelBtn.titleLabel.textColor = [ThemeColor cancelButtonTextColor];
[_cancelBtn setBackgroundImage:image forState:UIControlStateNormal];
_cancelBtn.layer.cornerRadius = 32 / 2;
_cancelBtn.layer.masksToBounds = YES;
[_cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
}
return _cancelBtn;