朋友圈一部分UI temp
22
xplan-ios/Assets.xcassets/Monents/monents_info_top.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "monents_info_top@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "monents_info_top@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Monents/monents_info_top.imageset/monents_info_top@2x.png
vendored
Normal file
After Width: | Height: | Size: 968 B |
BIN
xplan-ios/Assets.xcassets/Monents/monents_info_top.imageset/monents_info_top@3x.png
vendored
Normal file
After Width: | Height: | Size: 1.4 KiB |
22
xplan-ios/Assets.xcassets/Monents/monents_info_topic_icon.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "monents_info_topic_icon@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "monents_info_topic_icon@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Monents/monents_info_topic_icon.imageset/monents_info_topic_icon@2x.png
vendored
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
xplan-ios/Assets.xcassets/Monents/monents_info_topic_icon.imageset/monents_info_topic_icon@3x.png
vendored
Normal file
After Width: | Height: | Size: 2.2 KiB |
22
xplan-ios/Assets.xcassets/Tabbar/tab_monents_normal.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "tab_monents_normal@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "tab_monents_normal@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Tabbar/tab_monents_normal.imageset/tab_monents_normal@2x.png
vendored
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
xplan-ios/Assets.xcassets/Tabbar/tab_monents_normal.imageset/tab_monents_normal@3x.png
vendored
Normal file
After Width: | Height: | Size: 2.2 KiB |
22
xplan-ios/Assets.xcassets/Tabbar/tab_monents_select.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "tab_monents_select@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "tab_monents_select@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Tabbar/tab_monents_select.imageset/tab_monents_select@2x.png
vendored
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
xplan-ios/Assets.xcassets/Tabbar/tab_monents_select.imageset/tab_monents_select@3x.png
vendored
Normal file
After Width: | Height: | Size: 2.3 KiB |
@@ -20,6 +20,7 @@ UIKIT_EXTERN NSString * const kImageTypeUserLibaryDetail;//用户相册大图nil
|
||||
UIKIT_EXTERN NSString * const kImageTypeCornerAvatar;//圆角图形,会先把图形裁剪成正方形,并且转换为png
|
||||
UIKIT_EXTERN NSString * const kImageTypeUserInfoAlbum;//用户信息里面相册
|
||||
UIKIT_EXTERN NSString * const kImageTypeUserCardLevel;///用户资料卡中 等级以高度20等比例缩放
|
||||
UIKIT_EXTERN NSString * const kImageTypeMonentsPhoto;///动态中的图片
|
||||
typedef NS_ENUM(NSUInteger, ImageType){
|
||||
ImageTypeRoomFace = 1, //房间表情
|
||||
ImageTypeRoomGift, //房间礼物
|
||||
@@ -27,7 +28,8 @@ typedef NS_ENUM(NSUInteger, ImageType){
|
||||
ImageTypeUserLibaryDetail, //用户相册大图
|
||||
ImageTypeCornerAvatar, //圆角图形,会先把图形裁剪成正方形,并且转换为png
|
||||
ImageTypeUserInfoAlbum, ///用户信息里面相册
|
||||
ImageTypeUserCardLevel /// 用户资料卡中 等级以高度20等比例缩放
|
||||
ImageTypeUserCardLevel, /// 用户资料卡中 等级以高度20等比例缩放
|
||||
ImageTypeMonentsPhoto, ///动态中的图片
|
||||
};
|
||||
|
||||
///展位图
|
||||
|
@@ -22,7 +22,8 @@ NSString * const kImageTypeCornerAvatar = @"imageMogr2/auto-orient/thumbnail/300
|
||||
NSString * const kImageTypeUserInfoAlbum = @"imageMogr2/auto-orient/blur/375x375";
|
||||
/// 用户信息里面相册
|
||||
NSString * const kImageTypeUserCardLevel = @"imageMogr2/thumbnail/x40";
|
||||
|
||||
/// 动态中的图片 400 * 400
|
||||
NSString * const kImageTypeMonentsPhoto = @"imageMogr2/auto-orient/thumbnail/400x400";
|
||||
|
||||
/// 头像的默认占位图
|
||||
+ (UIImage *)defaultAvatarPlaceholder {
|
||||
@@ -76,6 +77,8 @@ NSString * const kImageTypeUserCardLevel = @"imageMogr2/thumbnail/x40";
|
||||
break;
|
||||
case ImageTypeUserCardLevel:
|
||||
configUrl = kImageTypeUserCardLevel;
|
||||
case ImageTypeMonentsPhoto:
|
||||
configUrl = kImageTypeMonentsPhoto;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
43
xplan-ios/Main/Monents/Api/Api+Monents.h
Normal file
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// Api+Monents.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/5/13.
|
||||
//
|
||||
|
||||
#import "Api.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface Api (Monents)
|
||||
/// 朋友圈动态推荐列表
|
||||
/// @param completion 完成
|
||||
/// @param page 当前的页数
|
||||
/// @param pageSize 一页的个数
|
||||
/// @param types 类型 0,2
|
||||
+ (void)monentsRecommendList:(HttpRequestHelperCompletion)completion page:(NSString *)page pageSize:(NSString *)pageSize types:(NSString *)types;
|
||||
|
||||
/// 朋友圈动态最新列表
|
||||
/// @param completion 完成
|
||||
/// @param dynamicId 最新动态的id
|
||||
/// @param pageSize 一页的个数
|
||||
/// @param types 类型 0,2
|
||||
+ (void)monentsLatestList:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId pageSize:(NSString *)pageSize types:(NSString *)types;
|
||||
|
||||
/// 朋友圈动态关注列表
|
||||
/// @param completion 完成
|
||||
/// @param dynamicId 最新动态的id
|
||||
/// @param pageSize 一页的个数
|
||||
/// @param types 类型 0,2
|
||||
+ (void)monentsFollowerList:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId pageSize:(NSString *)pageSize types:(NSString *)types;
|
||||
|
||||
/// 分享动态
|
||||
/// @param completion 完成
|
||||
/// @param dynamicId 动态的id
|
||||
/// @param uid 动态发布者的uid
|
||||
/// @param worldId 动态的话题id
|
||||
/// @param shareUid 分享者的uid
|
||||
+ (void)userShareMonents:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId uid:(NSString *)uid worldId:(NSString *)worldId shareUid:(NSString *)shareUid;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
49
xplan-ios/Main/Monents/Api/Api+Monents.m
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// Api+Monents.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/5/13.
|
||||
//
|
||||
|
||||
#import "Api+Monents.h"
|
||||
|
||||
@implementation Api (Monents)
|
||||
|
||||
/// 朋友圈动态推荐列表
|
||||
/// @param completion 完成
|
||||
/// @param page 当前的页数
|
||||
/// @param pageSize 一页的个数
|
||||
/// @param types 类型 0,2
|
||||
+ (void)monentsRecommendList:(HttpRequestHelperCompletion)completion page:(NSString *)page pageSize:(NSString *)pageSize types:(NSString *)types {
|
||||
[self makeRequest:@"dynamic/square/recommendDynamics" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, page, pageSize, types, nil];
|
||||
}
|
||||
|
||||
/// 朋友圈动态最新列表
|
||||
/// @param completion 完成
|
||||
/// @param dynamicId 最新动态的id
|
||||
/// @param pageSize 一页的个数
|
||||
/// @param types 类型 0,2
|
||||
+ (void)monentsLatestList:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId pageSize:(NSString *)pageSize types:(NSString *)types {
|
||||
[self makeRequest:@"dynamic/square/latestDynamics" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, dynamicId, pageSize, types, nil];
|
||||
}
|
||||
|
||||
/// 朋友圈动态关注列表
|
||||
/// @param completion 完成
|
||||
/// @param dynamicId 最新动态的id
|
||||
/// @param pageSize 一页的个数
|
||||
/// @param types 类型 0,2
|
||||
+ (void)monentsFollowerList:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId pageSize:(NSString *)pageSize types:(NSString *)types {
|
||||
[self makeRequest:@"dynamic/square/latestDynamics" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, dynamicId, pageSize, types, nil];
|
||||
}
|
||||
|
||||
/// 分享动态
|
||||
/// @param completion 完成
|
||||
/// @param dynamicId 动态的id
|
||||
/// @param uid 动态发布者的uid
|
||||
/// @param worldId 动态的话题id
|
||||
/// @param shareUid 分享者的uid
|
||||
+ (void)userShareMonents:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId uid:(NSString *)uid worldId:(NSString *)worldId shareUid:(NSString *)shareUid {
|
||||
[self makeRequest:@"dynamic/share" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, dynamicId, uid, worldId, shareUid, nil];
|
||||
}
|
||||
|
||||
@end
|
@@ -71,6 +71,14 @@ typedef NS_ENUM(NSInteger, MonentsContentType) {
|
||||
@property (nonatomic,assign) BOOL isFold;
|
||||
///cell的高度
|
||||
@property (nonatomic,assign) CGFloat rowHeight;
|
||||
///图片的高度
|
||||
@property (nonatomic,assign) CGFloat picHeight;
|
||||
///文本内容的高度
|
||||
@property (nonatomic,assign) CGFloat contentHeight;
|
||||
///显示的内容的富文本
|
||||
@property (nonatomic,strong) NSMutableAttributedString *contentAttribute;
|
||||
///收起的
|
||||
@property (nonatomic,strong, nullable) NSMutableAttributedString *foldAttribute;
|
||||
@end
|
||||
|
||||
@interface MonentsPicInfoModel : NSObject
|
||||
|
@@ -10,6 +10,12 @@
|
||||
#define aMinute 60
|
||||
|
||||
@implementation MonentsInfoModel
|
||||
- (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
self.isFold = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (NSDictionary *)objectClassInArray {
|
||||
return @{@"dynamicResList":MonentsPicInfoModel.class};
|
||||
@@ -17,7 +23,7 @@
|
||||
|
||||
|
||||
- (NSString *)publishTime {
|
||||
return [self stringWithTimeStamp:self.publishTime];
|
||||
return [self stringWithTimeStamp:_publishTime];
|
||||
}
|
||||
|
||||
- (NSString *)stringWithTimeStamp:(NSString *)timeStamp {
|
||||
@@ -74,6 +80,7 @@
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@@ -11,14 +11,18 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
#define kMONENTS_CONTENT_LEFT_PADDING 67
|
||||
#define kMONENTS_CONTENT_RIGHT_PADDING 36
|
||||
#define kMONENTS_CONTENT_MAX_WIDTH (KScreenWidth -kMONENTS_CONTENT_LEFT_PADDING - kMONENTS_CONTENT_RIGHT_PADDING)
|
||||
#define kMONENTS_PIC_ONE_WIDTH 150 ///只有一个动态图片的高度
|
||||
#define kMONENTS_PIC_ONE_WIDTH 200 ///只有一个动态图片的高度
|
||||
#define kMONENTS_PIC_SPACE 4 ///图片之间的间隙的宽度或者高度
|
||||
#define kMONENTS_USER_INFO_HEIGHT 60 ///用户信息的高度
|
||||
#define kMONENTS_TOOL_BAR_HEIGHT 58 ///底部操作栏的高度
|
||||
#define kMONENTS_CONTENT_SPACAE_HEIGHT 12 /// 每个内容之间下面的间隙的高度
|
||||
#define kMONENTS_TEXT_TOPIC_HEIGHT 20 /// 话题的高度
|
||||
#define kMONENTS_FOLD_HEIGHT 20 /// 展开 关闭的高度
|
||||
@class MonentsInfoModel;
|
||||
@interface XPMonentsLayoutConfig : NSObject
|
||||
|
||||
+ (void)layoutMonentsModel:(MonentsInfoModel *)monents;
|
||||
+ (CGFloat)monentsPicHeight:(MonentsInfoModel *)monents;
|
||||
+ (CGFloat)monentsContentHeight:(MonentsInfoModel *)monents;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -6,7 +6,102 @@
|
||||
//
|
||||
|
||||
#import "XPMonentsLayoutConfig.h"
|
||||
#import <YYText/YYText.h>
|
||||
#import "ThemeColor.h"
|
||||
///Model
|
||||
#import "MonentsInfoModel.h"
|
||||
|
||||
@implementation XPMonentsLayoutConfig
|
||||
|
||||
+ (void)layoutMonentsModel:(MonentsInfoModel *)monents {
|
||||
CGFloat rowHeight = kMONENTS_USER_INFO_HEIGHT+ 20;
|
||||
///用户信息和文字之间的间隙
|
||||
rowHeight = rowHeight + kMONENTS_CONTENT_SPACAE_HEIGHT;
|
||||
///文字内容的高度
|
||||
rowHeight = rowHeight + [self monentsContentHeight:monents];
|
||||
///图片的高度
|
||||
rowHeight = rowHeight + [self monentsPicHeight:monents];
|
||||
///如果没有图片的话 间隙就只有一个
|
||||
if (monents.type == MonentsContentType_Picture) {
|
||||
rowHeight = rowHeight + kMONENTS_CONTENT_SPACAE_HEIGHT * 2;
|
||||
}else {
|
||||
rowHeight = rowHeight + kMONENTS_CONTENT_SPACAE_HEIGHT;
|
||||
}
|
||||
///话题的高度
|
||||
rowHeight = rowHeight + kMONENTS_TEXT_TOPIC_HEIGHT;
|
||||
///底部操作栏的高度
|
||||
rowHeight = rowHeight + kMONENTS_TOOL_BAR_HEIGHT;
|
||||
monents.rowHeight = rowHeight;
|
||||
}
|
||||
|
||||
+ (CGFloat)monentsPicHeight:(MonentsInfoModel *)monents {
|
||||
///计算图片的高度
|
||||
NSInteger picCount = monents.dynamicResList.count;
|
||||
CGFloat picHeight;
|
||||
if (picCount == 0) {
|
||||
picHeight = 0;
|
||||
} else if(picCount == 1) {
|
||||
picHeight = kMONENTS_PIC_ONE_WIDTH;
|
||||
} else if(picCount == 2) {
|
||||
picHeight = (kMONENTS_CONTENT_MAX_WIDTH - kMONENTS_PIC_SPACE) / 2;
|
||||
} else {
|
||||
if (picCount > 9) {
|
||||
picCount = 9;
|
||||
}
|
||||
CGFloat itemWidth = (kMONENTS_CONTENT_MAX_WIDTH - kMONENTS_PIC_SPACE * 2) / 3;
|
||||
NSInteger page = picCount % 3;
|
||||
NSInteger line = picCount / 3;
|
||||
if (page == 0) {
|
||||
picHeight = itemWidth * line + (line -1)* kMONENTS_PIC_SPACE;
|
||||
} else {
|
||||
picHeight = itemWidth * (line +1) + line * kMONENTS_PIC_SPACE;
|
||||
}
|
||||
}
|
||||
monents.picHeight = picHeight;
|
||||
return picHeight;
|
||||
}
|
||||
|
||||
+ (CGFloat)monentsContentHeight:(MonentsInfoModel *)monents {
|
||||
///计算文本的高度
|
||||
if (!monents.contentAttribute) {
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||||
///置顶
|
||||
if (monents.squareTop) {
|
||||
UIImageView *imageView = [[UIImageView alloc]init];
|
||||
imageView.frame = CGRectMake(0, 0, 36, 14);
|
||||
imageView.image = [UIImage imageNamed:@"monents_info_top"];
|
||||
NSMutableAttributedString * topAttrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.frame.size.width, imageView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||||
[attribute appendAttributedString:topAttrString];
|
||||
}
|
||||
|
||||
///文本
|
||||
NSString * text = monents.content;
|
||||
if (text == nil || text.length <= 0) {
|
||||
text = @"";
|
||||
}
|
||||
NSMutableAttributedString *contentAttribute = [[NSMutableAttributedString alloc] initWithString:text attributes:nil];
|
||||
contentAttribute.yy_font = [UIFont systemFontOfSize:14];
|
||||
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
paraStyle.lineSpacing = 4.0f;//行间距
|
||||
// 强制排版(从左到右)
|
||||
paraStyle.alignment = NSTextAlignmentLeft;
|
||||
paraStyle.baseWritingDirection = NSWritingDirectionLeftToRight;
|
||||
contentAttribute.yy_paragraphStyle = paraStyle;
|
||||
[attribute appendAttributedString:contentAttribute];
|
||||
monents.contentAttribute = attribute;
|
||||
}
|
||||
|
||||
YYTextContainer *container = [YYTextContainer new];
|
||||
container.size = CGSizeMake(kMONENTS_CONTENT_MAX_WIDTH, CGFLOAT_MAX);
|
||||
container.maximumNumberOfRows = 0;
|
||||
YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:monents.contentAttribute];
|
||||
CGFloat foldHeight = 0;
|
||||
if (layout.rowCount > 6) {
|
||||
foldHeight = kMONENTS_FOLD_HEIGHT;
|
||||
}
|
||||
YYTextLayout *realLayout = [YYTextLayout layoutWithContainer:container text:monents.contentAttribute];
|
||||
monents.contentHeight = realLayout.textBoundingSize.height;
|
||||
return realLayout.textBoundingSize.height + foldHeight;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// XPMonentsRecommendPresenter.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/5/13.
|
||||
//
|
||||
|
||||
#import "BaseMvpPresenter.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPMonentsRecommendPresenter : BaseMvpPresenter
|
||||
/// 获取朋友圈动态推荐列表
|
||||
/// @param page 当前的页数
|
||||
/// @param pageSize 一页的个数
|
||||
/// @param state 状态
|
||||
- (void)getMonentsRecommendList:(NSInteger)page pageSize:(NSInteger)pageSize state:(int)state;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// XPMonentsRecommendPresenter.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/5/13.
|
||||
//
|
||||
|
||||
#import "XPMonentsRecommendPresenter.h"
|
||||
#import "Api+Monents.h"
|
||||
#import "MonentsInfoModel.h"
|
||||
#import "XPMonentsRecommendProtocol.h"
|
||||
@implementation XPMonentsRecommendPresenter
|
||||
|
||||
|
||||
/// 获取朋友圈动态推荐列表
|
||||
/// @param page 当前的页数
|
||||
/// @param pageSize 一页的个数
|
||||
/// @param state 状态
|
||||
- (void)getMonentsRecommendList:(NSInteger)page pageSize:(NSInteger)pageSize state:(int)state {
|
||||
NSString * pageStr = [NSString stringWithFormat:@"%ld", page];
|
||||
NSString * pageSizeStr = [NSString stringWithFormat:@"%ld", pageSize];
|
||||
[Api monentsRecommendList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
NSArray *array = [MonentsInfoModel modelsWithArray:data.data];
|
||||
[[self getView] getMonentsRecommendListSuccess:array state:state];
|
||||
}] page:pageStr pageSize:pageSizeStr types:@"0,2"];
|
||||
}
|
||||
|
||||
|
||||
@end
|
19
xplan-ios/Main/Monents/Protocol/XPMonentsRecommendProtocol.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// XPMonentsRecommendProtocol.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/5/13.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol XPMonentsRecommendProtocol <NSObject>
|
||||
|
||||
///获取推荐列表从成功
|
||||
- (void)getMonentsRecommendListSuccess:(NSArray *)array state:(int)state;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// XPMonentsEmptyTableViewCell.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/5/13.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPMonentsEmptyTableViewCell : UITableViewCell
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// XPMonentsEmptyTableViewCell.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/5/13.
|
||||
//
|
||||
|
||||
#import "XPMonentsEmptyTableViewCell.h"
|
||||
|
||||
@implementation XPMonentsEmptyTableViewCell
|
||||
|
||||
- (void)awakeFromNib {
|
||||
[super awakeFromNib];
|
||||
// Initialization code
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||||
[super setSelected:selected animated:animated];
|
||||
|
||||
// Configure the view for the selected state
|
||||
}
|
||||
|
||||
@end
|
@@ -8,7 +8,7 @@
|
||||
#import "XPMonentsTableViewCell.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <YYText/YYText.h>
|
||||
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "NetImageView.h"
|
||||
@@ -20,6 +20,8 @@
|
||||
#import "XPMonentsPhotoView.h"
|
||||
#import "XPMonentsTooBarView.h"
|
||||
#import "XPMoentsTopicView.h"
|
||||
#import "XPMonentsContentView.h"
|
||||
#import "XPMonentsLayoutConfig.h"
|
||||
@interface XPMonentsTableViewCell ()
|
||||
///显示颜色的 有的时候stackView 不能显示颜色
|
||||
@property (nonatomic,strong) UIView * backView;
|
||||
@@ -27,12 +29,12 @@
|
||||
@property (nonatomic,strong) UIStackView *stackView;
|
||||
///用户信息
|
||||
@property (nonatomic,strong) XPMonentsUserInfoView * userInfoView;
|
||||
///显示内容的
|
||||
@property (nonatomic,strong) XPMonentsContentView *textView;
|
||||
///图片
|
||||
@property (nonatomic,strong) XPMonentsPhotoView *photoView;
|
||||
///显示底部的操作栏
|
||||
@property (nonatomic,strong) XPMonentsTooBarView *toolBarView;
|
||||
///显示内容
|
||||
@property (nonatomic,strong) YYLabel *contentLabel;
|
||||
///话题
|
||||
@property (nonatomic,strong) XPMoentsTopicView *topicView;
|
||||
@end
|
||||
@@ -57,7 +59,7 @@
|
||||
[self.backView addSubview:self.stackView];
|
||||
[self.backView addSubview:self.toolBarView];
|
||||
|
||||
[self.stackView addArrangedSubview:self.contentLabel];
|
||||
[self.stackView addArrangedSubview:self.textView];
|
||||
[self.stackView addArrangedSubview:self.photoView];
|
||||
[self.stackView addArrangedSubview:self.topicView];
|
||||
}
|
||||
@@ -67,13 +69,8 @@
|
||||
make.edges.mas_equalTo(self.contentView);
|
||||
}];
|
||||
|
||||
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.contentView);
|
||||
}];
|
||||
|
||||
[self.userInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.backView);
|
||||
make.right.mas_equalTo(self.backView);
|
||||
make.left.right.top.mas_equalTo(self.backView);
|
||||
make.height.mas_equalTo(kMONENTS_USER_INFO_HEIGHT);
|
||||
}];
|
||||
|
||||
@@ -94,55 +91,31 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)createMonentsContentAttribute {
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||||
if (self.monentsInfo.squareTop) {
|
||||
[attribute appendAttributedString:[self createImageAttribute:[UIImage imageNamed:@""]]];
|
||||
}
|
||||
|
||||
NSString * text = _monentsInfo.content;
|
||||
if (text == nil || text.length <= 0) {
|
||||
text = @"";
|
||||
}
|
||||
NSMutableAttributedString *contentAttribute = [[NSMutableAttributedString alloc] initWithString:text attributes:nil];
|
||||
contentAttribute.yy_font = [UIFont systemFontOfSize:14];
|
||||
contentAttribute.yy_color = [ThemeColor mainTextColor];
|
||||
contentAttribute.yy_paragraphStyle = [self paragraphStyle];
|
||||
[attribute appendAttributedString:contentAttribute];
|
||||
return attribute;
|
||||
}
|
||||
|
||||
/// 生成本地一个图片的富文本
|
||||
/// @param image 本地的图片
|
||||
- (NSMutableAttributedString *)createImageAttribute:(UIImage *)image {
|
||||
UIImageView *imaveView = [[UIImageView alloc]init];
|
||||
imaveView.image = image;
|
||||
CGFloat scale = (CGFloat)imaveView.image.size.width / (CGFloat)imaveView.image.size.height;
|
||||
imaveView.bounds = CGRectMake(0, 0, 20 * scale, 20);
|
||||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imaveView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imaveView.frame.size.width, imaveView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||||
return attrString;
|
||||
}
|
||||
|
||||
/// 设置文本的样式 间隙 缩进 ...
|
||||
- (NSMutableParagraphStyle *)paragraphStyle {
|
||||
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
paraStyle.lineSpacing = 4.0f;//行间距
|
||||
// 强制排版(从左到右)
|
||||
paraStyle.alignment = NSTextAlignmentLeft;
|
||||
paraStyle.baseWritingDirection = NSWritingDirectionLeftToRight;
|
||||
return paraStyle;
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setMonentsInfo:(MonentsInfoModel *)monentsInfo {
|
||||
_monentsInfo = monentsInfo;
|
||||
if (_monentsInfo) {
|
||||
self.userInfoView.monentsInfo = _monentsInfo;
|
||||
self.contentLabel.attributedText = [self createMonentsContentAttribute];
|
||||
self.textView.monentsInfo = _monentsInfo;
|
||||
self.photoView.dynamicResList = _monentsInfo.dynamicResList;
|
||||
self.photoView.hidden = _monentsInfo.type == MonentsContentType_Text;
|
||||
self.topicView.monentsInfo = _monentsInfo;
|
||||
self.toolBarView.monentsInfo = _monentsInfo;
|
||||
if (_monentsInfo.type == MonentsContentType_Text) {
|
||||
self.photoView.hidden = YES;
|
||||
[self.photoView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(0);
|
||||
}];
|
||||
} else {
|
||||
CGFloat picHeight = _monentsInfo.picHeight <=0 ? [XPMonentsLayoutConfig monentsPicHeight:_monentsInfo] : _monentsInfo.picHeight;
|
||||
[self.photoView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(picHeight);
|
||||
}];
|
||||
}
|
||||
|
||||
CGFloat contentHeight = _monentsInfo.contentHeight <=0 ? [XPMonentsLayoutConfig monentsContentHeight:_monentsInfo] : _monentsInfo.contentHeight;
|
||||
[self.textView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(contentHeight);
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,14 +134,6 @@
|
||||
return _userInfoView;
|
||||
}
|
||||
|
||||
- (YYLabel *)contentLabel {
|
||||
if (!_contentLabel) {
|
||||
_contentLabel = [[YYLabel alloc] init];
|
||||
_contentLabel.preferredMaxLayoutWidth = kMONENTS_CONTENT_MAX_WIDTH;
|
||||
}
|
||||
return _contentLabel;
|
||||
}
|
||||
|
||||
- (XPMonentsPhotoView *)photoView {
|
||||
if (!_photoView) {
|
||||
_photoView = [[XPMonentsPhotoView alloc] init];
|
||||
@@ -179,14 +144,21 @@
|
||||
- (UIStackView *)stackView {
|
||||
if (!_stackView) {
|
||||
_stackView = [[UIStackView alloc] init];
|
||||
_stackView.axis = UILayoutConstraintAxisHorizontal;
|
||||
_stackView.axis = UILayoutConstraintAxisVertical;
|
||||
_stackView.distribution = UIStackViewDistributionFill;
|
||||
_stackView.alignment = UIStackViewAlignmentFill;
|
||||
_stackView.alignment = UIStackViewAlignmentLeading;
|
||||
_stackView.spacing = kMONENTS_CONTENT_SPACAE_HEIGHT;
|
||||
}
|
||||
return _stackView;
|
||||
}
|
||||
|
||||
- (XPMonentsContentView *)textView {
|
||||
if (!_textView) {
|
||||
_textView = [[XPMonentsContentView alloc] init];
|
||||
}
|
||||
return _textView;
|
||||
}
|
||||
|
||||
- (XPMoentsTopicView *)topicView {
|
||||
if (!_topicView) {
|
||||
_topicView = [[XPMoentsTopicView alloc] init];
|
||||
|
@@ -53,7 +53,7 @@
|
||||
}];
|
||||
|
||||
[self.topicImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.topicLabel).offset(9);
|
||||
make.right.mas_equalTo(self.topicLabel.mas_right).offset(9);
|
||||
}];
|
||||
|
||||
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -69,6 +69,7 @@
|
||||
}
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setMonentsInfo:(MonentsInfoModel *)monentsInfo {
|
||||
_monentsInfo = monentsInfo;
|
||||
if (_monentsInfo) {
|
||||
if (_monentsInfo.topicId > 0) {
|
||||
self.topicImageView.hidden = NO;
|
||||
@@ -106,7 +107,7 @@
|
||||
if (!_iconImageView) {
|
||||
_iconImageView = [[UIImageView alloc] init];
|
||||
_iconImageView.userInteractionEnabled = YES;
|
||||
_iconImageView.image = [UIImage imageNamed:@""];
|
||||
_iconImageView.image = [UIImage imageNamed:@"monents_info_topic_icon"];
|
||||
}
|
||||
return _iconImageView;
|
||||
}
|
||||
|
16
xplan-ios/Main/Monents/View/SubViews/XPMonentsContentView.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// XPMonentsContentView.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/5/13.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class MonentsInfoModel;
|
||||
@interface XPMonentsContentView : UIView
|
||||
@property (nonatomic,strong) MonentsInfoModel *monentsInfo;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
151
xplan-ios/Main/Monents/View/SubViews/XPMonentsContentView.m
Normal file
@@ -0,0 +1,151 @@
|
||||
//
|
||||
// XPMonentsContentView.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/5/13.
|
||||
//
|
||||
|
||||
#import "XPMonentsContentView.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <YYText/YYText.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "XPMonentsLayoutConfig.h"
|
||||
///Model
|
||||
#import "MonentsInfoModel.h"
|
||||
@interface XPMonentsContentView ()
|
||||
///容器
|
||||
@property (nonatomic,strong) UIStackView *stackView;
|
||||
///显示内容
|
||||
@property (nonatomic,strong) YYLabel *contentLabel;
|
||||
///折叠的按钮
|
||||
@property (nonatomic,strong) UIButton *foldButton;
|
||||
@end
|
||||
|
||||
|
||||
@implementation XPMonentsContentView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self addSubview:self.stackView];
|
||||
[self.stackView addSubview:self.contentLabel];
|
||||
[self.stackView addSubview:self.foldButton];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self);
|
||||
}];
|
||||
|
||||
[self.foldButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(kMONENTS_FOLD_HEIGHT);
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)createMonentsContentAttribute {
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||||
if (self.monentsInfo.squareTop) {
|
||||
[attribute appendAttributedString:[self createImageAttribute:[UIImage imageNamed:@"monents_info_top"]]];
|
||||
}
|
||||
|
||||
NSString * text = _monentsInfo.content;
|
||||
if (text == nil || text.length <= 0) {
|
||||
text = @"";
|
||||
}
|
||||
NSMutableAttributedString *contentAttribute = [[NSMutableAttributedString alloc] initWithString:text attributes:nil];
|
||||
contentAttribute.yy_font = [UIFont systemFontOfSize:14];
|
||||
contentAttribute.yy_color = [ThemeColor mainTextColor];
|
||||
contentAttribute.yy_paragraphStyle = [self paragraphStyle];
|
||||
[attribute appendAttributedString:contentAttribute];
|
||||
return attribute;
|
||||
}
|
||||
|
||||
/// 生成本地一个图片的富文本
|
||||
/// @param image 本地的图片
|
||||
- (NSMutableAttributedString *)createImageAttribute:(UIImage *)image {
|
||||
UIImageView *imaveView = [[UIImageView alloc]init];
|
||||
imaveView.image = image;
|
||||
CGFloat scale = (CGFloat)imaveView.image.size.width / (CGFloat)imaveView.image.size.height;
|
||||
imaveView.bounds = CGRectMake(0, 0, 20 * scale, 20);
|
||||
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imaveView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imaveView.frame.size.width, imaveView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
|
||||
return attrString;
|
||||
}
|
||||
|
||||
/// 设置文本的样式 间隙 缩进 ...
|
||||
- (NSMutableParagraphStyle *)paragraphStyle {
|
||||
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
paraStyle.lineSpacing = 4.0f;//行间距
|
||||
// 强制排版(从左到右)
|
||||
paraStyle.alignment = NSTextAlignmentLeft;
|
||||
paraStyle.baseWritingDirection = NSWritingDirectionLeftToRight;
|
||||
return paraStyle;
|
||||
}
|
||||
|
||||
#pragma mark - Event Response
|
||||
- (void)didClickFoldButton:(UIButton *)sender {
|
||||
//TODO: 展开收起
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setMonentsInfo:(MonentsInfoModel *)monentsInfo {
|
||||
_monentsInfo = monentsInfo;
|
||||
if (_monentsInfo) {
|
||||
self.contentLabel.attributedText = [self createMonentsContentAttribute];
|
||||
YYTextContainer *container = [YYTextContainer new];
|
||||
container.size = CGSizeMake(kMONENTS_CONTENT_MAX_WIDTH, CGFLOAT_MAX);
|
||||
container.maximumNumberOfRows = 0;
|
||||
YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:self.contentLabel.attributedText];
|
||||
if (layout.rowCount > 6) {
|
||||
self.foldButton.hidden = NO;
|
||||
} else {
|
||||
self.foldButton.hidden = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (UIStackView *)stackView {
|
||||
if (!_stackView) {
|
||||
_stackView = [[UIStackView alloc] init];
|
||||
_stackView.axis = UILayoutConstraintAxisVertical;
|
||||
_stackView.distribution = UIStackViewDistributionFill;
|
||||
_stackView.alignment = UIStackViewAlignmentFill;
|
||||
_stackView.spacing = 0;
|
||||
}
|
||||
return _stackView;
|
||||
}
|
||||
|
||||
- (UIButton *)foldButton {
|
||||
if (_foldButton == nil) {
|
||||
_foldButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_foldButton setTitle:@"展开" forState:UIControlStateNormal];
|
||||
[_foldButton setTitle:@"收起" forState:UIControlStateSelected];
|
||||
[_foldButton setTitleColor:UIColorFromRGB(0x34A7FF) forState:UIControlStateNormal];
|
||||
[_foldButton setTitleColor:UIColorFromRGB(0x34A7FF) forState:UIControlStateSelected];
|
||||
_foldButton.titleLabel.font = [UIFont systemFontOfSize:15];
|
||||
_foldButton.hidden = YES;
|
||||
[_foldButton addTarget:self action:@selector(didClickFoldButton:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _foldButton;
|
||||
}
|
||||
|
||||
|
||||
- (YYLabel *)contentLabel {
|
||||
if (!_contentLabel) {
|
||||
_contentLabel = [[YYLabel alloc] init];
|
||||
_contentLabel.preferredMaxLayoutWidth = kMONENTS_CONTENT_MAX_WIDTH;
|
||||
_contentLabel.numberOfLines = 0;
|
||||
}
|
||||
return _contentLabel;
|
||||
}
|
||||
|
||||
@end
|
@@ -75,7 +75,7 @@
|
||||
|
||||
} else if (_dynamicResList.count == 1) {
|
||||
self.firstImageView.hidden = NO;
|
||||
[self.firstImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
[self.firstImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(kMONENTS_PIC_ONE_WIDTH, kMONENTS_PIC_ONE_WIDTH));
|
||||
make.left.top.mas_equalTo(self);
|
||||
}];
|
||||
@@ -93,7 +93,7 @@
|
||||
self.firstImageView.imageUrl = picInfo.resUrl;
|
||||
|
||||
self.secondImageView.hidden = NO;
|
||||
[self.secondImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
[self.secondImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(itemWidth, itemWidth));
|
||||
make.top.mas_equalTo(self);
|
||||
make.left.mas_equalTo(self.firstImageView.mas_right).offset(kMONENTS_PIC_SPACE);
|
||||
@@ -117,7 +117,7 @@
|
||||
NSInteger page = i % 3;
|
||||
NSInteger line = i / 3;
|
||||
NetImageView * imageView = [self.subViewArray objectAtIndex:i];
|
||||
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
[imageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(itemWidth, itemWidth));
|
||||
make.left.mas_equalTo(page * (itemWidth + kMONENTS_PIC_SPACE));
|
||||
make.top.mas_equalTo(line * (itemWidth + kMONENTS_PIC_SPACE));
|
||||
@@ -130,11 +130,12 @@
|
||||
- (NetImageView *)firstImageView {
|
||||
if (!_firstImageView) {
|
||||
NetImageConfig * config = [[NetImageConfig alloc]init];
|
||||
config.imageType = ImageTypeUserIcon;
|
||||
config.imageType = ImageTypeMonentsPhoto;
|
||||
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
||||
_firstImageView = [[NetImageView alloc] initWithConfig:config];
|
||||
_firstImageView.layer.masksToBounds = YES;
|
||||
_firstImageView.layer.cornerRadius = 12;
|
||||
_firstImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
}
|
||||
return _firstImageView;
|
||||
}
|
||||
@@ -142,11 +143,12 @@
|
||||
- (NetImageView *)secondImageView {
|
||||
if (!_secondImageView) {
|
||||
NetImageConfig * config = [[NetImageConfig alloc]init];
|
||||
config.imageType = ImageTypeUserIcon;
|
||||
config.imageType = ImageTypeMonentsPhoto;
|
||||
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
||||
_secondImageView = [[NetImageView alloc] initWithConfig:config];
|
||||
_secondImageView.layer.masksToBounds = YES;
|
||||
_secondImageView.layer.cornerRadius = 12;
|
||||
_secondImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
}
|
||||
return _secondImageView;
|
||||
}
|
||||
@@ -154,11 +156,12 @@
|
||||
- (NetImageView *)thirdImageView {
|
||||
if (!_thirdImageView) {
|
||||
NetImageConfig * config = [[NetImageConfig alloc]init];
|
||||
config.imageType = ImageTypeUserIcon;
|
||||
config.imageType = ImageTypeMonentsPhoto;
|
||||
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
||||
_thirdImageView = [[NetImageView alloc] initWithConfig:config];
|
||||
_thirdImageView.layer.masksToBounds = YES;
|
||||
_thirdImageView.layer.cornerRadius = 12;
|
||||
_thirdImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
}
|
||||
return _thirdImageView;
|
||||
}
|
||||
@@ -167,11 +170,12 @@
|
||||
- (NetImageView *)fourthImageView {
|
||||
if (!_fourthImageView) {
|
||||
NetImageConfig * config = [[NetImageConfig alloc]init];
|
||||
config.imageType = ImageTypeUserIcon;
|
||||
config.imageType = ImageTypeMonentsPhoto;
|
||||
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
||||
_fourthImageView = [[NetImageView alloc] initWithConfig:config];
|
||||
_fourthImageView.layer.masksToBounds = YES;
|
||||
_fourthImageView.layer.cornerRadius = 12;
|
||||
_fourthImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
}
|
||||
return _fourthImageView;
|
||||
}
|
||||
@@ -179,11 +183,12 @@
|
||||
- (NetImageView *)fifthImageView {
|
||||
if (!_fifthImageView) {
|
||||
NetImageConfig * config = [[NetImageConfig alloc]init];
|
||||
config.imageType = ImageTypeUserIcon;
|
||||
config.imageType = ImageTypeMonentsPhoto;
|
||||
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
||||
_fifthImageView = [[NetImageView alloc] initWithConfig:config];
|
||||
_fifthImageView.layer.masksToBounds = YES;
|
||||
_fifthImageView.layer.cornerRadius = 12;
|
||||
_fifthImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
}
|
||||
return _fifthImageView;
|
||||
}
|
||||
@@ -192,11 +197,12 @@
|
||||
- (NetImageView *)sixthImageView {
|
||||
if (!_sixthImageView) {
|
||||
NetImageConfig * config = [[NetImageConfig alloc]init];
|
||||
config.imageType = ImageTypeUserIcon;
|
||||
config.imageType = ImageTypeMonentsPhoto;
|
||||
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
||||
_sixthImageView = [[NetImageView alloc] initWithConfig:config];
|
||||
_sixthImageView.layer.masksToBounds = YES;
|
||||
_sixthImageView.layer.cornerRadius = 12;
|
||||
_sixthImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
}
|
||||
return _sixthImageView;
|
||||
}
|
||||
@@ -205,11 +211,12 @@
|
||||
- (NetImageView *)sevenImageView {
|
||||
if (!_sevenImageView) {
|
||||
NetImageConfig * config = [[NetImageConfig alloc]init];
|
||||
config.imageType = ImageTypeUserIcon;
|
||||
config.imageType = ImageTypeMonentsPhoto;
|
||||
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
||||
_sevenImageView = [[NetImageView alloc] initWithConfig:config];
|
||||
_sevenImageView.layer.masksToBounds = YES;
|
||||
_sevenImageView.layer.cornerRadius = 12;
|
||||
_sevenImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
}
|
||||
return _sevenImageView;
|
||||
}
|
||||
@@ -218,11 +225,12 @@
|
||||
- (NetImageView *)eighthImageView {
|
||||
if (!_eighthImageView) {
|
||||
NetImageConfig * config = [[NetImageConfig alloc]init];
|
||||
config.imageType = ImageTypeUserIcon;
|
||||
config.imageType = ImageTypeMonentsPhoto;
|
||||
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
||||
_eighthImageView = [[NetImageView alloc] initWithConfig:config];
|
||||
_eighthImageView.layer.masksToBounds = YES;
|
||||
_eighthImageView.layer.cornerRadius = 12;
|
||||
_eighthImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
}
|
||||
return _eighthImageView;
|
||||
}
|
||||
@@ -231,13 +239,14 @@
|
||||
- (NetImageView *)ninthImageView {
|
||||
if (!_ninthImageView) {
|
||||
NetImageConfig * config = [[NetImageConfig alloc]init];
|
||||
config.imageType = ImageTypeUserIcon;
|
||||
config.imageType = ImageTypeMonentsPhoto;
|
||||
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
||||
_ninthImageView = [[NetImageView alloc] initWithConfig:config];
|
||||
_ninthImageView.layer.masksToBounds = YES;
|
||||
_ninthImageView.layer.cornerRadius = 12;
|
||||
_ninthImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
}
|
||||
return _firstImageView;
|
||||
return _ninthImageView;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -75,34 +75,35 @@
|
||||
}];
|
||||
|
||||
[self.likeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.likeView);
|
||||
make.right.mas_equalTo(self.likeView.mas_right).offset(-3);
|
||||
make.centerY.mas_equalTo(self.likeView);
|
||||
}];
|
||||
|
||||
[self.likeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(22, 22));
|
||||
make.centerY.mas_equalTo(self.likeView);
|
||||
make.right.mas_equalTo(self.likeView.mas_left).offset(-2);
|
||||
make.right.mas_equalTo(self.likeLabel.mas_left).offset(-3);
|
||||
}];
|
||||
|
||||
[self.commentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.commentButton.mas_left);
|
||||
make.left.mas_equalTo(self.commentButton.mas_left).offset(-2);
|
||||
make.height.mas_equalTo(22);
|
||||
make.centerY.mas_equalTo(self.reportButton);
|
||||
make.right.mas_equalTo(self.shareButton.mas_left).offset(-12);
|
||||
}];
|
||||
|
||||
[self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.commentView);
|
||||
make.centerY.mas_equalTo(self.commentView);
|
||||
}];
|
||||
|
||||
|
||||
[self.commentButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(22, 22));
|
||||
make.centerY.mas_equalTo(self.commentView);
|
||||
make.right.mas_equalTo(self.commentLabel.mas_left).offset(-2);
|
||||
}];
|
||||
|
||||
[self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.commentView.mas_right).offset(-3);
|
||||
make.centerY.mas_equalTo(self.commentView);
|
||||
}];
|
||||
|
||||
[self.shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(22, 22));
|
||||
make.right.mas_equalTo(self).offset(-32);
|
||||
@@ -214,11 +215,11 @@
|
||||
}
|
||||
|
||||
- (UIView *)lineView {
|
||||
if (!_likeView) {
|
||||
_likeView = [[UIView alloc] init];
|
||||
_likeView.backgroundColor = [ThemeColor dividerColor];
|
||||
if (!_lineView) {
|
||||
_lineView = [[UIView alloc] init];
|
||||
_lineView.backgroundColor = [ThemeColor dividerColor];
|
||||
}
|
||||
return _likeView;
|
||||
return _lineView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -253,7 +253,7 @@
|
||||
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
|
||||
_avatarImageView.userInteractionEnabled = YES;
|
||||
_avatarImageView.layer.masksToBounds = YES;
|
||||
_avatarImageView.layer.cornerRadius = 25;
|
||||
_avatarImageView.layer.cornerRadius = 20;
|
||||
_avatarImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
}
|
||||
return _avatarImageView;
|
||||
|
@@ -6,21 +6,162 @@
|
||||
//
|
||||
|
||||
#import "XPMonentsRecommendViewController.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <MJRefresh/MJRefresh.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "XPMacro.h"
|
||||
#import "XPMonentsLayoutConfig.h"
|
||||
///Model
|
||||
#import "MonentsInfoModel.h"
|
||||
///P
|
||||
#import "XPMonentsRecommendPresenter.h"
|
||||
#import "XPMonentsRecommendProtocol.h"
|
||||
///View
|
||||
#import "XPMonentsTableViewCell.h"
|
||||
#import "XPMonentsEmptyTableViewCell.h"
|
||||
|
||||
@interface XPMonentsRecommendViewController ()
|
||||
|
||||
@interface XPMonentsRecommendViewController ()<UITableViewDelegate, UITableViewDataSource,XPMonentsRecommendProtocol>
|
||||
///列表
|
||||
@property (nonatomic,strong) UITableView *tableView;
|
||||
///数据源
|
||||
@property (nonatomic,strong) NSMutableArray *datasource;
|
||||
@property (nonatomic,strong) NSMutableArray<MonentsInfoModel *> *datasource;
|
||||
///当前的页数
|
||||
@property (nonatomic,assign) NSInteger page;
|
||||
///是否有更多的数据
|
||||
@property (nonatomic,assign) BOOL hasNoMoreData;
|
||||
@end
|
||||
|
||||
@implementation XPMonentsRecommendViewController
|
||||
|
||||
- (__kindof id)createPresenter {
|
||||
return [[XPMonentsRecommendPresenter alloc] init];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initHeaderAndFooterRrfresh];
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self.view addSubview:self.tableView];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.view);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - 下拉刷新
|
||||
- (void)initHeaderAndFooterRrfresh {
|
||||
MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
|
||||
header.stateLabel.font = [UIFont systemFontOfSize:10.0];
|
||||
header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0];
|
||||
header.stateLabel.textColor = [ThemeColor secondTextColor];
|
||||
header.lastUpdatedTimeLabel.textColor = [ThemeColor secondTextColor];
|
||||
self.tableView.mj_header = header;
|
||||
|
||||
MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)];
|
||||
footer.stateLabel.textColor = [ThemeColor secondTextColor];
|
||||
footer.stateLabel.font = [UIFont systemFontOfSize:10.0];
|
||||
self.tableView.mj_footer = footer;
|
||||
|
||||
[self headerRefresh];
|
||||
}
|
||||
|
||||
#pragma mark - 刷新的fangfa
|
||||
- (void)headerRefresh {
|
||||
self.page = 1;
|
||||
[self.presenter getMonentsRecommendList:self.page pageSize:20 state:0];
|
||||
}
|
||||
|
||||
- (void)footerRefresh {
|
||||
if (self.hasNoMoreData) {
|
||||
[self showErrorToast:@"没有更多数据了"];
|
||||
return;
|
||||
}
|
||||
self.page++;
|
||||
[self.presenter getMonentsRecommendList:self.page pageSize:20 state:1];
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.datasource.count > 0 ? self.datasource.count : 1;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (self.datasource.count > 0) {
|
||||
MonentsInfoModel * monentInfo= [self.datasource objectAtIndex:indexPath.row];
|
||||
[XPMonentsLayoutConfig layoutMonentsModel:monentInfo];
|
||||
return monentInfo.rowHeight;
|
||||
}
|
||||
return KScreenHeight - kNavigationHeight - 49 - kSafeAreaBottomHeight;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (self.datasource.count > 0) {
|
||||
XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])];
|
||||
MonentsInfoModel * monentsInfo = [self.datasource objectAtIndex:indexPath.row];
|
||||
cell.monentsInfo = monentsInfo;
|
||||
return cell;
|
||||
}
|
||||
XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
|
||||
return cell;
|
||||
}
|
||||
|
||||
#pragma mark - XPMonentsRecommendProtocol
|
||||
- (void)getMonentsRecommendListSuccess:(NSArray *)array state:(int)state {
|
||||
if (state == 0) {
|
||||
[self.datasource removeAllObjects];
|
||||
}
|
||||
if (array.count > 0) {
|
||||
[self.datasource addObjectsFromArray:array];
|
||||
}
|
||||
|
||||
if (state == 0) {
|
||||
self.hasNoMoreData = NO;
|
||||
[self.tableView.mj_header endRefreshing];
|
||||
} else {
|
||||
if (array.count > 0) {
|
||||
self.hasNoMoreData = NO;
|
||||
[self.tableView.mj_footer endRefreshing];
|
||||
} else {
|
||||
self.hasNoMoreData = YES;
|
||||
[self.tableView.mj_footer endRefreshingWithNoMoreData];
|
||||
}
|
||||
}
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (UITableView *)tableView {
|
||||
if (!_tableView) {
|
||||
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||||
_tableView.delegate = self;
|
||||
_tableView.dataSource = self;
|
||||
_tableView.tableFooterView = [UIView new];
|
||||
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
_tableView.backgroundColor = [UIColor clearColor];
|
||||
if (@available(iOS 11.0, *)) {
|
||||
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
}
|
||||
[_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])];
|
||||
[_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
|
||||
|
||||
- (NSMutableArray<MonentsInfoModel *> *)datasource {
|
||||
if (!_datasource) {
|
||||
_datasource = [NSMutableArray array];
|
||||
}
|
||||
return _datasource;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -62,6 +62,7 @@
|
||||
#import "XPTaskCompleteTipView.h"
|
||||
#import "XPWebViewController.h"
|
||||
#import "XPMineUserInfoViewController.h"
|
||||
#import "XPMonentsRecommendViewController.h"
|
||||
///Present
|
||||
#import "MainPresenter.h"
|
||||
#import "MainProtocol.h"
|
||||
@@ -373,14 +374,15 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
|
||||
- (void)initTabs:(BOOL)logined {
|
||||
self.viewControllers = nil;
|
||||
NSArray *normalImageNames = @[@"tab_gameHome_normal",@"tab_live_normal",@"tab_message_normal", @"tab_mine_normal"];
|
||||
NSArray *selectImageNames = @[@"tab_gameHome_selected",@"tab_live_selected",@"tab_message_selected", @"tab_mine_selected"];
|
||||
NSArray *tabLabel = @[@"派对",@"直播",@"消息", @"我的"];
|
||||
NSArray *normalImageNames = @[@"tab_gameHome_normal",@"tab_monents_normal",@"tab_message_normal", @"tab_mine_normal"];
|
||||
NSArray *selectImageNames = @[@"tab_gameHome_selected",@"tab_monents_select",@"tab_message_selected", @"tab_mine_selected"];
|
||||
NSArray *tabLabel = @[@"派对",@"广场",@"消息", @"我的"];
|
||||
|
||||
UIViewController *game;
|
||||
UIViewController *msg;
|
||||
UIViewController *me;
|
||||
UIViewController * home;
|
||||
UIViewController * monents;
|
||||
if (logined) {
|
||||
XplanFBFlutterViewContainer *fvcGame = XplanFBFlutterViewContainer.new;
|
||||
#ifdef DEBUG
|
||||
@@ -388,22 +390,23 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
#else
|
||||
[fvcGame setName:@"/" uniqueId:nil params:nil];
|
||||
#endif
|
||||
game = [[XPHomeLivesViewController alloc] init];
|
||||
msg = [[SessionListViewController alloc] init];
|
||||
me = [[XPMineViewController alloc] init];
|
||||
|
||||
home = [[XPHomeViewController alloc] init];
|
||||
monents = [[XPMonentsRecommendViewController alloc] init];
|
||||
} else {
|
||||
game = [[BaseViewController alloc]init];
|
||||
msg = [[SessionListViewController alloc]init];
|
||||
me = [[BaseViewController alloc]init];
|
||||
home = [[BaseViewController alloc] init];
|
||||
monents = [[BaseViewController alloc] init];
|
||||
}
|
||||
[self createTabBarItem:home title:tabLabel[0] image:normalImageNames[0] selectedImage:selectImageNames[0]];
|
||||
[self createTabBarItem:game title:tabLabel[1] image:normalImageNames[1] selectedImage:selectImageNames[1]];
|
||||
[self createTabBarItem:monents title:tabLabel[1] image:normalImageNames[1] selectedImage:selectImageNames[1]];
|
||||
[self createTabBarItem:msg title:tabLabel[2] image:normalImageNames[2] selectedImage:selectImageNames[2]];
|
||||
[self createTabBarItem:me title:tabLabel[3] image:normalImageNames[3] selectedImage:selectImageNames[3]];
|
||||
self.viewControllers = @[home,game,msg,me];
|
||||
self.viewControllers = @[home,monents,msg,me];
|
||||
self.selectedIndex = 0;
|
||||
}
|
||||
|
||||
|