礼物面板可以显示礼物了
@@ -96,6 +96,7 @@
|
||||
73FFADDC93E195344047A2EC /* Pods_xplan_ios.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CACF623970097D653132D69A /* Pods_xplan_ios.framework */; };
|
||||
9B0E1C5926E77022005D4442 /* BaseNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0E1C5826E77022005D4442 /* BaseNavigationController.m */; };
|
||||
E80487652717DDD9008595F2 /* XPRoomMenuItem.m in Sources */ = {isa = PBXBuildFile; fileRef = E80487642717DDD9008595F2 /* XPRoomMenuItem.m */; };
|
||||
E8133916273E532D00708B66 /* XPGiftItemCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E8133915273E532D00708B66 /* XPGiftItemCollectionViewCell.m */; };
|
||||
E81366E326F0A1FC0076364C /* LoginBindPhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E81366E226F0A1FC0076364C /* LoginBindPhoneViewController.m */; };
|
||||
E81366E726F0A49E0076364C /* NSString+Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = E81366E626F0A49E0076364C /* NSString+Utils.m */; };
|
||||
E81366F326F0B7C80076364C /* LoginFullInfoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E81366F226F0B7C80076364C /* LoginFullInfoViewController.m */; };
|
||||
@@ -143,6 +144,7 @@
|
||||
E86596432701611A00846EBD /* UIImage+ImageEffects.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596412701611A00846EBD /* UIImage+ImageEffects.m */; };
|
||||
E86596512701A1C000846EBD /* StatisticsService.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596502701A1C000846EBD /* StatisticsService.m */; };
|
||||
E86596542701A55500846EBD /* StatisticsServiceHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596532701A55500846EBD /* StatisticsServiceHelper.m */; };
|
||||
E8659909273E800D00EE349D /* XPGiftCollectionViewFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = E8659908273E800D00EE349D /* XPGiftCollectionViewFlowLayout.m */; };
|
||||
E8680718271967B00024F48F /* MicroView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8680717271967B00024F48F /* MicroView.m */; };
|
||||
E872308926E89BE000B90D4F /* LoginPhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308826E89BE000B90D4F /* LoginPhoneViewController.m */; };
|
||||
E872308D26E89DAA00B90D4F /* LoginInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308C26E89DAA00B90D4F /* LoginInputView.m */; };
|
||||
@@ -429,6 +431,8 @@
|
||||
CACF623970097D653132D69A /* Pods_xplan_ios.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_xplan_ios.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
E80487632717DDD9008595F2 /* XPRoomMenuItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMenuItem.h; sourceTree = "<group>"; };
|
||||
E80487642717DDD9008595F2 /* XPRoomMenuItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomMenuItem.m; sourceTree = "<group>"; };
|
||||
E8133914273E532D00708B66 /* XPGiftItemCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPGiftItemCollectionViewCell.h; sourceTree = "<group>"; };
|
||||
E8133915273E532D00708B66 /* XPGiftItemCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPGiftItemCollectionViewCell.m; sourceTree = "<group>"; };
|
||||
E81366E126F0A1FC0076364C /* LoginBindPhoneViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginBindPhoneViewController.h; sourceTree = "<group>"; };
|
||||
E81366E226F0A1FC0076364C /* LoginBindPhoneViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginBindPhoneViewController.m; sourceTree = "<group>"; };
|
||||
E81366E526F0A49E0076364C /* NSString+Utils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSString+Utils.h"; sourceTree = "<group>"; };
|
||||
@@ -518,6 +522,8 @@
|
||||
E86596502701A1C000846EBD /* StatisticsService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StatisticsService.m; sourceTree = "<group>"; };
|
||||
E86596522701A55500846EBD /* StatisticsServiceHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatisticsServiceHelper.h; sourceTree = "<group>"; };
|
||||
E86596532701A55500846EBD /* StatisticsServiceHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StatisticsServiceHelper.m; sourceTree = "<group>"; };
|
||||
E8659907273E800D00EE349D /* XPGiftCollectionViewFlowLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPGiftCollectionViewFlowLayout.h; sourceTree = "<group>"; };
|
||||
E8659908273E800D00EE349D /* XPGiftCollectionViewFlowLayout.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPGiftCollectionViewFlowLayout.m; sourceTree = "<group>"; };
|
||||
E8680716271967B00024F48F /* MicroView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MicroView.h; sourceTree = "<group>"; };
|
||||
E8680717271967B00024F48F /* MicroView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MicroView.m; sourceTree = "<group>"; };
|
||||
E872308726E89BE000B90D4F /* LoginPhoneViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginPhoneViewController.h; sourceTree = "<group>"; };
|
||||
@@ -1563,6 +1569,10 @@
|
||||
E878894B273A607C00BF1D57 /* XPGiftUserCollectionViewCell.m */,
|
||||
E890BC05273CF1800007C46B /* XPGiftCountCollectionViewCell.h */,
|
||||
E890BC06273CF1800007C46B /* XPGiftCountCollectionViewCell.m */,
|
||||
E8133914273E532D00708B66 /* XPGiftItemCollectionViewCell.h */,
|
||||
E8133915273E532D00708B66 /* XPGiftItemCollectionViewCell.m */,
|
||||
E8659907273E800D00EE349D /* XPGiftCollectionViewFlowLayout.h */,
|
||||
E8659908273E800D00EE349D /* XPGiftCollectionViewFlowLayout.m */,
|
||||
);
|
||||
path = Cell;
|
||||
sourceTree = "<group>";
|
||||
@@ -2171,6 +2181,7 @@
|
||||
18E7B22626E8CDCF0064BC9B /* XplanFlutterBoostDelegate.m in Sources */,
|
||||
E8EEB8F326FC2050007C6EBA /* SDWaitingView.m in Sources */,
|
||||
E8788942273A55AD00BF1D57 /* XPGiftUsersView.m in Sources */,
|
||||
E8659909273E800D00EE349D /* XPGiftCollectionViewFlowLayout.m in Sources */,
|
||||
E8B846CB26FDD7CD00A777FE /* XPMineRechargeViewController.m in Sources */,
|
||||
E86596512701A1C000846EBD /* StatisticsService.m in Sources */,
|
||||
E824544026F58F9400BE8163 /* XPMinePayPwdViewController.m in Sources */,
|
||||
@@ -2329,6 +2340,7 @@
|
||||
18E7B29026EA0E6B0064BC9B /* FlutterBoost+Xplan.m in Sources */,
|
||||
E8B846DC26FDE24300A777FE /* RechargeListModel.m in Sources */,
|
||||
189DD75926E6003C00AB55B1 /* Api.m in Sources */,
|
||||
E8133916273E532D00708B66 /* XPGiftItemCollectionViewCell.m in Sources */,
|
||||
E8788934273A53D700BF1D57 /* XPSendGiftView.m in Sources */,
|
||||
E88B5CB826FB325200DA9178 /* XPMineTeenagerPwdPresenter.m in Sources */,
|
||||
E84B0E462727EF9D008818C6 /* XPRoomMessageParser.m in Sources */,
|
||||
|
22
xplan-ios/Assets.xcassets/Gift/gift_diamond.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_diamond@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_diamond@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Gift/gift_diamond.imageset/gift_diamond@2x.png
vendored
Normal file
After Width: | Height: | Size: 728 B |
BIN
xplan-ios/Assets.xcassets/Gift/gift_diamond.imageset/gift_diamond@3x.png
vendored
Normal file
After Width: | Height: | Size: 1.4 KiB |
22
xplan-ios/Assets.xcassets/Gift/gift_tag_effect.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_effect@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_effect@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Gift/gift_tag_effect.imageset/gift_tag_effect@2x.png
vendored
Normal file
After Width: | Height: | Size: 460 B |
BIN
xplan-ios/Assets.xcassets/Gift/gift_tag_effect.imageset/gift_tag_effect@3x.png
vendored
Normal file
After Width: | Height: | Size: 999 B |
22
xplan-ios/Assets.xcassets/Gift/gift_tag_exclude.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_exclude@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_exclude@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Gift/gift_tag_exclude.imageset/gift_tag_exclude@2x.png
vendored
Normal file
After Width: | Height: | Size: 431 B |
BIN
xplan-ios/Assets.xcassets/Gift/gift_tag_exclude.imageset/gift_tag_exclude@3x.png
vendored
Normal file
After Width: | Height: | Size: 913 B |
22
xplan-ios/Assets.xcassets/Gift/gift_tag_latest.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_latest@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_latest@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Gift/gift_tag_latest.imageset/gift_tag_latest@2x.png
vendored
Normal file
After Width: | Height: | Size: 461 B |
BIN
xplan-ios/Assets.xcassets/Gift/gift_tag_latest.imageset/gift_tag_latest@3x.png
vendored
Normal file
After Width: | Height: | Size: 1.0 KiB |
22
xplan-ios/Assets.xcassets/Gift/gift_tag_time_limit.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_time_limit@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "gift_tag_time_limit@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Gift/gift_tag_time_limit.imageset/gift_tag_time_limit@2x.png
vendored
Normal file
After Width: | Height: | Size: 465 B |
BIN
xplan-ios/Assets.xcassets/Gift/gift_tag_time_limit.imageset/gift_tag_time_limit@3x.png
vendored
Normal file
After Width: | Height: | Size: 1.0 KiB |
@@ -46,7 +46,7 @@
|
||||
/// @param roomUid 房主的uid 获取房间专属礼物
|
||||
- (void)getNormalGiftList:(NSString *)roomUid {
|
||||
[Api requestNormalGiftList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
NSArray * info = [GiftInfoModel modelsWithArray:data.data];
|
||||
NSArray * info = [GiftInfoModel modelsWithArray:data.data[@"gift"]];
|
||||
[[self getView] getNormalGiftListSuccess:info];
|
||||
} roomUid:roomUid];
|
||||
}
|
||||
|
@@ -18,6 +18,16 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
+ (UIColor *)giftBackGroundColor;
|
||||
///钱包余额信息 0xffffff 0.5
|
||||
+ (UIColor *)giftBalanceColor;
|
||||
/// 送礼物 分页指示器的颜色
|
||||
+ (UIColor *)giftPageIndicatorColor;
|
||||
/// 分段控制器文字默认的颜色 #0C0B0C
|
||||
+ (UIColor *)giftSegmentNormalTitleColor;
|
||||
/// 礼物选中的时候的颜色 0xFF903E
|
||||
+ (UIColor *)giftNameSelectColor;
|
||||
/// 礼物选中的时候的颜色 0xFF903E 0.65
|
||||
+ (UIColor *)giftPriceSelectColor;
|
||||
/// 礼物价格没有选中的时候的眼色#0B0B0D
|
||||
+ (UIColor *)giftPriceNormalColor;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -19,7 +19,7 @@
|
||||
return UIColorFromRGB(0xFF903E);
|
||||
}
|
||||
|
||||
/// 礼物主背景色 #0B0B0D
|
||||
/// 礼物主背景色 #0C0B0C
|
||||
+ (UIColor *)giftBackGroundColor {
|
||||
return UIColorRGBAlpha(0x0C0B0C, 0.9);
|
||||
}
|
||||
@@ -28,5 +28,24 @@
|
||||
+ (UIColor *)giftBalanceColor {
|
||||
return UIColorRGBAlpha(0xffffff, 0.5);
|
||||
}
|
||||
|
||||
/// 送礼物 分页指示器的颜色
|
||||
+ (UIColor *)giftPageIndicatorColor {
|
||||
return [UIColor whiteColor];
|
||||
}
|
||||
/// 分段控制器文字默认的颜色 #0C0B0C
|
||||
+ (UIColor *)giftSegmentNormalTitleColor {
|
||||
return UIColorFromRGB(0x0C0B0C);
|
||||
}
|
||||
/// 礼物选中的时候的颜色 0xFF903E
|
||||
+ (UIColor *)giftNameSelectColor {
|
||||
return UIColorFromRGB(0xFF903E);
|
||||
}
|
||||
/// 礼物选中的时候的颜色 0xFF903E 0.65
|
||||
+ (UIColor *)giftPriceSelectColor {
|
||||
return UIColorRGBAlpha(0xFF903E, 0.65);
|
||||
}
|
||||
/// 礼物价格没有选中的时候的眼色#0B0B0D
|
||||
+ (UIColor *)giftPriceNormalColor {
|
||||
return UIColorRGBAlpha(0xffffff, 0.5);;
|
||||
}
|
||||
@end
|
||||
|
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// XPGiftCollectionViewFlowLayout.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/11/12.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPGiftCollectionViewFlowLayout : UICollectionViewFlowLayout
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,148 @@
|
||||
//
|
||||
// XPGiftCollectionViewFlowLayout.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/11/12.
|
||||
//
|
||||
|
||||
#import "XPGiftCollectionViewFlowLayout.h"
|
||||
|
||||
@interface XPGiftCollectionViewFlowLayout ()
|
||||
@property (nonatomic, copy) NSMutableDictionary *sectionDic;
|
||||
@property (nonatomic, strong) NSMutableArray *allAttributes;
|
||||
@end
|
||||
|
||||
@implementation XPGiftCollectionViewFlowLayout
|
||||
#pragma mark - life cycle
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - overload
|
||||
|
||||
- (void)prepareLayout {
|
||||
|
||||
[super prepareLayout];
|
||||
|
||||
_sectionDic = [NSMutableDictionary dictionary];
|
||||
self.allAttributes = [NSMutableArray array];
|
||||
//获取section的数量
|
||||
NSUInteger section = [self.collectionView numberOfSections];
|
||||
|
||||
for (int sec = 0; sec < section; sec++) {
|
||||
//获取每个section的cell个数
|
||||
NSUInteger count = [self.collectionView numberOfItemsInSection:sec];
|
||||
|
||||
for (NSUInteger item = 0; item<count; item++) {
|
||||
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:item inSection:sec];
|
||||
//重新排列
|
||||
UICollectionViewLayoutAttributes *attributes = [self layoutAttributesForItemAtIndexPath:indexPath];
|
||||
[self.allAttributes addObject:attributes];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (CGSize)collectionViewContentSize {
|
||||
|
||||
//每个section的页码的总数
|
||||
NSInteger actualLo = 0;
|
||||
for (NSString *key in [_sectionDic allKeys]) {
|
||||
actualLo += [_sectionDic[key] integerValue];
|
||||
}
|
||||
return CGSizeMake(actualLo*self.collectionView.frame.size.width, self.collectionView.contentSize.height);
|
||||
}
|
||||
|
||||
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
|
||||
UICollectionViewLayoutAttributes *attr = [super layoutAttributesForItemAtIndexPath:indexPath].copy;
|
||||
|
||||
[self applyLayoutAttributes:attr];
|
||||
return attr;
|
||||
}
|
||||
|
||||
- (NSArray<UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect {
|
||||
|
||||
return self.allAttributes;
|
||||
}
|
||||
|
||||
#pragma mark - private method
|
||||
|
||||
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)attributes {
|
||||
|
||||
if(attributes.representedElementKind != nil){
|
||||
return;
|
||||
}
|
||||
//attributes 的宽度
|
||||
CGFloat itemW = attributes.frame.size.width;
|
||||
//attributes 的高度
|
||||
CGFloat itemH = attributes.frame.size.height;
|
||||
|
||||
//collectionView 的宽度
|
||||
CGFloat width = self.collectionView.frame.size.width;
|
||||
//collectionView 的高度
|
||||
CGFloat height = self.collectionView.frame.size.height;
|
||||
//每个attributes的下标值 从0开始
|
||||
NSInteger itemIndex = attributes.indexPath.item;
|
||||
|
||||
CGFloat stride = (self.scrollDirection == UICollectionViewScrollDirectionHorizontal) ? width : height;
|
||||
|
||||
|
||||
//获取现在的attributes是第几组
|
||||
NSInteger section = attributes.indexPath.section;
|
||||
//获取每个section的item的个数
|
||||
NSInteger itemCount = [self.collectionView numberOfItemsInSection:section];
|
||||
|
||||
|
||||
CGFloat offset = section * stride;
|
||||
|
||||
//计算x方向item个数
|
||||
NSInteger xCount = (width / itemW);
|
||||
//计算y方向item个数
|
||||
NSInteger yCount = (height / itemH);
|
||||
//计算一页总个数
|
||||
NSInteger allCount = (xCount * yCount);
|
||||
//获取每个section的页数,从0开始
|
||||
NSInteger page = itemIndex / allCount;
|
||||
|
||||
//余数,用来计算item的x的偏移量
|
||||
NSInteger remain = (itemIndex % xCount);
|
||||
//取商,用来计算item的y的偏移量
|
||||
NSInteger merchant = (itemIndex-page*allCount)/xCount;
|
||||
|
||||
|
||||
//x方向每个item的偏移量
|
||||
CGFloat xCellOffset = remain * itemW;
|
||||
//y方向每个item的偏移量
|
||||
CGFloat yCellOffset = merchant * itemH;
|
||||
|
||||
//获取每个section中item占了几页
|
||||
NSInteger pageRe = (itemCount % allCount == 0)? (itemCount / allCount) : (itemCount / allCount) + 1;
|
||||
//将每个section与pageRe对应,计算下面的位置
|
||||
[_sectionDic setValue:@(pageRe) forKey:[NSString stringWithFormat:@"%ld", section]];
|
||||
|
||||
if(self.scrollDirection == UICollectionViewScrollDirectionHorizontal) {
|
||||
|
||||
NSInteger actualLo = 0;
|
||||
//将每个section中的页数相加
|
||||
for (NSString *key in [_sectionDic allKeys]) {
|
||||
actualLo += [_sectionDic[key] integerValue];
|
||||
}
|
||||
//获取到的最后的数减去最后一组的页码数
|
||||
actualLo -= [_sectionDic[[NSString stringWithFormat:@"%ld", [_sectionDic allKeys].count-1]] integerValue];
|
||||
xCellOffset += page*width + actualLo*width;
|
||||
|
||||
} else {
|
||||
|
||||
yCellOffset += offset;
|
||||
}
|
||||
|
||||
attributes.frame = CGRectMake(xCellOffset, yCellOffset, itemW, itemH);
|
||||
}
|
||||
|
||||
|
||||
@end
|
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// XPGiftItemCollectionViewCell.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/11/12.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class GiftInfoModel;
|
||||
@interface XPGiftItemCollectionViewCell : UICollectionViewCell
|
||||
///
|
||||
@property (nonatomic,strong) GiftInfoModel *giftInfo;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,223 @@
|
||||
//
|
||||
// XPGiftItemCollectionViewCell.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/11/12.
|
||||
//
|
||||
|
||||
#import "XPGiftItemCollectionViewCell.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
///Tool
|
||||
#import "ThemeColor+SendGift.h"
|
||||
#import "NetImageView.h"
|
||||
///Model
|
||||
#import "GiftInfoModel.h"
|
||||
|
||||
@interface XPGiftItemCollectionViewCell ()
|
||||
///礼物图片
|
||||
@property (nonatomic,strong) NetImageView *giftImageView;
|
||||
///礼物名称
|
||||
@property (nonatomic,strong) UILabel *giftNameLabel;
|
||||
///
|
||||
@property (nonatomic,strong) UIStackView *priceStackView;
|
||||
///价格
|
||||
@property (nonatomic,strong) UILabel *priceLabel;
|
||||
///💎
|
||||
@property (nonatomic,strong) UIImageView *logoImageView;
|
||||
///
|
||||
@property (nonatomic,strong) UIStackView *tagStackView;
|
||||
///新的
|
||||
@property (nonatomic,strong) UIImageView *giftNewImageView;
|
||||
///特别的
|
||||
@property (nonatomic,strong) UIImageView *specialImageView;
|
||||
///限定
|
||||
@property (nonatomic,strong) UIImageView *limitImageView;
|
||||
///专属
|
||||
@property (nonatomic,strong) UIImageView *exclusiveImageView;
|
||||
///
|
||||
@property (nonatomic,strong) UIView * coverView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XPGiftItemCollectionViewCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self.contentView addSubview:self.tagStackView];
|
||||
[self.contentView addSubview:self.giftImageView];
|
||||
[self.contentView addSubview:self.giftNameLabel];
|
||||
[self.contentView addSubview:self.priceStackView];
|
||||
[self.contentView addSubview:self.coverView];
|
||||
|
||||
[self.tagStackView addArrangedSubview:self.exclusiveImageView];
|
||||
[self.tagStackView addArrangedSubview:self.giftNewImageView];
|
||||
[self.tagStackView addArrangedSubview:self.limitImageView];
|
||||
[self.tagStackView addArrangedSubview:self.specialImageView];
|
||||
|
||||
[self.priceStackView addArrangedSubview:self.priceLabel];
|
||||
[self.priceStackView addArrangedSubview:self.logoImageView];
|
||||
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.tagStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.top.mas_equalTo(self.contentView);
|
||||
make.height.mas_equalTo(14);
|
||||
}];
|
||||
|
||||
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self);
|
||||
}];
|
||||
|
||||
|
||||
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.contentView).offset(18);
|
||||
make.centerX.mas_equalTo(self.contentView);
|
||||
make.size.mas_equalTo(CGSizeMake(48, 48));
|
||||
}];
|
||||
|
||||
[self.giftNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.giftImageView.mas_bottom).offset(3);
|
||||
make.centerX.mas_equalTo(self.giftImageView);
|
||||
}];
|
||||
|
||||
[self.priceStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.giftNameLabel.mas_bottom).offset(5);
|
||||
make.centerX.equalTo(self.contentView);
|
||||
make.height.mas_equalTo(10);
|
||||
}];
|
||||
}
|
||||
|
||||
- (UIImageView *)createImageView:(NSString *)imageName {
|
||||
UIImageView * imageView = [[UIImageView alloc] init];
|
||||
imageView.userInteractionEnabled = YES;
|
||||
imageView.image = [UIImage imageNamed:imageName];
|
||||
return imageView;
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setGiftInfo:(GiftInfoModel *)giftInfo {
|
||||
_giftInfo = giftInfo;
|
||||
if (_giftInfo) {
|
||||
self.giftImageView.imageUrl = giftInfo.giftUrl;
|
||||
self.giftNameLabel.text = _giftInfo.giftName.length > 0 ? _giftInfo.giftName : @"";
|
||||
self.coverView.hidden = !giftInfo.isSelected;
|
||||
NSString *strr = [NSString stringWithFormat:@"%ld",(long)_giftInfo.goldPrice];
|
||||
self.priceLabel.text = strr;
|
||||
|
||||
self.exclusiveImageView.hidden = !_giftInfo.roomExclude;
|
||||
self.giftNewImageView.hidden = !_giftInfo.hasLatest;
|
||||
self.limitImageView.hidden = !_giftInfo.hasTimeLimit;
|
||||
self.specialImageView.hidden = !_giftInfo.hasEffect;
|
||||
}
|
||||
}
|
||||
|
||||
- (UIStackView *)tagStackView {
|
||||
if (!_tagStackView) {
|
||||
_tagStackView = [[UIStackView alloc] init];
|
||||
_tagStackView.axis = UILayoutConstraintAxisHorizontal;
|
||||
_tagStackView.distribution = UIStackViewDistributionFill;
|
||||
_tagStackView.alignment = UIStackViewAlignmentCenter;
|
||||
_tagStackView.spacing = 2;
|
||||
}
|
||||
return _tagStackView;
|
||||
}
|
||||
|
||||
- (UIImageView *)exclusiveImageView {
|
||||
if (!_exclusiveImageView) {
|
||||
_exclusiveImageView = [self createImageView:@"gift_tag_exclude"];
|
||||
}
|
||||
return _exclusiveImageView;
|
||||
}
|
||||
|
||||
- (UIImageView *)limitImageView {
|
||||
if (!_limitImageView) {
|
||||
_limitImageView = [self createImageView:@"gift_tag_time_limit"];
|
||||
}
|
||||
return _limitImageView;
|
||||
}
|
||||
|
||||
- (UIImageView *)specialImageView {
|
||||
if (!_specialImageView) {
|
||||
_specialImageView = [self createImageView:@"gift_tag_effect"];
|
||||
}
|
||||
return _specialImageView;
|
||||
}
|
||||
- (UIImageView *)giftNewImageView {
|
||||
if (!_giftNewImageView) {
|
||||
_giftNewImageView = [self createImageView:@"gift_tag_latest"];
|
||||
}
|
||||
return _giftNewImageView;
|
||||
}
|
||||
|
||||
- (UIStackView *)priceStackView {
|
||||
if (!_priceStackView) {
|
||||
_priceStackView = [[UIStackView alloc] init];
|
||||
_priceStackView.axis = UILayoutConstraintAxisHorizontal;
|
||||
_priceStackView.distribution = UIStackViewDistributionEqualSpacing;
|
||||
_priceStackView.alignment = UIStackViewAlignmentCenter;
|
||||
_priceStackView.spacing = 2;
|
||||
}
|
||||
return _priceStackView;
|
||||
}
|
||||
|
||||
- (UIImageView *)logoImageView {
|
||||
if (!_logoImageView) {
|
||||
_logoImageView = [self createImageView:@"gift_diamond"];
|
||||
}
|
||||
return _logoImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)priceLabel {
|
||||
if (!_priceLabel) {
|
||||
_priceLabel = [[UILabel alloc] init];
|
||||
_priceLabel.font = [UIFont systemFontOfSize:9];
|
||||
_priceLabel.textColor = [ThemeColor giftPriceNormalColor];
|
||||
}
|
||||
return _priceLabel;
|
||||
}
|
||||
|
||||
|
||||
- (UILabel *)giftNameLabel {
|
||||
if (!_giftNameLabel) {
|
||||
_giftNameLabel = [[UILabel alloc] init];
|
||||
_giftNameLabel.font = [UIFont systemFontOfSize:10];
|
||||
_giftNameLabel.textAlignment = NSTextAlignmentCenter;
|
||||
_giftNameLabel.textColor = [ThemeColor mainTextColor];
|
||||
}
|
||||
return _giftNameLabel;
|
||||
}
|
||||
|
||||
- (UIView *)coverView {
|
||||
if (!_coverView) {
|
||||
_coverView = [[UIView alloc] init];
|
||||
_coverView.backgroundColor = [ThemeColor appMainColor];
|
||||
_coverView.alpha = 0.6;
|
||||
_coverView.layer.borderColor = [ThemeColor appMainColor].CGColor;
|
||||
_coverView.layer.borderWidth = 1;
|
||||
_coverView.hidden = YES;
|
||||
}
|
||||
return _coverView;
|
||||
}
|
||||
|
||||
- (NetImageView *)giftImageView {
|
||||
if (!_giftImageView) {
|
||||
_giftImageView = [[NetImageView alloc] init];
|
||||
_giftImageView.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
return _giftImageView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
@@ -8,13 +8,20 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSInteger, GiftSegmentType) {
|
||||
GiftSegmentType_Normal = 1, ///普通的礼物
|
||||
GiftSegmentType_Lucky,///幸运礼物
|
||||
GiftSegmentType_Pack,///背包礼物
|
||||
};
|
||||
|
||||
@class GiftInfoModel;
|
||||
@interface XPGiftInfoView : UIView
|
||||
|
||||
///普通礼物/幸运礼物
|
||||
@property (nonatomic,strong) NSArray *normalGiftArray;
|
||||
@property (nonatomic,strong) NSArray *normalOriginArray;
|
||||
///背包礼物
|
||||
@property (nonatomic,strong) NSArray *packGiftArray;
|
||||
@property (nonatomic,strong) NSArray *packOriginArray;
|
||||
|
||||
@end
|
||||
|
||||
|
@@ -8,6 +8,40 @@
|
||||
#import "XPGiftInfoView.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
///Tool
|
||||
#import "XPMacro.h"
|
||||
#import "ThemeColor+SendGift.h"
|
||||
///
|
||||
#import "GiftInfoModel.h"
|
||||
///View
|
||||
#import "XPGiftItemCollectionViewCell.h"
|
||||
#import "XPGiftCollectionViewFlowLayout.h"
|
||||
@interface XPGiftInfoView ()<UICollectionViewDelegate, UICollectionViewDataSource>
|
||||
///
|
||||
@property (nonatomic,strong) UIStackView *segmentStackView;
|
||||
///
|
||||
@property (nonatomic,strong) UIButton *normalGiftButton;
|
||||
///
|
||||
@property (nonatomic,strong) UIButton *packGiftButton;
|
||||
///
|
||||
@property (nonatomic,strong) UIButton *luckyGiftButton;
|
||||
///占位的
|
||||
@property (nonatomic,strong) UIView * segmentPlaceView;
|
||||
///
|
||||
@property (nonatomic,strong) UIStackView *giftStackView;
|
||||
///l礼物列表
|
||||
@property (nonatomic,strong) UICollectionView *giftcollectionView;
|
||||
///分页控件
|
||||
@property (nonatomic, strong) UIPageControl *pageController;
|
||||
///礼物的数据源
|
||||
@property (nonatomic,strong) NSArray<NSArray<GiftInfoModel *> *> *giftArray;
|
||||
///幸运礼物的数据源
|
||||
@property (nonatomic,strong) NSArray<NSArray<GiftInfoModel *> *> *giftLuckyArray;
|
||||
///背包礼物的数据源
|
||||
@property (nonatomic,strong) NSArray<NSArray<GiftInfoModel *> *> *giftPackArray;
|
||||
///当前展示的数据的类型
|
||||
@property (nonatomic,assign) GiftSegmentType segmentType;
|
||||
@end
|
||||
|
||||
@implementation XPGiftInfoView
|
||||
|
||||
@@ -17,20 +51,246 @@
|
||||
if (self) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
self.segmentType = GiftSegmentType_Normal;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Response
|
||||
- (void)didClickGiftSegmentAction:(UIButton *)sender {
|
||||
self.segmentType = sender.tag;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
self.backgroundColor = [UIColor yellowColor];
|
||||
|
||||
[self addSubview:self.segmentStackView];
|
||||
[self addSubview:self.giftStackView];
|
||||
///分段控制
|
||||
[self.segmentStackView addArrangedSubview:self.normalGiftButton];
|
||||
[self.segmentStackView addArrangedSubview:self.luckyGiftButton];
|
||||
[self.segmentStackView addArrangedSubview:self.packGiftButton];
|
||||
[self.segmentStackView addArrangedSubview:self.segmentPlaceView];
|
||||
///礼物
|
||||
[self.giftStackView addArrangedSubview:self.giftcollectionView];
|
||||
[self.giftStackView addArrangedSubview:self.pageController];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(250);
|
||||
make.height.mas_equalTo(30 + 105 * 2 + 10 + 10);
|
||||
}];
|
||||
|
||||
|
||||
[self.segmentStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.left.right.mas_equalTo(self);
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
[self.giftStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.segmentStackView.mas_bottom);
|
||||
make.left.right.mas_equalTo(self);
|
||||
make.height.mas_equalTo(105 * 2 + 20);
|
||||
}];
|
||||
|
||||
[self.giftcollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(105 * 2 + 10);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
- (NSArray<NSArray<GiftInfoModel *> *> *)dealGiftArray:(NSArray<GiftInfoModel *> *)originArray {
|
||||
if (originArray.count <= 0) {
|
||||
return nil;
|
||||
}
|
||||
///总共有几页 每页有8个
|
||||
int page = (int)originArray.count / 8;
|
||||
if (page > 0) {
|
||||
NSMutableArray * sectionArray = [NSMutableArray array];
|
||||
for (int i = 0; i < page; i++) {
|
||||
NSMutableArray * rowArray = [NSMutableArray array];
|
||||
for (int j = 0; j< 8 ; j++) {
|
||||
int row = i * 8 + j;
|
||||
GiftInfoModel * info = [originArray objectAtIndex:row];
|
||||
[rowArray addObject:info];
|
||||
}
|
||||
[sectionArray addObject:rowArray];
|
||||
}
|
||||
return sectionArray;
|
||||
} else {
|
||||
return @[originArray];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UICollectionViewDelegate And UICollectionDatasource
|
||||
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
|
||||
if (self.segmentType == GiftSegmentType_Normal) {
|
||||
return self.giftArray.count;
|
||||
} else if(self.segmentType == GiftSegmentType_Lucky) {
|
||||
return self.giftLuckyArray.count;
|
||||
} else if(self.segmentType == GiftSegmentType_Pack) {
|
||||
return self.giftPackArray.count;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
||||
if (self.segmentType == GiftSegmentType_Normal) {
|
||||
return self.giftArray[section].count;
|
||||
} else if(self.segmentType == GiftSegmentType_Lucky) {
|
||||
return self.giftLuckyArray[section].count;
|
||||
} else if(self.segmentType == GiftSegmentType_Pack) {
|
||||
return self.giftPackArray[section].count;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
XPGiftItemCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftItemCollectionViewCell class]) forIndexPath:indexPath];
|
||||
GiftInfoModel * giftInfo;
|
||||
if (self.segmentType == GiftSegmentType_Normal) {
|
||||
giftInfo= [[self.giftArray objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
|
||||
} else if(self.segmentType == GiftSegmentType_Lucky) {
|
||||
giftInfo= [[self.giftLuckyArray objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
|
||||
} else if(self.segmentType == GiftSegmentType_Pack) {
|
||||
giftInfo= [[self.giftPackArray objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
|
||||
}
|
||||
cell.giftInfo = giftInfo;
|
||||
return cell;
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setSegmentType:(GiftSegmentType)segmentType {
|
||||
_segmentType = segmentType;
|
||||
[self.giftcollectionView reloadData];
|
||||
}
|
||||
|
||||
- (void)setNormalOriginArray:(NSArray *)normalOriginArray {
|
||||
_normalOriginArray = normalOriginArray;
|
||||
NSMutableArray * luckyArray = [NSMutableArray array];
|
||||
NSMutableArray * normaleArray = [NSMutableArray array];
|
||||
[_normalOriginArray enumerateObjectsUsingBlock:^(GiftInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if (obj.giftType == GiftType_Lucky) {
|
||||
[luckyArray addObject:obj];
|
||||
} else {
|
||||
[normaleArray addObject:obj];
|
||||
}
|
||||
}];
|
||||
self.giftArray = [self dealGiftArray:[normaleArray copy]];
|
||||
self.giftLuckyArray = [self dealGiftArray:[luckyArray copy]];
|
||||
[self.giftcollectionView reloadData];
|
||||
}
|
||||
|
||||
- (void)setPackOriginArray:(NSArray *)packOriginArray {
|
||||
_packOriginArray = packOriginArray;
|
||||
self.giftPackArray = [self dealGiftArray:[_packOriginArray copy]];
|
||||
[self.giftcollectionView reloadData];
|
||||
}
|
||||
|
||||
|
||||
- (UIStackView *)segmentStackView {
|
||||
if (!_segmentStackView) {
|
||||
_segmentStackView = [[UIStackView alloc] init];
|
||||
_segmentStackView.axis = UILayoutConstraintAxisHorizontal;
|
||||
_segmentStackView.distribution = UIStackViewDistributionFill;
|
||||
_segmentStackView.alignment = UIStackViewAlignmentCenter;
|
||||
_segmentStackView.spacing = 22;
|
||||
_segmentStackView.backgroundColor = [UIColor redColor];
|
||||
}
|
||||
return _segmentStackView;
|
||||
}
|
||||
|
||||
- (UIStackView *)giftStackView {
|
||||
if (!_giftStackView) {
|
||||
_giftStackView = [[UIStackView alloc] init];
|
||||
_giftStackView.axis = UILayoutConstraintAxisVertical;
|
||||
_giftStackView.distribution = UIStackViewDistributionFill;
|
||||
_giftStackView.alignment = UIStackViewAlignmentFill;
|
||||
_giftStackView.spacing = 0;
|
||||
}
|
||||
return _giftStackView;
|
||||
}
|
||||
|
||||
- (UIButton *)normalGiftButton {
|
||||
if (!_normalGiftButton) {
|
||||
_normalGiftButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_normalGiftButton setTitle:@"礼物" forState:UIControlStateNormal];
|
||||
[_normalGiftButton setTitleColor:[ThemeColor mainTextColor] forState:UIControlStateSelected];
|
||||
[_normalGiftButton setTitleColor:[ThemeColor giftSegmentNormalTitleColor] forState:UIControlStateNormal];
|
||||
_normalGiftButton.titleLabel.font = [UIFont systemFontOfSize:10];
|
||||
_normalGiftButton.tag = GiftSegmentType_Normal;
|
||||
_normalGiftButton.selected = YES;
|
||||
[_normalGiftButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _normalGiftButton;
|
||||
}
|
||||
|
||||
- (UIButton *)luckyGiftButton {
|
||||
if (!_luckyGiftButton) {
|
||||
_luckyGiftButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_luckyGiftButton setTitle:@"幸运礼物" forState:UIControlStateNormal];
|
||||
[_luckyGiftButton setTitleColor:[ThemeColor mainTextColor] forState:UIControlStateSelected];
|
||||
[_luckyGiftButton setTitleColor:[ThemeColor giftSegmentNormalTitleColor] forState:UIControlStateNormal];
|
||||
_luckyGiftButton.titleLabel.font = [UIFont systemFontOfSize:10];
|
||||
_luckyGiftButton.tag = GiftSegmentType_Lucky;
|
||||
_luckyGiftButton.selected = NO;
|
||||
[_luckyGiftButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _luckyGiftButton;
|
||||
}
|
||||
|
||||
- (UIButton *)packGiftButton {
|
||||
if (!_packGiftButton) {
|
||||
_packGiftButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_packGiftButton setTitle:@"背包" forState:UIControlStateNormal];
|
||||
[_packGiftButton setTitleColor:[ThemeColor mainTextColor] forState:UIControlStateSelected];
|
||||
[_packGiftButton setTitleColor:[ThemeColor giftSegmentNormalTitleColor] forState:UIControlStateNormal];
|
||||
_packGiftButton.titleLabel.font = [UIFont systemFontOfSize:10];
|
||||
_packGiftButton.tag = GiftSegmentType_Pack;
|
||||
_packGiftButton.selected = NO;
|
||||
[_packGiftButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _packGiftButton;
|
||||
}
|
||||
|
||||
- (UICollectionView *)giftcollectionView{
|
||||
if (!_giftcollectionView) {
|
||||
XPGiftCollectionViewFlowLayout *layout = [[XPGiftCollectionViewFlowLayout alloc] init];
|
||||
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||||
CGFloat itemWidth = (KScreenWidth - 10 - 5 * 3) / 4;
|
||||
layout.itemSize = CGSizeMake(itemWidth, 105);
|
||||
layout.minimumLineSpacing = 5;
|
||||
layout.minimumInteritemSpacing = 10;
|
||||
layout.sectionInset = UIEdgeInsetsMake(0, 5, 0, 5);
|
||||
_giftcollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
||||
_giftcollectionView.dataSource = self;
|
||||
_giftcollectionView.delegate = self;
|
||||
_giftcollectionView.backgroundColor = [UIColor clearColor];
|
||||
[_giftcollectionView registerClass:[XPGiftItemCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftItemCollectionViewCell class])];
|
||||
}
|
||||
return _giftcollectionView;
|
||||
}
|
||||
|
||||
|
||||
- (UIPageControl *)pageController {
|
||||
if (!_pageController) {
|
||||
_pageController = [[UIPageControl alloc] init];
|
||||
_pageController.currentPageIndicatorTintColor = [ThemeColor giftPageIndicatorColor];
|
||||
}
|
||||
return _pageController;
|
||||
}
|
||||
|
||||
- (UIView *)segmentPlaceView {
|
||||
if (!_segmentPlaceView) {
|
||||
_segmentPlaceView = [[UIView alloc] init];
|
||||
_segmentPlaceView.backgroundColor = [UIColor yellowColor];
|
||||
}
|
||||
return _segmentPlaceView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
@@ -118,12 +118,12 @@
|
||||
|
||||
///普通礼物 /幸运礼物
|
||||
- (void)getPacketGiftListSuccess:(NSArray<GiftInfoModel *> *)giftList {
|
||||
self.giftInfoView.packGiftArray = giftList;
|
||||
self.giftInfoView.packOriginArray = giftList;
|
||||
}
|
||||
|
||||
///背包礼物
|
||||
- (void)getNormalGiftListSuccess:(NSArray<GiftInfoModel *> *)giftList {
|
||||
self.giftInfoView.normalGiftArray = giftList;
|
||||
self.giftInfoView.normalOriginArray = giftList;
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
|
@@ -61,8 +61,8 @@
|
||||
}
|
||||
|
||||
// TODO: [setImageUrl] 和 [loadImage] 重复加载,需要逻辑优化。
|
||||
- (void)setImageUrl:(NSString *)url {
|
||||
_imageUrl = url;
|
||||
- (void)setImageUrl:(NSString *)imageUrl {
|
||||
_imageUrl = imageUrl;
|
||||
_innerConfigedUrl = [UIImageConstant configUrl:_imageUrl type:self.imageType radius:self.radius];
|
||||
UIImage * image = [[SDImageCache sharedImageCache] imageFromCacheForKey:_innerConfigedUrl];
|
||||
if (image) {
|
||||
|