Selaa lähdekoodia

类别列表展示和跳转逻辑切换

iOS-Abel 2 vuotta sitten
vanhempi
commit
490de33439
23 muutettua tiedostoa jossa 167 lisäystä ja 33 poistoa
  1. 6 0
      Asteria/AppDelegate.m
  2. 2 2
      Asteria/Fuction/Category/Category.xcassets/moneyType/search_payMoneyType_select.imageset/Contents.json
  3. BIN
      Asteria/Fuction/Category/Category.xcassets/moneyType/search_payMoneyType_select.imageset/search_payMoneyType_select@2x.png
  4. BIN
      Asteria/Fuction/Category/Category.xcassets/moneyType/search_payMoneyType_select.imageset/search_payMoneyType_select@3x.png
  5. BIN
      Asteria/Fuction/Category/Category.xcassets/moneyType/search_payMoneyType_select.imageset/选中@2x.png
  6. BIN
      Asteria/Fuction/Category/Category.xcassets/moneyType/search_payMoneyType_select.imageset/选中@3x.png
  7. 22 0
      Asteria/Fuction/Category/Category.xcassets/search_hadMore.imageset/Contents.json
  8. BIN
      Asteria/Fuction/Category/Category.xcassets/search_hadMore.imageset/组 8043@2x.png
  9. BIN
      Asteria/Fuction/Category/Category.xcassets/search_hadMore.imageset/组 8043@3x.png
  10. 22 0
      Asteria/Fuction/Category/Category.xcassets/search_openMore.imageset/Contents.json
  11. BIN
      Asteria/Fuction/Category/Category.xcassets/search_openMore.imageset/search_openMore@2x.png
  12. BIN
      Asteria/Fuction/Category/Category.xcassets/search_openMore.imageset/search_openMore@3x.png
  13. 2 0
      Asteria/Fuction/Category/Target_Category.h
  14. 5 2
      Asteria/Fuction/Category/Target_Category.m
  15. 2 0
      Asteria/Fuction/Category/m/KWSearchSubTypeModel.h
  16. 36 0
      Asteria/Fuction/Category/m/KWSearchSubTypeModel.m
  17. 1 0
      Asteria/Fuction/Category/v/KWMoneyTypeHeadView.m
  18. 2 2
      Asteria/Fuction/Category/v/KWSearchSubTypeCell.m
  19. 2 2
      Asteria/Fuction/Category/v/KWSearchSubTypeTableView.m
  20. 36 20
      Asteria/Fuction/Category/vc/ASCategoryViewController.m
  21. 1 0
      Asteria/Product/CTMediatoaTargets/CTMediator+Categorys.h
  22. 3 0
      Asteria/Product/CTMediatoaTargets/CTMediator+Categorys.m
  23. 25 5
      Asteria/Tabber/AS_TabBarViewController.m

+ 6 - 0
Asteria/AppDelegate.m

@@ -21,6 +21,12 @@
 
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     // Override point for customization after application launch.
+    if (@available(iOS 15.0, *)) {
+        UITableView.appearance.sectionHeaderTopPadding = 0;
+    } else {
+        // Fallback on earlier versions
+    }
+    
     [self xxx_ytkNetConfig];
     self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
     AS_TabBarViewController *tab = [[AS_TabBarViewController alloc] init];

+ 2 - 2
Asteria/Fuction/Category/Category.xcassets/moneyType/search_payMoneyType_select.imageset/Contents.json

@@ -5,12 +5,12 @@
       "scale" : "1x"
     },
     {
-      "filename" : "search_payMoneyType_select@2x.png",
+      "filename" : "选中@2x.png",
       "idiom" : "universal",
       "scale" : "2x"
     },
     {
-      "filename" : "search_payMoneyType_select@3x.png",
+      "filename" : "选中@3x.png",
       "idiom" : "universal",
       "scale" : "3x"
     }

BIN
Asteria/Fuction/Category/Category.xcassets/moneyType/search_payMoneyType_select.imageset/search_payMoneyType_select@2x.png


BIN
Asteria/Fuction/Category/Category.xcassets/moneyType/search_payMoneyType_select.imageset/search_payMoneyType_select@3x.png


BIN
Asteria/Fuction/Category/Category.xcassets/moneyType/search_payMoneyType_select.imageset/选中@2x.png


BIN
Asteria/Fuction/Category/Category.xcassets/moneyType/search_payMoneyType_select.imageset/选中@3x.png


+ 22 - 0
Asteria/Fuction/Category/Category.xcassets/search_hadMore.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "组 8043@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "组 8043@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
Asteria/Fuction/Category/Category.xcassets/search_hadMore.imageset/组 8043@2x.png


BIN
Asteria/Fuction/Category/Category.xcassets/search_hadMore.imageset/组 8043@3x.png


+ 22 - 0
Asteria/Fuction/Category/Category.xcassets/search_openMore.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "search_openMore@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "search_openMore@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
Asteria/Fuction/Category/Category.xcassets/search_openMore.imageset/search_openMore@2x.png


BIN
Asteria/Fuction/Category/Category.xcassets/search_openMore.imageset/search_openMore@3x.png


+ 2 - 0
Asteria/Fuction/Category/Target_Category.h

@@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface Target_Category : NSObject
 
+- (Class)Action_categoryListVcClass:(NSDictionary *)params;
+
 - (UIViewController *)Action_getCategoryListVc:(NSDictionary *)params;
 
 - (UIViewController *)Action_getSearchVc:(NSDictionary *)params;

+ 5 - 2
Asteria/Fuction/Category/Target_Category.m

@@ -6,7 +6,7 @@
 //
 
 #import "Target_Category.h"
-#import "APCategoryViewController.h"
+#import "ASCategoryViewController.h"
 #import "APOnlySearchViewController.h"
 #import "ASSearchViewController.h"
 #import "ASBaseNavController.h"
@@ -14,9 +14,12 @@
 @implementation Target_Category
 
 - (UIViewController *)Action_getCategoryListVc:(NSDictionary *)params {
-    APCategoryViewController *vc = [[APCategoryViewController alloc] init];
+    ASCategoryViewController *vc = [[ASCategoryViewController alloc] init];
     return  vc;
 }
+- (Class)Action_categoryListVcClass:(NSDictionary *)params {
+    return ASCategoryViewController.class;
+}
 
 - (UIViewController *)Action_getSearchVc:(NSDictionary *)params {
     ASSearchViewController *vc = [ASSearchViewController new];

+ 2 - 0
Asteria/Fuction/Category/m/KWSearchSubTypeModel.h

@@ -44,6 +44,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property (nonatomic, assign) BOOL isMoneyType;
 
++ (KWMainTypeModel *)demoData;
+
 
 @end
 NS_ASSUME_NONNULL_END

+ 36 - 0
Asteria/Fuction/Category/m/KWSearchSubTypeModel.m

@@ -16,12 +16,34 @@
     };
 }
 
++ (KWSearchSubTypeModel *)demoData {
+    KWSearchSubTypeModel *m = [KWSearchSubTypeModel new];
+    m.Id = [NSString stringWithFormat:@"%u",arc4random()%1000000];
+    m.thumbnail_url = @"";
+    m.title = [NSString stringWithFormat:@"sub_%u",arc4random()%10021];
+    return m;
+}
 
 
 @end
 
 @implementation KWSubTypeSectionModel
 
++ (KWSubTypeSectionModel *)demoData {
+    KWSubTypeSectionModel *m = [KWSubTypeSectionModel new];
+    m.Id = [NSString stringWithFormat:@"%u",arc4random()%1000000];
+    m.isMoneyType = false;
+    m.thumbnail_url = @"";
+    m.isOpen = false;
+    m.title = [NSString stringWithFormat:@"section_%u",arc4random()%10021];
+    NSMutableArray *tempArr = [NSMutableArray array];
+    for (int i = 0; i<arc4random()%20; i++) {
+        [tempArr addObject:[KWSearchSubTypeModel demoData]];
+    }
+    m.children = tempArr;
+    return m;
+}
+
 
 + (NSDictionary *)mj_replacedKeyFromPropertyName {
     return @{
@@ -46,6 +68,20 @@
 
 @implementation KWMainTypeModel
 
++ (KWMainTypeModel *)demoData {
+    KWMainTypeModel *m = [KWMainTypeModel new];
+    m.Id = [NSString stringWithFormat:@"%u",arc4random()%1000000];
+    m.isMoneyType = false;
+    m.thumbnail_url = @"";
+    m.title = [NSString stringWithFormat:@"main_%u",arc4random()%10021];
+    NSMutableArray *tempArr = [NSMutableArray array];
+    for (int i = 0; i<arc4random()%20; i++) {
+        [tempArr addObject:[KWSubTypeSectionModel demoData]];
+    }
+    m.children = tempArr;
+    return m;
+}
+
 
 + (NSDictionary *)mj_objectClassInArray{
     

+ 1 - 0
Asteria/Fuction/Category/v/KWMoneyTypeHeadView.m

@@ -23,6 +23,7 @@
     self.titleLb.text = m.Id;
     self.typeImgV.image = [UIImage imageNamed:m.Id];
     self.imgV.hidden = !isSelect;
+    self.contentView.backgroundColor = isSelect ? Col_000 : Col_FFF;
     
     
 }

+ 2 - 2
Asteria/Fuction/Category/v/KWSearchSubTypeCell.m

@@ -22,7 +22,7 @@
     if (!m.thumbnail_url || [m.thumbnail_url isEqualToString:@""] || ![[m.thumbnail_url lowercaseString] hasPrefix:@"http"] ) {
         self.imgV.hidden = true;
         [self.bgV mas_updateConstraints:^(MASConstraintMaker *make) {
-            make.height.equalTo(@57);
+            make.height.equalTo(@45);
         }];
     } else {
         self.imgV.hidden = false;
@@ -49,7 +49,7 @@
     [self.contentView addSubview:self.bgV];
     [self.bgV addSubview:self.stackV];
     [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.top.equalTo(self.contentView).offset(3);
+        make.top.equalTo(self.contentView);
         make.left.equalTo(self.contentView);
         make.right.equalTo(self.contentView);
         make.bottom.equalTo(self.contentView);

+ 2 - 2
Asteria/Fuction/Category/v/KWSearchSubTypeTableView.m

@@ -67,7 +67,7 @@
 }
 
 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
-    return  60;
+    return  45;
 }
 
 - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
@@ -114,7 +114,7 @@
 
 
 - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
-    return  10;
+    return 5;
 }
 
 - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {

+ 36 - 20
Asteria/Fuction/Category/vc/ASCategoryViewController.m

@@ -14,7 +14,6 @@
 @property (nonatomic, strong) KWSearchMainTypeTableView *leftTableV;
 @property (nonatomic, strong) KWSearchSubTypeTableView *rightTableV;
 @property (nonatomic, strong) UIView *bottomV;
-@property (nonatomic, strong) UIButton *cusBackBt;
 
 @end
 
@@ -24,6 +23,39 @@
     [super viewDidLoad];
     [self loadSubVs];
     
+    
+    NSMutableArray<KWMainTypeModel *> *tempArr = [NSMutableArray array];
+    for (int i = 0; i<8; i++) {
+        [tempArr addObject:[KWMainTypeModel demoData]];
+    }
+    
+    NSMutableArray *subArr = [[NSMutableArray alloc] init];
+    
+    
+    for (NSString *dic in @[@"AUD",@"CAD",@"EUR",@"GBP",@"USD",@"ZAR"]) {
+        NSString *name = dic;
+        NSString *short_name = dic;
+        NSNumber *status =[NSNumber numberWithBool:[dic isEqualToString:@"USD"]];
+        
+        KWSubTypeSectionModel *m = [[KWSubTypeSectionModel alloc] init];
+        m.Id = short_name;
+        m.title = name;
+        m.isOpen = status.boolValue;
+        m.isMoneyType = true;
+        m.children = [[NSMutableArray alloc] init];
+        [subArr addObject:m];
+    }
+    
+    KWMainTypeModel *model = [KWMainTypeModel new];
+    model.title = @"CURRENCY";
+    model.isMoneyType = true;
+    model.children = subArr;
+    [tempArr addObject:model];
+    _leftTableV.arr = tempArr;
+    _rightTableV.arr = tempArr.firstObject.children;
+    [_leftTableV reloadData];
+    [_rightTableV reloadData];
+    
 }
 
 - (void)loadSubVs {
@@ -31,13 +63,6 @@
     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];
@@ -72,15 +97,13 @@
    [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];
+        leftTab.backgroundColor = _F8F8F8;
         @weakify(self);
         _leftTableV = leftTab;
         leftTab.callBack = ^{
@@ -107,6 +130,7 @@
 - (KWSearchSubTypeTableView *)rightTableV {
     if(!_rightTableV) {
         KWSearchSubTypeTableView *tab = [[KWSearchSubTypeTableView alloc] initWithFrame:CGRectMake(0, 10, 180, self.view.bounds.size.height) style:UITableViewStylePlain];
+        tab.backgroundColor = _F8F8F8;
         _rightTableV = tab;
         @weakify(self);
         [_rightTableV setCallBack:^(NSIndexPath * _Nonnull indexP) {
@@ -139,15 +163,7 @@
     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 {

+ 1 - 0
Asteria/Product/CTMediatoaTargets/CTMediator+Categorys.h

@@ -11,6 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface CTMediator (Categorys)
 
+- (Class)categoryListVcClass;
 - (UIViewController *)getCategoryListVc:(NSDictionary *)params;
 
 - (UIViewController *)getSearchVc:(NSDictionary *)params;

+ 3 - 0
Asteria/Product/CTMediatoaTargets/CTMediator+Categorys.m

@@ -12,6 +12,9 @@
 - (UIViewController *)getCategoryListVc:(NSDictionary *)params{
     return [self performTarget:@"Category" action:@"getCategoryListVc" params:params shouldCacheTarget:NO];
 }
+- (Class)categoryListVcClass{
+    return [self performTarget:@"Category" action:@"categoryListVcClass" params:@{} shouldCacheTarget:NO];
+}
 
 - (UIViewController *)getSearchVc:(NSDictionary *)params{
     return [self performTarget:@"Category" action:@"getSearchVc" params:params shouldCacheTarget:NO];

+ 25 - 5
Asteria/Tabber/AS_TabBarViewController.m

@@ -10,8 +10,8 @@
 #import <UCMBaseC.h>
 #import "AViewController.h"
 
-
-@interface AS_TabBarViewController ()
+@class APCategoryViewController;
+@interface AS_TabBarViewController ()<UITabBarControllerDelegate>
 
 @end
 
@@ -19,12 +19,12 @@
 
 - (void)didInitialize {
     [super didInitialize];
-    
+        
     self.tabBar.backgroundColor = UIColor.whiteColor;
     self.tabBar.unselectedItemTintColor = Col_666;
     self.tabBar.tintColor = _1CBC9D;
     
-    UIViewController *vc1 = [[CTMediator sharedInstance] getCategoryAndSearchVc:@{}];
+    UIViewController *vc1 = [[CTMediator sharedInstance] getCategoryListVc:@{}];
     UIViewController *vc2 = [[CTMediator sharedInstance] getHomeVc:@{}];
     AViewController *cartv = [AViewController new];
     UIViewController *vc3 = [[CTMediator sharedInstance] getUserCenterVc:@{}];
@@ -52,9 +52,9 @@
         [tabvcAry addObject:uikitNavController];
     }
     self.viewControllers = tabvcAry;
+    self.delegate = self;
 }
 
-
 - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
     if (self.tabBar.items.count > 2) {
         UITabBarItem *temp = self.tabBar.items[2];
@@ -63,4 +63,24 @@
     }
 }
 
+- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
+    if ([viewController isKindOfClass:QMUINavigationController.class]) {
+        QMUINavigationController *nav = (QMUINavigationController *)viewController;
+        UIViewController *vc = nav.qmui_rootViewController;
+        if ([vc isKindOfClass:[CTMediator.sharedInstance categoryListVcClass]]) {
+            
+            UIViewController *vc1 = [[CTMediator sharedInstance] getCategoryListVc:@{}];
+            
+            [self.selectedViewController pushViewController:vc1 animated:true];
+            
+            return false;
+        }
+//        NSString *name = [NSString stringWithFormat:@"%s", object_getClassName(vc)];
+//        if ([name isEqualToString:@"APCategoryViewController"]) {
+//            return <#expression#>;
+//        }
+    }
+    return true;
+}
+
 @end