房间心愿除了特效礼物都完成了

This commit is contained in:
fengshuo
2022-10-20 18:36:38 +08:00
parent 9fdf1d7a07
commit b93d46fb3f
28 changed files with 618 additions and 125 deletions

View File

@@ -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 = "<group>"; };
E89DCF5828FFF1AD001647EC /* XPWishGiftSectionView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPWishGiftSectionView.h; sourceTree = "<group>"; };
E89DCF5928FFF1AD001647EC /* XPWishGiftSectionView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPWishGiftSectionView.m; sourceTree = "<group>"; };
E89DCF5B2900E5EE001647EC /* WishGiftHistoryModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WishGiftHistoryModel.h; sourceTree = "<group>"; };
E89DCF5C2900E5EE001647EC /* WishGiftHistoryModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WishGiftHistoryModel.m; sourceTree = "<group>"; };
E89DCF5E2900F4FB001647EC /* XPWishGiftEnterView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPWishGiftEnterView.h; sourceTree = "<group>"; };
E89DCF5F2900F4FB001647EC /* XPWishGiftEnterView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPWishGiftEnterView.m; sourceTree = "<group>"; };
E8A03DE02762FA000098D9EA /* XPCandyTreeMoreView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyTreeMoreView.h; sourceTree = "<group>"; };
E8A03DE12762FA000098D9EA /* XPCandyTreeMoreView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCandyTreeMoreView.m; sourceTree = "<group>"; };
E8A03DE7276301CC0098D9EA /* XPCandyRankContainerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyRankContainerView.h; sourceTree = "<group>"; };
@@ -7318,6 +7324,8 @@
E8A3539028FE5F0F0014A784 /* WishGiftInfoModel.m */,
E8A3539228FE605F0014A784 /* WishGiftUserModel.h */,
E8A3539328FE605F0014A784 /* WishGiftUserModel.m */,
E89DCF5B2900E5EE001647EC /* WishGiftHistoryModel.h */,
E89DCF5C2900E5EE001647EC /* WishGiftHistoryModel.m */,
);
path = Model;
sourceTree = "<group>";
@@ -7374,6 +7382,8 @@
E8A3540928FEC0510014A784 /* XPWishGiftListView.m */,
E89DCF5828FFF1AD001647EC /* XPWishGiftSectionView.h */,
E89DCF5928FFF1AD001647EC /* XPWishGiftSectionView.m */,
E89DCF5E2900F4FB001647EC /* XPWishGiftEnterView.h */,
E89DCF5F2900F4FB001647EC /* XPWishGiftEnterView.m */,
);
path = View;
sourceTree = "<group>";
@@ -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 */,

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@@ -31,6 +31,8 @@
+ (NSString *)getDateWithYYMM:(NSString *)time;
+ (NSString *)getDateWithMMDD:(NSString *)time;
+ (NSDate *)getDateWithYearMonthDay:(NSString *)time;
+ (NSString *)getMonthDayContent:(NSDate *)date;

View File

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

View File

@@ -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<NIMCustomAttachment>
@property (nonatomic,assign) int first;
@property (nonatomic,assign) int second;

View File

@@ -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 <self.datasource.count; i++) {
GiftInfoModel * gift = [self.datasource objectAtIndex:i];
if (gift.giftId == [self.defaultSelectGiftId integerValue]) {
[self dealSelectGift:gift];
self.selectIndex = [self.datasource indexOfObject:gift];
NSInteger page = i / 8;
currentPage = page;
break;
}
}
} else {
GiftInfoModel * gift = [self.datasource firstObject];
[self dealSelectGift:gift];
@@ -385,9 +396,9 @@
}
self.pageController.hidden = page <= 1 || _segmentType == GiftSegmentType_WeekStar;
[self.pageController setNumberOfPages:page];
self.pageController.currentPage = 0;
self.pageController.currentPage = currentPage;
self.selectCurrentPage = currentPage;
[self.giftcollectionView reloadData];
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoView:didClickSegment:)]) {
[self.delegate xPGiftInfoView:self didClickSegment:_segmentType];
}
@@ -395,6 +406,10 @@
if (self.segmentType != GiftSegmentType_Graffiti && self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoView:didClickItem:type:)]) {
[self.delegate xPGiftInfoView:self didClickItem:self.lastSelectGift type:_segmentType];
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.giftcollectionView setContentOffset:CGPointMake(self.selectCurrentPage * KScreenWidth, 0) animated:NO];;
});
}
- (void)setNormalOriginArray:(NSArray *)normalOriginArray {

View File

@@ -63,7 +63,6 @@
}
- (void)initSubViewConstraints {
self.backgroundColor = [UIColor redColor];
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(0);
make.left.right.mas_equalTo(self).inset(10);

View File

@@ -149,7 +149,10 @@ typedef NS_ENUM(NSInteger, RoomDatingStateChangeType) {
@property (nonatomic, assign) BOOL showPkBeginTime;
///跨房PK开始时间
@property (nonatomic, assign) long long pkBeginTime;
/// 是否有心愿礼物权限
@property (nonatomic,assign) BOOL hasWishGiftPermit;
///是否已经开启心愿礼物
@property (nonatomic,assign) BOOL hasOpenWishGift;
@end
NS_ASSUME_NONNULL_END

View File

@@ -29,6 +29,7 @@
#import "XPRoomMiniManager.h"
#import "Api+RoomPK.h"
#import "Api+Room.h"
#import "Api+WishGift.h"
#import "StatisticsServiceHelper.h"
///Model
#import "RoomInfoModel.h"
@@ -48,6 +49,7 @@
#import "GiftInfoModel.h"
#import "RoomPKTeamModel.h"
#import "RoomNewUserGreetModel.h"
#import "WishGiftInfoModel.h"
///View
#import "XPRoomHalfWebView.h"
#import "XPAnchorAudienceUpMicView.h"
@@ -78,6 +80,7 @@
#import "XPAcrossRoomPKCountDownView.h"
#import "XPNewUserRoomGiftView.h"
#import "XPWishGiftViewController.h"
#import "XPWishGiftEnterView.h"
///PK
#import "XPAnchorFansTeamEntranceView.h"
#import "XPAnchorFansTeamViewController.h"
@@ -86,7 +89,7 @@
#import "XPWebViewController.h"
#import "XPRoomPKProgressView.h"
@interface XPRoomFunctionContainerView ()<XPAcrpssRoomPKPanelViewDelegate, XPRoomLittleGameListViewDelegate, XPAnchorPkPanelViewDelegate, XPRoomBackMusicPlayerViewDelegate, XPRoomNewUserGreetViewDelegate>
@interface XPRoomFunctionContainerView ()<XPAcrpssRoomPKPanelViewDelegate, XPRoomLittleGameListViewDelegate, XPAnchorPkPanelViewDelegate, XPRoomBackMusicPlayerViewDelegate, XPRoomNewUserGreetViewDelegate, XPWishGiftViewControllerDelegate>
///host
@property (nonatomic,weak) id<RoomHostDelegate>delegate;
///
@@ -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];
}

View File

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

View File

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

View File

@@ -0,0 +1,21 @@
//
// WishGiftHistoryModel.h
// xplan-ios
//
// Created by 冯硕 on 2022/10/20.
//
#import <Foundation/Foundation.h>
#import "WishGiftInfoModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface WishGiftHistoryModel : NSObject
///创建时间
@property (nonatomic,strong) NSString *createDate;
///礼物列表
@property (nonatomic,strong) NSArray<WishGiftInfoModel *> *gifts;
@end
NS_ASSUME_NONNULL_END

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,15 @@
//
// XPWishGiftEnterView.h
// xplan-ios
//
// Created by 冯硕 on 2022/10/20.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPWishGiftEnterView : UIView
@property (nonatomic,strong) NSArray * giftList;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,223 @@
//
// XPWishGiftEnterView.m
// xplan-ios
//
// Created by on 2022/10/20.
//
#import "XPWishGiftEnterView.h"
///Third
#import <Masonry/Masonry.h>
#import <SDCycleScrollView.h>
#import <YYText.h>
///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()<SDCycleScrollViewDelegate>
///
@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

View File

@@ -10,7 +10,7 @@
NS_ASSUME_NONNULL_BEGIN
@class WishGiftInfoModel, XPWishGiftInfoView;
@protocol XPWishGiftInfoView <NSObject>
@protocol XPWishGiftInfoViewDelegate <NSObject>
- (void)xPWishGiftInfoView:(XPWishGiftInfoView *)view didClickSender:(WishGiftInfoModel *)info;
@@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic,strong) WishGiftInfoModel *giftInfo;
///代理
@property (nonatomic,weak) id<XPWishGiftInfoView> delegate;
@property (nonatomic,weak) id<XPWishGiftInfoViewDelegate> delegate;
@end

View File

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

View File

@@ -60,12 +60,8 @@
@interface XPWishGiftListView ()<UITableViewDelegate, UITableViewDataSource>
///
@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];

View File

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

View File

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

View File

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

View File

@@ -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<NSArray<WishGiftInfoModel *> *> *datasource;
@property (nonatomic,strong) NSArray<WishGiftHistoryModel *> *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 {

View File

@@ -9,10 +9,19 @@
NS_ASSUME_NONNULL_BEGIN
@protocol XPWishGiftViewControllerDelegate <NSObject>
- (void)xPWishGiftViewControllerSendClick:(NSString *)giftId;
@end
@interface XPWishGiftViewController : MvpViewController
- (instancetype)initWithRoomUid:(NSString *)roomUid;
///代理
@property (nonatomic,weak) id<XPWishGiftViewControllerDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -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 ()<XPWishGiftProtocol>
@interface XPWishGiftViewController ()<XPWishGiftProtocol, XPWishGiftInfoViewDelegate>
///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;
}