搜索页面清空记录UI优化
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user