Commit d4652210 by ludi

规范订阅view

parent d090263f
Showing with 142 additions and 1 deletions
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "zone_subscribe_info_bgImage@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "zone_subscribe_info_bgImage@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "zone_subscribe_info_subscribeBtn_off@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "zone_subscribe_info_subscribeBtn_off@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -727,6 +727,7 @@
[weakSelf.myZoneBottomView fus_updateBottomViewWithModel:zoneModel];
}
weakSelf.tableView.zoneModel = weakSelf.zoneModel;
weakSelf.newsFeedListView.zoneModel = zoneModel;
} failure:^(NSString *msg, NSInteger code) {
if (code == -43) {
if ([UIViewController fus_topViewController] == weakSelf) {
......
......@@ -30,9 +30,15 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy) void(^heightDidChangedHandler)(CGFloat height);
// 持有空间信息的mdoel
@property (nonatomic, strong) FUSZoneInfosModel *zoneModel;
// 页面的最大高度
@property (nonatomic, assign) CGFloat maxHeight;
// 是否禁止进入订阅分页,YES 时点击订阅只弹提示且不能横滑进入订阅页
@property (nonatomic, assign) BOOL forbidEnterSubscribePage;
@end
NS_ASSUME_NONNULL_END
......@@ -12,6 +12,9 @@ NS_ASSUME_NONNULL_BEGIN
@interface FUSMyZoneSubscribeCollectionView : FUSNewsFeedCollectionView
// 持有空间信息的mdoel
@property (nonatomic, strong) FUSZoneInfosModel *zoneModel;
/// 订阅分页的固定内容容器,用于承载后续自定义内容。
@property (nonatomic, strong, readonly) UIView *subscribeContainerView;
......
......@@ -7,19 +7,53 @@
//
#import "FUSMyZoneSubscribeCollectionView.h"
#import <FUSFoundation/FUSFoundation-Swift.h>
@interface FUSMyZoneSubscribeCollectionView ()
/// 订阅分页的固定内容容器,用于保持与动态分页一致的实体页结构。
@property (nonatomic, strong) UIView *subscribeContainerView;
/// 订阅信息卡片容器,用于承载头像、昵称和 ID 信息。
@property (nonatomic, strong) UIImageView *subscribeInfoCardView;
/// 订阅头像,用于展示当前空间主人的头像。
@property (nonatomic, strong) UIImageView *avatarImageView;
/// 订阅昵称,用于展示当前空间主人的昵称。
@property (nonatomic, strong) UILabel *nameLabel;
/// 订阅用户 ID,用于展示当前空间主人的 ID。
@property (nonatomic, strong) UILabel *userIdLabel;
/// 订阅按钮,用于展示当前订阅状态。
@property (nonatomic, strong) UIButton *subscribeButton;
@end
@implementation FUSMyZoneSubscribeCollectionView
- (instancetype)initWithFrame:(CGRect)frame dataType:(FUSNewsFeedDataType)dataType columnNum:(NSInteger)columnNum zoneId:(NSString *)zoneId {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
layout.minimumLineSpacing = 1;
layout.minimumInteritemSpacing = 1;
CGFloat width = (CGRectGetWidth(frame) - layout.minimumLineSpacing) / columnNum;
layout.itemSize = CGSizeMake(width, width);
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
self = [super initWithFrame:frame collectionViewLayout:layout];
if (self) {
self.rootVC = [UIViewController fus_topViewController];
[self fus_initials];
}
return self;
}
/// 重写父类初始化逻辑,仅保留统一的容器风格,不走动态列表请求。
- (void)fus_initials {
self.backgroundColor = UIColor.fus_appBGColor;
self.scrollEnabled = NO;
self.alwaysBounceVertical = NO;
self.showsHorizontalScrollIndicator = NO;
self.showsVerticalScrollIndicator = NO;
self.bounces = NO;
......@@ -30,6 +64,43 @@
self.subscribeContainerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds), self.subscribeContentHeight)];
self.subscribeContainerView.backgroundColor = UIColor.clearColor;
[self addSubview:self.subscribeContainerView];
self.subscribeInfoCardView = [[UIImageView alloc] initWithFrame:CGRectZero];
self.subscribeInfoCardView.contentMode = UIViewContentModeScaleAspectFit;
self.subscribeInfoCardView.image = [FUSUserCenterBunble imageNamed:@"zone_subscribe_info_bgImage"];
self.subscribeInfoCardView.userInteractionEnabled = YES;
[self.subscribeContainerView addSubview:self.subscribeInfoCardView];
self.avatarImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
self.avatarImageView.layer.cornerRadius = 32.0;
self.avatarImageView.layer.masksToBounds = YES;
self.avatarImageView.contentMode = UIViewContentModeScaleAspectFill;
self.avatarImageView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.05];
[self.subscribeInfoCardView addSubview:self.avatarImageView];
self.nameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
self.nameLabel.font = [UIFont fus_themeBoldFont:18];
self.nameLabel.textColor = [UIColor fus_textColorRich];
self.nameLabel.text = @"";
[self.subscribeInfoCardView addSubview:self.nameLabel];
self.userIdLabel = [[UILabel alloc] initWithFrame:CGRectZero];
self.userIdLabel.font = [UIFont fus_themeFont:14];
self.userIdLabel.textColor = [UIColor fus_textColorMedium];
self.userIdLabel.text = @"";
[self.subscribeInfoCardView addSubview:self.userIdLabel];
self.subscribeButton = [UIButton buttonWithType:UIButtonTypeCustom];
self.subscribeButton.userInteractionEnabled = NO;
self.subscribeButton.backgroundColor = [UIColor colorWithWhite:0 alpha:0.12];
self.subscribeButton.titleLabel.font = [UIFont fus_themeBoldFont:16];
[self.subscribeButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
[self.subscribeButton setTitle:[NSString stringWithFormat:@" %@",[NSString fus_versionLocalString:@"未开启订阅"]] forState:UIControlStateNormal];
[self.subscribeButton setImage:[FUSUserCenterBunble imageNamed:@"zone_subscribe_info_subscribeBtn_off"] forState:UIControlStateNormal];
self.subscribeButton.layer.cornerRadius = 26.0;
self.subscribeButton.layer.masksToBounds = YES;
[self.subscribeContainerView addSubview:self.subscribeButton];
self.contentSize = CGSizeMake(CGRectGetWidth(self.bounds), self.subscribeContentHeight);
}
......@@ -38,12 +109,19 @@
[super layoutSubviews];
self.subscribeContainerView.frame = CGRectMake(0, 0, CGRectGetWidth(self.bounds), self.subscribeContentHeight);
self.subscribeInfoCardView.frame = CGRectMake(15, 12, CGRectGetWidth(self.bounds) - 30, 124);
self.avatarImageView.frame = CGRectMake(16, 20, 64, 64);
CGFloat textOriginX = CGRectGetMaxX(self.avatarImageView.frame) + 16;
CGFloat textWidth = CGRectGetWidth(self.subscribeInfoCardView.bounds) - textOriginX - 16;
self.nameLabel.frame = CGRectMake(textOriginX, 25, textWidth, 28);
self.userIdLabel.frame = CGRectMake(textOriginX, CGRectGetMaxY(self.nameLabel.frame) + 8, textWidth, 20);
self.subscribeButton.frame = CGRectMake(15, CGRectGetMaxY(self.subscribeInfoCardView.frame) + 18, CGRectGetWidth(self.bounds) - 30, 52);
self.contentSize = CGSizeMake(CGRectGetWidth(self.bounds), self.subscribeContentHeight);
}
/// 返回订阅分页的固定内容高度。
- (CGFloat)subscribeContentHeight {
return 256.0;
return 220.0;
}
/// 返回订阅分页用于占位的最小高度。
......@@ -51,4 +129,13 @@
return self.subscribeContentHeight;
}
#pragma mark --- setter
- (void)setZoneModel:(FUSZoneInfosModel *)zoneModel {
_zoneModel = zoneModel;
[self.avatarImageView setImageWithURL:[NSURL URLWithString:zoneModel.face.fus_bigCdn] placeholder:[UIImage fus_defaultIcon]];
self.nameLabel.text = zoneModel.nickname;
self.userIdLabel.text = [NSString stringWithFormat:@"ID: %@",zoneModel.uid];
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment