diff --git a/YuMi/Appdelegate/AppDelegate.m b/YuMi/Appdelegate/AppDelegate.m index 4ba89197..96f40a13 100644 --- a/YuMi/Appdelegate/AppDelegate.m +++ b/YuMi/Appdelegate/AppDelegate.m @@ -36,16 +36,28 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - ///初始化一些 sdk配置 + self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; + + UIStoryboard *launchStoryboard = [UIStoryboard storyboardWithName:@"Launch Screen" bundle:nil]; + UIViewController *launchScreenVC = [launchStoryboard instantiateInitialViewController]; + self.window.rootViewController = launchScreenVC; + [self.window makeKeyAndVisible]; + + + ///初始化一些 sdk配置 [self initThirdConfig]; [self initUM:application launchOptions:launchOptions]; - self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; - [self.window makeKeyAndVisible]; - - [self loadMainPage]; - [self setupLaunchADView]; + @kWeakify(self); + [[ClientConfig shareConfig] clientConfig:^{ + @kStrongify(self); + dispatch_async(dispatch_get_main_queue(), ^{ + [self loadMainPage]; + [self setupLaunchADView]; + }); + }]; + return YES; } diff --git a/YuMi/Config/ClientConfig.h b/YuMi/Config/ClientConfig.h index 91bc12af..37ea79e3 100644 --- a/YuMi/Config/ClientConfig.h +++ b/YuMi/Config/ClientConfig.h @@ -14,12 +14,18 @@ NS_ASSUME_NONNULL_BEGIN ///初始化 - (void)clientInit; +/// 获取 UI 配置 +- (void)clientConfig:(void(^)(void))finish; + /// iOS第三方登录是否需要绑定手机号 @property (nonatomic,assign) BOOL iOSPhoneBind; /// 是否开启了糖果树 @property (nonatomic,assign) BOOL openCandyTree; ///配置信息 @property (nonatomic,strong) ClientDataModel *configInfo; + +@property (nonatomic, strong) AppUISetting *uiSetting; + ///开箱子 大于等级 展示 @property (nonatomic, assign) NSInteger openCandyTreeLimitLevel; @@ -46,14 +52,19 @@ NS_ASSUME_NONNULL_BEGIN - (UIColor *)bgColor; -- (UIImage *)navBGImage; -- (UIImage *)tabbarBGImage; - (NSString *)tabName:(NSInteger)tabIndex; - (NSString *)tabNormalImage:(NSInteger)tabIndex; - (NSString *)tabSelectedImage:(NSInteger)tabIndex; +- (UIImage *)tabNormalImageImage:(NSInteger)tabIndex; +- (UIImage *)tabSelectedImageImage:(NSInteger)tabIndex; @property (nonatomic, copy) NSString *reloadNavigationAreaImageKey; +@property (nonatomic, copy) NSString *reloadViewBackgroundColorKey; + @property (nonatomic, strong) UIImage *navigationAreaBG; +@property (nonatomic, strong) UIImage *tabbarBGImage; + +- (void)loadTabImages; @property (nonatomic, copy) void(^updateTabbarBG)(UIImage *image); @property (nonatomic, copy) void(^updateNormalTabImage)(UIImage *normalImage, NSInteger index); diff --git a/YuMi/Config/ClientConfig.m b/YuMi/Config/ClientConfig.m index 4783f8df..d3ae89d1 100644 --- a/YuMi/Config/ClientConfig.m +++ b/YuMi/Config/ClientConfig.m @@ -42,6 +42,7 @@ config = [[ClientConfig alloc] init]; config.isTF = [ClientConfig isTestFlight]; config.reloadNavigationAreaImageKey = @"今天光线很好"; + config.reloadViewBackgroundColorKey = @"年轻人买不起:美国买房平均年龄飙升至56岁"; }); return config; } @@ -105,9 +106,6 @@ self.configInfo = model; [[NSNotificationCenter defaultCenter] postNotificationName:@"reloadAfterLoadConfig" object:nil]; - - [self prepareCustomUI]; - } else { if (self.retryCount < 10) { [self clientInit]; @@ -117,44 +115,45 @@ }]; } +- (void)clientConfig:(void(^)(void))finish { + @kWeakify(self); + [Api clientConfig:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + @kStrongify(self); + if (code == 200) { + self.uiSetting = [AppUISetting modelWithJSON:data.data[@"appUiSetting"]]; + } + [self prepareCustomUI]; + if (finish) { + finish(); + } + }]; +} + +- (void)loadTabImages { + [self loadNormalTabImage:0]; + [self loadSelectedTabImage:0]; +} + - (void)prepareCustomUI { NSArray *defaultArray = @[@"", @"", @"", @"", @""]; self.normalTabImageSource = defaultArray.mutableCopy; self.selectedTabImageSource = defaultArray.mutableCopy; -#if DEBUG - self.configInfo.appUiSetting.homeSelectIcon = @"https://cdn-icons-png.flaticon.com/128/18174/18174161.png"; - self.configInfo.appUiSetting.homeUnSelectIcon = @""; - self.configInfo.appUiSetting.gameSelectIcon = @""; - self.configInfo.appUiSetting.gameUnSelectIcon = @"https://cdn-icons-png.flaticon.com/128/18174/18174164.png"; - self.configInfo.appUiSetting.dynamicSelectIcon = @"https://cdn-icons-png.flaticon.com/128/18174/18174165.png"; - self.configInfo.appUiSetting.dynamicUnSelectIcon = @"https://cdn-icons-png.flaticon.com/128/18174/18174166.png"; - self.configInfo.appUiSetting.msgSelectIcon = @""; - self.configInfo.appUiSetting.msgUnSelectIcon = @"https://cdn-icons-png.flaticon.com/128/18174/18174168.png"; - self.configInfo.appUiSetting.mineSelectIcon = @"https://cdn-icons-png.flaticon.com/128/18174/18174169.png"; - self.configInfo.appUiSetting.mineUnSelectIcon = @" "; - - self.configInfo.appUiSetting.headIcon = @"https://wx1.moyu.im/mw2000/4e093a49ly1hvbccotkj8j23jm2g8e84.jpg"; - self.configInfo.appUiSetting.navbar = @"https://wx2.moyu.im/mw600/008ElFOcly1hvbe8wq5tkj318g0totuv.jpg"; - - self.configInfo.appUiSetting.settingStatus = arc4random()%2; -#endif - - if (self.configInfo && self.configInfo.appUiSetting && self.configInfo.appUiSetting.settingStatus == 1) { + if (self.uiSetting) { NSArray *unselectIcons = @[ - self.configInfo.appUiSetting.homeUnSelectIcon ?: @"", - self.configInfo.appUiSetting.gameUnSelectIcon ?: @"", - self.configInfo.appUiSetting.dynamicUnSelectIcon ?: @"", - self.configInfo.appUiSetting.msgUnSelectIcon ?: @"", - self.configInfo.appUiSetting.mineUnSelectIcon ?: @"" + self.uiSetting.homeUnSelectIcon ?: @"", + self.uiSetting.gameUnSelectIcon ?: @"", + self.uiSetting.dynamicUnSelectIcon ?: @"", + self.uiSetting.msgUnSelectIcon ?: @"", + self.uiSetting.mineUnSelectIcon ?: @"" ]; NSArray *selectIcons = @[ - self.configInfo.appUiSetting.homeSelectIcon ?: @"", - self.configInfo.appUiSetting.gameSelectIcon ?: @"", - self.configInfo.appUiSetting.dynamicSelectIcon ?: @"", - self.configInfo.appUiSetting.msgSelectIcon ?: @"", - self.configInfo.appUiSetting.mineSelectIcon ?: @"" + self.uiSetting.homeSelectIcon ?: @"", + self.uiSetting.gameSelectIcon ?: @"", + self.uiSetting.dynamicSelectIcon ?: @"", + self.uiSetting.msgSelectIcon ?: @"", + self.uiSetting.mineSelectIcon ?: @"" ]; self.normalTabImageSource = unselectIcons.mutableCopy; @@ -162,14 +161,12 @@ [self loadNavigationAreaBG]; [self loadTabbarBG]; + [self loadBGColor]; } else { if (self.updateTabbarBG) { self.updateTabbarBG(kImage(@"tab_bar_bg")); } } - - [self loadNormalTabImage:0]; - [self loadSelectedTabImage:0]; } - (UIImage *)navigationAreaBG { @@ -186,7 +183,7 @@ } @kWeakify(self); - [self.navigationAreaBGImageLoader loadImageWithUrl:self.configInfo.appUiSetting.headIcon + [self.navigationAreaBGImageLoader loadImageWithUrl:self.uiSetting.headIcon completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) { @kStrongify(self); self.navigationAreaBG = image; @@ -201,9 +198,10 @@ } @kWeakify(self); - [self.tabbarBGImageLoader loadImageWithUrl:self.configInfo.appUiSetting.navbar + [self.tabbarBGImageLoader loadImageWithUrl:self.uiSetting.navbar completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) { @kStrongify(self); + self.tabbarBGImage = image; if (self.updateTabbarBG) { self.updateTabbarBG(image); } @@ -220,41 +218,36 @@ return; } - NSString *normalURLString = self.normalTabImageSource[index]; - if ([normalURLString isEmpty]) { - self.updateNormalTabImage([UIImage imageNamed:[self tabNormalImage:index]], index); - [self loadNormalTabImage:index + 1]; + if (!self.updateNormalTabImage) { return; } - - dispatch_group_t downloadGroup = dispatch_group_create(); + NSString *normalURLString = self.normalTabImageSource[index]; + if ([NSString isEmpty:normalURLString]) { + self.updateNormalTabImage([UIImage imageNamed:[self _tabNormalImage:index]], index); + [self loadNormalTabImage:index + 1]; + return; + } __block UIImage *normalImage = nil; - if (!self.normalTabImageLoader) { - self.normalTabImageLoader = [[NetImageView alloc] init]; + if (!_normalTabImageLoader) { + _normalTabImageLoader = [[NetImageView alloc] init]; } - - dispatch_group_enter(downloadGroup); + @kWeakify(self); [self.normalTabImageLoader loadImageWithUrl:normalURLString completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) { normalImage = image; - dispatch_group_leave(downloadGroup); - } - fail:^(NSError * _Nonnull error) { - dispatch_group_leave(downloadGroup); - }]; - - // 当两个图片都下载完成后回调 - @kWeakify(self); - dispatch_group_notify(downloadGroup, dispatch_get_main_queue(), ^{ @kStrongify(self); if (normalImage && self.updateNormalTabImage) { self.updateNormalTabImage([normalImage resizeTo:CGSizeMake(25, 25)], - index); + index); } [self loadNormalTabImage:index + 1]; - }); + } + fail:^(NSError * _Nonnull error) { + @kStrongify(self); + [self loadNormalTabImage:index + 1]; + }]; } - (void)loadSelectedTabImage:(NSInteger)index { @@ -262,40 +255,43 @@ return; } + if (!self.updateSelectedTabImage) { + return; + } + NSString *selectedURLString = self.selectedTabImageSource[index]; - if ([selectedURLString isEmpty]) { - self.updateSelectedTabImage([UIImage imageNamed:[self tabSelectedImage:index]], index); + if ([NSString isEmpty:selectedURLString]) { + self.updateSelectedTabImage([UIImage imageNamed:[self _tabSelectedImage:index]], index); [self loadSelectedTabImage:index + 1]; return; } - dispatch_group_t downloadGroup = dispatch_group_create(); __block UIImage *selectedImage = nil; - if (!self.selectedTabImageLoader) { - self.selectedTabImageLoader = [[NetImageView alloc] init]; + if (!_selectedTabImageLoader) { + _selectedTabImageLoader = [[NetImageView alloc] init]; } - dispatch_group_enter(downloadGroup); + @kWeakify(self); [self.selectedTabImageLoader loadImageWithUrl:selectedURLString completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) { - selectedImage = image; - dispatch_group_leave(downloadGroup); - } - fail:^(NSError * _Nonnull error) { - dispatch_group_leave(downloadGroup); - }]; - - // 当两个图片都下载完成后回调 - @kWeakify(self); - dispatch_group_notify(downloadGroup, dispatch_get_main_queue(), ^{ @kStrongify(self); + selectedImage = image; if (selectedImage && self.updateSelectedTabImage) { self.updateSelectedTabImage([selectedImage resizeTo:CGSizeMake(25, 25)], - index); + index); } [self loadSelectedTabImage:index + 1]; - }); + } + fail:^(NSError * _Nonnull error) { + @kStrongify(self); + [self loadSelectedTabImage:index + 1]; + }]; +} + +- (void)loadBGColor { + [[NSNotificationCenter defaultCenter] postNotificationName:self.reloadNavigationAreaImageKey + object:nil]; } - (void)addHeartBratTimer { @@ -315,29 +311,13 @@ } } - - (UIColor *)bgColor { - if (self.configInfo && self.configInfo.appUiSetting.settingStatus == 1) { - + if (self.uiSetting) { + return [DJDKMIMOMColor colorWithHexString:self.uiSetting.backgroundColor]; } return [DJDKMIMOMColor colorWithHexString:@"#FCF4DF"]; } -- (UIImage *)navBGImage { - if (self.configInfo && self.configInfo.appUiSetting.settingStatus == 1) { - - } - - return nil; -} - -- (UIImage *)tabbarBGImage { - if (self.configInfo && self.configInfo.appUiSetting.settingStatus == 1) { - - } - - return nil; -} - (NSString *)tabName:(NSInteger)tabIndex { return @[YMLocalizedString(@"TabbarViewController2"), @@ -347,7 +327,7 @@ YMLocalizedString(@"TabbarViewController5")][tabIndex]; } -- (NSString *)tabNormalImage:(NSInteger)tabIndex { +- (NSString *)_tabNormalImage:(NSInteger)tabIndex { return @[@"tab_gameHome_normal", @"tab_gameHome_game_normal", @"tab_monents_normal", @@ -355,7 +335,7 @@ @"tab_mine_normal"][tabIndex]; } -- (NSString *)tabSelectedImage:(NSInteger)tabIndex { +- (NSString *)_tabSelectedImage:(NSInteger)tabIndex { return @[@"tab_gameHome_selected", @"tab_gameHome_game_selected", @"tab_monents_select", @@ -363,4 +343,20 @@ @"tab_mine_selected"][tabIndex]; } +- (NSString *)tabNormalImage:(NSInteger)tabIndex { + return [self.normalTabImageSource xpSafeObjectAtIndex:tabIndex]; +} + +- (NSString *)tabSelectedImage:(NSInteger)tabIndex { + return [self.selectedTabImageSource xpSafeObjectAtIndex:tabIndex]; +} + +- (UIImage *)tabNormalImageImage:(NSInteger)tabIndex { + return nil; +} + +- (UIImage *)tabSelectedImageImage:(NSInteger)tabIndex { + return nil; +} + @end diff --git a/YuMi/Modules/YMMessage/View/Session/XPSessionMainViewController.m b/YuMi/Modules/YMMessage/View/Session/XPSessionMainViewController.m index d2805bfc..5e262332 100644 --- a/YuMi/Modules/YMMessage/View/Session/XPSessionMainViewController.m +++ b/YuMi/Modules/YMMessage/View/Session/XPSessionMainViewController.m @@ -60,8 +60,8 @@ - (void)setupTopTheme { __block UIImageView *theme = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kGetScaleWidth(140))]; - theme.image = [[ClientConfig shareConfig] navigationAreaBG];// [UIImage imageNamed:@"home_top_bg"]; - theme.contentMode = UIViewContentModeScaleAspectFit; + theme.image = [[ClientConfig shareConfig] navigationAreaBG]; + theme.contentMode = UIViewContentModeScaleAspectFill; [self.view addSubview:theme]; [[NSNotificationCenter defaultCenter] addObserverForName:[ClientConfig shareConfig].reloadNavigationAreaImageKey diff --git a/YuMi/Modules/YMMine/View/XPMineViewController.m b/YuMi/Modules/YMMine/View/XPMineViewController.m index ed11fe38..9852a852 100644 --- a/YuMi/Modules/YMMine/View/XPMineViewController.m +++ b/YuMi/Modules/YMMine/View/XPMineViewController.m @@ -120,8 +120,8 @@ UIKIT_EXTERN NSString *kRequestTicket; - (void)setupTopTheme { __block UIImageView *theme = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kGetScaleWidth(140))]; - theme.image = [[ClientConfig shareConfig] navigationAreaBG];// [UIImage imageNamed:@"home_top_bg"]; - theme.contentMode = UIViewContentModeScaleAspectFit; + theme.image = [[ClientConfig shareConfig] navigationAreaBG]; + theme.contentMode = UIViewContentModeScaleAspectFill; [self.view addSubview:theme]; [[NSNotificationCenter defaultCenter] addObserverForName:[ClientConfig shareConfig].reloadNavigationAreaImageKey diff --git a/YuMi/Modules/YMMonents/View/XPMomentsViewController.m b/YuMi/Modules/YMMonents/View/XPMomentsViewController.m index 79b18a47..5f8933d8 100644 --- a/YuMi/Modules/YMMonents/View/XPMomentsViewController.m +++ b/YuMi/Modules/YMMonents/View/XPMomentsViewController.m @@ -66,8 +66,8 @@ - (void)setupTopTheme { __block UIImageView *theme = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kGetScaleWidth(140))]; - theme.image = [[ClientConfig shareConfig] navigationAreaBG];// [UIImage imageNamed:@"home_top_bg"]; - theme.contentMode = UIViewContentModeScaleAspectFit; + theme.image = [[ClientConfig shareConfig] navigationAreaBG]; + theme.contentMode = UIViewContentModeScaleAspectFill; [self.view addSubview:theme]; [[NSNotificationCenter defaultCenter] addObserverForName:[ClientConfig shareConfig].reloadNavigationAreaImageKey diff --git a/YuMi/Modules/YMNewHome/View/XPHomePagingViewController.m b/YuMi/Modules/YMNewHome/View/XPHomePagingViewController.m index 06093755..f1e561ea 100644 --- a/YuMi/Modules/YMNewHome/View/XPHomePagingViewController.m +++ b/YuMi/Modules/YMNewHome/View/XPHomePagingViewController.m @@ -89,8 +89,8 @@ - (void)setupTopTheme { __block UIImageView *theme = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kGetScaleWidth(140))]; - theme.image = [[ClientConfig shareConfig] navigationAreaBG];// [UIImage imageNamed:@"home_top_bg"]; - theme.contentMode = UIViewContentModeScaleAspectFit; + theme.image = [[ClientConfig shareConfig] navigationAreaBG]; + theme.contentMode = UIViewContentModeScaleAspectFill; [self.view addSubview:theme]; [[NSNotificationCenter defaultCenter] addObserverForName:[ClientConfig shareConfig].reloadNavigationAreaImageKey diff --git a/YuMi/Modules/YMNewHome/View/XPHomePartyViewController.m b/YuMi/Modules/YMNewHome/View/XPHomePartyViewController.m index 5c532361..39b425ef 100644 --- a/YuMi/Modules/YMNewHome/View/XPHomePartyViewController.m +++ b/YuMi/Modules/YMNewHome/View/XPHomePartyViewController.m @@ -53,7 +53,9 @@ _bannerInfoList = bannerInfoList; NSMutableArray *picArray = @[].mutableCopy; for (HomeBannerInfoModel *model in bannerInfoList) { - [picArray addObject:model.bannerPic]; + if (![NSString isEmpty:model.bannerPic]) { + [picArray addObject:model.bannerPic]; + } } self.bannerView.imageURLStringsGroup = picArray.copy; self.bannerView.autoScroll = YES; diff --git a/YuMi/Modules/YMRoom/Api/Api+CustomBackground.h b/YuMi/Modules/YMRoom/Api/Api+CustomBackground.h index b2e143dd..4d0ee69c 100644 --- a/YuMi/Modules/YMRoom/Api/Api+CustomBackground.h +++ b/YuMi/Modules/YMRoom/Api/Api+CustomBackground.h @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN + (void)buyRoomBackground:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid - backgroundItemId:(NSString *)id; + id:(NSString *)bid; + (void)deleteRoomBackground:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN + (void)selectedRoomBackground:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid - backgroundItemId:(NSString *)id; + id:(NSString *)bid; @end diff --git a/YuMi/Modules/YMRoom/Api/Api+CustomBackground.m b/YuMi/Modules/YMRoom/Api/Api+CustomBackground.m index 537b363a..5ca8d191 100644 --- a/YuMi/Modules/YMRoom/Api/Api+CustomBackground.m +++ b/YuMi/Modules/YMRoom/Api/Api+CustomBackground.m @@ -11,10 +11,10 @@ + (void)buyRoomBackground:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid - backgroundItemId:(NSString *)id{ + id:(NSString *)bid{ [self makeRequest:@"room/background/buy" method:HttpRequestHelperMethodPOST - completion:completion, __FUNCTION__, roomUid, id, nil]; + completion:completion, __FUNCTION__, roomUid, bid, nil]; } + (void)deleteRoomBackground:(HttpRequestHelperCompletion)completion @@ -34,10 +34,10 @@ + (void)selectedRoomBackground:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid - backgroundItemId:(NSString *)id { + id:(NSString *)bid { [self makeRequest:@"room/background/select" method:HttpRequestHelperMethodPOST - completion:completion, __FUNCTION__, roomUid, id, nil]; + completion:completion, __FUNCTION__, roomUid, bid, nil]; } @end diff --git a/YuMi/Modules/YMRoom/Model/CustomRoomBGItemModel.h b/YuMi/Modules/YMRoom/Model/CustomRoomBGItemModel.h index b65b797b..7d5f2c86 100644 --- a/YuMi/Modules/YMRoom/Model/CustomRoomBGItemModel.h +++ b/YuMi/Modules/YMRoom/Model/CustomRoomBGItemModel.h @@ -9,6 +9,20 @@ NS_ASSUME_NONNULL_BEGIN + +typedef enum : NSUInteger { + RoomBGStatus_Expired = -1, + RoomBGStatus_Reviewing = 0, + RoomBGStatus_Pass = 1, + RoomBGStatus_Rejected = 2 +} RoomBGStatus; + +typedef enum : NSUInteger { + RoomBGType_Free = 0, + RoomBGType_Pay = 1, + RoomBGType_Custom = 2 , +} RoomBGType; + @interface CustomRoomBGItemModel : PIBaseModel @property (nonatomic, assign) NSInteger buyHour; @@ -17,9 +31,16 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, assign) BOOL isCur; @property (nonatomic, assign) NSInteger remainHour; @property (nonatomic, copy) NSString *url; -@property (nonatomic, assign) NSInteger type; // 0=免费,1=付费,2=自定义 -@property (nonatomic, assign) NSInteger status; // -1=过期,0=审核中,1=通过,2=不过审 +/// 0=免费,1=付费,2=自定义 +@property (nonatomic, assign) RoomBGType type; +@property (nonatomic, assign) RoomBGStatus status; // -1=过期,0=审核中,1=通过,2=不过审 @end +@interface CustomRoomBGModel : PIBaseModel +@property (nonatomic, assign) NSInteger customHour; +@property (nonatomic, assign) NSInteger customGoldPrice; +@property (nonatomic, copy) NSArray *itemList; +@end + NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/Model/CustomRoomBGItemModel.m b/YuMi/Modules/YMRoom/Model/CustomRoomBGItemModel.m index ed0d3ca8..f202ad03 100644 --- a/YuMi/Modules/YMRoom/Model/CustomRoomBGItemModel.m +++ b/YuMi/Modules/YMRoom/Model/CustomRoomBGItemModel.m @@ -9,4 +9,15 @@ @implementation CustomRoomBGItemModel +@end + +@implementation CustomRoomBGModel + ++ (NSDictionary *)objectClassInArray { + return @{ + @"itemList": CustomRoomBGItemModel.class + }; +} + + @end diff --git a/YuMi/Modules/YMRoom/View/Custom Background/CustomRoomBGContentViewController.m b/YuMi/Modules/YMRoom/View/Custom Background/CustomRoomBGContentViewController.m index 9acb50ad..d360c39a 100644 --- a/YuMi/Modules/YMRoom/View/Custom Background/CustomRoomBGContentViewController.m +++ b/YuMi/Modules/YMRoom/View/Custom Background/CustomRoomBGContentViewController.m @@ -62,22 +62,40 @@ self.customBackgrounds = @[].mutableCopy; [self setupUI]; - [self didSelectedButton:self.freeButton]; [self setupData]; } - (void)setupData { + __block CustomRoomBGItemModel *currentModel = nil; @kWeakify(self); [self.presenter loadListOfRoomBG:self.roomUID - complete:^(NSArray * _Nonnull list) { + complete:^(CustomRoomBGModel *roomBGModel) { @kStrongify(self); - for (CustomRoomBGItemModel *model in list) { - if (model.goldPrice == 0) { - [self.freeBackgrounds addObject:model]; - } else { - [self.payBackgrounds addObject:model]; + for (CustomRoomBGItemModel *model in roomBGModel.itemList) { + if (model.isCur) { + currentModel = model; } + switch (model.type) { + case RoomBGType_Free: + [self.freeBackgrounds addObject:model]; + break; + case RoomBGType_Pay: + [self.payBackgrounds addObject:model]; + break; + case RoomBGType_Custom: + [self.customBackgrounds addObject:model]; + break; + + default: + break; + } + } + + if (currentModel) { + [self updateTabButtonStatus:currentModel]; + } else { + [self didSelectedButton:self.freeButton]; } [self.collectionView reloadData]; @@ -87,6 +105,24 @@ }]; } +- (void)updateTabButtonStatus:(CustomRoomBGItemModel *)model { + self.currentSelectedTabIndex = model.type; + switch (model.type) { + case RoomBGType_Pay: + [self didSelectedButton:self.payButton]; + break; + case RoomBGType_Free: + [self didSelectedButton:self.freeButton]; + break; + case RoomBGType_Custom: + [self didSelectedButton:self.customButton]; + break; + + default: + break; + } +} + - (void)setupUI { self.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3]; [self setupBackgroundContent]; @@ -327,15 +363,52 @@ - (void)updateRoomBG { + switch (self.currentSelectedModel.type) { + case 0: + [self applyBG]; + break; + case 1: + if (self.currentSelectedModel.status == 1) { + [self applyBG]; + } else { + [self buyBG]; + } + break; + case 2: + [self uploadBG]; + break; + + default: + break; + } +} + +- (void)buyBG { + @kWeakify(self); + [self.presenter buyRoomBG:self.roomUID + itemID:@(self.currentSelectedModel.id).stringValue + complete:^{ + @kStrongify(self); + [self applyBG]; + } + failure:^{}]; +} + +- (void)uploadBG { + +} + +- (void)applyBG { @kWeakify(self); [self.presenter useRoomBG:self.roomUID itemID:@(self.currentSelectedModel.id).stringValue complete:^{ -// MARK: RoomVC 會接受云信通知 - } failure:^{ - - }]; + @kStrongify(self); + [self didTapEmptySpace]; + } + failure:^{}]; } + #pragma mark - - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { switch (self.currentSelectedTabIndex) { @@ -401,10 +474,19 @@ break; } if (model) { - self.currentSelectedItemIndex = indexPath.row; - [self displayPreviewArea]; - [self updatePreviewArea:model]; - [collectionView reloadData]; + self.currentSelectedModel = model; + if (model.isCur) { + [collectionView reloadData]; + return; + } + if (model.status == RoomBGStatus_Pass) { + [self applyBG]; + } else { + self.currentSelectedItemIndex = indexPath.row; + [self displayPreviewArea]; + [self updatePreviewArea:model]; + [collectionView reloadData]; + } } } diff --git a/YuMi/Modules/YMRoom/View/Custom Background/CustomRoomBGPresenter.h b/YuMi/Modules/YMRoom/View/Custom Background/CustomRoomBGPresenter.h index 4e624771..aff3c9c1 100644 --- a/YuMi/Modules/YMRoom/View/Custom Background/CustomRoomBGPresenter.h +++ b/YuMi/Modules/YMRoom/View/Custom Background/CustomRoomBGPresenter.h @@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN failure:(void(^)(void))failure; - (void)loadListOfRoomBG:(NSString *)roomUID - complete:(void(^)(NSArray *list))complete + complete:(void(^)(CustomRoomBGModel *model))complete failure:(void(^)(void))failure; @end diff --git a/YuMi/Modules/YMRoom/View/Custom Background/CustomRoomBGPresenter.m b/YuMi/Modules/YMRoom/View/Custom Background/CustomRoomBGPresenter.m index f2db41af..f35d2c0f 100644 --- a/YuMi/Modules/YMRoom/View/Custom Background/CustomRoomBGPresenter.m +++ b/YuMi/Modules/YMRoom/View/Custom Background/CustomRoomBGPresenter.m @@ -15,9 +15,9 @@ itemID:(NSString *)itemID complete:(void(^)(void))complete failure:(void(^)(void))failure { - @kWeakify(self); +// @kWeakify(self); [Api buyRoomBackground:[self createHttpCompletion:^(BaseModel * _Nonnull data) { - @kStrongify(self); +// @kStrongify(self); if (complete) { complete(); } @@ -30,16 +30,16 @@ showLoading:YES errorToast:YES] roomUid:roomUID - backgroundItemId:itemID]; + id:itemID]; } - (void)deleteRoomBG:(NSString *)roomUID itemID:(NSString *)itemID complete:(void(^)(void))complete failure:(void(^)(void))failure { - @kWeakify(self); +// @kWeakify(self); [Api deleteRoomBackground:[self createHttpCompletion:^(BaseModel * _Nonnull data) { - @kStrongify(self); +// @kStrongify(self); if (complete) { complete(); } @@ -72,16 +72,16 @@ showLoading:YES errorToast:YES] roomUid:roomUID - backgroundItemId:itemID]; + id:itemID]; } - (void)loadListOfRoomBG:(NSString *)roomUID - complete:(void(^)(NSArray *list))complete + complete:(void(^)(CustomRoomBGModel *model))complete failure:(void(^)(void))failure { [Api listOfRoomBackground:[self createHttpCompletion:^(BaseModel * _Nonnull data) { if (complete) { - NSArray *array = [CustomRoomBGItemModel modelsWithArray:data.data]; - complete(array); + CustomRoomBGModel *model = [CustomRoomBGModel modelWithJSON:data.data]; + complete(model); } } fail:^(NSInteger code, NSString * _Nullable msg) { diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m b/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m index 041b2c38..175ef4e4 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m @@ -41,6 +41,13 @@ [super viewDidLoad]; [self installUI]; [self installConstraints]; + + [[NSNotificationCenter defaultCenter] addObserverForName:[ClientConfig shareConfig].reloadViewBackgroundColorKey + object:nil + queue:[NSOperationQueue mainQueue] + usingBlock:^(NSNotification * _Nonnull notification) { + self.view.backgroundColor = [[ClientConfig shareConfig] bgColor]; + }]; } -(void)installUI{ @@ -53,8 +60,8 @@ - (void)setupTopTheme { __block UIImageView *theme = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kGetScaleWidth(140))]; - theme.image = [[ClientConfig shareConfig] navigationAreaBG];// [UIImage imageNamed:@"home_top_bg"]; - theme.contentMode = UIViewContentModeScaleAspectFit; + theme.image = [[ClientConfig shareConfig] navigationAreaBG]; + theme.contentMode = UIViewContentModeScaleAspectFill; [self.view addSubview:theme]; [[NSNotificationCenter defaultCenter] addObserverForName:[ClientConfig shareConfig].reloadNavigationAreaImageKey diff --git a/YuMi/Modules/YMRoom/View/XPRoomViewController.m b/YuMi/Modules/YMRoom/View/XPRoomViewController.m index 5cd75068..ff51b606 100644 --- a/YuMi/Modules/YMRoom/View/XPRoomViewController.m +++ b/YuMi/Modules/YMRoom/View/XPRoomViewController.m @@ -2046,8 +2046,14 @@ XPCandyTreeInsufficientBalanceViewDelegate> } else if (attachment.first == CustomMessageType_Custom_Room_Background) { if (attachment.second == Custom_Message_Sub_Custom_Room_Background) { // TODO: 更新 背景 - self.roomInfo.backPic = @"https://tva1.moyu.im/mw600/9f0b0dd5ly1hvacrep5fhj20jg0t60w4.jpg"; - [self.backContainerView onRoomUpdate]; + if ([attachment.data isKindOfClass:[NSDictionary class]]) { + NSString *url = attachment.data[@"url"]; + if (![NSString isEmpty:url]) { + self.roomInfo.backPic = url;//@"https://tva1.moyu.im/mw600/9f0b0dd5ly1hvacrep5fhj20jg0t60w4.jpg"; + [self.backContainerView onRoomUpdate]; + } + } + } } [self.messageContainerView handleNIMCustomMessage:message]; diff --git a/YuMi/Modules/YMTabbar/Api/Api+Main.h b/YuMi/Modules/YMTabbar/Api/Api+Main.h index a518d240..cbdef686 100644 --- a/YuMi/Modules/YMTabbar/Api/Api+Main.h +++ b/YuMi/Modules/YMTabbar/Api/Api+Main.h @@ -21,6 +21,8 @@ NS_ASSUME_NONNULL_BEGIN /// @param complection 完成 + (void)clientInitConfig:(HttpRequestHelperCompletion)complection; ++ (void)clientConfig:(HttpRequestHelperCompletion)completion; + ///邀请码进房 /// @param completion 完成 /// @param inviteCode 邀请码 diff --git a/YuMi/Modules/YMTabbar/Api/Api+Main.m b/YuMi/Modules/YMTabbar/Api/Api+Main.m index 02724a0d..bc784745 100644 --- a/YuMi/Modules/YMTabbar/Api/Api+Main.m +++ b/YuMi/Modules/YMTabbar/Api/Api+Main.m @@ -51,7 +51,11 @@ /// @param complection 完成 + (void)clientInitConfig:(HttpRequestHelperCompletion)complection { NSString * fang = [NSString stringFromBase64String:@"Y2xpZW50L2luaXQ="];///client/init - [HttpRequestHelper request:fang method:HttpRequestHelperMethodGET params:[NSMutableDictionary dictionary] completion:complection]; + [HttpRequestHelper request:fang method:HttpRequestHelperMethodGET params:@{} completion:complection]; +} + ++ (void)clientConfig:(HttpRequestHelperCompletion)completion { + [HttpRequestHelper request:@"client/config" method:HttpRequestHelperMethodGET params:@{} completion:completion]; } diff --git a/YuMi/Modules/YMTabbar/View/TabbarViewController.m b/YuMi/Modules/YMTabbar/View/TabbarViewController.m index 81497191..0a07dc49 100644 --- a/YuMi/Modules/YMTabbar/View/TabbarViewController.m +++ b/YuMi/Modules/YMTabbar/View/TabbarViewController.m @@ -199,6 +199,9 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; [self configTheme:image]; }]; + [self configTheme:[[ClientConfig shareConfig] tabbarBGImage]]; + [[ClientConfig shareConfig] loadTabImages]; + [[RoomBoomManager sharedManager] registerBoomBanner:^(id _Nonnull sth) { dispatch_async(dispatch_get_main_queue(), ^{ [RoomBoomBannerAnimation display:kWindow @@ -802,6 +805,8 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; // 设置视图控制器数组和默认选择项 self.viewControllers = [viewControllers copy]; self.selectedIndex = 0; + + [[ClientConfig shareConfig] loadTabImages]; } - (BaseNavigationController *)createTabBarItem:(UIViewController *)itemVc @@ -818,6 +823,11 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; itemVc.tabBarItem.image = [[UIImage imageNamed:imageURL] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; itemVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageURL] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; } + +// if ([imageURL hasPrefix:@"http"]) { +// itemVc.tabBarItem.image = [[[ClientConfig shareConfig] tabNormalImageImage:index] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; +// } + BaseNavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:itemVc]; return nav; } diff --git a/YuMi/Tools/NSString/NSString+Utils.h b/YuMi/Tools/NSString/NSString+Utils.h index 62ed97c5..13c755b1 100644 --- a/YuMi/Tools/NSString/NSString+Utils.h +++ b/YuMi/Tools/NSString/NSString+Utils.h @@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN + (NSString *)createUUID; + (BOOL)isEmpty:(NSString *)string; -- (BOOL)isEmpty; +//- (BOOL)isEmpty; @end diff --git a/YuMi/Tools/NSString/NSString+Utils.m b/YuMi/Tools/NSString/NSString+Utils.m index 05155297..a9872afa 100644 --- a/YuMi/Tools/NSString/NSString+Utils.m +++ b/YuMi/Tools/NSString/NSString+Utils.m @@ -339,8 +339,8 @@ return trimmedString.length == 0; } -- (BOOL)isEmpty { - return [NSString isEmpty:self]; -} +//- (BOOL)isEmpty { +// return [NSString isEmpty:self]; +//} @end