内更新弹窗
This commit is contained in:
@@ -236,6 +236,8 @@
|
||||
9B9DFD9A27DB2194000F95B3 /* XPSessionMessageHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B9DFD9927DB2194000F95B3 /* XPSessionMessageHeadView.m */; };
|
||||
9B9EEF4E27C8755C006B0EB3 /* XPSkillCardResourcePropModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B9EEF4D27C8755C006B0EB3 /* XPSkillCardResourcePropModel.m */; };
|
||||
9B9EEF5427C8AFEA006B0EB3 /* XPSkillCardRecordPropModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B9EEF5327C8AFEA006B0EB3 /* XPSkillCardRecordPropModel.m */; };
|
||||
9BA3B40B293DCDFD0071DF1C /* XPVersionUpdateModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BA3B40A293DCDFD0071DF1C /* XPVersionUpdateModel.m */; };
|
||||
9BA3B40F293DD2F90071DF1C /* XPUpgradeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BA3B40E293DD2F90071DF1C /* XPUpgradeView.m */; };
|
||||
9BA708A12823D4C900C474A2 /* LittleGameScrollStageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BA708A02823D4C900C474A2 /* LittleGameScrollStageView.m */; };
|
||||
9BA812D228BF145700783EA7 /* ClientRedPacketModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BA812D128BF145700783EA7 /* ClientRedPacketModel.m */; };
|
||||
9BA812D628BF52E100783EA7 /* XPRoomSendRedPacketViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BA812D528BF52E100783EA7 /* XPRoomSendRedPacketViewController.m */; };
|
||||
@@ -1684,6 +1686,10 @@
|
||||
9B9EEF4D27C8755C006B0EB3 /* XPSkillCardResourcePropModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPSkillCardResourcePropModel.m; sourceTree = "<group>"; };
|
||||
9B9EEF5227C8AFEA006B0EB3 /* XPSkillCardRecordPropModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPSkillCardRecordPropModel.h; sourceTree = "<group>"; };
|
||||
9B9EEF5327C8AFEA006B0EB3 /* XPSkillCardRecordPropModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPSkillCardRecordPropModel.m; sourceTree = "<group>"; };
|
||||
9BA3B409293DCDFD0071DF1C /* XPVersionUpdateModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPVersionUpdateModel.h; sourceTree = "<group>"; };
|
||||
9BA3B40A293DCDFD0071DF1C /* XPVersionUpdateModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPVersionUpdateModel.m; sourceTree = "<group>"; };
|
||||
9BA3B40D293DD2F90071DF1C /* XPUpgradeView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPUpgradeView.h; sourceTree = "<group>"; };
|
||||
9BA3B40E293DD2F90071DF1C /* XPUpgradeView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPUpgradeView.m; sourceTree = "<group>"; };
|
||||
9BA7089F2823D4C900C474A2 /* LittleGameScrollStageView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LittleGameScrollStageView.h; sourceTree = "<group>"; };
|
||||
9BA708A02823D4C900C474A2 /* LittleGameScrollStageView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LittleGameScrollStageView.m; sourceTree = "<group>"; };
|
||||
9BA812D028BF145700783EA7 /* ClientRedPacketModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ClientRedPacketModel.h; sourceTree = "<group>"; };
|
||||
@@ -4780,6 +4786,15 @@
|
||||
name = "Recovered References";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9BA3B40C293DD2E00071DF1C /* VersionUpdate */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9BA3B40D293DD2F90071DF1C /* XPUpgradeView.h */,
|
||||
9BA3B40E293DD2F90071DF1C /* XPUpgradeView.m */,
|
||||
);
|
||||
path = VersionUpdate;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9BA812D328BF52A500783EA7 /* SendRedPacket */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -7751,6 +7766,7 @@
|
||||
E8B3E8042848B842009746AB /* View */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9BA3B40C293DD2E00071DF1C /* VersionUpdate */,
|
||||
9B53D57728E2CEE8005187A3 /* Teenager */,
|
||||
9BFB101C2897CC3300B3985E /* AnchorCard */,
|
||||
9BFB10172897C95200B3985E /* NewUserRecharge */,
|
||||
@@ -7781,6 +7797,8 @@
|
||||
9BE01AEF2893E31700B50299 /* NewUserRechargeModel.m */,
|
||||
9BFB10202897D68400B3985E /* XPTabAnchorCardModel.h */,
|
||||
9BFB10212897D68400B3985E /* XPTabAnchorCardModel.m */,
|
||||
9BA3B409293DCDFD0071DF1C /* XPVersionUpdateModel.h */,
|
||||
9BA3B40A293DCDFD0071DF1C /* XPVersionUpdateModel.m */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
@@ -9489,6 +9507,7 @@
|
||||
9B2A12D82783F42300CED41B /* XPNoblePrivilegeContentCell.m in Sources */,
|
||||
189DD53426DE255300AB55B1 /* TabbarViewController.m in Sources */,
|
||||
E81EF6E4279AB92E00FF3EDE /* LittleGameInfoModel.m in Sources */,
|
||||
9BA3B40B293DCDFD0071DF1C /* XPVersionUpdateModel.m in Sources */,
|
||||
E87A26F927587C62002DDC7A /* XPHomeContainerPresenter.m in Sources */,
|
||||
9B88E21228C6365B00D26FBA /* XPHomeSearchRecordCell.m in Sources */,
|
||||
18EE401A2754BA9F00A452BF /* NIMMessageMaker.m in Sources */,
|
||||
@@ -9521,6 +9540,7 @@
|
||||
9BE01ACE28925F7D00B50299 /* XPMineNewUserRechargeView.m in Sources */,
|
||||
E83ABF03280EC90C00322EE4 /* ContentApplicationShareModel.m in Sources */,
|
||||
9BA812E028BF6ABB00783EA7 /* Api+RedPacket.m in Sources */,
|
||||
9BA3B40F293DD2F90071DF1C /* XPUpgradeView.m in Sources */,
|
||||
E81A654928351B9500F55894 /* XPMonentsRecommendHeaderView.m in Sources */,
|
||||
E84B0E3F2727EDF6008818C6 /* XPRoomMessageTableViewCell.m in Sources */,
|
||||
E8E5E18B27C332EE00F457D8 /* XPHomeViewController.m in Sources */,
|
||||
|
@@ -21,7 +21,8 @@ typedef NS_ENUM(NSInteger, XPMineSettingItemType){
|
||||
XPMineSettingItemType_Helper,///帮助
|
||||
XPMineSettingItemType_Feedback,//我要反馈
|
||||
XPMineSettingItemType_Clear_Memory,///清楚缓存
|
||||
XPMineSettingItemType_About_Us,///关于我们
|
||||
XPMineSettingItemType_About_Us,///关于我们
|
||||
XPMineSettingItemType_CheckUpdate,///检查更新
|
||||
};
|
||||
|
||||
@interface XPMineSettingItemModel : NSObject
|
||||
|
@@ -21,6 +21,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// 退出当前账号
|
||||
- (void)logoutCurrentAccount;
|
||||
|
||||
///获取版本更新
|
||||
- (void)getVersionUpdate;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -14,6 +14,9 @@
|
||||
#import "UserInfoModel.h"
|
||||
#import "AccountModel.h"
|
||||
#import "XPMineSettingItemModel.h"
|
||||
#import "YYUtility.h"
|
||||
#import "XPVersionUpdateModel.h"
|
||||
#import "Api+Main.h"
|
||||
///Tool
|
||||
#import "AccountInfoStorage.h"
|
||||
#import "XPRoomMiniManager.h"
|
||||
@@ -93,6 +96,11 @@
|
||||
clearMemoryItem.subTitle = @"";
|
||||
clearMemoryItem.type = XPMineSettingItemType_Clear_Memory;
|
||||
|
||||
XPMineSettingItemModel *updateItem = [[XPMineSettingItemModel alloc] init];
|
||||
updateItem.title = @"检查更新";
|
||||
updateItem.subTitle = @"";
|
||||
updateItem.type = XPMineSettingItemType_CheckUpdate;
|
||||
|
||||
XPMineSettingItemModel * aboutusItem = [[XPMineSettingItemModel alloc] init];
|
||||
aboutusItem.title = [NSString stringWithFormat:@"关于%@", AppName];
|
||||
aboutusItem.subTitle = @"";
|
||||
@@ -101,7 +109,7 @@
|
||||
NSArray * oneSection = @[phoneItem];
|
||||
NSArray * twoSection = @[loginItem,payItem, notificaItem, blackListItem];
|
||||
NSArray * threeSection = @[privacyItem];
|
||||
NSArray * fourthSection = @[helperItem, feedbackItem, clearMemoryItem, aboutusItem];
|
||||
NSArray * fourthSection = @[helperItem, feedbackItem, clearMemoryItem, updateItem, aboutusItem];
|
||||
|
||||
self.datasouce = @[oneSection, twoSection, threeSection, fourthSection];
|
||||
}
|
||||
@@ -142,5 +150,18 @@
|
||||
[self logout];
|
||||
}
|
||||
|
||||
#pragma mark - 版本更新
|
||||
-(void)getVersionUpdate{
|
||||
NSString *appVersion = [YYUtility appVersion];
|
||||
NSString *os = @"ios";
|
||||
NSString *channel = [YYUtility getAppSource];
|
||||
[Api requestVersionUpdate:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
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];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -9,6 +9,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class XPVersionUpdateModel;
|
||||
@protocol XPMineSettingProtocol <NSObject>
|
||||
|
||||
/// 获取数据成功
|
||||
@@ -17,6 +18,12 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo;
|
||||
///退出当前账号成功
|
||||
- (void)logoutCurrentAccountSuccess;
|
||||
|
||||
///版本更新接口失败
|
||||
- (void)getVersionUpdateFail;
|
||||
///版本更新
|
||||
-(void)getVersionUpdate:(XPVersionUpdateModel *)model;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -16,13 +16,16 @@
|
||||
#import "XPMacro.h"
|
||||
#import "NSArray+Safe.h"
|
||||
#import "XPHtmlUrl.h"
|
||||
#import "YYUtility.h"
|
||||
///Model
|
||||
#import "XPMineSettingItemModel.h"
|
||||
#import "UserInfoModel.h"
|
||||
#import "XPVersionUpdateModel.h"
|
||||
///View
|
||||
#import "XPMineSettingTableViewCell.h"
|
||||
#import "TTAlertConfig.h"
|
||||
#import "TTPopup.h"
|
||||
#import "XPUpgradeView.h"
|
||||
///P
|
||||
#import "XPMineSettingPresent.h"
|
||||
#import "XPMineSettingProtocol.h"
|
||||
@@ -196,7 +199,12 @@
|
||||
[self.navigationController pushViewController:aboutusVC animated:YES];
|
||||
}
|
||||
break;
|
||||
|
||||
case XPMineSettingItemType_CheckUpdate:
|
||||
{
|
||||
[self showLoading];
|
||||
[self.presenter getVersionUpdate];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -280,6 +288,37 @@
|
||||
[self.navigationController popToRootViewControllerAnimated:NO];
|
||||
}
|
||||
|
||||
- (void)getVersionUpdateFail{
|
||||
[self hideHUD];
|
||||
}
|
||||
///版本更新
|
||||
-(void)getVersionUpdate:(XPVersionUpdateModel *)model{
|
||||
[self hideHUD];
|
||||
if(model.updateVersion.length == 0){
|
||||
[self showErrorToast:@"目前已更新到最新版本"];
|
||||
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){
|
||||
[self showErrorToast:@"目前已更新到最新版本"];
|
||||
return;
|
||||
}
|
||||
XPUpgradeView *view = [[XPUpgradeView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
||||
view.versionModel = model;
|
||||
[[UIApplication sharedApplication].keyWindow addSubview:view];
|
||||
}
|
||||
|
||||
#pragma mark - Event Response
|
||||
- (void)logoutButtonAction:(UIButton *)sender {
|
||||
[self.presenter logoutCurrentAccount];
|
||||
|
@@ -43,6 +43,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// @param completion 完成
|
||||
+ (void)requestAnchorCardInfo:(HttpRequestHelperCompletion)completion;
|
||||
|
||||
/// 获取版本更新
|
||||
/// @param compltion 完成
|
||||
/// @param appVersion 当前版本
|
||||
/// @param os os
|
||||
/// @param channel cannel
|
||||
+ (void)requestVersionUpdate:(HttpRequestHelperCompletion)completion appVersion:(NSString *)appVersion os:(NSString *)os channel:(NSString *)channel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -83,4 +83,13 @@
|
||||
[self makeRequest:@"user/get/userCard" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, nil];
|
||||
}
|
||||
|
||||
/// 获取版本更新
|
||||
/// @param completion 完成
|
||||
/// @param appVersion 当前版本
|
||||
/// @param os os
|
||||
/// @param channel cannel
|
||||
+ (void)requestVersionUpdate:(HttpRequestHelperCompletion)completion appVersion:(NSString *)appVersion os:(NSString *)os channel:(NSString *)channel {
|
||||
[self makeRequest:@"version/getNewestVersion" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, appVersion, os, channel, nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
32
xplan-ios/Main/Tabbar/Model/XPVersionUpdateModel.h
Normal file
32
xplan-ios/Main/Tabbar/Model/XPVersionUpdateModel.h
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// XPVersionUpdateModel.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/12/5.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPVersionUpdateModel : NSObject
|
||||
@property (nonatomic,copy) NSString *os;
|
||||
@property (nonatomic,copy) NSString *version;
|
||||
@property (nonatomic,assign) int status;
|
||||
@property (nonatomic,copy) NSString *updateVersionDesc;
|
||||
@property (nonatomic,copy) NSString *updateVersion;
|
||||
@property (nonatomic,copy) NSString *updateDownloadLink;
|
||||
@property (nonatomic,copy) NSString *updateFileMd5;
|
||||
@property (nonatomic,assign)int updateStatus;
|
||||
@property (nonatomic,copy) NSString *updateOs;
|
||||
|
||||
@end
|
||||
@interface XPVersionUpdateItemModel : NSObject
|
||||
@property (nonatomic,copy) NSString *version;
|
||||
@property (nonatomic,copy) NSString *time;
|
||||
@property (nonatomic,copy) NSString *num;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
17
xplan-ios/Main/Tabbar/Model/XPVersionUpdateModel.m
Normal file
17
xplan-ios/Main/Tabbar/Model/XPVersionUpdateModel.m
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// XPVersionUpdateModel.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/12/5.
|
||||
//
|
||||
|
||||
#import "XPVersionUpdateModel.h"
|
||||
|
||||
@implementation XPVersionUpdateModel
|
||||
|
||||
@end
|
||||
|
||||
@implementation XPVersionUpdateItemModel
|
||||
|
||||
@end
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#import "BaseMvpPresenter.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class XPVersionUpdateModel;
|
||||
@interface MainPresenter : BaseMvpPresenter
|
||||
|
||||
- (void)autoLogin;
|
||||
@@ -35,6 +35,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
///获取主播卡片信息
|
||||
- (void)getAnchorCardInfo;
|
||||
|
||||
///获取版本更新
|
||||
- (void)getVersionUpdate;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@@ -17,6 +17,10 @@
|
||||
#import "NewUserGreetModel.h"
|
||||
#import "NewUserRechargeModel.h"
|
||||
#import "XPTabAnchorCardModel.h"
|
||||
#import "YYUtility.h"
|
||||
#import "XPVersionUpdateModel.h"
|
||||
|
||||
static NSString * kUpdateVersionNum = @"kUpdateVersionNum";
|
||||
|
||||
@implementation MainPresenter
|
||||
|
||||
@@ -123,4 +127,90 @@
|
||||
} errorToast:NO]];
|
||||
}
|
||||
|
||||
#pragma mark - 版本更新
|
||||
-(void)getVersionUpdate{
|
||||
NSString *appVersion = [YYUtility appVersion];
|
||||
NSString *os = @"ios";
|
||||
NSString *channel = [YYUtility getAppSource];
|
||||
[Api requestVersionUpdate:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
XPVersionUpdateModel *model = [XPVersionUpdateModel modelWithDictionary:data.data];
|
||||
if([MainPresenter isUpdateVersion:model] == NO) return;
|
||||
[[self getView] getVersionUpdate:model];
|
||||
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
||||
NSLog(@"%@", msg);
|
||||
} errorToast:NO] appVersion:appVersion os:os channel:channel];
|
||||
}
|
||||
|
||||
+(BOOL)isUpdateVersion:(XPVersionUpdateModel *)versionModel{
|
||||
if(versionModel.updateStatus == 1 || versionModel.updateStatus == 2)return NO;
|
||||
if(versionModel.updateStatus == 3)return YES;
|
||||
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 = versionModel.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)return NO;
|
||||
NSDictionary *appVersionDic = [[NSUserDefaults standardUserDefaults]valueForKey:kUpdateVersionNum];
|
||||
if(appVersionDic == nil){
|
||||
[self saveDataWithVersion:versionModel.updateVersion updateVersionList:@[]];
|
||||
|
||||
return YES;
|
||||
};
|
||||
NSMutableDictionary *getAppVersionDic = [[NSMutableDictionary alloc]initWithDictionary:appVersionDic];
|
||||
NSArray *updateVersionDic = getAppVersionDic[versionModel.updateVersion];
|
||||
if(updateVersionDic == nil){
|
||||
[self saveDataWithVersion:versionModel.updateVersion updateVersionList:@[]];
|
||||
return YES;
|
||||
};
|
||||
NSArray<XPVersionUpdateItemModel *> *itemModelList = [XPVersionUpdateItemModel modelsWithArray:updateVersionDic];
|
||||
if(itemModelList.count >= 3)return NO;
|
||||
BOOL isDayUpdate = NO;
|
||||
for (XPVersionUpdateItemModel *itemModel in itemModelList){
|
||||
if([itemModel.time isEqualToString:[MainPresenter GetCurrentTime]]){
|
||||
isDayUpdate = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(isDayUpdate == YES)return NO;
|
||||
[self saveDataWithVersion:versionModel.updateVersion updateVersionList:updateVersionDic];
|
||||
return YES;
|
||||
|
||||
}
|
||||
|
||||
+(void)saveDataWithVersion:(NSString *)version updateVersionList:(NSArray *)list{
|
||||
if(version == nil)return;
|
||||
XPVersionUpdateItemModel *itemModel = [XPVersionUpdateItemModel new];
|
||||
itemModel.time = [MainPresenter GetCurrentTime];
|
||||
itemModel.version = version;
|
||||
itemModel.num = @"1";
|
||||
NSMutableArray *getUpdateVersionList = [NSMutableArray arrayWithArray:list];
|
||||
[getUpdateVersionList addObject:[itemModel model2dictionary]];
|
||||
|
||||
NSDictionary *appVersionDic = [[NSUserDefaults standardUserDefaults]valueForKey:kUpdateVersionNum];
|
||||
NSMutableDictionary *saveDic;
|
||||
if(appVersionDic == nil){
|
||||
saveDic = [NSMutableDictionary dictionary];
|
||||
}else{
|
||||
saveDic = [NSMutableDictionary dictionaryWithDictionary:appVersionDic];
|
||||
}
|
||||
[saveDic setObject:getUpdateVersionList forKey:version];
|
||||
[[NSUserDefaults standardUserDefaults]setObject:saveDic forKey:kUpdateVersionNum];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
+ (NSString *)GetCurrentTime{
|
||||
NSDate *now = [NSDate date];
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
|
||||
formatter.dateFormat = @"yyyy-MM-dd";
|
||||
NSString *dateStr = [formatter stringFromDate:now];
|
||||
return dateStr;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "UserInfoModel.h"
|
||||
@class InviteUserInfoModel, NewUserGreetModel, NewUserRechargeModel, XPTabAnchorCardModel;
|
||||
@class InviteUserInfoModel, NewUserGreetModel, NewUserRechargeModel, XPTabAnchorCardModel, XPVersionUpdateModel;
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol MainProtocol <NSObject>
|
||||
@@ -28,6 +28,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
///获取主播卡片信息成功
|
||||
- (void)getAnchorCardInfoSuccess:(XPTabAnchorCardModel *)cardInfo;
|
||||
|
||||
///获取更新版本信息成功
|
||||
- (void)getVersionUpdate:(XPVersionUpdateModel *)versionModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -6,7 +6,6 @@
|
||||
//
|
||||
#import <UIKit/UIKit.h>
|
||||
///Third
|
||||
#import <flutter_boost/FlutterBoost.h>
|
||||
#import <ReactiveObjC/ReactiveObjC.h>
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
#import <Masonry/Masonry.h>
|
||||
@@ -44,6 +43,7 @@
|
||||
#import "MonentsUnReadModel.h"
|
||||
#import "XPReceiveRedPacketModel.h"
|
||||
#import "XPRoomGiftBroadCastModel.h"
|
||||
#import "XPVersionUpdateModel.h"
|
||||
///VC
|
||||
#import "TabbarViewController.h"
|
||||
#import "BaseViewController.h"
|
||||
@@ -72,6 +72,7 @@
|
||||
#import "XPMonentsViewController.h"
|
||||
#import "XPReceiveRedPacketView.h"
|
||||
#import "XPRoomYearActivityView.h"
|
||||
#import "XPUpgradeView.h"
|
||||
///Present
|
||||
#import "MainPresenter.h"
|
||||
#import "MainProtocol.h"
|
||||
@@ -133,6 +134,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showNewUserRecharge) name:kNewUserRechargeKey object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showAnchorCardKey:) name:kTabShowAnchorCardKey object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(teenagerStatusChange:) name:kTeenagerStatusChange object:nil];
|
||||
[self.presenter getVersionUpdate];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
@@ -304,6 +306,16 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
}
|
||||
}
|
||||
|
||||
///获取更新版本信息成功
|
||||
- (void)getVersionUpdate:(XPVersionUpdateModel *)versionModel {
|
||||
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC));
|
||||
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
|
||||
XPUpgradeView *view = [[XPUpgradeView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
||||
view.versionModel = versionModel;
|
||||
[[UIApplication sharedApplication].keyWindow addSubview:view];
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - NIMLoginManagerDelegate
|
||||
- (void)onAutoLoginFailed:(NSError *)error {
|
||||
// 如果非上次登录设备 autoLogin 会返回 417
|
||||
|
19
xplan-ios/Main/Tabbar/View/VersionUpdate/XPUpgradeView.h
Normal file
19
xplan-ios/Main/Tabbar/View/VersionUpdate/XPUpgradeView.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// XPUpgradeView.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/12/5.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "XPVersionUpdateModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPUpgradeView : UIView
|
||||
|
||||
@property (nonatomic,strong) XPVersionUpdateModel *versionModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
229
xplan-ios/Main/Tabbar/View/VersionUpdate/XPUpgradeView.m
Normal file
229
xplan-ios/Main/Tabbar/View/VersionUpdate/XPUpgradeView.m
Normal file
@@ -0,0 +1,229 @@
|
||||
//
|
||||
// XPUpgradeView.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/12/5.
|
||||
//
|
||||
|
||||
#import "XPUpgradeView.h"
|
||||
#import <Masonry/Masonry.h>
|
||||
#import "UIImage+Utils.h"
|
||||
#import "XPMacro.h"
|
||||
#import "ThemeColor.h"
|
||||
#import "UIView+Corner.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) UIButton *updateBtn;
|
||||
@property (nonatomic,strong) UIButton *cancelBtn;
|
||||
@end
|
||||
|
||||
@implementation XPUpgradeView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame{
|
||||
self = [super initWithFrame:frame];
|
||||
if(self){
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (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];
|
||||
}
|
||||
- (void)initSubViewConstraints {
|
||||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.equalTo(self);
|
||||
make.width.mas_equalTo(279);
|
||||
make.height.mas_greaterThanOrEqualTo(348);
|
||||
}];
|
||||
[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.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);
|
||||
}];
|
||||
[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);
|
||||
}];
|
||||
|
||||
[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);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
-(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{
|
||||
NSURL *url = [[NSURL alloc]initWithString:self.versionModel.updateDownloadLink];
|
||||
if ([[UIApplication sharedApplication] canOpenURL:url]) {
|
||||
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
|
||||
if(self.versionModel.updateStatus != 3){
|
||||
[self removeFromSuperview];
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
-(void)cancelAction{
|
||||
[self removeFromSuperview];
|
||||
}
|
||||
#pragma mark - 懒加载
|
||||
|
||||
- (UIImageView *)bgImageView{
|
||||
if (!_bgImageView){
|
||||
_bgImageView = [UIImageView new];
|
||||
_bgImageView.backgroundColor = [UIColor clearColor];
|
||||
_bgImageView.userInteractionEnabled = YES;
|
||||
}
|
||||
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{
|
||||
if (!_textView){
|
||||
_textView = [[UILabel alloc]init];
|
||||
_textView.textColor = UIColorFromRGB(0x6D6B89);
|
||||
_textView.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
|
||||
_textView.backgroundColor = [UIColor clearColor];
|
||||
_textView.numberOfLines = 0;
|
||||
|
||||
}
|
||||
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];
|
||||
_updateBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
_updateBtn.titleLabel.textColor = [UIColor whiteColor];
|
||||
[_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.masksToBounds = YES;
|
||||
[_updateBtn addTarget:self action:@selector(updateAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _updateBtn;
|
||||
}
|
||||
-(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 addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _cancelBtn;
|
||||
|
||||
}
|
||||
|
||||
@end
|
Reference in New Issue
Block a user