Răsfoiți Sursa

1.修改iOS Apex & Drivers首页TableView Section显隐,增加登出,以及调节Action按钮高度。

Pen Li 8 ani în urmă
părinte
comite
339c837a21

+ 8 - 0
Redant Drivers/Apex And Drivers.xcodeproj/project.pbxproj

@@ -61,6 +61,8 @@
 		4255EC9C20C5286D00E5DA24 /* RAEditMultInputModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 4255EC9B20C5286D00E5DA24 /* RAEditMultInputModel.m */; };
 		4255EC9F20C5287D00E5DA24 /* RAEditPhotoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 4255EC9E20C5287D00E5DA24 /* RAEditPhotoModel.m */; };
 		4255ECA120C5400400E5DA24 /* Barcode_h.png in Resources */ = {isa = PBXBuildFile; fileRef = 4255ECA020C5400300E5DA24 /* Barcode_h.png */; };
+		4258D16120CE296E00067071 /* logout.png in Resources */ = {isa = PBXBuildFile; fileRef = 4258D16020CE296E00067071 /* logout.png */; };
+		4258D16320CE298500067071 /* list.png in Resources */ = {isa = PBXBuildFile; fileRef = 4258D16220CE298500067071 /* list.png */; };
 		425B97CB20C7895F00B35713 /* RASingleton.m in Sources */ = {isa = PBXBuildFile; fileRef = 425B97CA20C7895F00B35713 /* RASingleton.m */; };
 		425B97D020C78ABE00B35713 /* RAUploadManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 425B97CE20C78ABE00B35713 /* RAUploadManager.m */; };
 		425B97D120C78ABE00B35713 /* RAUploadOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 425B97CF20C78ABE00B35713 /* RAUploadOperation.m */; };
@@ -203,6 +205,8 @@
 		4255EC9D20C5287D00E5DA24 /* RAEditPhotoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RAEditPhotoModel.h; sourceTree = "<group>"; };
 		4255EC9E20C5287D00E5DA24 /* RAEditPhotoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RAEditPhotoModel.m; sourceTree = "<group>"; };
 		4255ECA020C5400300E5DA24 /* Barcode_h.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Barcode_h.png; sourceTree = "<group>"; };
+		4258D16020CE296E00067071 /* logout.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = logout.png; sourceTree = "<group>"; };
+		4258D16220CE298500067071 /* list.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = list.png; sourceTree = "<group>"; };
 		425B97C920C7895F00B35713 /* RASingleton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RASingleton.h; sourceTree = "<group>"; };
 		425B97CA20C7895F00B35713 /* RASingleton.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RASingleton.m; sourceTree = "<group>"; };
 		425B97CC20C78ABD00B35713 /* RAUploadOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RAUploadOperation.h; path = ../../common/upload/RAUploadOperation.h; sourceTree = "<group>"; };
@@ -652,6 +656,8 @@
 			children = (
 				4255EC8120C51A4F00E5DA24 /* Barcode_n.png */,
 				4255ECA020C5400300E5DA24 /* Barcode_h.png */,
+				4258D16020CE296E00067071 /* logout.png */,
+				4258D16220CE298500067071 /* list.png */,
 				71EAA33020B9571B002F003C /* Apex And Drivers */,
 				71EAA32F20B9571B002F003C /* Products */,
 			);
@@ -763,6 +769,7 @@
 				71EAA33E20B95720002F003C /* LaunchScreen.storyboard in Resources */,
 				4255EC8220C51A5000E5DA24 /* Barcode_n.png in Resources */,
 				4255ECA120C5400400E5DA24 /* Barcode_h.png in Resources */,
+				4258D16320CE298500067071 /* list.png in Resources */,
 				42D8B8A320C2253E001C125F /* fake_order_list.json in Resources */,
 				424204E420C65827005AEED9 /* Camera.storyboard in Resources */,
 				42D8B8E020C28755001C125F /* fake_order_detail.json in Resources */,
@@ -772,6 +779,7 @@
 				424204DE20C6156E005AEED9 /* QRCode.storyboard in Resources */,
 				424204F020C66D2D005AEED9 /* PhotoPreview.storyboard in Resources */,
 				4280034220C0F146004D4F50 /* LICENSE in Resources */,
+				4258D16120CE296E00067071 /* logout.png in Resources */,
 				425B97EA20C7BF4E00B35713 /* Upload.storyboard in Resources */,
 				4255EC7620C5097200E5DA24 /* Edit.storyboard in Resources */,
 				4205FD6320C136F900DB42B4 /* Home.storyboard in Resources */,

+ 31 - 13
Redant Drivers/Apex And Drivers/AppDelegate.m

@@ -28,6 +28,24 @@
     self.window.rootViewController = nav;
 }
 
+- (void)showLoginVC {
+    
+    LoginViewController *rootVC = [LoginViewController viewControllerFromStoryboard];
+    
+    __weak typeof(self) weakSelf = self;
+    rootVC.loginSuccessful = ^(NSString *user,NSString *password){
+        
+        RASingleton.sharedInstance.user = user;
+        RASingleton.sharedInstance.password = password;
+        [RASingleton.sharedInstance saveUserInfo];
+        
+        [weakSelf showHomeVC];
+    };
+    
+    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:rootVC];
+    self.window.rootViewController = nav;
+}
+
 - (void)saveUploadTasks {
     
     if(self.uploadManager.arr_queue!=nil)
@@ -71,6 +89,15 @@
     }
 }
 
+- (void)receiveLogoutNotification:(NSNotification *)notification {
+    [self showLoginVC];
+}
+
+- (void)registActionNotification {
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveLogoutNotification:) name:RANotificationLogout object:nil];
+}
+
 #pragma mark - AppDelegate
 
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
@@ -81,24 +108,15 @@
     self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
     self.window.backgroundColor = [UIColor whiteColor];
     
-    LoginViewController *rootVC = [LoginViewController viewControllerFromStoryboard];
-    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:rootVC];
-    self.window.rootViewController = nav;
-    
-    __weak typeof(self) weakSelf = self;
-    rootVC.loginSuccessful = ^(NSString *user,NSString *password){
-        
-        RASingleton.sharedInstance.user = user;
-        RASingleton.sharedInstance.password = password;
-        [RASingleton.sharedInstance saveUserInfo];
-        
-        [weakSelf showHomeVC];
-    };
+    [self showLoginVC];
     
     [self.window makeKeyAndVisible];
     
     [self startLocation];
     
+    //
+    [self registActionNotification];
+    
     //消息推送注册
     UNUserNotificationCenter * center = [UNUserNotificationCenter currentNotificationCenter];
     [center setDelegate:self];

+ 2 - 0
Redant Drivers/Apex And Drivers/Detail/Cell/RADetailActionsCell.m

@@ -41,10 +41,12 @@
     [super prepareForReuse];
     
     self.model = nil;
+    self.delegate = nil;
 }
 
 - (void)setModel:(RADetailActionCollectionModel *)model {
     _model = model;
+    self.actionLayout.delegate = model;
     [self.actionCollectionView reloadData];
 }
 

+ 1 - 1
Redant Drivers/Apex And Drivers/Detail/Model/RADetailActionCollectionModel.m

@@ -28,7 +28,7 @@
     if (self = [super init]) {
         
         _itemSpacing = 10.0f;
-        _itemHeight = 30.0f;
+        _itemHeight = 45.0f;
         _numberOfColumns = 2;
         
     }

+ 0 - 1
Redant Drivers/Apex And Drivers/Detail/RAOrderDetailViewController+TableViewDataSource.m

@@ -55,7 +55,6 @@
         case RAOrderDetailValueTypeAction: {
             RADetailActionCollectionModel *actionModel = (RADetailActionCollectionModel *)model;
             RADetailActionsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RADetailActionsCell" forIndexPath:indexPath];
-            cell.actionLayout.delegate = actionModel;
             [cell setModel:actionModel];
             cell.delegate = self;
             return cell;

+ 20 - 1
Redant Drivers/Apex And Drivers/Home/RAHomeViewController+HomeTableDelegate.m

@@ -12,6 +12,8 @@
 
 @implementation RAHomeViewController (HomeTableDelegate)
 
+#pragma mark - TableView Delegate
+
 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
     return 110.0f;
 }
@@ -20,10 +22,20 @@
     
     UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(tableView.bounds), 44.0f)];
     header.backgroundColor = [UIColor lightGrayColor];
-    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 11, CGRectGetWidth(tableView.bounds) - 20, 22)];
+    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 11, CGRectGetWidth(tableView.bounds) - 100, 22)];
     [header addSubview:label];
     
     label.text = [self titleForSection:section];
+
+    UIButton *expandBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    expandBtn.frame = CGRectMake(CGRectGetWidth(tableView.bounds) - 90, 11, 80, 22);
+    [expandBtn setTitle:@"Hide" forState:UIControlStateNormal];
+    [expandBtn setTitle:@"Show" forState:UIControlStateSelected];
+    expandBtn.tag = section;
+    [expandBtn addTarget:self action:@selector(sectionExpandSwithBtnClick:) forControlEvents:UIControlEventTouchUpInside];
+    [header addSubview:expandBtn];
+    
+    expandBtn.selected = ![self isExpandAtSection:section];
     
     return header;
 }
@@ -39,4 +51,11 @@
     [self pushDetailViewControllerForModel:order];
 }
 
+#pragma mark - Action
+
+- (void)sectionExpandSwithBtnClick:(UIButton *)sender {
+    sender.selected = !sender.isSelected;
+    [self setExpand:!sender.isSelected forSection:sender.tag];
+}
+
 @end

+ 3 - 0
Redant Drivers/Apex And Drivers/Home/RAHomeViewController.h

@@ -21,9 +21,12 @@
 - (NSUInteger)orderCountForSection:(NSInteger)section;
 - (RAHomeOrderModel *)orderModelForIndexPath:(NSIndexPath *)indexPath;
 - (NSString *)titleForSection:(NSInteger)section;
+- (BOOL)isExpandAtSection:(NSInteger)section;
 
 #pragma mark - Controller Action
 
 - (void)pushDetailViewControllerForModel:(RAHomeOrderModel *)model;
 
+- (void)setExpand:(BOOL)expand forSection:(NSInteger)section;
+
 @end

+ 45 - 5
Redant Drivers/Apex And Drivers/Home/RAHomeViewController.m

@@ -18,11 +18,20 @@
 @property (nonatomic,strong) NSArray <RAHomeOrderModel *> *orders;
 @property (nonatomic,copy) NSString *title;
 @property (nonatomic,readonly) NSInteger ordersCount;
+@property (nonatomic,assign) BOOL expand;
+@property (nonatomic,assign) NSInteger section;
 
 @end
 
 @implementation RAHomeSectionModel
 
+- (instancetype)init {
+    if (self = [super init]) {
+        self.expand = YES;
+    }
+    return self;
+}
+
 - (void)setOrders:(NSArray *)orders {
     
     NSMutableArray *orderArr = [NSMutableArray array];
@@ -40,6 +49,9 @@
 }
 
 - (NSInteger)ordersCount {
+    if (!self.expand) {
+        return 0;
+    }
     return self.orders.count;
 }
 
@@ -118,8 +130,17 @@
 }
 
 - (void)configureNavigationBar {
-    UIBarButtonItem *uploadListItem = [[UIBarButtonItem alloc] initWithTitle:@"Upload List" style:UIBarButtonItemStylePlain target:self action:@selector(uploadListItemClick:)];
-    self.navigationItem.rightBarButtonItem = uploadListItem;
+    UIBarButtonItem *uploadListItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"list"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
+                                                                       style:UIBarButtonItemStylePlain
+                                                                       target:self
+                                                                      action:@selector(uploadListItemClick:)];
+    
+    UIBarButtonItem *logoutItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"logout"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
+                                                                   style:UIBarButtonItemStylePlain
+                                                                  target:self
+                                                                  action:@selector(logoutItemClick:)];
+    
+    self.navigationItem.rightBarButtonItems = @[logoutItem,uploadListItem];
 }
 
 - (void)registNotification {
@@ -135,6 +156,10 @@
     [self.navigationController pushViewController:vc animated:YES];
 }
 
+- (void)logoutItemClick:(UIBarButtonItem *)sender {
+    [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationLogout object:nil];
+}
+
 - (void)refreshControlValueChanged:(UIRefreshControl *)refresh {
     [self loadData];
 }
@@ -168,6 +193,11 @@
     return sectionModel.title;
 }
 
+- (BOOL)isExpandAtSection:(NSInteger)section {
+    RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
+    return sectionModel.expand;
+}
+
 #pragma mark - Data
 
 - (void)loadData {
@@ -197,21 +227,24 @@
                     
                     NSArray *sectionArray = [json objectForKey:@"sections"];
                     [strongSelf.sectionArray removeAllObjects];
+                    strongSelf.currentIndexPath = nil;
+                    
                     for (int i = 0; i < sectionArray.count; i++) {
                         NSDictionary *section = [sectionArray objectAtIndex:i];
                         RAHomeSectionModel *sectionModel = [RAHomeSectionModel new];
+                        sectionModel.section = i;
                         [sectionModel setValuesForKeysWithDictionary:section];
                         [strongSelf.sectionArray addObject:sectionModel];
-                        if (self.currentOrderID.length > 0) {
+                        if (strongSelf.currentOrderID.length > 0) {
                             NSInteger idx = [sectionModel orderModelIndexForID:self.currentOrderID];
                             if (idx > -1) {
-                                self.currentIndexPath = [NSIndexPath indexPathForRow:idx inSection:i];
+                                strongSelf.currentIndexPath = [NSIndexPath indexPathForRow:idx inSection:i];
                             }
                         }
                     }
 
                     [strongSelf.homeOrderTableView reloadData];
-                    if (self.currentIndexPath) {
+                    if (strongSelf.currentIndexPath) {
 //                        [strongSelf.homeOrderTableView scrollToRowAtIndexPath:self.currentIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO];
                         [strongSelf.homeOrderTableView selectRowAtIndexPath:self.currentIndexPath animated:NO scrollPosition:UITableViewScrollPositionMiddle];
                     } else {
@@ -238,6 +271,13 @@
     [self.navigationController pushViewController:detailVC animated:YES];
 }
 
+- (void)setExpand:(BOOL)expand forSection:(NSInteger)section {
+    RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
+    sectionModel.expand = expand;
+    
+    [self.homeOrderTableView reloadSections:[NSIndexSet indexSetWithIndex:section] withRowAnimation:UITableViewRowAnimationNone];
+}
+
 #pragma mark - Nofitication Selector
 
 - (void)receiveNewOrderNotification:(NSNotification *)notification {

+ 1 - 0
Redant Drivers/Apex And Drivers/RANotificationNameCenter.h

@@ -11,3 +11,4 @@
 
 FOUNDATION_EXTERN NSString * const RANotificationNewOrder;
 FOUNDATION_EXTERN NSString * const RANotificationReloadHome;
+FOUNDATION_EXTERN NSString * const RANotificationLogout;

+ 1 - 1
Redant Drivers/Apex And Drivers/RANotificationNameCenter.m

@@ -11,4 +11,4 @@
 
 NSString * const RANotificationNewOrder     = @"RANotificationNewOrder";
 NSString * const RANotificationReloadHome   = @"RANotificationReloadHome";
-
+NSString * const RANotificationLogout       = @"RANotificationLogout";

BIN
Redant Drivers/list.png


BIN
Redant Drivers/logout.png