diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index f8716d12..48d749df 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -917,6 +917,8 @@ E89DCF5428FFEC67001647EC /* XPWishGiftHistoryTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E89DCF5328FFEC67001647EC /* XPWishGiftHistoryTableViewCell.m */; }; E89DCF5728FFF076001647EC /* XPWishGiftEmptyTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E89DCF5628FFF076001647EC /* XPWishGiftEmptyTableViewCell.m */; }; E89DCF5A28FFF1AD001647EC /* XPWishGiftSectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = E89DCF5928FFF1AD001647EC /* XPWishGiftSectionView.m */; }; + E89DCF5D2900E5EE001647EC /* WishGiftHistoryModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E89DCF5C2900E5EE001647EC /* WishGiftHistoryModel.m */; }; + E89DCF602900F4FB001647EC /* XPWishGiftEnterView.m in Sources */ = {isa = PBXBuildFile; fileRef = E89DCF5F2900F4FB001647EC /* XPWishGiftEnterView.m */; }; E8A03DE22762FA000098D9EA /* XPCandyTreeMoreView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A03DE12762FA000098D9EA /* XPCandyTreeMoreView.m */; }; E8A03DE9276301CC0098D9EA /* XPCandyRankContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A03DE8276301CC0098D9EA /* XPCandyRankContainerView.m */; }; E8A03DEC276301EF0098D9EA /* XPCandyTreeRankView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A03DEB276301EF0098D9EA /* XPCandyTreeRankView.m */; }; @@ -2883,6 +2885,10 @@ E89DCF5628FFF076001647EC /* XPWishGiftEmptyTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPWishGiftEmptyTableViewCell.m; sourceTree = ""; }; E89DCF5828FFF1AD001647EC /* XPWishGiftSectionView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPWishGiftSectionView.h; sourceTree = ""; }; E89DCF5928FFF1AD001647EC /* XPWishGiftSectionView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPWishGiftSectionView.m; sourceTree = ""; }; + E89DCF5B2900E5EE001647EC /* WishGiftHistoryModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WishGiftHistoryModel.h; sourceTree = ""; }; + E89DCF5C2900E5EE001647EC /* WishGiftHistoryModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WishGiftHistoryModel.m; sourceTree = ""; }; + E89DCF5E2900F4FB001647EC /* XPWishGiftEnterView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPWishGiftEnterView.h; sourceTree = ""; }; + E89DCF5F2900F4FB001647EC /* XPWishGiftEnterView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPWishGiftEnterView.m; sourceTree = ""; }; E8A03DE02762FA000098D9EA /* XPCandyTreeMoreView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyTreeMoreView.h; sourceTree = ""; }; E8A03DE12762FA000098D9EA /* XPCandyTreeMoreView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCandyTreeMoreView.m; sourceTree = ""; }; E8A03DE7276301CC0098D9EA /* XPCandyRankContainerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyRankContainerView.h; sourceTree = ""; }; @@ -7318,6 +7324,8 @@ E8A3539028FE5F0F0014A784 /* WishGiftInfoModel.m */, E8A3539228FE605F0014A784 /* WishGiftUserModel.h */, E8A3539328FE605F0014A784 /* WishGiftUserModel.m */, + E89DCF5B2900E5EE001647EC /* WishGiftHistoryModel.h */, + E89DCF5C2900E5EE001647EC /* WishGiftHistoryModel.m */, ); path = Model; sourceTree = ""; @@ -7374,6 +7382,8 @@ E8A3540928FEC0510014A784 /* XPWishGiftListView.m */, E89DCF5828FFF1AD001647EC /* XPWishGiftSectionView.h */, E89DCF5928FFF1AD001647EC /* XPWishGiftSectionView.m */, + E89DCF5E2900F4FB001647EC /* XPWishGiftEnterView.h */, + E89DCF5F2900F4FB001647EC /* XPWishGiftEnterView.m */, ); path = View; sourceTree = ""; @@ -9377,6 +9387,7 @@ 9B734F73288A787000CBDAA9 /* XPMineAccountView.m in Sources */, E8AA6EF227DF1E97009B4C2B /* XPRoomTopicPresenter.m in Sources */, 9BF4BEBC28D4182E009CF6C2 /* XPOpenRedPacketModel.m in Sources */, + E89DCF5D2900E5EE001647EC /* WishGiftHistoryModel.m in Sources */, 187EEEFE26E8A82C002833B2 /* NSObject+AutoCoding.m in Sources */, E873EB0C2809850D0071030D /* MessageContentCustomView.m in Sources */, E884C36F2743AAC800E1EBED /* AttachmentModel.m in Sources */, @@ -9458,6 +9469,7 @@ E8E859CB28264C2300EE4857 /* MultipartMessageHeaderField.m in Sources */, 9B2A12DB2783F88800CED41B /* XPNoblePrivilegeCell.m in Sources */, E8B3E7FE28489232009746AB /* XPNewUserGreetRoomAlertView.m in Sources */, + E89DCF602900F4FB001647EC /* XPWishGiftEnterView.m in Sources */, E81366E326F0A1FC0076364C /* LoginBindPhoneViewController.m in Sources */, 9B2EA7CC2804245500ED17BF /* XPAnchorPKPanelUserView.m in Sources */, E851E46527FF1F53002F3ACB /* XPMineGuildSetNameViewController.m in Sources */, diff --git a/xplan-ios/Assets.xcassets/Room/WishGift/room_more_menu_wish_gift.imageset/Contents.json b/xplan-ios/Assets.xcassets/Room/WishGift/room_more_menu_wish_gift.imageset/Contents.json new file mode 100644 index 00000000..ce26d098 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Room/WishGift/room_more_menu_wish_gift.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "room_more_menu_wish_gift@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "room_more_menu_wish_gift@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Room/WishGift/room_more_menu_wish_gift.imageset/room_more_menu_wish_gift@2x.png b/xplan-ios/Assets.xcassets/Room/WishGift/room_more_menu_wish_gift.imageset/room_more_menu_wish_gift@2x.png new file mode 100644 index 00000000..71b1b690 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/WishGift/room_more_menu_wish_gift.imageset/room_more_menu_wish_gift@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/WishGift/room_more_menu_wish_gift.imageset/room_more_menu_wish_gift@3x.png b/xplan-ios/Assets.xcassets/Room/WishGift/room_more_menu_wish_gift.imageset/room_more_menu_wish_gift@3x.png new file mode 100644 index 00000000..a5ba12d9 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/WishGift/room_more_menu_wish_gift.imageset/room_more_menu_wish_gift@3x.png differ diff --git a/xplan-ios/Base/Tool/Date/PLTimeUtil.h b/xplan-ios/Base/Tool/Date/PLTimeUtil.h index c5f4878f..a799d68c 100644 --- a/xplan-ios/Base/Tool/Date/PLTimeUtil.h +++ b/xplan-ios/Base/Tool/Date/PLTimeUtil.h @@ -31,6 +31,8 @@ + (NSString *)getDateWithYYMM:(NSString *)time; ++ (NSString *)getDateWithMMDD:(NSString *)time; + + (NSDate *)getDateWithYearMonthDay:(NSString *)time; + (NSString *)getMonthDayContent:(NSDate *)date; diff --git a/xplan-ios/Base/Tool/Date/PLTimeUtil.m b/xplan-ios/Base/Tool/Date/PLTimeUtil.m index 41b9b2f4..a0193826 100644 --- a/xplan-ios/Base/Tool/Date/PLTimeUtil.m +++ b/xplan-ios/Base/Tool/Date/PLTimeUtil.m @@ -60,6 +60,7 @@ return date; } + + (NSString *)getMonthDayContent:(NSDate *)date { NVDate *currentNVDate = [[NVDate alloc] initUsingDate:date]; @@ -113,6 +114,7 @@ return dateStr; } + + (NSString *)getDateWithYYMMDD:(NSString *)time { NSDateFormatter* formatter = [[NSDateFormatter alloc] init]; formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"]; @@ -166,6 +168,25 @@ return dateString; } ++ (NSString *)getDateWithMMDD:(NSString *)time { + NSDateFormatter* formatter = [[NSDateFormatter alloc] init]; + formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"]; + [formatter setDateStyle:NSDateFormatterMediumStyle]; + [formatter setTimeStyle:NSDateFormatterShortStyle]; + [formatter setDateFormat:@"MM月dd日"]; + // 毫秒值转化为秒 + NSString * times; + if ([self is32bit] && [[YYUtility systemVersion] floatValue] <= 10.0) { + times = [NSString stringWithFormat:@"%f", ([time doubleValue] + 3600 * 1000 * 8)]; + }else{ + times = time; + } + NSDate* date = [NSDate dateWithTimeIntervalSince1970:[times doubleValue]/ 1000.0]; + NSString* dateString = [formatter stringFromDate:date]; + return dateString; +} + + + (NSString *)getDateWithHHMMSS:(NSString *)time { diff --git a/xplan-ios/Main/IM/Model/AttachmentModel.h b/xplan-ios/Main/IM/Model/AttachmentModel.h index ee77a6fd..ac9e40fc 100644 --- a/xplan-ios/Main/IM/Model/AttachmentModel.h +++ b/xplan-ios/Main/IM/Model/AttachmentModel.h @@ -94,6 +94,8 @@ typedef NS_ENUM(NSUInteger, CustomMessageType) { CustomMessageType_Gift_Compound = 93, ///涂鸦礼物 CustomMessageType_Graffiti_Gift = 94, + ///心愿礼物 + CustomMessageType_Wish_Gift = 95, }; @@ -500,6 +502,17 @@ typedef NS_ENUM(NSUInteger, CustomMessageGraffitiGift) { Custom_Message_Sub_Graffiti_Gift = 941, }; +typedef NS_ENUM(NSInteger, CustomMessageWishGift) { + ///开启心愿礼物 + Custom_Message_Sub_Wish_Gift_Open = 951, + ///心愿礼物完成 + Custom_Message_Sub_Wish_Gift_Finish = 952, + ///心愿礼物庆祝动效 + Custom_Message_Sub_Wish_Gift_Gelebrate = 953, + ///心愿礼物进度更新 + Custom_Message_Sub_Wish_Gift_Update = 954, +}; + @interface AttachmentModel : NSObject @property (nonatomic,assign) int first; @property (nonatomic,assign) int second; diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftInfoView.m b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftInfoView.m index 14da9f7d..cc7f2fbd 100644 --- a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftInfoView.m +++ b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftInfoView.m @@ -67,6 +67,8 @@ @property (nonatomic,strong) GiftInfoModel *lastSelectGift; @property (nonatomic, assign) NSInteger selectIndex; +///当前选中的page +@property (nonatomic,assign) NSInteger selectCurrentPage; @end @implementation XPGiftInfoView @@ -125,6 +127,7 @@ } } + #pragma mark - Private Method - (void)initSubViews { @@ -250,9 +253,11 @@ #pragma mark - scrollviewdelegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView { - CGFloat offX = scrollView.contentOffset.x; - CGFloat width = CGRectGetWidth(scrollView.frame); - self.pageController.currentPage = ceilf(offX/width); + if (scrollView == self.giftcollectionView) { + CGFloat offX = scrollView.contentOffset.x; + CGFloat width = CGRectGetWidth(scrollView.frame); + self.pageController.currentPage = ceilf(offX/width); + } } #pragma mark - UICollectionViewDelegate And UICollectionDatasource @@ -364,14 +369,20 @@ [self.datasource addObjectsFromArray:self.giftArray]; break; } + NSInteger currentPage = 0; if (self.datasource.count > 0) { if (self.defaultSelectGiftId.length) { - for (GiftInfoModel * gift in self.datasource) { - if (gift.giftId == [self.defaultSelectGiftId integerValue]) { - [self dealSelectGift:gift]; - self.selectIndex = [self.datasource indexOfObject:gift]; - } - } + for (int i = 0 ; i +@interface XPRoomFunctionContainerView () ///host 代理 @property (nonatomic,weak) iddelegate; ///房间榜 @@ -135,9 +138,8 @@ @property (nonatomic,assign) BOOL isLoadGreet; ///获取新用户礼物倒计时3s @property (nonatomic, strong) dispatch_source_t userGiftTimer; - ///许愿礼物 -@property (nonatomic,strong) UIView *wishGiftView; +@property (nonatomic,strong) XPWishGiftEnterView *wishGiftView; @end @@ -237,8 +239,6 @@ [self addSubview:self.topicStackView]; [self.topicStackView addArrangedSubview:self.topicLabel]; [self.topicStackView addArrangedSubview:self.editButton]; - - [self addSubview:self.wishGiftView]; } - (void)initSubViewConstraints { @@ -254,12 +254,6 @@ make.height.mas_equalTo(15); make.top.mas_equalTo(50 + 5 + 6 + 12 + 3 + kNavigationHeight); }]; - - [self.wishGiftView mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(100, 40)); - make.right.mas_equalTo(self); - make.top.mas_equalTo(self).offset(kNavigationHeight + 50); - }]; } - (void)showLittleGameMiniView:(RoomType)type micCount:(NSInteger)micCount { @@ -606,6 +600,8 @@ [self handleNewUserGreet]; ///新用户房间礼物 [self handleNewUserRoomGift]; + ///房间心愿礼物 + [self configWishGiftEnter]; } - (void)onRoomMiniEntered { @@ -1651,10 +1647,50 @@ - (void)tapWishGift { NSString * roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid]; XPWishGiftViewController * vc = [[XPWishGiftViewController alloc] initWithRoomUid:roomUid]; + vc.delegate = self; vc.modalPresentationStyle = UIModalPresentationOverFullScreen; [self.delegate.getCurrentNav presentViewController:vc animated:YES completion:nil]; } +- (void)configWishGiftEnter { + RoomInfoModel * roomInfo = self.delegate.getRoomInfo; + NSString * roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid]; + roomInfo.hasOpenWishGift = YES; + if (roomInfo.hasOpenWishGift) { + if (!self.wishGiftView.superview) { + [self addSubview:self.wishGiftView]; + [self.wishGiftView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self).offset(kNavigationHeight + 47); + make.right.mas_equalTo(self.mas_right).offset(0); + make.size.mas_equalTo(CGSizeMake(81, 30)); + }]; + } + [Api wishGiftList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if (code == 200) { + NSArray * array = [WishGiftInfoModel modelsWithArray:data.data]; + self.wishGiftView.giftList = array; + self.wishGiftView.hidden = NO; + } else { + self.wishGiftView.hidden = YES; + } + } roomUid:roomUid]; + } else { + if (self.wishGiftView.superview) { + [self.wishGiftView removeFromSuperview]; + } + } +} + +- (void)xPWishGiftViewControllerSendClick:(NSString *)giftId { + NSString * roomUid = [NSString stringWithFormat:@"%ld", [self.delegate getRoomInfo].uid]; + XPSendGiftView * giftView = [[XPSendGiftView alloc] initWithType:SendGiftType_Room uid:roomUid]; + giftView.delegate = self.delegate; + NSArray * giftUses = [self configGiftUsers:[self.delegate getMicroQueue]]; + [giftView configGiftUsers:giftUses]; + giftView.selectGiftId = giftId; + [self.delegate.getCurrentNav presentViewController:giftView animated:YES completion:nil]; +} + #pragma mark - Getters And Setters - (XPRoomRankEntranceView *)contributeEnterView { if (!_contributeEnterView) { @@ -1817,10 +1853,9 @@ return _acrossPKCountView; } -- (UIView *)wishGiftView { +- (XPWishGiftEnterView *)wishGiftView { if (!_wishGiftView) { - _wishGiftView = [[UIView alloc] init]; - _wishGiftView.backgroundColor = [UIColor clearColor]; + _wishGiftView = [[XPWishGiftEnterView alloc] init]; UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapWishGift)]; [_wishGiftView addGestureRecognizer:tap]; } diff --git a/xplan-ios/Main/Room/View/MoreView/Presenter/XPMoreMenuPresenter.m b/xplan-ios/Main/Room/View/MoreView/Presenter/XPMoreMenuPresenter.m index aa231728..ca3a1cc4 100644 --- a/xplan-ios/Main/Room/View/MoreView/Presenter/XPMoreMenuPresenter.m +++ b/xplan-ios/Main/Room/View/MoreView/Presenter/XPMoreMenuPresenter.m @@ -45,7 +45,7 @@ XPRoomMoreItemModel * wishGift = [[XPRoomMoreItemModel alloc] init]; wishGift.title = @"心愿礼物"; - wishGift.imageName = @"room_more_menu_gift_effect"; + wishGift.imageName = @"room_more_menu_wish_gift"; wishGift.type = RoomMoreMenuType_Room_Wish_Gift; wishGift.titleColor = [ThemeColor roomMoreMenuTextColor]; @@ -151,7 +151,7 @@ } - if ((isCreator || isManager || isSuperAdmin) && roomInfo.type != RoomType_MiniGame) { + if ((isCreator || isManager || isSuperAdmin) && roomInfo.hasWishGiftPermit) { [array addObject:wishGift]; } diff --git a/xplan-ios/Main/Room/View/WishGift/Api/Api+WishGift.m b/xplan-ios/Main/Room/View/WishGift/Api/Api+WishGift.m index bf7bac3d..9cd80773 100644 --- a/xplan-ios/Main/Room/View/WishGift/Api/Api+WishGift.m +++ b/xplan-ios/Main/Room/View/WishGift/Api/Api+WishGift.m @@ -39,7 +39,7 @@ [dic setValue:giftId forKey:@"giftId"]; [dic setValue:seq forKey:@"seq"]; [dic setValue:targetNum forKey:@"targetNum"]; - [self makeRequest:@"wishGift/addItem" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, roomUid, giftId, itemId, seq, targetNum, nil]; + [HttpRequestHelper request:@"wishGift/addItem" method:HttpRequestHelperMethodPOST params:dic completion:completion]; } /// 获取房间心愿礼物列表 diff --git a/xplan-ios/Main/Room/View/WishGift/Model/WishGiftHistoryModel.h b/xplan-ios/Main/Room/View/WishGift/Model/WishGiftHistoryModel.h new file mode 100644 index 00000000..d9b45c2c --- /dev/null +++ b/xplan-ios/Main/Room/View/WishGift/Model/WishGiftHistoryModel.h @@ -0,0 +1,21 @@ +// +// WishGiftHistoryModel.h +// xplan-ios +// +// Created by 冯硕 on 2022/10/20. +// + +#import +#import "WishGiftInfoModel.h" +NS_ASSUME_NONNULL_BEGIN + +@interface WishGiftHistoryModel : NSObject + +///创建时间 +@property (nonatomic,strong) NSString *createDate; +///礼物列表 +@property (nonatomic,strong) NSArray *gifts; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/WishGift/Model/WishGiftHistoryModel.m b/xplan-ios/Main/Room/View/WishGift/Model/WishGiftHistoryModel.m new file mode 100644 index 00000000..c1a7d907 --- /dev/null +++ b/xplan-ios/Main/Room/View/WishGift/Model/WishGiftHistoryModel.m @@ -0,0 +1,15 @@ +// +// WishGiftHistoryModel.m +// xplan-ios +// +// Created by 冯硕 on 2022/10/20. +// + +#import "WishGiftHistoryModel.h" + +@implementation WishGiftHistoryModel ++ (NSDictionary *)objectClassInArray { + return @{@"gifts" : WishGiftInfoModel.class}; +} + +@end diff --git a/xplan-ios/Main/Room/View/WishGift/Presenter/XPWishGiftPresenter.m b/xplan-ios/Main/Room/View/WishGift/Presenter/XPWishGiftPresenter.m index d250f15a..25a7f3f4 100644 --- a/xplan-ios/Main/Room/View/WishGift/Presenter/XPWishGiftPresenter.m +++ b/xplan-ios/Main/Room/View/WishGift/Presenter/XPWishGiftPresenter.m @@ -10,6 +10,7 @@ #import "XPWishGiftProtocol.h" #import "WishGiftInfoModel.h" #import "WishGiftUserModel.h" +#import "WishGiftHistoryModel.h" @implementation XPWishGiftPresenter @@ -56,7 +57,7 @@ ///获取房间历史列表 - (void)wishGiftHistroyList:(NSString *)roomUid { [Api wishGiftHistoryList:[self createHttpCompletion:^(BaseModel * _Nonnull data) { - NSArray * array = [WishGiftUserModel modelsWithArray:data.data]; + NSArray * array = [WishGiftHistoryModel modelsWithArray:data.data]; [[self getView] wishGiftHistroyListSuccess:array]; } showLoading:YES] roomUid:roomUid]; } diff --git a/xplan-ios/Main/Room/View/WishGift/View/Cell/XPWishGiftHistoryTableViewCell.m b/xplan-ios/Main/Room/View/WishGift/View/Cell/XPWishGiftHistoryTableViewCell.m index 5158fc8c..97c7de8a 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/Cell/XPWishGiftHistoryTableViewCell.m +++ b/xplan-ios/Main/Room/View/WishGift/View/Cell/XPWishGiftHistoryTableViewCell.m @@ -115,6 +115,14 @@ } } +- (UIView *)backView { + if (!_backView) { + _backView = [[UIView alloc] init]; + _backView.backgroundColor = [UIColor whiteColor]; + } + return _backView; +} + - (UILabel *)levleLabel { if (!_levleLabel) { _levleLabel = [[UILabel alloc] init]; diff --git a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.h b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.h new file mode 100644 index 00000000..fc9340f8 --- /dev/null +++ b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.h @@ -0,0 +1,15 @@ +// +// XPWishGiftEnterView.h +// xplan-ios +// +// Created by 冯硕 on 2022/10/20. +// + +#import + +NS_ASSUME_NONNULL_BEGIN +@interface XPWishGiftEnterView : UIView +@property (nonatomic,strong) NSArray * giftList; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.m b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.m new file mode 100644 index 00000000..46852869 --- /dev/null +++ b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.m @@ -0,0 +1,223 @@ +// +// XPWishGiftEnterView.m +// xplan-ios +// +// Created by 冯硕 on 2022/10/20. +// + +#import "XPWishGiftEnterView.h" +///Third +#import +#import +#import +///Tool +#import "ThemeColor.h" +#import "NetImageView.h" +#import "UIImage+Utils.h" +#import "UIView+Corner.h" +///Model +#import "WishGiftInfoModel.h" + + +@interface XPWishGiftEnterCell : UICollectionViewCell +///礼物 +@property (nonatomic,strong) NetImageView *giftImageView; +///礼物名称 +@property (nonatomic,strong) UILabel *giftLabel; +///进度 +@property (nonatomic,strong) UILabel *progressLabel; +///进度 +@property (nonatomic,strong) UISlider *progressView; +@property (nonatomic,strong) WishGiftInfoModel *giftInfo; +@end + +@implementation XPWishGiftEnterCell + +- (instancetype)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; +} + +#pragma mark - Private Method +- (void)initSubViews { + self.contentView.backgroundColor = [UIColor clearColor]; + [self.contentView addSubview:self.giftImageView]; + [self.contentView addSubview:self.giftLabel]; + [self.contentView addSubview:self.progressLabel]; + [self.contentView addSubview:self.progressView]; +} + +- (void)initSubViewConstraints { + + [self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.top.bottom.mas_equalTo(self.contentView); + make.width.mas_equalTo(self.giftImageView.mas_height); + }]; + + [self.giftLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.giftImageView.mas_right).offset(6); + make.top.mas_equalTo(self.contentView).offset(0); + make.right.mas_equalTo(self.contentView).offset(-2); + }]; + + [self.progressLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.giftLabel); + make.right.mas_equalTo(self.contentView); + make.top.mas_equalTo(self.giftLabel.mas_bottom).offset(1); + }]; + + [self.progressView mas_makeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(2); + make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-2); + make.left.mas_equalTo(self.giftImageView.mas_right).offset(2); + make.right.mas_equalTo(self.contentView).offset(-5); + }]; +} + +- (NSAttributedString *)createProgressAttribute { + NSString * targetNum = [NSString stringWithFormat:@"/%ld", self.giftInfo.targetNum]; + NSString * actualNum = (self.giftInfo.actualNum > self.giftInfo.targetNum) ? [NSString stringWithFormat:@"%ld+", self.giftInfo.targetNum] : [NSString stringWithFormat:@"%ld", self.giftInfo.actualNum]; + NSString * title = [NSString stringWithFormat:@"%@%@", actualNum, targetNum]; + NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10], NSForegroundColorAttributeName:[ThemeColor colorWithHexString:@"#FFC300"]}]; + if (self.giftInfo.targetNum == self.giftInfo.actualNum) { + [attribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor colorWithHexString:@"#FFC300"] range:[title rangeOfString:targetNum]]; + } else { + [attribute addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithWhite:1 alpha:1] range:[title rangeOfString:targetNum]]; + } + return attribute; +} + +#pragma mark - Getters And Setters +- (void)setGiftInfo:(WishGiftInfoModel *)giftInfo { + _giftInfo = giftInfo; + if (_giftInfo) { + self.giftImageView.imageUrl = _giftInfo.giftUrl; + self.giftLabel.text = _giftInfo.giftName; + self.progressView.value = (CGFloat)giftInfo.actualNum / (CGFloat)_giftInfo.targetNum; + self.progressLabel.attributedText = [self createProgressAttribute]; + self.progressLabel.textAlignment = NSTextAlignmentCenter; + } +} + +- (UISlider *)progressView { + if(!_progressView) { + _progressView = [[UISlider alloc] init]; + _progressView.enabled = NO; + [_progressView setMinimumTrackImage:[UIImage gradientColorImageFromColors:@[[ThemeColor colorWithHexString:@"#FFA0C3"], [ThemeColor colorWithHexString:@"#C176FF"]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(1, 1)] forState:UIControlStateNormal]; + _progressView.thumbTintColor = [UIColor clearColor]; + _progressView.value = 0.4l; + [_progressView setMaximumTrackImage:[UIImage imageWithColor:[ThemeColor colorWithHexString:@"#17093E"]] forState:UIControlStateNormal]; + } + return _progressView; +} + +- (NetImageView *)giftImageView { + if (!_giftImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.imageType = ImageTypeUserIcon; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _giftImageView = [[NetImageView alloc] initWithConfig:config]; + _giftImageView.layer.masksToBounds = YES; + _giftImageView.layer.cornerRadius = 15; + _giftImageView.layer.borderWidth = 0.5; + _giftImageView.layer.borderColor = UIColorRGBAlpha(0xFFEEBE, 0.7).CGColor; + _giftImageView.contentMode = UIViewContentModeScaleAspectFill; + } + return _giftImageView; +} + +- (UILabel *)giftLabel { + if (!_giftLabel) { + _giftLabel = [[UILabel alloc] init]; + _giftLabel.font = [UIFont systemFontOfSize:10]; + _giftLabel.textAlignment = NSTextAlignmentCenter; + _giftLabel.textColor = [UIColor whiteColor]; + _giftLabel.textAlignment = NSTextAlignmentCenter; + } + return _giftLabel; +} + +- (UILabel *)progressLabel { + if (!_progressLabel) { + _progressLabel = [[UILabel alloc] init]; + } + return _progressLabel; +} + +@end + +@interface XPWishGiftEnterView() +///文字轮播 +@property (nonatomic, strong) SDCycleScrollView *cycleScrollView; + +@end + +@implementation XPWishGiftEnterView + +- (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:1 alpha:0.2]; + [self addSubview:self.cycleScrollView]; + self.layer.masksToBounds = YES; + + [self setCornerWithLeftTopCorner:15 rightTopCorner:0 bottomLeftCorner:15 bottomRightCorner:0 size:CGSizeMake(81, 30)]; +} + +- (void)initSubViewConstraints { + [self.cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self); + }]; + +} + +#pragma mark - SDCycleScrollViewDelegate +- (Class)customCollectionViewCellClassForCycleScrollView:(SDCycleScrollView *)view { + return XPWishGiftEnterCell.class; +} + +- (void)setupCustomCell:(UICollectionViewCell *)cell forIndex:(NSInteger)index cycleScrollView:(SDCycleScrollView *)view { + XPWishGiftEnterCell *myCell = (XPWishGiftEnterCell *)cell; + WishGiftInfoModel * info = [self.giftList objectAtIndex:index]; + myCell.giftInfo = info; +} +#pragma mark - Getters And Setters +- (void)setGiftList:(NSArray *)giftList { + _giftList = giftList; + if (_giftList.count > 0) { + NSMutableArray * array = [NSMutableArray array]; + for (WishGiftInfoModel * item in _giftList) { + [array addObject:item.giftName]; + } + if (array.count > 0) { + self.cycleScrollView.imageURLStringsGroup = array; + [self.cycleScrollView autoScroll]; + } + } +} + +- (SDCycleScrollView *)cycleScrollView { + if (!_cycleScrollView) { + _cycleScrollView = [[SDCycleScrollView alloc] init]; + _cycleScrollView.backgroundColor = [UIColor clearColor]; + _cycleScrollView.layer.masksToBounds = YES; + _cycleScrollView.delegate = self; + _cycleScrollView.showPageControl = NO; + _cycleScrollView.autoScrollTimeInterval = 10.0; + } + return _cycleScrollView; +} +@end diff --git a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.h b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.h index 8e853631..6dd8220d 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.h +++ b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.h @@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN @class WishGiftInfoModel, XPWishGiftInfoView; -@protocol XPWishGiftInfoView +@protocol XPWishGiftInfoViewDelegate - (void)xPWishGiftInfoView:(XPWishGiftInfoView *)view didClickSender:(WishGiftInfoModel *)info; @@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic,strong) WishGiftInfoModel *giftInfo; ///代理 -@property (nonatomic,weak) id delegate; +@property (nonatomic,weak) id delegate; @end diff --git a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.m b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.m index 06ef2b2c..c35bae9e 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.m +++ b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.m @@ -63,19 +63,19 @@ }]; [self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(40, 40)); - make.top.mas_equalTo(self.bgView).offset(10); + make.size.mas_equalTo(CGSizeMake(50, 50)); + make.top.mas_equalTo(self.bgView).offset(6); make.centerX.mas_equalTo(self.bgView); }]; [self.giftLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.mas_equalTo(self.bgView).inset(2); - make.top.mas_equalTo(self.giftImageView.mas_bottom).offset(10); + make.top.mas_equalTo(self.giftImageView.mas_bottom).offset(4); }]; [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.mas_equalTo(self.bgView).inset(2); - make.top.mas_equalTo(self.giftLabel.mas_bottom).offset(10); + make.top.mas_equalTo(self.giftLabel.mas_bottom).offset(4); }]; [self.progressView mas_makeConstraints:^(MASConstraintMaker *make) { @@ -86,13 +86,13 @@ [self.progressLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.mas_equalTo(self.bgView); - make.top.mas_equalTo(self.progressView.mas_bottom).offset(5); + make.top.mas_equalTo(self.progressView.mas_bottom).offset(4); }]; [self.senderButton mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(50, 24)); + make.size.mas_equalTo(CGSizeMake(76, 22)); make.centerX.mas_equalTo(self.bgView); - make.top.mas_equalTo(self.progressLabel.mas_bottom).offset(10); + make.bottom.mas_equalTo(self.bgView.mas_bottom).offset(-10); }]; } @@ -102,9 +102,9 @@ NSString * title = [NSString stringWithFormat:@"%@%@", actualNum, targetNum]; NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10], NSForegroundColorAttributeName:[ThemeColor colorWithHexString:@"#FFA0C3"]}]; if (self.giftInfo.targetNum == self.giftInfo.actualNum) { - [attribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor colorWithHexString:@"#FFA0C3"] range:[targetNum rangeOfString:title]]; + [attribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor colorWithHexString:@"#FFA0C3"] range:[title rangeOfString:targetNum]]; } else { - [attribute addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithWhite:1 alpha:0.5] range:[targetNum rangeOfString:title]]; + [attribute addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithWhite:1 alpha:0.5] range:[title rangeOfString:targetNum]]; } return attribute; } @@ -124,7 +124,8 @@ self.giftLabel.text = _giftInfo.giftName; self.priceLabel.text = [NSString stringWithFormat:@"%ld钻石", _giftInfo.goldPrice]; self.progressView.value = (CGFloat)giftInfo.actualNum / (CGFloat)_giftInfo.targetNum; - self.priceLabel.attributedText = [self createProgressAttribute]; + self.progressLabel.attributedText = [self createProgressAttribute]; + self.progressLabel.textAlignment = NSTextAlignmentCenter; self.completionImageView.hidden = _giftInfo.targetNum != _giftInfo.actualNum; } } @@ -184,15 +185,15 @@ - (UISlider *)progressView { if(!_progressView) { _progressView = [[UISlider alloc] init]; - _progressView.tintColor = [UIColor redColor]; _progressView.enabled = NO; - _progressView.minimumValueImage = [UIImage gradientColorImageFromColors:@[[ThemeColor colorWithHexString:@"#FFA0C3"], [ThemeColor colorWithHexString:@"#C176FF"]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(1, 1)]; - _progressView.maximumValueImage = [UIImage imageWithColor:[ThemeColor colorWithHexString:@"#17093E"]]; + [_progressView setMinimumTrackImage:[UIImage gradientColorImageFromColors:@[[ThemeColor colorWithHexString:@"#FFA0C3"], [ThemeColor colorWithHexString:@"#C176FF"]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(1, 1)] forState:UIControlStateNormal]; + _progressView.thumbTintColor = [UIColor clearColor]; + _progressView.value = 0.4l; + [_progressView setMaximumTrackImage:[UIImage imageWithColor:[ThemeColor colorWithHexString:@"#17093E"]] forState:UIControlStateNormal]; } return _progressView; } - - (UILabel *)progressLabel { if (!_progressLabel) { _progressLabel = [[UILabel alloc] init]; diff --git a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftListView.m b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftListView.m index 82a9962f..4950261f 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftListView.m +++ b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftListView.m @@ -60,12 +60,8 @@ @interface XPWishGiftListView () ///容器 @property (nonatomic,strong) UIStackView *stackView; -///选中的背景 -@property (nonatomic,strong) UIView *leftView; -///选中的背景 -@property (nonatomic,strong) UIView *rightView; ///选中的时候容器 -@property (nonatomic,strong) UIStackView *selectStackView; +@property (nonatomic,strong) UIView *selectView; ///标题 @property (nonatomic,strong) UILabel *titlelable; ///箭头 @@ -92,7 +88,7 @@ } #pragma mark - Public Method - (void)configDefaultInfo:(WishGiftInfoModel *)giftInfo { - if (giftInfo.level) { + if (giftInfo.levelName) { self.titlelable.text = giftInfo.levelName; } else { self.titlelable.text = giftInfo.giftName; @@ -105,13 +101,12 @@ self.layer.cornerRadius = 4; self.backgroundColor = UIColor.clearColor; [self addSubview:self.stackView]; - [self.stackView addArrangedSubview:self.selectStackView]; + [self.stackView addArrangedSubview:self.selectView]; [self.stackView addArrangedSubview:self.tableView]; - [self.selectStackView addArrangedSubview:self.leftView]; - [self.selectStackView addArrangedSubview:self.titlelable]; - [self.selectStackView addArrangedSubview:self.arrowImageView]; - [self.selectStackView addArrangedSubview:self.rightView]; + [self.selectView addSubview:self.titlelable]; + [self.selectView addSubview:self.arrowImageView]; + } - (void)initSubViewConstraints { @@ -124,7 +119,7 @@ make.top.mas_equalTo(self); }]; - [self.selectStackView mas_makeConstraints:^(MASConstraintMaker *make) { + [self.selectView mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(36); }]; @@ -134,14 +129,13 @@ [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(22, 22)); + make.right.mas_equalTo(self.selectView.mas_right).offset(-11); + make.centerY.mas_equalTo(self.selectView); }]; - [self.leftView mas_makeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(13); - }]; - - [self.rightView mas_makeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(13); + [self.titlelable mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerY.mas_equalTo(self.selectView); + make.left.mas_equalTo(self.selectView).offset(13); }]; } @@ -172,13 +166,14 @@ } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [tableView deselectRowAtIndexPath:indexPath animated:YES]; if (self.datasource.count > 0) { - self.tableView.hidden = YES; if (self.delegate && [self.delegate respondsToSelector:@selector(xPWishGiftListView:didSelectItem:)]) { WishGiftInfoModel * giftInfo = [self.datasource objectAtIndex:indexPath.row]; [self configDefaultInfo:giftInfo]; [self.delegate xPWishGiftListView:self didSelectItem:giftInfo]; } + self.tableView.hidden = YES; } } @@ -216,22 +211,16 @@ return _stackView; } -- (UIView *)leftView { - if (!_leftView) { - _leftView = [[UIView alloc] init]; - _leftView.backgroundColor = [UIColor clearColor]; +- (UIView *)selectView { + if (!_selectView) { + _selectView = [[UIView alloc] init]; + _selectView.backgroundColor = [UIColor clearColor]; + _selectView.backgroundColor = [ThemeColor colorWithHexString:@"#E4E4E4"]; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gamePlayButtonAction:)]; + [_selectView addGestureRecognizer:tap]; } - return _leftView; + return _selectView; } - -- (UIView *)rightView { - if (!_rightView) { - _rightView = [[UIView alloc] init]; - _rightView.backgroundColor = [UIColor clearColor]; - } - return _rightView; -} - - (UITableView *)tableView { if (!_tableView) { _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; @@ -249,20 +238,6 @@ return _tableView; } - -- (UIStackView *)selectStackView { - if (!_selectStackView) { - _selectStackView = [[UIStackView alloc] init]; - _selectStackView.axis = UILayoutConstraintAxisHorizontal; - _selectStackView.distribution = UIStackViewDistributionFillProportionally; - _selectStackView.alignment = UIStackViewAlignmentCenter; - _selectStackView.backgroundColor = [ThemeColor colorWithHexString:@"#E4E4E4"]; - UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gamePlayButtonAction:)]; - [_selectStackView addGestureRecognizer:tap]; - } - return _selectStackView; -} - - (UIImageView *)arrowImageView { if (!_arrowImageView) { _arrowImageView = [[UIImageView alloc] init]; diff --git a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateItemViewController.h b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateItemViewController.h index 442c17c5..8c41d4f0 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateItemViewController.h +++ b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateItemViewController.h @@ -8,11 +8,14 @@ #import "MvpViewController.h" NS_ASSUME_NONNULL_BEGIN - +@class WishGiftInfoModel; @interface XPWishGiftCreateItemViewController : MvpViewController ///房主的uid @property (nonatomic,strong) NSString *roomUid; +///需要修改的礼物信息 +@property (nonatomic,strong) WishGiftInfoModel *modifiGiftInfo; + ///创建完成 @property (nonatomic,copy) void(^Dismiss)(BOOL finish); @end diff --git a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateItemViewController.m b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateItemViewController.m index b6bffb60..bd60559d 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateItemViewController.m +++ b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateItemViewController.m @@ -72,10 +72,12 @@ #pragma mark - Private Method - (void)initWishGiftCongifList { - self.number = 1; - self.levleInfo = self.levelLists.firstObject; - [self handleLevleDatasource:self.levleInfo.level]; - [self.levelView configDefaultInfo:self.levleInfo]; + if (self.modifiGiftInfo == nil) { + self.number = 1; + self.levleInfo = self.levelLists.firstObject; + [self handleLevleDatasource:self.levleInfo.level]; + [self.levelView configDefaultInfo:self.levleInfo]; + } [self.presenter wishGiftConfigList:self.roomUid level:@"1"]; [self.presenter wishGiftConfigList:self.roomUid level:@"2"]; [self.presenter wishGiftConfigList:self.roomUid level:@"3"]; @@ -213,30 +215,33 @@ self.levleInfo = info; ///处理等级 [self handleLevleDatasource:info.level]; - WishGiftInfoModel * info; + WishGiftInfoModel * giftInfo; if (info.level == WishGiftLevel_Normal) { ///处理等级对应的礼物 if (self.levelOneGiftList.count > 0) { - info = self.levelOneGiftList.firstObject; + giftInfo = self.levelOneGiftList.firstObject; } self.giftView.datasource = self.levelOneGiftList; self.textField.text = @"10"; + [self handleGiftDatasource:self.levelThirdGiftList giftId:giftInfo.giftId]; } else if (info.level == WishGiftLevel_Middle) { if (self.levelTwoGiftList.count > 0) { - info = self.levelTwoGiftList.firstObject; + giftInfo = self.levelTwoGiftList.firstObject; } self.giftView.datasource = self.levelTwoGiftList; self.textField.text = @"10"; + [self handleGiftDatasource:self.levelThirdGiftList giftId:giftInfo.giftId]; } else { if (self.levelThirdGiftList.count > 0) { - info = self.levelThirdGiftList.firstObject; + giftInfo = self.levelThirdGiftList.firstObject; } self.giftView.datasource = self.levelThirdGiftList; self.textField.text = @"1"; + [self handleGiftDatasource:self.levelThirdGiftList giftId:giftInfo.giftId]; } + self.giftInfo = giftInfo; self.number = self.textField.text.intValue; - [self.giftView configDefaultInfo:info]; - [self handleLevleDatasource:info.level]; + [self.giftView configDefaultInfo:giftInfo]; } else { self.giftInfo = info; } @@ -246,7 +251,7 @@ - (void)wishGiftConfigListSucces:(NSArray *)list level:(NSString *)level { if (level.intValue == 1) { self.levelOneGiftList = list; - if (list.count > 0) { + if (list.count > 0 && !self.modifiGiftInfo) { self.giftInfo = list.firstObject; [self.giftView configDefaultInfo:list.firstObject]; self.giftView.datasource = self.levelOneGiftList; @@ -305,6 +310,40 @@ } #pragma mark - Getters And Setters +- (void)setModifiGiftInfo:(WishGiftInfoModel *)modifiGiftInfo { + _modifiGiftInfo = modifiGiftInfo; + if (_modifiGiftInfo) { + WishGiftInfoModel * levelInfo; + + for (WishGiftInfoModel * info in self.levelLists) { + if (info.level == _modifiGiftInfo.level) { + levelInfo = info; + } + } + if (levelInfo) { + self.levleInfo = levelInfo; + self.giftInfo = _modifiGiftInfo; + [self.levelView configDefaultInfo:levelInfo]; + [self.giftView configDefaultInfo:_modifiGiftInfo]; + ///处理等级 + [self handleLevleDatasource:levelInfo.level]; + ///处理等级 + if (_modifiGiftInfo.level == WishGiftLevel_Normal) { + [self handleGiftDatasource:self.levelOneGiftList giftId:_modifiGiftInfo.giftId]; + } else if (_modifiGiftInfo.level == WishGiftLevel_Middle) { + [self handleGiftDatasource:self.levelTwoGiftList giftId:_modifiGiftInfo.giftId]; + } else { + [self handleGiftDatasource:self.levelThirdGiftList giftId:_modifiGiftInfo.giftId]; + } + self.textField.text = [NSString stringWithFormat:@"%ld", _modifiGiftInfo.targetNum]; + self.number = (int)_modifiGiftInfo.targetNum; + + } else { + [self disMissView]; + } + } +} + - (UIView *)topView { if (!_topView) { _topView = [[UIView alloc] init]; @@ -315,6 +354,18 @@ return _topView; } + +- (UIView *)bottomView { + if (!_bottomView) { + _bottomView = [[UIView alloc] init]; + _bottomView.backgroundColor = [UIColor clearColor]; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(disMissView)]; + [_bottomView addGestureRecognizer:tap]; + } + return _bottomView; +} + + - (UIView *)backView { if (!_backView) { _backView = [[UIView alloc] init]; diff --git a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateViewController.m b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateViewController.m index 02d20603..15cb5d4e 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateViewController.m +++ b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateViewController.m @@ -116,7 +116,7 @@ cell = [[XPWishGiftTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPWishGiftTableViewCell class])]; } WishGiftInfoModel *giftInfo = [self.datasource objectAtIndex:indexPath.row]; - giftInfo.row = indexPath.row; + giftInfo.row = indexPath.row + 1; cell.giftInfo = giftInfo; cell.delegate = self; return cell; @@ -137,7 +137,16 @@ } - (void)xPWishGiftTableViewCell:(XPWishGiftTableViewCell *)view didUpdateWishGift:(WishGiftInfoModel *)info { -//TODO: 修改心愿单 + XPWishGiftCreateItemViewController * createItemVC = [[XPWishGiftCreateItemViewController alloc] init]; + createItemVC.roomUid = self.roomUid; + createItemVC.modifiGiftInfo = info; + @kWeakify(self); + createItemVC.Dismiss = ^(BOOL finish) { + @kStrongify(self); + [self initWishGiftList]; + }; + createItemVC.modalPresentationStyle = UIModalPresentationOverFullScreen; + [self.navigationController presentViewController:createItemVC animated:YES completion:nil]; } #pragma mark - XPWishGiftProtocol @@ -153,6 +162,7 @@ #pragma mark - Event Response - (void)rightButtonAction:(UIButton *)sender { XPWishGiftHistoryViewController * historyVC = [[XPWishGiftHistoryViewController alloc] init]; + historyVC.roomUid = self.roomUid; [self.navigationController pushViewController:historyVC animated:YES]; } diff --git a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftHistoryViewController.m b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftHistoryViewController.m index 37d4b5e4..b7213d18 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftHistoryViewController.m +++ b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftHistoryViewController.m @@ -11,6 +11,9 @@ ///Tool #import "ThemeColor.h" #import "XPMacro.h" +#import "PLTimeUtil.h" +///Model +#import "WishGiftHistoryModel.h" ///View #import "XPWishGiftHistoryTableViewCell.h" #import "XPWishGiftEmptyTableViewCell.h" @@ -23,7 +26,7 @@ ///列表 @property (nonatomic,strong) UITableView *tableView; ///数据源 -@property (nonatomic,strong) NSMutableArray *> *datasource; +@property (nonatomic,strong) NSArray *datasource; @end @implementation XPWishGiftHistoryViewController @@ -34,12 +37,14 @@ - (void)viewDidLoad { [super viewDidLoad]; + [self initWishGiftHistoryList]; [self initSubViews]; [self initSubViewConstraints]; } - (void)initSubViews { + self.title = @"历史心愿单"; [self.view addSubview:self.tableView]; } @@ -67,8 +72,8 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (self.datasource.count > 0) { - NSArray * array = [self.datasource objectAtIndex:section]; - return array.count; + WishGiftHistoryModel *info = [self.datasource objectAtIndex:section]; + return info.gifts.count; } return 0; } @@ -79,8 +84,9 @@ if (cell == nil) { cell = [[XPWishGiftHistoryTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPWishGiftHistoryTableViewCell class])]; } - NSArray * array = [self.datasource objectAtIndex:indexPath.section]; - WishGiftInfoModel * info= [array objectAtIndex:indexPath.row]; + WishGiftHistoryModel *historyInfo = [self.datasource objectAtIndex:indexPath.section]; + WishGiftInfoModel * info= [historyInfo.gifts objectAtIndex:indexPath.row]; + info.row = (indexPath.row + 1); cell.giftInfo = info; if (indexPath.row == 0) { cell.isTop = YES; @@ -88,7 +94,7 @@ cell.isTop = NO; } - if (indexPath.row == array.count -1) { + if (indexPath.row == historyInfo.gifts.count -1) { cell.isBottom = YES; } else { cell.isBottom = false; @@ -116,12 +122,22 @@ } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { - XPWishGiftSectionView * view = [[XPWishGiftSectionView alloc] init]; - view.frame = CGRectMake(0, 0, KScreenWidth, 45); - return view; + if (self.datasource.count > 0) { + XPWishGiftSectionView * view = [[XPWishGiftSectionView alloc] init]; + view.frame = CGRectMake(0, 0, KScreenWidth, 45); + WishGiftHistoryModel *historyInfo = [self.datasource objectAtIndex:section]; + view.title = historyInfo.createDate; + return view; + } + return [UIView new]; } #pragma mark - XPWishGiftProtocol +///历史心愿成功 +- (void)wishGiftHistroyListSuccess:(NSArray *)list { + self.datasource = list; + [self.tableView reloadData]; +} #pragma mark - Getters And Setters - (UITableView *)tableView { diff --git a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.h b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.h index 4a98c7bb..c9d2f054 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.h +++ b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.h @@ -9,10 +9,19 @@ NS_ASSUME_NONNULL_BEGIN +@protocol XPWishGiftViewControllerDelegate + +- (void)xPWishGiftViewControllerSendClick:(NSString *)giftId; + +@end + @interface XPWishGiftViewController : MvpViewController - (instancetype)initWithRoomUid:(NSString *)roomUid; +///代理 +@property (nonatomic,weak) id delegate; + @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.m b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.m index 7d8682aa..84e4991e 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.m +++ b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.m @@ -11,6 +11,7 @@ ///Tool #import "ThemeColor.h" #import "NetImageView.h" +#import "XPMacro.h" ///View #import "XPWishGiftInfoView.h" ///Model @@ -19,7 +20,7 @@ ///P #import "XPWishGiftPresenter.h" #import "XPWishGiftProtocol.h" -@interface XPWishGiftViewController () +@interface XPWishGiftViewController () ///顶部的view @property (nonatomic,strong) UIView *topView; ///背景 @@ -58,6 +59,7 @@ - (instancetype)initWithRoomUid:(NSString *)roomUid { if (self = [super init]) { + self.roomUid = roomUid; [self initDefaultData]; } return self; @@ -107,7 +109,7 @@ [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.mas_equalTo(self.view); - make.height.mas_equalTo(320); + make.height.mas_equalTo(283 + kSafeAreaBottomHeight); }]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { @@ -140,7 +142,7 @@ [self.giftStackView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self.backImageView); make.height.mas_equalTo(165); - make.bottom.mas_equalTo(self.backImageView).offset(-46); + make.bottom.mas_equalTo(self.backImageView).offset(-9 -kSafeAreaBottomHeight); }]; [self.firstView mas_makeConstraints:^(MASConstraintMaker *make) { @@ -151,11 +153,20 @@ make.width.mas_equalTo(106); }]; - [self.secondView mas_makeConstraints:^(MASConstraintMaker *make) { + [self.thirdView mas_makeConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(106); }]; } +#pragma mark - XPWishGiftInfoViewDelegate +- (void)xPWishGiftInfoView:(XPWishGiftInfoView *)view didClickSender:(WishGiftInfoModel *)info { + [self disMissView]; + if (info.giftId > 0 && self.delegate && [self.delegate respondsToSelector:@selector(xPWishGiftViewControllerSendClick:)]) { + NSString * giftId = [NSString stringWithFormat:@"%ld", info.giftId]; + [self.delegate xPWishGiftViewControllerSendClick:giftId]; + } +} + #pragma mark - XPWishGiftProtocol - (void)getWishGiftAssistUserListSuccess:(NSArray *)list { for (int i = 0; i < self.userStackView.subviews.count; i++) { @@ -172,7 +183,7 @@ NSString * number = [NSString stringWithFormat:@"%ld", list.count]; NSString * title = [NSString stringWithFormat:@"%@%@", number, @"人已助力"]; NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12], NSForegroundColorAttributeName:[ThemeColor textThirdColor]}]; - [attribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor colorWithHexString:@"#FFC300"] range:[number rangeOfString:title]]; + [attribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor colorWithHexString:@"#FFC300"] range:[title rangeOfString:number]]; self.assistNumLabel.attributedText = attribute; } @@ -194,8 +205,7 @@ view.hidden = YES; } } - - self.titleLabel.text = [NSString stringWithFormat:@"%d/%ld",finishNumber,list.count]; + self.titleLabel.text = [NSString stringWithFormat:@"今日心愿礼物%d/%ld",finishNumber,list.count]; } #pragma mark - Event Response @@ -285,7 +295,6 @@ return _secondAvatarImageView; } - - (NetImageView *)thirdAvatarImageView { if (!_thirdAvatarImageView) { NetImageConfig * config = [[NetImageConfig alloc]init]; @@ -305,9 +314,21 @@ return _assistNumLabel; } +- (UIStackView *)giftStackView { + if (!_giftStackView) { + _giftStackView = [[UIStackView alloc] init]; + _giftStackView.axis = UILayoutConstraintAxisHorizontal; + _giftStackView.distribution = UIStackViewDistributionFill; + _giftStackView.alignment = UIStackViewAlignmentFill; + _giftStackView.spacing = 12; + } + return _giftStackView; +} + - (XPWishGiftInfoView *)firstView { if(!_firstView) { _firstView = [[XPWishGiftInfoView alloc] init]; + _firstView.delegate = self; } return _firstView; } @@ -315,6 +336,7 @@ - (XPWishGiftInfoView *)secondView { if(!_secondView) { _secondView = [[XPWishGiftInfoView alloc] init]; + _secondView.delegate = self; } return _secondView; } @@ -322,6 +344,7 @@ - (XPWishGiftInfoView *)thirdView { if(!_thirdView) { _thirdView = [[XPWishGiftInfoView alloc] init]; + _thirdView.delegate = self; } return _thirdView; }