123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- //
- // ASCategoryViewController.m
- // Asteria
- //
- // Created by iOS on 2023/7/10.
- //
- #import "ASCategoryViewController.h"
- #import "KWSearchMainTypeTableView.h"
- #import "KWSearchSubTypeTableView.h"
- @interface ASCategoryViewController ()
- @property (nonatomic, strong) KWSearchMainTypeTableView *leftTableV;
- @property (nonatomic, strong) KWSearchSubTypeTableView *rightTableV;
- @property (nonatomic, strong) UIView *bottomV;
- @property (nonatomic, strong) UIButton *cusBackBt;
- @end
- @implementation ASCategoryViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self loadSubVs];
-
- }
- - (void)loadSubVs {
- self.statusBgV.backgroundColor = _E0FFF5;
- self.customNavBar.backgroundColor = _E0FFF5;
- self.titleStr = @"Category";
-
- [self.customNavBar addSubview:self.cusBackBt];
- [self.cusBackBt mas_makeConstraints:^(MASConstraintMaker *make) {
- make.trailing.equalTo(self.customNavBar).offset(-10);
- make.centerY.equalTo(self.customNavBar);
- make.width.height.equalTo(@44);
- }];
-
- [self.view addSubview:self.bottomV];
- [self.bottomV addSubview:self.leftTableV];
- [self.bottomV addSubview:self.rightTableV];
-
- [self.bottomV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.customNavBar.mas_bottom).offset(10);
- make.left.right.equalTo(self.view);
- make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
- }];
-
- [self.leftTableV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.equalTo(@130);
- make.left.top.bottom.equalTo(self.bottomV);
- }];
- [self.rightTableV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.bottom.right.equalTo(self.bottomV);
- make.left.equalTo(self.leftTableV.mas_right);
- }];
-
- }
- // MARK: - actions
- - (void)toResult:(NSString *)key type:(NSString *)type keyWord:(NSString *)word {
- NSDictionary *para = @{
- @"type":type, //String
- @"title":key,//String
- @"searchKey":word,//String
- };
- UIViewController *vc = [CTMediator.sharedInstance getProductListVc:para];
-
- [self.navigationController pushViewController:vc animated:true];
- }
- - (void)backAction {
- [self dismissViewControllerAnimated:true completion:nil];
- }
- // MARK: - subvs
- - (KWSearchMainTypeTableView *)leftTableV {
- if (!_leftTableV) {
- KWSearchMainTypeTableView *leftTab = [[KWSearchMainTypeTableView alloc] initWithFrame:CGRectMake(0, 10, 180, self.view.bounds.size.height) style:UITableViewStylePlain];
- @weakify(self);
- _leftTableV = leftTab;
- leftTab.callBack = ^{
- NSInteger selectIndex = weak_self.leftTableV.selectIndex;
- if (selectIndex >= weak_self.leftTableV.arr.count) {
- weak_self.rightTableV.arr = weak_self.leftTableV.moneyType.children;
- [weak_self.rightTableV reloadData];
- return;
- }
-
- KWMainTypeModel *m = weak_self.leftTableV.arr[selectIndex];
- if (m.children.count == 0) {
- [self toResult:m.title type:m.Id keyWord:@""];
- } else {
- weak_self.rightTableV.arr = m.children;
- [weak_self.rightTableV reloadData];
- }
- };
- }
- return _leftTableV;
- }
- - (KWSearchSubTypeTableView *)rightTableV {
- if(!_rightTableV) {
- KWSearchSubTypeTableView *tab = [[KWSearchSubTypeTableView alloc] initWithFrame:CGRectMake(0, 10, 180, self.view.bounds.size.height) style:UITableViewStylePlain];
- _rightTableV = tab;
- @weakify(self);
- [_rightTableV setCallBack:^(NSIndexPath * _Nonnull indexP) {
- KWSearchSubTypeModel *m = weak_self.rightTableV.arr[indexP.section].children[indexP.item];
- [weak_self toResult:m.title type:m.Id keyWord:@""];
- }];
- [_rightTableV setCallBackSection:^(NSInteger index) {
- KWSubTypeSectionModel *m = weak_self.rightTableV.arr[index];
- if (m.isMoneyType) {
- [MBProgressHUD showHUDAddedTo:weak_self.view animated:true];
- // [weak_self.vm switchCurrencie:m callback:^(BOOL flag) {
- //
- // if (flag) {
- // [[NSNotificationCenter defaultCenter] postNotificationName:MoneyTypeChanged object:nil];
- // [weak_self.vm reqCurrenciesList:^{
- // [MBProgressHUD hideHUDForView:weak_self.view animated:true];
- // weak_self.leftTableV.moneyType = weak_self.vm.moneyType;
- // weak_self.rightTableV.arr = weak_self.vm.moneyType.children;
- // [weak_self.rightTableV reloadData];
- // }];
- // } else {
- // [MBProgressHUD hideHUDForView:weak_self.view animated:true];
- // }
- // }];
- return;
- }
- [weak_self toResult:m.title type:m.Id keyWord:@""];
- }];
- }
- return _rightTableV;
- }
- - (UIButton *)cusBackBt {
- if (!_cusBackBt) {
- UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
- [bt setImage:[UIImage imageNamed:@"nav_back"] forState:UIControlStateNormal];
- [bt addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
- _cusBackBt = bt;
- }
- return _cusBackBt;
- }
- -(UIView *)bottomV {
- if (!_bottomV) {
- UIView *v = [[UIView alloc] init];
- v.backgroundColor = [UIColor colorWithHexString:@"#ffffff"];
- _bottomV = v;
- }
- return _bottomV;
- }
- @end
|