108 lines
3.0 KiB
Objective-C
Executable File
108 lines
3.0 KiB
Objective-C
Executable File
//
|
|
// SPHomeSortAlert.m
|
|
// SweetParty
|
|
//
|
|
// Created by bj_szd on 2022/5/31.
|
|
//
|
|
|
|
#import "SPHomeSortAlert.h"
|
|
#import "SPHomeSortSingleView.h"
|
|
#import "QQCorner.h"
|
|
|
|
@interface SPHomeSortAlert ()
|
|
|
|
@property (weak, nonatomic) IBOutlet UIView *bgView;
|
|
@property (weak, nonatomic) IBOutlet UIImageView *touchImgV;
|
|
@property (weak, nonatomic) IBOutlet UIButton *confirmBtn;
|
|
|
|
@property (nonatomic, assign) NSInteger sex_type;//性别 0不限 1男2女
|
|
@property (nonatomic, assign) NSInteger distance_type;//距离 0不限 1距离优先
|
|
@property (nonatomic, assign) NSInteger age_type;//年龄 0不限 1往后依次
|
|
|
|
@end
|
|
|
|
@implementation SPHomeSortAlert
|
|
|
|
- (void)layoutSubviews {
|
|
[super layoutSubviews];
|
|
|
|
[self.bgView updateCornerRadius:^(QQCorner *corner) {
|
|
corner.radius = QQRadiusMake(20, 20, 0, 0);
|
|
}];
|
|
}
|
|
|
|
- (void)awakeFromNib {
|
|
[super awakeFromNib];
|
|
|
|
[self createUI];
|
|
}
|
|
|
|
- (void)createUI {
|
|
WEAK_SELF
|
|
[self.touchImgV dg_Tapped:^{
|
|
[weakSelf onDismiss];
|
|
}];
|
|
[self.confirmBtn setJianBianWithCGSize:CGSizeMake(ScreenWidth-27*2, 49)];
|
|
|
|
SPHomeSortSingleView *sexView = [[SPHomeSortSingleView alloc] initWithType:1];
|
|
sexView.onSelectIndexBlock = ^(NSInteger index) {
|
|
weakSelf.sex_type = index;
|
|
};
|
|
[self.bgView addSubview:sexView];
|
|
|
|
SPHomeSortSingleView *distanceView = [[SPHomeSortSingleView alloc] initWithType:2];
|
|
distanceView.hidden = YES;
|
|
distanceView.onSelectIndexBlock = ^(NSInteger index) {
|
|
weakSelf.distance_type = index;
|
|
};
|
|
[self.bgView addSubview:distanceView];
|
|
|
|
SPHomeSortSingleView *ageView = [[SPHomeSortSingleView alloc] initWithType:3];
|
|
ageView.onSelectIndexBlock = ^(NSInteger index) {
|
|
weakSelf.age_type = index;
|
|
};
|
|
[self.bgView addSubview:ageView];
|
|
|
|
[sexView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.bgView).offset(60);
|
|
make.left.right.equalTo(self.bgView);
|
|
make.height.mas_equalTo(86);
|
|
}];
|
|
[distanceView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(sexView.mas_bottom);
|
|
make.left.right.equalTo(self.bgView);
|
|
make.height.mas_equalTo(86);
|
|
}];
|
|
[ageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(sexView.mas_bottom);
|
|
make.left.right.equalTo(self.bgView);
|
|
make.height.mas_equalTo(130);
|
|
}];
|
|
}
|
|
|
|
- (void)onShow {
|
|
[KEYWINDOW addSubview:self];
|
|
self.bgView.transform = CGAffineTransformMakeTranslation(0, 380);
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
self.bgView.transform = CGAffineTransformIdentity;
|
|
}];
|
|
}
|
|
|
|
- (void)onDismiss {
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
self.bgView.transform = CGAffineTransformMakeTranslation(0, 380);
|
|
} completion:^(BOOL finished) {
|
|
[self removeFromSuperview];
|
|
}];
|
|
}
|
|
|
|
- (IBAction)onConfirm:(id)sender {
|
|
if (self.onConfirmSelBlock) {
|
|
self.onConfirmSelBlock(self.sex_type, self.distance_type, self.age_type);
|
|
}
|
|
[self onDismiss];
|
|
}
|
|
|
|
|
|
@end
|