搜索页面清空记录UI优化

This commit is contained in:
chenguilong
2022-09-09 17:17:37 +08:00
parent f8887a3a2a
commit f5848b3a38

View File

@@ -26,18 +26,25 @@
NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey";
@interface XPRoomSearchRecordViewController ()<UICollectionViewDelegate, UICollectionViewDataSource, XPInRoomRecordProtocol>
///
@property (nonatomic, strong) UIView *searchContentView;
///
@property (nonatomic, strong) UIView *roomContentView;
///
@property (nonatomic, strong) UILabel *recordTitle;
///
@property (nonatomic, strong) UIButton *clearRecordBtn;
///
@property (nonatomic, strong) UILabel *roomTitle;
///
@property (nonatomic, strong) UIButton *clearRoomBtn;
///
///
@property (nonatomic, strong) UICollectionView *searchCollectionView;
///
@property (nonatomic, strong) UICollectionView *roomCollectionView;
///
///
@property (nonatomic, strong) NSMutableArray *searchList;
///
@property (nonatomic, strong) NSMutableArray *inRoomList;
@end
@@ -61,21 +68,19 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey";
NSArray *array = [self searchRecordList];
[self.searchList addObjectsFromArray:array];
[self.searchCollectionView reloadData];
if (array.count) {
if (!array.count) {
[self.searchContentView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(0);
}];
self.searchContentView.hidden = YES;
} else {
self.searchContentView.hidden = NO;
[self.searchContentView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(30+26+8);
}];
}
}
- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self.view endEditing:YES];
@@ -83,18 +88,27 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey";
#pragma mark - Private Method
- (void)initSubViews {
[self.view addSubview:self.recordTitle];
[self.view addSubview:self.clearRecordBtn];
[self.view addSubview:self.searchCollectionView];
[self.view addSubview:self.roomTitle];
[self.view addSubview:self.clearRoomBtn];
[self.view addSubview:self.roomCollectionView];
[self.view addSubview:self.searchContentView];
[self.view addSubview:self.roomContentView];
[self.searchContentView addSubview:self.recordTitle];
[self.searchContentView addSubview:self.clearRecordBtn];
[self.searchContentView addSubview:self.searchCollectionView];
[self.roomContentView addSubview:self.roomTitle];
[self.roomContentView addSubview:self.clearRoomBtn];
[self.roomContentView addSubview:self.roomCollectionView];
}
- (void)initSubViewConstraints {
[self.searchContentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(0);
make.top.mas_equalTo(0);
make.height.mas_equalTo(30+26+8);
}];
[self.recordTitle mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(16);
make.top.mas_equalTo(10);
make.top.mas_equalTo(self.searchContentView).mas_offset(10);
make.height.mas_equalTo(20);
}];
[self.clearRecordBtn mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -108,9 +122,15 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey";
make.top.mas_equalTo(self.recordTitle.mas_bottom).mas_offset(8);
}];
[self.roomContentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(0);
make.top.mas_equalTo(self.searchContentView.mas_bottom).mas_offset(24);
make.bottom.mas_equalTo(self.roomCollectionView.mas_bottom);
}];
[self.roomTitle mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(16);
make.top.mas_equalTo(self.searchCollectionView.mas_bottom).mas_offset(24);
make.top.mas_equalTo(self.roomContentView);
make.height.mas_equalTo(20);
}];
[self.clearRoomBtn mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -222,12 +242,16 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey";
[self.inRoomList removeAllObjects];
[self.inRoomList addObjectsFromArray:array];
[self.roomCollectionView reloadData];
if (array.count == 0) {
self.roomContentView.hidden = YES;
}
}
///
- (void)cleanInRoomRecordSuccess {
[self.inRoomList removeAllObjects];
[self.roomCollectionView reloadData];
self.roomContentView.hidden = YES;
}
#pragma mark - action
@@ -240,6 +264,10 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey";
[self cleanSearchRecord];
[self.searchList removeAllObjects];
[self.searchCollectionView reloadData];
[self.searchContentView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(0);
}];
self.searchContentView.hidden = YES;
} cancelHandler:^{
}];
}
@@ -346,4 +374,19 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey";
return _inRoomList;
}
- (UIView *)searchContentView {
if (!_searchContentView) {
_searchContentView = [[UIView alloc] init];
}
return _searchContentView;
}
- (UIView *)roomContentView {
if (!_roomContentView) {
_roomContentView = [[UIView alloc] init];
}
return _roomContentView;
}
@end