114 lines
3.7 KiB
Objective-C
114 lines
3.7 KiB
Objective-C
//
|
|
// BankView.m
|
|
// ShenQi
|
|
//
|
|
// Created by Yao on 2024/11/9.
|
|
//
|
|
|
|
#import "BankView.h"
|
|
|
|
#import "MacroDefine.h"
|
|
#import "AreaCodeTableViewCell.h"
|
|
|
|
static NSString *identifier = @"AreaCodeTableViewCell";
|
|
|
|
@implementation BankView
|
|
|
|
-(void)awakeFromNib
|
|
{
|
|
[super awakeFromNib];
|
|
|
|
self.titleLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"PLS", nil),NSLocalizedString(@"Choose", nil)];
|
|
|
|
self.bottomConstraint.constant = 0;
|
|
[UIView animateWithDuration:0.25 animations:^{
|
|
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
|
|
[self layoutIfNeeded];
|
|
}];
|
|
|
|
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_WIDTH, 400) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(12,12)];
|
|
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
|
|
maskLayer.frame = CGRectMake(0, 0, SCREEN_WIDTH, 400);
|
|
maskLayer.path = maskPath.CGPath;
|
|
self.mainView.layer.mask = maskLayer;
|
|
|
|
self.bankTableView.delegate = self;
|
|
self.bankTableView.dataSource = self;
|
|
self.bankTableView.rowHeight = 50;
|
|
[self.bankTableView registerNib:[UINib nibWithNibName:@"AreaCodeTableViewCell" bundle:nil] forCellReuseIdentifier:identifier];
|
|
[self.bankTableView setSeparatorStyle:(UITableViewCellSeparatorStyleSingleLine)];
|
|
[self.bankTableView setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
|
|
self.bankTableView.tableFooterView = [UIView new];
|
|
}
|
|
|
|
- (IBAction)dismissAction:(id)sender
|
|
{
|
|
self.bottomConstraint.constant = -400;
|
|
[UIView animateWithDuration:0.25 animations:^{
|
|
[self layoutIfNeeded];
|
|
} completion:^(BOOL finished) {
|
|
[self removeFromSuperview];
|
|
}];
|
|
}
|
|
|
|
-(void)setBankdic:(NSDictionary *)bankdic
|
|
{
|
|
_bankdic = bankdic;
|
|
|
|
if (self.chooseType == ChooseBankCodeType) {
|
|
self.bankArray = @[].mutableCopy;
|
|
[self.bankArray addObjectsFromArray:self.bankdic.allKeys];
|
|
[self.bankTableView reloadData];
|
|
}
|
|
}
|
|
|
|
-(void)setCurrentBankCode:(NSString *)currentBankCode
|
|
{
|
|
_currentBankCode = currentBankCode;
|
|
|
|
if (self.chooseType == ChooseBankNameType && !ISNULLSTR(self.currentBankCode) && !ISNULL(self.bankdic)) {
|
|
self.bankArray = @[].mutableCopy;
|
|
NSArray *bankArray = [self.bankdic objectForKey:self.currentBankCode];
|
|
for (NSDictionary *bankdic in bankArray) {
|
|
BankModelData *bank = [[BankModelData alloc] initWithDictionary:bankdic];
|
|
[self.bankArray addObject:bank];
|
|
}
|
|
[self.bankTableView reloadData];
|
|
}
|
|
}
|
|
|
|
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|
{
|
|
return self.bankArray.count;
|
|
}
|
|
|
|
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
AreaCodeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
|
|
if (self.chooseType == ChooseBankNameType) {
|
|
BankModelData *data = [self.bankArray objectAtIndex:indexPath.row];
|
|
cell.titleLabel.text = data.bankName;
|
|
}else{
|
|
cell.titleLabel.text = [self.bankArray objectAtIndex:indexPath.row];
|
|
}
|
|
return cell;
|
|
}
|
|
|
|
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
if (self.chooseType == ChooseBankNameType) {
|
|
BankModelData *data = [self.bankArray objectAtIndex:indexPath.row];
|
|
if (self.selectedCompleteBlock) {
|
|
self.selectedCompleteBlock(data);
|
|
}
|
|
}else{
|
|
NSString *code = [self.bankArray objectAtIndex:indexPath.row];
|
|
if (self.selectedCompleteBlock) {
|
|
self.selectedCompleteBlock(code);
|
|
}
|
|
}
|
|
[self dismissAction:nil];
|
|
}
|
|
|
|
@end
|