2
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
#import "Masonry.h"
|
||||
|
||||
@interface KBChatPanelView () <UITableViewDataSource, UITableViewDelegate>
|
||||
//@property (nonatomic, strong) UIImageView *backgroundImageView;
|
||||
@property (nonatomic, strong) UIView *headerView;
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
@property (nonatomic, strong) UIButton *closeButton;
|
||||
@property (nonatomic, strong) UITableView *tableViewInternal;
|
||||
@property (nonatomic, copy) NSArray<KBChatMessage *> *messages;
|
||||
@end
|
||||
@@ -17,13 +21,25 @@
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.backgroundColor = [UIColor colorWithHex:0xD1D3DB];
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
|
||||
// [self addSubview:self.backgroundImageView];
|
||||
[self addSubview:self.headerView];
|
||||
[self addSubview:self.tableViewInternal];
|
||||
|
||||
// [self.backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.edges.equalTo(self);
|
||||
// }];
|
||||
|
||||
[self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self);
|
||||
make.top.equalTo(self.mas_top);
|
||||
make.height.mas_equalTo(KBFit(36.0f));
|
||||
}];
|
||||
|
||||
[self.tableViewInternal mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self);
|
||||
make.top.equalTo(self.mas_top).offset(8);
|
||||
make.top.equalTo(self.headerView.mas_bottom).offset(4);
|
||||
make.bottom.equalTo(self.mas_bottom).offset(-8);
|
||||
}];
|
||||
}
|
||||
@@ -43,6 +59,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
//- (void)kb_setBackgroundImage:(UIImage *)image {
|
||||
// self.backgroundImageView.image = image;
|
||||
//}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (void)kb_onTapClose {
|
||||
if ([self.delegate respondsToSelector:@selector(chatPanelViewDidTapClose:)]) {
|
||||
[self.delegate chatPanelViewDidTapClose:self];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDataSource
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
@@ -80,6 +108,7 @@
|
||||
if (!_tableViewInternal) {
|
||||
_tableViewInternal = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||||
_tableViewInternal.backgroundColor = [UIColor clearColor];
|
||||
_tableViewInternal.backgroundView = nil;
|
||||
_tableViewInternal.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
_tableViewInternal.dataSource = self;
|
||||
_tableViewInternal.delegate = self;
|
||||
@@ -90,6 +119,61 @@
|
||||
return _tableViewInternal;
|
||||
}
|
||||
|
||||
- (UIView *)headerView {
|
||||
if (!_headerView) {
|
||||
_headerView = [[UIView alloc] init];
|
||||
_headerView.backgroundColor = [UIColor clearColor];
|
||||
[_headerView addSubview:self.titleLabel];
|
||||
[_headerView addSubview:self.closeButton];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(_headerView.mas_left).offset(12);
|
||||
make.centerY.equalTo(_headerView);
|
||||
}];
|
||||
|
||||
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(_headerView.mas_right).offset(-12);
|
||||
make.centerY.equalTo(_headerView);
|
||||
make.width.height.mas_equalTo(KBFit(24.0f));
|
||||
}];
|
||||
}
|
||||
return _headerView;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
|
||||
_titleLabel.textColor = [UIColor colorWithHex:0x1B1F1A];
|
||||
_titleLabel.text = KBLocalized(@"AI对话");
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
- (UIButton *)closeButton {
|
||||
if (!_closeButton) {
|
||||
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
UIImage *icon = [UIImage imageNamed:@"close_icon"];
|
||||
[_closeButton setImage:icon forState:UIControlStateNormal];
|
||||
_closeButton.backgroundColor = [UIColor clearColor];
|
||||
[_closeButton addTarget:self
|
||||
action:@selector(kb_onTapClose)
|
||||
forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _closeButton;
|
||||
}
|
||||
|
||||
//- (UIImageView *)backgroundImageView {
|
||||
// if (!_backgroundImageView) {
|
||||
// _backgroundImageView = [[UIImageView alloc] init];
|
||||
// _backgroundImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
// _backgroundImageView.clipsToBounds = YES;
|
||||
// _backgroundImageView.backgroundColor = [UIColor clearColor];
|
||||
// _backgroundImageView.userInteractionEnabled = NO;
|
||||
// }
|
||||
// return _backgroundImageView;
|
||||
//}
|
||||
|
||||
#pragma mark - Expose
|
||||
|
||||
- (UITableView *)tableView { return self.tableViewInternal; }
|
||||
|
||||
Reference in New Issue
Block a user