cdts/xdts-ios 3/TreeHole/Code/Features/Bottle/View/BottleUserNearbyShaiXuanAlertView.m

144 lines
6.0 KiB
Mathematica
Raw Normal View History

2023-07-27 09:20:00 +08:00
//
// BottleUserNearbyShaiXuanAlertView.m
// TreeHole
//
// Created by on 2022/10/7.
//
#import "BottleUserNearbyShaiXuanAlertView.h"
#import "BottleShaiXuanCellView.h"
@interface BottleUserNearbyShaiXuanAlertView()
@property (nonatomic, strong)UIView* contentView;
@property (nonatomic, strong)UIView* contentTopView;
@property (nonatomic, strong)UIView* contentBodyView;
@property (nonatomic, strong)UILabel* contentBodyLab;
@property (nonatomic, strong)NSMutableDictionary* dataDict;
@end
@implementation BottleUserNearbyShaiXuanAlertView
-(instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = COLOR_WITH_RGB_A(0x000000, 0.2);
[UIView animateWithDuration:0.2 animations:^{
self.backgroundColor = COLOR_WITH_RGB_A(0x000000, 0.7);
}];
[self addSubview:self.contentView];
WeakSelf(self);
[UIView animateWithDuration:0.5 animations:^{
weakself.contentView.y = SCREEN_HEIGHT - weakself.contentView.height;
}];
//
[_contentView addSubview:self.contentTopView];
//
// [_contentView addSubview:self.contentBodyView];
// [_contentBodyView addSubview:self.contentBodyLab];
// NSArray* titleArray = @[@"TA的属性",@"TA的年龄",@"高级筛选"];
// NSArray* contentArray = @[@[@"全部",@"CD",@"TS",@"ZN"],
// @[@"全部",@"18-20",@"21-30",@"30+"],
// @[@"全部",@"VIP",@"在线",@"新人"]];
NSArray* titleArray = @[@"TA的属性",@"高级筛选"];
NSArray* contentArray = @[@[@"全部",@"CD",@"TS",@"ZN"],
@[@"全部",@"VIP",@"在线",@"新人"]];
_dataDict = [NSMutableDictionary dictionaryWithDictionary: [[NSUserDefaults standardUserDefaults]objectForKey:@"UserNearbyShaiXuanDict"]];
if (!_dataDict) {
_dataDict = [NSMutableDictionary dictionaryWithDictionary: @{@"sx_age":@"全部",@"sx_gender":@"全部",@"sx_gjsx":@"全部"}];
}
// _dataDict = [NSMutableDictionary dictionaryWithDictionary: @{@"age":@"",@"gender_str":@"",@"online":@"1",@"new":@"1",@"vip":@"1"}];
for (NSInteger i = 0; i < titleArray.count; i++) {
BottleShaiXuanCellView* cellView = [[BottleShaiXuanCellView alloc]initWithFrame:CGRectMake(0, _contentTopView.bottom + 25 + (53+25)*i, SCREEN_WIDTH, 53)];
cellView.titleStr = titleArray[i];
cellView.selectContentArray = contentArray[i];
cellView.selectContentStrBlockClick = ^(NSString * _Nonnull titleStr, NSString * _Nonnull selectStr) {
if ([titleStr isEqualToString:@"TA的属性"]) {
weakself.dataDict[@"sx_gender"] = selectStr;
}
if ([titleStr isEqualToString:@"TA的年龄"]) {
weakself.dataDict[@"sx_age"] = selectStr;
}
if ([titleStr isEqualToString:@"高级筛选"]) {
weakself.dataDict[@"sx_gjsx"] = selectStr;
}
};
[_contentView addSubview:cellView];
}
// [_contentView addSubview:self.contentFooterView];
//
// [CQOtherVender animationAlert:_contentView];
}
return self;
}
- (UIView *)contentView{
if (!_contentView) {
_contentView = [[UIView alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, 356 - (53+25))];
_contentView.backgroundColor = COLOR_WITH_RGB(0x292247);
_contentView.layer.mask = [ZcqVender setShapeLayer:_contentView.bounds andWithRectCorner:UIRectCornerTopLeft|UIRectCornerTopRight andWithNumCorner:10];
_contentView.layer.masksToBounds = YES;
}
return _contentView;
}
-(UIView *)contentTopView{
if(!_contentTopView){
_contentTopView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 44)];
UIButton* cancelBtn = [[UIButton alloc]initWithFrame:CGRectMake(28, 22, 35, 22)];
[cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
[cancelBtn setTitleColor:COLOR_WITH_RGB(0xFFFFFF) forState:UIControlStateNormal];
cancelBtn.titleLabel.font = MT_FONT_MEDIUM_NO_SCALE_SIZE(16);
[cancelBtn addTarget:self action:@selector(cancelBtnClick:) forControlEvents:UIControlEventTouchUpInside];
[_contentTopView addSubview:cancelBtn];
UILabel* titleLab = [[UILabel alloc]initWithFrame:CGRectMake((SCREEN_WIDTH-200)/2.0, 20, 200, 24)];
titleLab.text = @"精准筛选";
titleLab.font = MT_FONT_BOLD_NO_SCALE_SIZE(18);
titleLab.textAlignment = NSTextAlignmentCenter;
[_contentTopView addSubview:titleLab];
UIButton* sureBtn = [[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 28 - 35, 22, 35, 22)];
[sureBtn setTitle:@"确认" forState:UIControlStateNormal];
[sureBtn setTitleColor:COLOR_WITH_RGB(0xFFFFFF) forState:UIControlStateNormal];
sureBtn.titleLabel.font = MT_FONT_MEDIUM_NO_SCALE_SIZE(16);
[sureBtn addTarget:self action:@selector(sureBtnClick:) forControlEvents:UIControlEventTouchUpInside];
[_contentTopView addSubview:sureBtn];
}
return _contentTopView;
}
-(void)cancelBtnClick:(UIButton*)sender{
[self removeCurrentAlertView];
}
-(void)sureBtnClick:(UIButton*)sender{
NSDictionary* dataDict = self.dataDict;
NSLog(@"dataDict : %@",dataDict);
[[NSUserDefaults standardUserDefaults]setObject:dataDict forKey:@"UserNearbyShaiXuanDict"];
!self.sureClickBlock?:self.sureClickBlock(dataDict);
[self removeCurrentAlertView];
}
-(void)removeCurrentAlertView{
WeakSelf(self);
[UIView animateWithDuration:0.5 animations:^{
weakself.backgroundColor = COLOR_WITH_RGB_A(0x000000, 0);
weakself.contentView.y = SCREEN_HEIGHT;
} completion:^(BOOL finished) {
if (finished) {
[self removeFromSuperview];
}
}];
}
@end