chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// TLUserSettingViewController.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/3/7.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class TLUser;
|
||||
@interface TLUserSettingViewController : ZZFlexibleLayoutViewController
|
||||
|
||||
@property (nonatomic, strong, readonly) TLUser *userModel;
|
||||
|
||||
- (instancetype)initWithUserModel:(TLUser *)userModel;
|
||||
- (instancetype)init __attribute__((unavailable("请使用 initWithUserModel:")));
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,140 @@
|
||||
//
|
||||
// TLUserSettingViewController.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/3/7.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLUserSettingViewController.h"
|
||||
#import "TLSettingItem.h"
|
||||
#import "TLUserHelper.h"
|
||||
#import "TLFriendHelper.h"
|
||||
|
||||
typedef NS_ENUM(NSInteger, TLUserSettingVCSectionType) {
|
||||
TLUserSettingVCSectionTypeRemark,
|
||||
TLUserSettingVCSectionTypeInvite,
|
||||
TLUserSettingVCSectionTypeStar,
|
||||
TLUserSettingVCSectionTypeRights,
|
||||
TLUserSettingVCSectionTypeBlack,
|
||||
TLUserSettingVCSectionTypeDelete,
|
||||
};
|
||||
|
||||
@implementation TLUserSettingViewController
|
||||
|
||||
- (instancetype)initWithUserModel:(TLUser *)userModel
|
||||
{
|
||||
if (self = [super init]) {
|
||||
_userModel = userModel;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)loadView
|
||||
{
|
||||
[super loadView];
|
||||
[self setTitle:LOCSTR(@"资料设置")];
|
||||
[self.view setBackgroundColor:[UIColor colorGrayBG]];
|
||||
|
||||
[self loadUserSettingUIWithUserModel:self.userModel];
|
||||
}
|
||||
|
||||
- (void)loadUserSettingUIWithUserModel:(TLUser *)userInfo
|
||||
{
|
||||
@weakify(self);
|
||||
self.clear();
|
||||
|
||||
// 备注
|
||||
{
|
||||
NSInteger sectionTag = TLUserSettingVCSectionTypeRemark;
|
||||
self.addSection(sectionTag).sectionInsets(UIEdgeInsetsMake(15, 0, 0, 0));
|
||||
|
||||
TLSettingItem *remark = TLCreateSettingItem(@"设置备注及标签");
|
||||
if (userInfo.remarkName.length > 0) {
|
||||
remark.subTitle = userInfo.remarkName;
|
||||
}
|
||||
self.addCell(CELL_ST_ITEM_NORMAL).toSection(sectionTag).withDataModel(remark).selectedAction(^ (TLSettingItem *data) {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// 推荐
|
||||
{
|
||||
NSInteger sectionTag = TLUserSettingVCSectionTypeInvite;
|
||||
self.addSection(sectionTag).sectionInsets(UIEdgeInsetsMake(20, 0, 0, 0));
|
||||
|
||||
self.addCell(CELL_ST_ITEM_NORMAL).toSection(sectionTag).withDataModel(TLCreateSettingItem(@"把他推荐给朋友")).selectedAction(^ (TLSettingItem *data) {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// 星标
|
||||
{
|
||||
NSInteger sectionTag = TLUserSettingVCSectionTypeStar;
|
||||
self.addSection(sectionTag).sectionInsets(UIEdgeInsetsMake(20, 0, 0, 0));
|
||||
|
||||
self.addCell(CELL_ST_ITEM_SWITCH).toSection(sectionTag).withDataModel(TLCreateSettingItem(@"设为星标朋友")).eventAction(^ id(NSInteger eventType, id data) {
|
||||
|
||||
return nil;
|
||||
});
|
||||
}
|
||||
|
||||
// 权限
|
||||
{
|
||||
NSInteger sectionTag = TLUserSettingVCSectionTypeRights;
|
||||
self.addSection(sectionTag).sectionInsets(UIEdgeInsetsMake(20, 0, 0, 0));
|
||||
|
||||
TLSettingItem *prohibit = TLCreateSettingItem(@"不让他看我的朋友圈");
|
||||
self.addCell(CELL_ST_ITEM_SWITCH).toSection(sectionTag).withDataModel(prohibit).eventAction(^ id(NSInteger eventType, id data) {
|
||||
|
||||
return nil;
|
||||
});
|
||||
|
||||
TLSettingItem *dismiss = TLCreateSettingItem(@"不看他的朋友圈");
|
||||
self.addCell(CELL_ST_ITEM_SWITCH).toSection(sectionTag).withDataModel(dismiss).eventAction(^ id(NSInteger eventType, id data) {
|
||||
|
||||
return nil;
|
||||
});
|
||||
}
|
||||
|
||||
// 黑名单
|
||||
{
|
||||
NSInteger sectionTag = TLUserSettingVCSectionTypeBlack;
|
||||
self.addSection(sectionTag).sectionInsets(UIEdgeInsetsMake(20, 0, 0, 0));
|
||||
|
||||
// 黑名单
|
||||
self.addCell(CELL_ST_ITEM_SWITCH).toSection(sectionTag).withDataModel(TLCreateSettingItem(@"加入黑名单")).eventAction(^ id(NSInteger eventType, id data) {
|
||||
|
||||
return nil;
|
||||
});
|
||||
|
||||
// 举报
|
||||
self.addCell(CELL_ST_ITEM_NORMAL).toSection(sectionTag).withDataModel(TLCreateSettingItem(@"举报")).selectedAction(^ (TLSettingItem *data) {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// 删除
|
||||
{
|
||||
NSInteger sectionTag = TLUserSettingVCSectionTypeDelete;
|
||||
self.addSection(sectionTag).sectionInsets(UIEdgeInsetsMake(20, 0, 40, 0));
|
||||
|
||||
self.addCell(@"TLSettingItemDeleteButtonCell").toSection(sectionTag).withDataModel(TLCreateSettingItem(@"删除")).eventAction(^ id(NSInteger eventType, id data) {
|
||||
@strongify(self);
|
||||
TLActionSheet *actionSheet = [[TLActionSheet alloc] initWithTitle:[NSString stringWithFormat:@"将联系人“%@”删除,同时删除与该联系人的聊天记录", self.userModel.showName] clickAction:^(NSInteger buttonIndex) {
|
||||
@strongify(self);
|
||||
if (buttonIndex == 0) {
|
||||
[[TLFriendHelper sharedFriendHelper] deleteFriendByUserId:self.userModel.userID];
|
||||
[self.navigationController popToRootViewControllerAnimated:YES];
|
||||
}
|
||||
} cancelButtonTitle:@"取消" destructiveButtonTitle:@"删除联系人" otherButtonTitles:nil];
|
||||
[actionSheet show];
|
||||
|
||||
return nil;
|
||||
});
|
||||
}
|
||||
|
||||
[self reloadView];
|
||||
}
|
||||
|
||||
@end
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// TLSettingItemDeleteButtonCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/3/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface TLSettingItemDeleteButtonCell : UICollectionViewCell <ZZFlexibleLayoutViewProtocol>
|
||||
|
||||
@property (nonatomic, copy) id (^eventAction)(NSInteger, id);
|
||||
|
||||
@end
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// TLSettingItemDeleteButtonCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/3/7.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLSettingItemDeleteButtonCell.h"
|
||||
#import "TLSettingItem.h"
|
||||
|
||||
@interface TLSettingItemDeleteButtonCell ()
|
||||
|
||||
@property (nonatomic, strong) UIButton *button;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLSettingItemDeleteButtonCell
|
||||
|
||||
+ (CGFloat)viewHeightByDataModel:(id)dataModel
|
||||
{
|
||||
return 62.0f;
|
||||
}
|
||||
|
||||
- (void)setViewEventAction:(id (^)(NSInteger, id))eventAction
|
||||
{
|
||||
self.eventAction = eventAction;
|
||||
}
|
||||
|
||||
- (void)setViewDataModel:(TLSettingItem *)dataModel
|
||||
{
|
||||
self.button.zz_make.title(dataModel.title);
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self setBackgroundColor:[UIColor clearColor]];
|
||||
@weakify(self);
|
||||
self.button = self.contentView.addButton(1)
|
||||
.backgroundColor([UIColor colorRedForButton]).titleColor([UIColor whiteColor]).titleFont([UIFont systemFontOfSize:18])
|
||||
.backgroundColorHL([UIColor colorRedForButtonHL]).titleColorHL([[UIColor whiteColor] colorWithAlphaComponent:0.7])
|
||||
.cornerRadius(5).borderWidth(1).borderColor([UIColor colorGrayLine].CGColor)
|
||||
.masonry(^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(15);
|
||||
make.right.mas_equalTo(-15);
|
||||
make.top.mas_equalTo(0);
|
||||
make.bottom.mas_equalTo(-15);
|
||||
})
|
||||
.eventBlock(UIControlEventTouchUpInside, ^(UIButton *sender) {
|
||||
@strongify(self);
|
||||
if (self.eventAction) {
|
||||
self.eventAction(0, nil);
|
||||
}
|
||||
})
|
||||
.view;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user