1.0.19 feat:首页 UI 配置更新

This commit is contained in:
eggmanQQQ
2024-11-06 17:57:32 +08:00
parent a5f7a5eb87
commit 694d56b604
22 changed files with 319 additions and 155 deletions

View File

@@ -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<CustomRoomBGItemModel *> * _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];
}
}
}

View File

@@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
failure:(void(^)(void))failure;
- (void)loadListOfRoomBG:(NSString *)roomUID
complete:(void(^)(NSArray <CustomRoomBGItemModel *>*list))complete
complete:(void(^)(CustomRoomBGModel *model))complete
failure:(void(^)(void))failure;
@end

View File

@@ -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 <CustomRoomBGItemModel *>*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) {

View File

@@ -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

View File

@@ -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];