增加换肤功能
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TUIGroupButtonCellData_Minimalist.h
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/4.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <TIMCommon/TIMCommonModel.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIGroupButtonCellData_Minimalist : TUICommonCellData
|
||||
@property(nonatomic, strong) NSString *title;
|
||||
@property SEL cbuttonSelector;
|
||||
@property TUIButtonStyle style;
|
||||
@property(nonatomic, strong) UIColor *textColor;
|
||||
@property(nonatomic, assign) BOOL hideSeparatorLine;
|
||||
@property(nonatomic, assign) BOOL isInfoPageLeftButton;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// TUIGroupButtonCellData_Minimalist.m
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/4.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIGroupButtonCellData_Minimalist.h"
|
||||
|
||||
@implementation TUIGroupButtonCellData_Minimalist
|
||||
- (CGFloat)heightOfWidth:(CGFloat)width {
|
||||
return 56;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// TUIGroupMemberCellData_Minimalist.h
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/3.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <TIMCommon/TIMCommonModel.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIGroupMemberCellData_Minimalist : TUICommonCellData
|
||||
@property(nonatomic, strong) NSString *identifier;
|
||||
|
||||
@property(nonatomic, strong) NSString *name;
|
||||
|
||||
@property(nonatomic, strong) UIImage *avatarImage;
|
||||
|
||||
@property(nonatomic, strong) NSString *avatarUrl;
|
||||
|
||||
@property(nonatomic, assign) BOOL showAccessory;
|
||||
|
||||
@property(nonatomic, copy) NSString *detailName;
|
||||
|
||||
@property NSInteger tag;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// TUIGroupMemberCellData_Minimalist.m
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/3.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIGroupMemberCellData_Minimalist.h"
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
#import <TUICore/TUIThemeManager.h>
|
||||
|
||||
@implementation TUIGroupMemberCellData_Minimalist
|
||||
- (CGFloat)heightOfWidth:(CGFloat)width {
|
||||
return kScale390(48);
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TUIGroupProfileCardCellData.h
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/3.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <TIMCommon/TIMCommonModel.h>
|
||||
@class UINavigationController;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIGroupProfileCardCellData_Minimalist : TUIProfileCardCellData
|
||||
|
||||
@property(nonatomic, weak) UINavigationController *navigationController;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// TUIGroupProfileCardCellData_Minimalist.m
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/3.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIGroupProfileCardCellData_Minimalist.h"
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
#import <TUICore/TUIThemeManager.h>
|
||||
|
||||
@implementation TUIGroupProfileCardCellData_Minimalist
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CGFloat)heightOfWidth:(CGFloat)width {
|
||||
return kScale390(329);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TUIMemberInfoCellData_Minimalist.h
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/9.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "TUIMemberInfoCellData.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIMemberInfoCellData_Minimalist : NSObject
|
||||
|
||||
@property(nonatomic, copy) NSString *identifier;
|
||||
@property(nonatomic, strong) UIImage *avatar;
|
||||
@property(nonatomic, copy) NSString *avatarUrl;
|
||||
@property(nonatomic, copy) NSString *name;
|
||||
@property(nonatomic, assign) TUIMemberInfoCellStyle style;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// TUIMemberInfoCellData_Minimalist.m
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/9.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIMemberInfoCellData_Minimalist.h"
|
||||
|
||||
@implementation TUIMemberInfoCellData_Minimalist
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// TUIProfileCardCellData_Minimalist.h
|
||||
// Masonry
|
||||
//
|
||||
// Created by wyl on 2022/12/6.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <TIMCommon/TIMCommonModel.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIProfileCardCellData_Minimalist : TUIProfileCardCellData
|
||||
@property(nonatomic, assign) BOOL showGroupType;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// TUIProfileCardCellData_Minimalist.m
|
||||
// Masonry
|
||||
//
|
||||
// Created by wyl on 2022/12/6.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIProfileCardCellData_Minimalist.h"
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
#import <TUICore/TUIThemeManager.h>
|
||||
|
||||
@implementation TUIProfileCardCellData_Minimalist
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.avatarImage = DefaultAvatarImage;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CGFloat)heightOfWidth:(CGFloat)width {
|
||||
return kScale390(86);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TUIGroupButtonCell_Minimalist.h
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/4.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <TIMCommon/TIMCommonModel.h>
|
||||
#import "TUIGroupButtonCellData_Minimalist.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIGroupButtonCell_Minimalist : TUICommonTableViewCell
|
||||
@property(nonatomic, strong) UIButton *button;
|
||||
@property(nonatomic, strong) TUIGroupButtonCellData_Minimalist *buttonData;
|
||||
|
||||
- (void)fillWithData:(TUIGroupButtonCellData_Minimalist *)data;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,168 @@
|
||||
//
|
||||
// TUIGroupButtonCell_Minimalist.m
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/4.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIGroupButtonCell_Minimalist.h"
|
||||
|
||||
#import <TUICore/TUIThemeManager.h>
|
||||
|
||||
@implementation TUIGroupButtonCell_Minimalist {
|
||||
UIView *_line;
|
||||
}
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
[self setupViews];
|
||||
self.changeColorWhenTouched = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setupViews {
|
||||
self.backgroundColor = [UIColor tui_colorWithHex:@"#f9f9f9"];
|
||||
self.contentView.backgroundColor = [UIColor tui_colorWithHex:@"#f9f9f9"];
|
||||
|
||||
_button = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_button.titleLabel setFont:[UIFont systemFontOfSize:16]];
|
||||
|
||||
[_button addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
[self.contentView addSubview:_button];
|
||||
|
||||
[self setSeparatorInset:UIEdgeInsetsMake(0, Screen_Width, 0, 0)];
|
||||
[self setSelectionStyle:UITableViewCellSelectionStyleNone];
|
||||
self.changeColorWhenTouched = YES;
|
||||
|
||||
_line = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[self.contentView addSubview:_line];
|
||||
_line.backgroundColor = [UIColor whiteColor];
|
||||
}
|
||||
|
||||
- (void)fillWithData:(TUIGroupButtonCellData_Minimalist *)data {
|
||||
[super fillWithData:data];
|
||||
self.buttonData = data;
|
||||
[_button setTitle:data.title forState:UIControlStateNormal];
|
||||
if(isRTL()) {
|
||||
_button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
|
||||
}
|
||||
else {
|
||||
_button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
|
||||
}
|
||||
_button.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
|
||||
switch (data.style) {
|
||||
case ButtonGreen: {
|
||||
[_button setTitleColor:TIMCommonDynamicColor(@"form_green_button_text_color", @"#FFFFFF") forState:UIControlStateNormal];
|
||||
_button.backgroundColor = TIMCommonDynamicColor(@"", @"#f9f9f9");
|
||||
[_button setBackgroundImage:[self imageWithColor:TIMCommonDynamicColor(@"", @"#f9f9f9")] forState:UIControlStateHighlighted];
|
||||
} break;
|
||||
case ButtonWhite: {
|
||||
[_button setTitleColor:TIMCommonDynamicColor(@"form_white_button_text_color", @"#000000") forState:UIControlStateNormal];
|
||||
_button.backgroundColor = TIMCommonDynamicColor(@"", @"#f9f9f9");
|
||||
} break;
|
||||
case ButtonRedText: {
|
||||
[_button setTitleColor:TIMCommonDynamicColor(@"form_redtext_button_text_color", @"#FF0000") forState:UIControlStateNormal];
|
||||
_button.backgroundColor = TIMCommonDynamicColor(@"", @"#f9f9f9");
|
||||
|
||||
break;
|
||||
}
|
||||
case ButtonBule: {
|
||||
if (data.isInfoPageLeftButton) {
|
||||
[_button setTitleColor:TIMCommonDynamicColor(@"", @"#0365F9") forState:UIControlStateNormal];
|
||||
_button.backgroundColor = TIMCommonDynamicColor(@"", @"#f9f9f9");
|
||||
} else {
|
||||
[_button.titleLabel setTextColor:[UIColor tui_colorWithHex:@"147AFF"]];
|
||||
_button.backgroundColor = [UIColor tui_colorWithHex:@"#f9f9f9"];
|
||||
_button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
|
||||
_button.layer.cornerRadius = kScale390(10);
|
||||
_button.layer.masksToBounds = YES;
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
self.contentView.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (data.textColor) {
|
||||
[_button setTitleColor:data.textColor forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
_line.hidden = data.hideSeparatorLine;
|
||||
|
||||
// tell constraints they need updating
|
||||
[self setNeedsUpdateConstraints];
|
||||
|
||||
// update constraints now so we can animate the change
|
||||
[self updateConstraintsIfNeeded];
|
||||
|
||||
[self layoutIfNeeded];
|
||||
|
||||
}
|
||||
|
||||
+ (BOOL)requiresConstraintBasedLayout {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// this is Apple's recommended place for adding/updating constraints
|
||||
- (void)updateConstraints {
|
||||
|
||||
[super updateConstraints];
|
||||
[self.button mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.contentView.mas_leading).mas_offset(kScale390(20));
|
||||
make.trailing.mas_equalTo(self.contentView.mas_trailing).mas_offset(- kScale390(20));
|
||||
make.top.mas_equalTo(self.contentView);
|
||||
make.bottom.mas_equalTo(self.contentView);
|
||||
}];
|
||||
|
||||
[_line mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.contentView.mas_leading).mas_offset(20);
|
||||
make.trailing.mas_equalTo(self.contentView.mas_trailing);
|
||||
make.height.mas_equalTo(0.2);
|
||||
make.bottom.mas_equalTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
|
||||
}
|
||||
|
||||
- (void)onClick:(UIButton *)sender {
|
||||
if (self.buttonData.cbuttonSelector) {
|
||||
UIViewController *vc = self.mm_viewController;
|
||||
if ([vc respondsToSelector:self.buttonData.cbuttonSelector]) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||
[vc performSelector:self.buttonData.cbuttonSelector withObject:self];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didAddSubview:(UIView *)subview {
|
||||
[super didAddSubview:subview];
|
||||
if (subview != self.contentView) {
|
||||
[subview removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
- (UIImage *)imageWithColor:(UIColor *)color {
|
||||
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
UIGraphicsBeginImageContext(rect.size);
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
|
||||
CGContextSetFillColorWithColor(context, [color CGColor]);
|
||||
CGContextFillRect(context, rect);
|
||||
|
||||
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TUIGroupMemberTableViewCell_Minimalist.h
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/3.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <TIMCommon/TIMCommonModel.h>
|
||||
#import "TUIGroupMemberCellData_Minimalist.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIGroupMemberTableViewCell_Minimalist : TUICommonTableViewCell
|
||||
@property(nonatomic, strong) UIImageView *avatarView;
|
||||
@property(nonatomic, strong) UILabel *titleLabel;
|
||||
@property(nonatomic, strong) UILabel *detailLabel;
|
||||
@property(nonatomic, strong) UIView *separtorView;
|
||||
|
||||
- (void)fillWithData:(TUIGroupMemberCellData_Minimalist *)data;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,108 @@
|
||||
//
|
||||
// TUIGroupMemberTableViewCell_Minimalist.m
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/3.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIGroupMemberTableViewCell_Minimalist.h"
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
#import <TUICore/TUIThemeManager.h>
|
||||
|
||||
@implementation TUIGroupMemberTableViewCell_Minimalist
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
self.contentView.backgroundColor = TIMCommonDynamicColor(@"", @"#FFFFFF");
|
||||
self.avatarView = [[UIImageView alloc] initWithImage:DefaultAvatarImage];
|
||||
[self.contentView addSubview:self.avatarView];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
self.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
self.titleLabel.textColor = TIMCommonDynamicColor(@"", @"#000000");
|
||||
|
||||
self.detailLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
[self.contentView addSubview:self.detailLabel];
|
||||
self.detailLabel.font = [UIFont systemFontOfSize:14];
|
||||
self.detailLabel.textColor = TIMCommonDynamicColor(@"", @"#666666");
|
||||
|
||||
_separtorView = [[UIView alloc] init];
|
||||
_separtorView.backgroundColor = [UIColor whiteColor];
|
||||
[self.contentView addSubview:_separtorView];
|
||||
|
||||
[self setSelectionStyle:UITableViewCellSelectionStyleNone];
|
||||
|
||||
self.changeColorWhenTouched = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)fillWithData:(TUIGroupMemberCellData_Minimalist *)contactData {
|
||||
[super fillWithData:contactData];
|
||||
|
||||
self.titleLabel.text = contactData.name;
|
||||
[self.avatarView sd_setImageWithURL:[NSURL URLWithString:contactData.avatarUrl] placeholderImage:contactData.avatarImage ?: DefaultAvatarImage];
|
||||
|
||||
self.detailLabel.text = contactData.detailName;
|
||||
|
||||
if (contactData.showAccessory) {
|
||||
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
||||
self.userInteractionEnabled = YES;
|
||||
} else {
|
||||
self.accessoryType = UITableViewCellAccessoryNone;
|
||||
self.userInteractionEnabled = NO;
|
||||
}
|
||||
// tell constraints they need updating
|
||||
[self setNeedsUpdateConstraints];
|
||||
|
||||
// update constraints now so we can animate the change
|
||||
[self updateConstraintsIfNeeded];
|
||||
|
||||
[self layoutIfNeeded];
|
||||
}
|
||||
+ (BOOL)requiresConstraintBasedLayout {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// this is Apple's recommended place for adding/updating constraints
|
||||
- (void)updateConstraints {
|
||||
|
||||
[super updateConstraints];
|
||||
|
||||
CGFloat imgWidth = kScale390(40);
|
||||
|
||||
[self.avatarView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.height.mas_equalTo(imgWidth);
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
make.leading.mas_equalTo(kScale390(16));
|
||||
}];
|
||||
if ([TUIConfig defaultConfig].avatarType == TAvatarTypeRounded) {
|
||||
self.avatarView.layer.masksToBounds = YES;
|
||||
self.avatarView.layer.cornerRadius = imgWidth / 2;
|
||||
} else if ([TUIConfig defaultConfig].avatarType == TAvatarTypeRadiusCorner) {
|
||||
self.avatarView.layer.masksToBounds = YES;
|
||||
self.avatarView.layer.cornerRadius = [TUIConfig defaultConfig].avatarCornerRadius;
|
||||
}
|
||||
|
||||
[self.titleLabel sizeToFit];
|
||||
[self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(self.avatarView.mas_centerY);
|
||||
make.leading.mas_equalTo(self.avatarView.mas_trailing).mas_offset(12);
|
||||
make.height.mas_equalTo(20);
|
||||
make.trailing.mas_lessThanOrEqualTo(self.contentView.mas_trailing).mas_offset(1);
|
||||
}];
|
||||
|
||||
[self.detailLabel sizeToFit];
|
||||
[self.detailLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(self.avatarView.mas_centerY);
|
||||
make.height.mas_equalTo(self.detailLabel.frame.size.height);
|
||||
make.trailing.mas_lessThanOrEqualTo(self.contentView.mas_trailing).mas_offset(- kScale390(16));
|
||||
}];
|
||||
}
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// TUIGroupProfileCardViewCell_Minimalist.h
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/3.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <TIMCommon/TIMCommonModel.h>
|
||||
#import "TUIGroupProfileCardCellData_Minimalist.h"
|
||||
|
||||
@class V2TIMGroupInfo;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIGroupProfileHeaderItemView_Minimalist : UIView
|
||||
@property(nonatomic, strong) UIImageView *iconView;
|
||||
@property(nonatomic, strong) UILabel *textLabel;
|
||||
@property(nonatomic, copy) void (^messageBtnClickBlock)(void);
|
||||
@end
|
||||
|
||||
@interface TUIGroupProfileHeaderView_Minimalist : UIView
|
||||
@property(nonatomic, strong) UIImageView *headImg;
|
||||
@property(nonatomic, copy) void (^headImgClickBlock)(void);
|
||||
@property(nonatomic, strong) UILabel *descriptionLabel;
|
||||
@property(nonatomic, strong) UIButton *editButton;
|
||||
@property(nonatomic, copy) void (^editBtnClickBlock)(void);
|
||||
@property(nonatomic, strong) UILabel *idLabel;
|
||||
@property(nonatomic, strong) UIView *functionListView;
|
||||
@property(nonatomic, strong) NSArray<TUIGroupProfileHeaderItemView_Minimalist *> *itemViewList;
|
||||
@property(nonatomic, strong) V2TIMGroupInfo *groupInfo;
|
||||
|
||||
@end
|
||||
|
||||
@interface TUIGroupProfileCardViewCell_Minimalist : TUICommonTableViewCell
|
||||
@property(nonatomic, strong) TUIGroupProfileHeaderView_Minimalist *headerView;
|
||||
@property(nonatomic, strong) TUIGroupProfileCardCellData_Minimalist *cardData;
|
||||
- (void)fillWithData:(TUIGroupProfileCardCellData_Minimalist *)data;
|
||||
|
||||
@property(nonatomic, strong) NSArray<TUIGroupProfileHeaderItemView_Minimalist *> *itemViewList;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,304 @@
|
||||
//
|
||||
// TUIGroupProfileCardViewCell.m
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/3.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIGroupProfileCardViewCell_Minimalist.h"
|
||||
#import <TIMCommon/TIMCommonModel.h>
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
#import <TIMCommon/TUIGroupAvatar+Helper.h>
|
||||
#import <TUICore/TUICore.h>
|
||||
#import <TUICore/TUIThemeManager.h>
|
||||
|
||||
@implementation TUIGroupProfileHeaderItemView_Minimalist
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self setupView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- (void)setupView {
|
||||
self.iconView = [[UIImageView alloc] initWithImage:DefaultAvatarImage];
|
||||
[self addSubview:self.iconView];
|
||||
self.iconView.userInteractionEnabled = YES;
|
||||
self.iconView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
|
||||
self.textLabel = [[UILabel alloc] init];
|
||||
self.textLabel.font = [UIFont systemFontOfSize:kScale390(16)];
|
||||
self.textLabel.rtlAlignment = TUITextRTLAlignmentCenter;
|
||||
self.textLabel.textColor = [UIColor tui_colorWithHex:@"#000000"];
|
||||
self.textLabel.userInteractionEnabled = YES;
|
||||
[self addSubview:self.textLabel];
|
||||
self.textLabel.text = @"Message";
|
||||
|
||||
self.backgroundColor = [UIColor tui_colorWithHex:@"#f9f9f9"];
|
||||
self.layer.cornerRadius = kScale390(12);
|
||||
self.layer.masksToBounds = YES;
|
||||
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click)];
|
||||
[self addGestureRecognizer:tap];
|
||||
}
|
||||
+ (BOOL)requiresConstraintBasedLayout {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// this is Apple's recommended place for adding/updating constraints
|
||||
- (void)updateConstraints {
|
||||
|
||||
[super updateConstraints];
|
||||
[self.iconView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.height.mas_equalTo(kScale390(30));
|
||||
make.top.mas_equalTo(kScale390(19));
|
||||
make.centerX.mas_equalTo(self);
|
||||
}];
|
||||
[self.textLabel sizeToFit];
|
||||
[self.textLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.trailing.mas_equalTo(self);
|
||||
make.height.mas_equalTo(kScale390(19));
|
||||
make.top.mas_equalTo(self.iconView.mas_bottom).mas_offset(kScale390(11));
|
||||
make.centerX.mas_equalTo(self);
|
||||
}];
|
||||
}
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
|
||||
}
|
||||
- (void)click {
|
||||
if (self.messageBtnClickBlock) {
|
||||
self.messageBtnClickBlock();
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@interface TUIGroupProfileHeaderView_Minimalist ()
|
||||
@end
|
||||
|
||||
@implementation TUIGroupProfileHeaderView_Minimalist
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self setupView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setupView {
|
||||
self.headImg = [[UIImageView alloc] initWithImage:DefaultAvatarImage];
|
||||
[self addSubview:self.headImg];
|
||||
self.headImg.userInteractionEnabled = YES;
|
||||
self.headImg.contentMode = UIViewContentModeScaleAspectFit;
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(headImageClick)];
|
||||
[self.headImg addGestureRecognizer:tap];
|
||||
|
||||
self.descriptionLabel = [[UILabel alloc] init];
|
||||
self.descriptionLabel.font = [UIFont boldSystemFontOfSize:kScale390(24)];
|
||||
self.descriptionLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.descriptionLabel.userInteractionEnabled = YES;
|
||||
[self addSubview:self.descriptionLabel];
|
||||
|
||||
self.editButton = [UIButton buttonWithType:UIButtonTypeSystem];
|
||||
[self addSubview:self.editButton];
|
||||
[self.editButton setImage:[UIImage imageNamed:TUIGroupImagePath(@"icon_group_edit")] forState:UIControlStateNormal];
|
||||
[self.editButton addTarget:self action:@selector(editButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
self.editButton.hidden = YES;
|
||||
|
||||
self.idLabel = [[UILabel alloc] init];
|
||||
self.idLabel.font = [UIFont systemFontOfSize:kScale390(12)];
|
||||
self.idLabel.textColor = [UIColor tui_colorWithHex:@"666666"];
|
||||
self.idLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.idLabel.userInteractionEnabled = YES;
|
||||
[self addSubview:self.idLabel];
|
||||
|
||||
self.functionListView = [[UIView alloc] init];
|
||||
self.functionListView.userInteractionEnabled = YES;
|
||||
[self addSubview:self.functionListView];
|
||||
}
|
||||
|
||||
- (void)setGroupInfo:(V2TIMGroupInfo *)groupInfo {
|
||||
_groupInfo = groupInfo;
|
||||
[self.headImg sd_setImageWithURL:[NSURL URLWithString:self.groupInfo.faceURL]
|
||||
placeholderImage:DefaultGroupAvatarImageByGroupType(self.groupInfo.groupType)];
|
||||
[self configHeadImageView:groupInfo];
|
||||
|
||||
self.descriptionLabel.text = groupInfo.groupName;
|
||||
self.idLabel.text = self.groupInfo.groupID;
|
||||
if ([self.class isMeSuper:groupInfo]) {
|
||||
self.editButton.hidden = NO;
|
||||
}
|
||||
|
||||
// tell constraints they need updating
|
||||
[self setNeedsUpdateConstraints];
|
||||
|
||||
// update constraints now so we can animate the change
|
||||
[self updateConstraintsIfNeeded];
|
||||
|
||||
[self layoutIfNeeded];
|
||||
|
||||
}
|
||||
- (void)configHeadImageView:(V2TIMGroupInfo *)groupInfo {
|
||||
/**
|
||||
* Setup default avatar
|
||||
*/
|
||||
if (groupInfo.groupID.length > 0) {
|
||||
/**
|
||||
* If it is a group, change the group default avatar to the last used avatar
|
||||
*/
|
||||
[self.headImg sd_setImageWithURL:[NSURL URLWithString:self.groupInfo.faceURL]
|
||||
placeholderImage:DefaultGroupAvatarImageByGroupType(self.groupInfo.groupType)];
|
||||
}
|
||||
|
||||
@weakify(self);
|
||||
NSString *groupID = groupInfo.groupID ?: @"";
|
||||
NSString *pFaceUrl = groupInfo.faceURL ?: @"";
|
||||
NSString *groupType = groupInfo.groupType ?: @"";
|
||||
UIImage *originAvatarImage = DefaultGroupAvatarImageByGroupType(self.groupInfo.groupType) ?: [UIImage new];
|
||||
|
||||
NSDictionary *param = @{
|
||||
@"groupID" : groupID,
|
||||
@"faceUrl" : pFaceUrl,
|
||||
@"groupType" : groupType,
|
||||
@"originAvatarImage" : originAvatarImage,
|
||||
};
|
||||
[TUIGroupAvatar configAvatarByParam:param targetView:self.headImg];
|
||||
}
|
||||
|
||||
- (void)setItemViewList:(NSArray<TUIGroupProfileHeaderItemView_Minimalist *> *)itemList {
|
||||
for (UIView *subView in self.functionListView.subviews) {
|
||||
[subView removeFromSuperview];
|
||||
}
|
||||
if (itemList.count > 0) {
|
||||
for (TUIGroupProfileHeaderItemView_Minimalist *itemView in itemList) {
|
||||
[self.functionListView addSubview:itemView];
|
||||
}
|
||||
CGFloat width = kScale390(92);
|
||||
CGFloat height = kScale390(95);
|
||||
CGFloat space = kScale390(18);
|
||||
CGFloat contentWidth = itemList.count * width + (itemList.count - 1) * space;
|
||||
CGFloat x = 0.5 * (self.bounds.size.width - contentWidth);
|
||||
for (TUIGroupProfileHeaderItemView_Minimalist *itemView in itemList) {
|
||||
itemView.frame = CGRectMake(x, 0, width, height);
|
||||
x = CGRectGetMaxX(itemView.frame) + space;
|
||||
}
|
||||
}
|
||||
}
|
||||
+ (BOOL)requiresConstraintBasedLayout {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// this is Apple's recommended place for adding/updating constraints
|
||||
- (void)updateConstraints {
|
||||
|
||||
[super updateConstraints];
|
||||
CGFloat imgWidth = kScale390(94);
|
||||
[self.headImg mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.height.mas_equalTo(imgWidth);
|
||||
make.centerX.mas_equalTo(self.mas_centerX);
|
||||
make.top.mas_equalTo(kScale390(42));
|
||||
}];
|
||||
|
||||
MASAttachKeys(self.headImg);
|
||||
|
||||
if ([TUIConfig defaultConfig].avatarType == TAvatarTypeRounded) {
|
||||
self.headImg.layer.masksToBounds = YES;
|
||||
self.headImg.layer.cornerRadius = imgWidth / 2;
|
||||
} else if ([TUIConfig defaultConfig].avatarType == TAvatarTypeRadiusCorner) {
|
||||
self.headImg.layer.masksToBounds = YES;
|
||||
self.headImg.layer.cornerRadius = [TUIConfig defaultConfig].avatarCornerRadius;
|
||||
}
|
||||
|
||||
[self.descriptionLabel sizeToFit];
|
||||
[self.descriptionLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.mas_centerX);
|
||||
make.top.mas_equalTo(self.headImg.mas_bottom).mas_offset(kScale390(10));
|
||||
make.height.mas_equalTo(30);
|
||||
make.width.mas_equalTo(self.descriptionLabel.frame.size.width);
|
||||
make.width.mas_lessThanOrEqualTo(self).multipliedBy(0.5);
|
||||
}];
|
||||
MASAttachKeys(self.descriptionLabel);
|
||||
|
||||
[self.editButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.descriptionLabel.mas_trailing).mas_equalTo(kScale390(3));
|
||||
make.top.mas_equalTo(self.descriptionLabel.mas_top);
|
||||
make.height.mas_equalTo(30);
|
||||
make.width.mas_equalTo(30);
|
||||
}];
|
||||
MASAttachKeys(self.editButton);
|
||||
|
||||
[self.idLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.mas_leading);
|
||||
make.top.mas_equalTo(self.descriptionLabel.mas_bottom).mas_offset(kScale390(8));
|
||||
make.height.mas_equalTo(30);
|
||||
make.width.mas_equalTo(self.frame.size.width);
|
||||
}];
|
||||
if (self.functionListView.subviews.count > 0) {
|
||||
[self.functionListView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(0);
|
||||
make.width.mas_equalTo(self.bounds.size.width);
|
||||
make.height.mas_equalTo(kScale390(95));
|
||||
make.top.mas_equalTo(self.idLabel.mas_bottom).mas_offset(kScale390(18));
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
}
|
||||
|
||||
- (void)headImageClick {
|
||||
if (self.headImgClickBlock && [self.class isMeSuper:self.groupInfo]) {
|
||||
self.headImgClickBlock();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)editButtonClick {
|
||||
if (self.editBtnClickBlock && [self.class isMeSuper:self.groupInfo]) {
|
||||
self.editBtnClickBlock();
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)isMeSuper:(V2TIMGroupInfo *)groupInfo {
|
||||
return [groupInfo.owner isEqualToString:[[V2TIMManager sharedInstance] getLoginUser]] && (groupInfo.role == V2TIM_GROUP_MEMBER_ROLE_SUPER);
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TUIGroupProfileCardViewCell_Minimalist
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
[self setupViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setupViews {
|
||||
self.headerView = [[TUIGroupProfileHeaderView_Minimalist alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, kScale390(355))];
|
||||
|
||||
[self.contentView addSubview:self.headerView];
|
||||
}
|
||||
|
||||
- (void)fillWithData:(TUIGroupProfileCardCellData_Minimalist *)data {
|
||||
[super fillWithData:data];
|
||||
self.cardData = data;
|
||||
|
||||
[self.headerView.headImg sd_setImageWithURL:data.avatarUrl placeholderImage:data.avatarImage];
|
||||
self.headerView.descriptionLabel.text = data.name;
|
||||
self.headerView.idLabel.text = [NSString stringWithFormat:@"ID: %@", data.identifier];
|
||||
}
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
if (self.headerView.functionListView.subviews.count > 0) {
|
||||
self.headerView.frame = CGRectMake(0, 0, self.contentView.bounds.size.width, kScale390(355));
|
||||
} else {
|
||||
self.headerView.frame = CGRectMake(0, 0, self.contentView.bounds.size.width, kScale390(257));
|
||||
}
|
||||
[self.headerView.descriptionLabel sizeToFit];
|
||||
self.headerView.itemViewList = self.itemViewList;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TUIMemberInfoCell_Minimalist.h
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/9.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TUIMemberInfoCellData_Minimalist.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIMemberInfoCell_Minimalist : UITableViewCell
|
||||
@property(nonatomic, strong) UIImageView *avatarImageView;
|
||||
@property(nonatomic, strong) UILabel *nameLabel;
|
||||
@property(nonatomic, strong) TUIMemberInfoCellData_Minimalist *data;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// TUIMemberInfoCell_Minimalist.m
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/1/9.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIMemberInfoCell_Minimalist.h"
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
#import <TUICore/TUIThemeManager.h>
|
||||
#import <TUICore/UIView+TUILayout.h>
|
||||
#import "TUIMemberInfoCellData.h"
|
||||
#import "UIImageView+WebCache.h"
|
||||
|
||||
#define kScale UIScreen.mainScreen.bounds.size.width / 375.0
|
||||
|
||||
@implementation TUIMemberInfoCell_Minimalist
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
||||
[self setupViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setupViews {
|
||||
[self.contentView addSubview:self.avatarImageView];
|
||||
[self.contentView addSubview:self.nameLabel];
|
||||
}
|
||||
|
||||
- (void)setData:(TUIMemberInfoCellData_Minimalist *)data {
|
||||
_data = data;
|
||||
|
||||
UIImage *defaultImage = DefaultAvatarImage;
|
||||
[self.avatarImageView sd_setImageWithURL:[NSURL URLWithString:data.avatarUrl] placeholderImage:data.avatar ?: defaultImage];
|
||||
self.nameLabel.text = data.name;
|
||||
|
||||
// tell constraints they need updating
|
||||
[self setNeedsUpdateConstraints];
|
||||
|
||||
// update constraints now so we can animate the change
|
||||
[self updateConstraintsIfNeeded];
|
||||
|
||||
[self layoutIfNeeded];
|
||||
}
|
||||
|
||||
+ (BOOL)requiresConstraintBasedLayout {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// this is Apple's recommended place for adding/updating constraints
|
||||
- (void)updateConstraints {
|
||||
|
||||
[super updateConstraints];
|
||||
CGFloat imgWidth = kScale390(20);
|
||||
if (self.data.style == TUIMemberInfoCellStyleAdd) {
|
||||
imgWidth = 20.0 * kScale;
|
||||
[self.avatarImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.height.mas_equalTo(20.0 * kScale);
|
||||
make.leading.mas_equalTo(kScale390(18));
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
}];
|
||||
self.nameLabel.font = [UIFont systemFontOfSize:16.0 * kScale];
|
||||
self.nameLabel.textColor = [UIColor tui_colorWithHex:@"#147AFF"];
|
||||
} else {
|
||||
imgWidth = 34.0 * kScale;
|
||||
[self.avatarImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.height.mas_equalTo(34.0 * kScale);
|
||||
make.leading.mas_equalTo(kScale390(16));
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
}];
|
||||
self.nameLabel.font = [UIFont systemFontOfSize:16.0 * kScale];
|
||||
self.nameLabel.textColor = TIMCommonDynamicColor(@"form_value_text_color", @"#000000");
|
||||
}
|
||||
|
||||
if ([TUIConfig defaultConfig].avatarType == TAvatarTypeRounded) {
|
||||
self.avatarImageView.layer.masksToBounds = YES;
|
||||
self.avatarImageView.layer.cornerRadius = imgWidth / 2;
|
||||
} else if ([TUIConfig defaultConfig].avatarType == TAvatarTypeRadiusCorner) {
|
||||
self.avatarImageView.layer.masksToBounds = YES;
|
||||
self.avatarImageView.layer.cornerRadius = [TUIConfig defaultConfig].avatarCornerRadius;
|
||||
}
|
||||
|
||||
[self.nameLabel sizeToFit];
|
||||
[self.nameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.avatarImageView.mas_trailing).mas_offset(14);
|
||||
make.centerY.mas_equalTo(self.contentView);
|
||||
make.size.mas_equalTo(self.nameLabel.frame.size);
|
||||
make.trailing.mas_lessThanOrEqualTo(self.contentView.mas_trailing).mas_offset(- 2.0 * kScale);
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (UIImageView *)avatarImageView {
|
||||
if (_avatarImageView == nil) {
|
||||
_avatarImageView = [[UIImageView alloc] init];
|
||||
}
|
||||
return _avatarImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)nameLabel {
|
||||
if (_nameLabel == nil) {
|
||||
_nameLabel = [[UILabel alloc] init];
|
||||
_nameLabel.font = [UIFont systemFontOfSize:18.0 * kScale];
|
||||
_nameLabel.textColor = [UIColor colorWithRed:17 / 255.0 green:17 / 255.0 blue:17 / 255.0 alpha:1 / 1.0];
|
||||
}
|
||||
return _nameLabel;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// TUIProfileCardCell_Minimalist.h
|
||||
// Masonry
|
||||
//
|
||||
// Created by wyl on 2022/12/6.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <TIMCommon/TIMCommonModel.h>
|
||||
#import "TUIProfileCardCellData_Minimalist.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIProfileCardCell_Minimalist : TUICommonTableViewCell
|
||||
@property(nonatomic, strong) UIImageView *avatar;
|
||||
@property(nonatomic, strong) UILabel *name;
|
||||
@property(nonatomic, strong) UILabel *identifier;
|
||||
@property(nonatomic, strong) UILabel *signature;
|
||||
@property(nonatomic, strong) UIImageView *genderIcon;
|
||||
@property(nonatomic, strong) TUIProfileCardCellData_Minimalist *cardData;
|
||||
@property(nonatomic, weak) id<TUIProfileCardDelegate> delegate;
|
||||
- (void)fillWithData:(TUIProfileCardCellData_Minimalist *)data;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,194 @@
|
||||
//
|
||||
// TUIProfileCardCell_Minimalist.m
|
||||
// Masonry
|
||||
//
|
||||
// Created by wyl on 2022/12/6.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIProfileCardCell_Minimalist.h"
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
#import <TUICore/TUIThemeManager.h>
|
||||
|
||||
@implementation TUIProfileCardCell_Minimalist
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
[self setupViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setupViews {
|
||||
CGSize headSize = CGSizeMake(kScale390(66), kScale390(66));
|
||||
_avatar = [[UIImageView alloc] initWithFrame:CGRectMake(kScale390(16), kScale390(10), headSize.width, headSize.height)];
|
||||
_avatar.contentMode = UIViewContentModeScaleAspectFit;
|
||||
_avatar.layer.cornerRadius = 4;
|
||||
_avatar.layer.masksToBounds = YES;
|
||||
UITapGestureRecognizer *tapAvatar = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapAvatar)];
|
||||
[_avatar addGestureRecognizer:tapAvatar];
|
||||
_avatar.userInteractionEnabled = YES;
|
||||
|
||||
if ([TUIConfig defaultConfig].avatarType == TAvatarTypeRounded) {
|
||||
self.avatar.layer.masksToBounds = YES;
|
||||
self.avatar.layer.cornerRadius = headSize.height / 2;
|
||||
} else if ([TUIConfig defaultConfig].avatarType == TAvatarTypeRadiusCorner) {
|
||||
self.avatar.layer.masksToBounds = YES;
|
||||
self.avatar.layer.cornerRadius = [TUIConfig defaultConfig].avatarCornerRadius;
|
||||
}
|
||||
[self.contentView addSubview:_avatar];
|
||||
|
||||
// CGSize genderIconSize = CGSizeMake(20, 20);
|
||||
_genderIcon = [[UIImageView alloc] init];
|
||||
_genderIcon.contentMode = UIViewContentModeScaleAspectFit;
|
||||
_genderIcon.image = self.cardData.genderIconImage;
|
||||
[self.contentView addSubview:_genderIcon];
|
||||
|
||||
_name = [[UILabel alloc] init];
|
||||
[_name setFont:[UIFont boldSystemFontOfSize:kScale390(24)]];
|
||||
[_name setTextColor:TIMCommonDynamicColor(@"form_title_color", @"#000000")];
|
||||
[self.contentView addSubview:_name];
|
||||
|
||||
_identifier = [[UILabel alloc] init];
|
||||
[_identifier setFont:[UIFont systemFontOfSize:kScale390(12)]];
|
||||
[_identifier setTextColor:TIMCommonDynamicColor(@"form_subtitle_color", @"#888888")];
|
||||
[self.contentView addSubview:_identifier];
|
||||
|
||||
_signature = [[UILabel alloc] init];
|
||||
[_signature setFont:[UIFont systemFontOfSize:kScale390(12)]];
|
||||
[_signature setTextColor:TIMCommonDynamicColor(@"form_subtitle_color", @"#888888")];
|
||||
[self.contentView addSubview:_signature];
|
||||
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
}
|
||||
|
||||
- (void)fillWithData:(TUIProfileCardCellData_Minimalist *)data {
|
||||
[super fillWithData:data];
|
||||
self.cardData = data;
|
||||
_signature.hidden = !data.showSignature;
|
||||
// set data
|
||||
@weakify(self);
|
||||
|
||||
RAC(_signature, text) = [RACObserve(data, signature) takeUntil:self.rac_prepareForReuseSignal];
|
||||
|
||||
[[[RACObserve(data, identifier) takeUntil:self.rac_prepareForReuseSignal] distinctUntilChanged] subscribeNext:^(NSString *x) {
|
||||
@strongify(self);
|
||||
self.identifier.text = [@"ID: " stringByAppendingString:data.identifier];
|
||||
}];
|
||||
|
||||
[[[RACObserve(data, name) takeUntil:self.rac_prepareForReuseSignal] distinctUntilChanged] subscribeNext:^(NSString *x) {
|
||||
@strongify(self);
|
||||
self.name.text = x;
|
||||
[self.name sizeToFit];
|
||||
}];
|
||||
[[RACObserve(data, avatarUrl) takeUntil:self.rac_prepareForReuseSignal] subscribeNext:^(NSURL *x) {
|
||||
@strongify(self);
|
||||
[self.avatar sd_setImageWithURL:x placeholderImage:self.cardData.avatarImage];
|
||||
}];
|
||||
|
||||
[[RACObserve(data, genderString) takeUntil:self.rac_prepareForReuseSignal] subscribeNext:^(NSString *x) {
|
||||
@strongify(self);
|
||||
if ([x isEqualToString:TIMCommonLocalizableString(Male)]) {
|
||||
self.genderIcon.image = TUIGroupCommonBundleImage(@"male");
|
||||
} else if ([x isEqualToString:TIMCommonLocalizableString(Female)]) {
|
||||
self.genderIcon.image = TUIGroupCommonBundleImage(@"female");
|
||||
} else {
|
||||
self.genderIcon.image = nil;
|
||||
}
|
||||
}];
|
||||
|
||||
if (data.showAccessory) {
|
||||
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
||||
} else {
|
||||
self.accessoryType = UITableViewCellAccessoryNone;
|
||||
}
|
||||
|
||||
// tell constraints they need updating
|
||||
[self setNeedsUpdateConstraints];
|
||||
|
||||
// update constraints now so we can animate the change
|
||||
[self updateConstraintsIfNeeded];
|
||||
|
||||
[self layoutIfNeeded];
|
||||
}
|
||||
|
||||
+ (BOOL)requiresConstraintBasedLayout {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// this is Apple's recommended place for adding/updating constraints
|
||||
- (void)updateConstraints {
|
||||
|
||||
[super updateConstraints];
|
||||
CGSize headSize = CGSizeMake(kScale390(66), kScale390(66));
|
||||
|
||||
[self.avatar mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(headSize);
|
||||
make.top.mas_equalTo(kScale390(10));
|
||||
make.leading.mas_equalTo(kScale390(16));
|
||||
}];
|
||||
|
||||
if ([TUIConfig defaultConfig].avatarType == TAvatarTypeRounded) {
|
||||
self.avatar.layer.masksToBounds = YES;
|
||||
self.avatar.layer.cornerRadius = headSize.height / 2;
|
||||
} else if ([TUIConfig defaultConfig].avatarType == TAvatarTypeRadiusCorner) {
|
||||
self.avatar.layer.masksToBounds = YES;
|
||||
self.avatar.layer.cornerRadius = [TUIConfig defaultConfig].avatarCornerRadius;
|
||||
}
|
||||
|
||||
[self.name sizeToFit];
|
||||
[self.name mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(TPersonalCommonCell_Margin);
|
||||
make.leading.mas_equalTo(self.avatar.mas_trailing).mas_offset(15);
|
||||
make.width.mas_lessThanOrEqualTo(self.name.frame.size.width);
|
||||
make.height.mas_greaterThanOrEqualTo(self.name.frame.size.height);
|
||||
make.trailing.mas_lessThanOrEqualTo(self.genderIcon.mas_leading).mas_offset(- 1);
|
||||
}];
|
||||
|
||||
[self.genderIcon mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.height.mas_equalTo(self.name.font.pointSize *0.9);
|
||||
make.centerY.mas_equalTo(self.name);
|
||||
make.leading.mas_equalTo(self.name.mas_trailing).mas_offset(1);
|
||||
make.trailing.mas_lessThanOrEqualTo(self.contentView.mas_trailing).mas_offset(- 10);
|
||||
}];
|
||||
|
||||
[self.identifier sizeToFit];
|
||||
[self.identifier mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.name);
|
||||
make.top.mas_equalTo(self.name.mas_bottom).mas_offset(5);
|
||||
if(self.identifier.frame.size.width > 80) {
|
||||
make.width.mas_greaterThanOrEqualTo(self.identifier.frame.size.width);
|
||||
}
|
||||
else {
|
||||
make.width.mas_greaterThanOrEqualTo(@80);
|
||||
}
|
||||
make.height.mas_greaterThanOrEqualTo(self.identifier.frame.size.height);
|
||||
make.trailing.mas_lessThanOrEqualTo(self.contentView.mas_trailing).mas_offset(-1);
|
||||
}];
|
||||
|
||||
if (self.cardData.showSignature) {
|
||||
[self.signature sizeToFit];
|
||||
[self.signature mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.leading.mas_equalTo(self.name);
|
||||
make.top.mas_equalTo(self.identifier.mas_bottom).mas_offset(5);
|
||||
if(self.signature.frame.size.width > 80) {
|
||||
make.width.mas_greaterThanOrEqualTo(self.signature.frame.size.width);
|
||||
}
|
||||
else {
|
||||
make.width.mas_greaterThanOrEqualTo(@80);
|
||||
}
|
||||
make.height.mas_greaterThanOrEqualTo(self.signature.frame.size.height);
|
||||
make.trailing.mas_lessThanOrEqualTo(self.contentView.mas_trailing).mas_offset(-1);
|
||||
}];
|
||||
|
||||
} else {
|
||||
self.signature.frame = CGRectZero;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)onTapAvatar {
|
||||
if (_delegate && [_delegate respondsToSelector:@selector(didTapOnAvatar:)]) [_delegate didTapOnAvatar:(id)self];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user