diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 271b700b..b4423b93 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -121,6 +121,7 @@ E80DE4072775665000BE5BCB /* XPFirstRechargeCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E80DE4062775665000BE5BCB /* XPFirstRechargeCollectionViewCell.m */; }; E80DE40A277568D300BE5BCB /* ThemeColor+FirstRecharge.m in Sources */ = {isa = PBXBuildFile; fileRef = E80DE409277568D300BE5BCB /* ThemeColor+FirstRecharge.m */; }; E80DE40D2775ABA500BE5BCB /* XPFirstRechargeFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = E80DE40C2775ABA500BE5BCB /* XPFirstRechargeFlowLayout.m */; }; + E80DE4102775C34E00BE5BCB /* XPFirstRechargeSuccessView.m in Sources */ = {isa = PBXBuildFile; fileRef = E80DE40F2775C34E00BE5BCB /* XPFirstRechargeSuccessView.m */; }; E811FFF72742367B00918544 /* XPGiftEmptyCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E811FFF62742367B00918544 /* XPGiftEmptyCollectionViewCell.m */; }; E8133916273E532D00708B66 /* XPGiftItemCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E8133915273E532D00708B66 /* XPGiftItemCollectionViewCell.m */; }; E81366E326F0A1FC0076364C /* LoginBindPhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E81366E226F0A1FC0076364C /* LoginBindPhoneViewController.m */; }; @@ -626,6 +627,8 @@ E80DE409277568D300BE5BCB /* ThemeColor+FirstRecharge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "ThemeColor+FirstRecharge.m"; sourceTree = ""; }; E80DE40B2775ABA500BE5BCB /* XPFirstRechargeFlowLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPFirstRechargeFlowLayout.h; sourceTree = ""; }; E80DE40C2775ABA500BE5BCB /* XPFirstRechargeFlowLayout.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPFirstRechargeFlowLayout.m; sourceTree = ""; }; + E80DE40E2775C34E00BE5BCB /* XPFirstRechargeSuccessView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPFirstRechargeSuccessView.h; sourceTree = ""; }; + E80DE40F2775C34E00BE5BCB /* XPFirstRechargeSuccessView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPFirstRechargeSuccessView.m; sourceTree = ""; }; E811FFF52742367B00918544 /* XPGiftEmptyCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPGiftEmptyCollectionViewCell.h; sourceTree = ""; }; E811FFF62742367B00918544 /* XPGiftEmptyCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPGiftEmptyCollectionViewCell.m; sourceTree = ""; }; E8133914273E532D00708B66 /* XPGiftItemCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPGiftItemCollectionViewCell.h; sourceTree = ""; }; @@ -2282,6 +2285,8 @@ E80DE4042775663500BE5BCB /* Cell */, E84150B627747B8B00A7F548 /* XPFirstRechargeViewController.h */, E84150B727747B8B00A7F548 /* XPFirstRechargeViewController.m */, + E80DE40E2775C34E00BE5BCB /* XPFirstRechargeSuccessView.h */, + E80DE40F2775C34E00BE5BCB /* XPFirstRechargeSuccessView.m */, ); path = View; sourceTree = ""; @@ -3559,6 +3564,7 @@ 9B7D80562753C595003DAC0C /* SendMessageView.m in Sources */, E84B0E3F2727EDF6008818C6 /* XPRoomMessageTableViewCell.m in Sources */, E82325FC274E4735003A3332 /* XPUserCardItemModel.m in Sources */, + E80DE4102775C34E00BE5BCB /* XPFirstRechargeSuccessView.m in Sources */, E8EEB8F226FC2050007C6EBA /* SDPhotoBrowser.m in Sources */, E81C27AB26EF2D920031E639 /* ThirdUserInfo.m in Sources */, E8788950273A699900BF1D57 /* ThemeColor+SendGift.m in Sources */, diff --git a/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m b/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m index 30f98acf..6ee42bc3 100644 --- a/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m +++ b/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m @@ -18,12 +18,15 @@ #import "UserInfoModel.h" #import "RoomInfoModel.h" #import "ActivityInfoModel.h" +#import "AttachmentModel.h" +#import "FirstRechargeModel.h" ///View #import "XPRoomHalfWebView.h" #import "XPCandyTreeViewController.h" #import "XPWebViewController.h" #import "XPRoomViewController.h" #import "XPFirstRechargeViewController.h" +#import "XPFirstRechargeSuccessView.h" @interface XPRoomActivityContainerView () ///容器 @@ -129,6 +132,15 @@ [self configCandyTree]; self.firstRechargeImageView.hidden = !self.hostDelegate.getUserInfo.isFirstCharge; } + +- (void)handleNIMCustomMessage:(AttachmentModel *)attachment { + if (attachment.first == CustomMessageType_First_Recharge_Reward && attachment.second == Custom_Message_Sub_Room_First_Recharge_Reward) { + FirstRechargeModel *model = [FirstRechargeModel modelWithJSON:attachment.data]; + XPFirstRechargeSuccessView * firstRechargeView= [[XPFirstRechargeSuccessView alloc] init]; + firstRechargeView.rechargeInfo = model; + [TTPopup popupView:firstRechargeView style:TTPopupStyleAlert]; + } +} #pragma mark - SDCycleScrollViewDelegate - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index { if (self.activityList.count > index) { @@ -173,7 +185,7 @@ _cycleScrollView.pageDotImage = [UIImage imageNamed:@"room_activity_banner_normal"]; _cycleScrollView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.00]; _cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFit; - _cycleScrollView.pageControlBottomOffset = -20; + _cycleScrollView.pageControlBottomOffset = -10; _cycleScrollView.hidden = YES; } return _cycleScrollView; diff --git a/xplan-ios/Main/Room/View/FirstRecharge/View/XPFirstRechargeSuccessView.h b/xplan-ios/Main/Room/View/FirstRecharge/View/XPFirstRechargeSuccessView.h new file mode 100644 index 00000000..f38c63c9 --- /dev/null +++ b/xplan-ios/Main/Room/View/FirstRecharge/View/XPFirstRechargeSuccessView.h @@ -0,0 +1,17 @@ +// +// XPFirstRechargeSuccessView.h +// xplan-ios +// +// Created by 冯硕 on 2021/12/24. +// + +#import + +NS_ASSUME_NONNULL_BEGIN +@class FirstRechargeModel; +@interface XPFirstRechargeSuccessView : UIView + +@property (nonatomic,strong) FirstRechargeModel *rechargeInfo; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/FirstRecharge/View/XPFirstRechargeSuccessView.m b/xplan-ios/Main/Room/View/FirstRecharge/View/XPFirstRechargeSuccessView.m new file mode 100644 index 00000000..d7603b68 --- /dev/null +++ b/xplan-ios/Main/Room/View/FirstRecharge/View/XPFirstRechargeSuccessView.m @@ -0,0 +1,200 @@ +// +// XPFirstRechargeSuccessView.m +// xplan-ios +// +// Created by 冯硕 on 2021/12/24. +// + +#import "XPFirstRechargeSuccessView.h" +///Third +#import +///Tool +#import "UIImage+Utils.h" +#import "ThemeColor+FirstRecharge.h" +#import "XPFirstRechargeFlowLayout.h" +#import "TTPopup.h" +///Model +#import "FirstRechargeModel.h" +///View +#import "XPFirstRechargeCollectionViewCell.h" + +@interface XPFirstRechargeSuccessView () +///背景图 +@property (nonatomic,strong) UIImageView *backImageView; +///奖励的背景 +@property (nonatomic,strong) UIImageView * rewardBackView; +///额外的奖励说明 +@property (nonatomic,strong) UIButton *extraButton; +///列表 +@property (nonatomic,strong) UICollectionView *collectionView; +///提示 +@property (nonatomic,strong) UILabel *descriptionLabel; +///知道了 +@property (nonatomic,strong) UIButton *knownButton; +///数据源 +@property (nonatomic,strong) NSArray *datasource; +@end + +@implementation XPFirstRechargeSuccessView +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; +} + +#pragma mark - Private Method +- (void)initSubViews { + [self addSubview:self.backImageView]; + [self addSubview:self.knownButton]; + + [self.backImageView addSubview:self.rewardBackView]; + [self.backImageView addSubview:self.descriptionLabel]; + + [self.rewardBackView addSubview:self.extraButton]; + [self.rewardBackView addSubview:self.collectionView]; +} + +- (void)initSubViewConstraints { + [self mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(290); + make.bottom.mas_equalTo(self.knownButton.mas_bottom); + }]; + + [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerX.top.mas_equalTo(self); + make.height.mas_equalTo(375); + make.width.mas_equalTo(290); + }]; + + [self.knownButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(185, 45)); + make.centerX.mas_equalTo(self); + make.centerY.mas_equalTo(self.backImageView.mas_bottom); + }]; + + [self.descriptionLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self); + make.top.mas_equalTo(self.collectionView.mas_bottom).offset(21); + }]; + + [self.rewardBackView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.backImageView).inset(20); + make.top.mas_equalTo(self.backImageView).offset(70); + make.height.mas_equalTo(235); + }]; + + [self.extraButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(245, 18)); + make.top.mas_equalTo(self.rewardBackView).offset(10); + make.centerX.mas_equalTo(self.rewardBackView); + }]; + + [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.extraButton.mas_bottom); + make.left.right.mas_equalTo(self.rewardBackView); + make.bottom.mas_equalTo(self.rewardBackView); + }]; +} + +#pragma mark - UICollectionViewDelegate And UICollectionViewDatasource +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { + return self.datasource.count; +} + +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { + XPFirstRechargeCollectionViewCell * cell= [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPFirstRechargeCollectionViewCell class]) forIndexPath:indexPath]; + cell.rewardInfo = [self.datasource objectAtIndex:indexPath.row]; + return cell; +} + +#pragma mark - Event Response +- (void)knowButtonAction:(UIButton *)sender { + [TTPopup dismiss]; +} + +#pragma mark - Getters And Setters +- (void)setRechargeInfo:(FirstRechargeModel *)rechargeInfo { + _rechargeInfo = rechargeInfo; + self.datasource = _rechargeInfo.firstChargeRewardList; + [self.collectionView reloadData]; + + NSString * title = rechargeInfo.chargeProdTitle; + NSString * chargeMoneyStr = [NSString stringWithFormat:@"%ld", rechargeInfo.chargeMoney]; + NSString * giveMoneyStr = [NSString stringWithFormat:@"%ld", rechargeInfo.giveMoney]; + NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12], NSForegroundColorAttributeName:[ThemeColor rewardSegmentTextColor]}]; + [attribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor rewardReminderTextColor] range:[title rangeOfString:chargeMoneyStr]]; + [attribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor rewardReminderTextColor] range:[title rangeOfString:giveMoneyStr]]; + [self.extraButton setAttributedTitle:attribute forState:UIControlStateNormal]; +} + +- (UICollectionView *)collectionView{ + if (!_collectionView) { + XPFirstRechargeFlowLayout *layout = [[XPFirstRechargeFlowLayout alloc] init]; + layout.itemSize = CGSizeMake(70, 70+ 16); + layout.minimumLineSpacing = 12; + layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10); + _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; + _collectionView.dataSource = self; + _collectionView.delegate = self; + _collectionView.backgroundColor = [UIColor clearColor]; + [_collectionView registerClass:[XPFirstRechargeCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPFirstRechargeCollectionViewCell class])]; + } + return _collectionView; +} + + +- (UIImageView *)backImageView { + if (!_backImageView) { + _backImageView = [[UIImageView alloc] init]; + _backImageView.userInteractionEnabled = YES; + _backImageView.image = [UIImage imageNamed:@"room_first_recharge_success_bg"]; + } + return _backImageView; +} + +- (UILabel *)descriptionLabel { + if (!_descriptionLabel) { + _descriptionLabel = [[UILabel alloc] init]; + _descriptionLabel.text = @"装扮类物品可进入“我的一我的装扮”使用哦"; + _descriptionLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:10]; + _descriptionLabel.textAlignment = NSTextAlignmentCenter; + _descriptionLabel.textColor = [ThemeColor firstRechargeTextColor]; + } + return _descriptionLabel; +} + +- (UIButton *)knownButton { + if (!_knownButton) { + _knownButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_knownButton setBackgroundImage:[UIImage imageNamed:@"room_first_recharge_recharge"] forState:UIControlStateNormal]; + [_knownButton setBackgroundImage:[UIImage imageNamed:@"room_first_recharge_recharge"] forState:UIControlStateSelected]; + [_knownButton setTitle:@"我知道了" forState:UIControlStateNormal]; + _knownButton.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Bold" size:20]; + [_knownButton setTitleColor:[ThemeColor firstRechargeTextColor] forState:UIControlStateNormal]; + [_knownButton addTarget:self action:@selector(knowButtonAction:) forControlEvents:UIControlEventTouchUpInside]; + } + return _knownButton; +} + +- (UIButton *)extraButton { + if (!_extraButton) { + _extraButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_extraButton setBackgroundImage:[UIImage imageNamed:@"room_first_recharge_reward_extra_bg"] forState:UIControlStateNormal]; + } + return _extraButton; +} + +- (UIImageView *)rewardBackView { + if (!_rewardBackView) { + _rewardBackView = [[UIImageView alloc] init]; + _rewardBackView.image = [UIImage gradientColorImageFromColors:@[[ThemeColor rewardBackgroundGradientTopColor], [ThemeColor rewardBackgroundGradientMiddleColor], [ThemeColor rewardBackgroundGradientTopColor]] gradientType:GradientTypeTopToBottom imgSize:CGSizeMake(10, 10)]; + _rewardBackView.layer.masksToBounds = YES; + _rewardBackView.layer.cornerRadius = 10; + } + return _rewardBackView; +} +@end diff --git a/xplan-ios/Main/Room/View/XPRoomViewController.m b/xplan-ios/Main/Room/View/XPRoomViewController.m index 50eca510..b2b36c57 100644 --- a/xplan-ios/Main/Room/View/XPRoomViewController.m +++ b/xplan-ios/Main/Room/View/XPRoomViewController.m @@ -330,9 +330,16 @@ } else if (message.messageType == NIMMessageTypeCustom) { NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { - [self.stageView handleNIMCustomMessage:obj.attachment]; - [self.animationView handleNIMCustomMessage:obj.attachment]; - [self.menuContainerView handleNIMCustomMessage:obj.attachment]; + AttachmentModel * attachment = obj.attachment; + [self.stageView handleNIMCustomMessage:attachment]; + [self.animationView handleNIMCustomMessage:attachment]; + [self.menuContainerView handleNIMCustomMessage:attachment]; + [self.activityContainerView handleNIMCustomMessage:attachment]; + if (attachment.first == CustomMessageType_First_Recharge_Reward && attachment.second == Custom_Message_Sub_Room_First_Recharge_Reward) { + self.userInfo.isFirstCharge = NO; + [self.menuContainerView onRoomUpdate]; + [self.activityContainerView onRoomUpdate]; + } } } }