Przeglądaj źródła

1.修改iOS Apex Drivers上传图标根据上传状态改变。

Pen Li 7 lat temu
rodzic
commit
169594d502

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

@@ -35,6 +35,8 @@
 		421C417621719EB500835447 /* RALoginNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 421C417521719EB500835447 /* RALoginNavigationController.m */; };
 		421C417921719F8100835447 /* RALoginBackgroundView.m in Sources */ = {isa = PBXBuildFile; fileRef = 421C417821719F8100835447 /* RALoginBackgroundView.m */; };
 		421C43ED217EEF0600D80B82 /* RAReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 421C43EC217EEF0600D80B82 /* RAReachability.m */; };
+		42248A31218C35B4002CBCC9 /* RABadgeButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 42248A30218C35B4002CBCC9 /* RABadgeButton.m */; };
+		42248A33218C35D1002CBCC9 /* badge_button.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42248A32218C35D1002CBCC9 /* badge_button.xib */; };
 		422B06BC21743ABE003DA2DA /* NSData+RAImageType.m in Sources */ = {isa = PBXBuildFile; fileRef = 422B06BB21743ABE003DA2DA /* NSData+RAImageType.m */; };
 		422BD95F213CE2E600DF8E89 /* RABadgeNumberView.m in Sources */ = {isa = PBXBuildFile; fileRef = 422BD95E213CE2E600DF8E89 /* RABadgeNumberView.m */; };
 		422DA1C02134FA7D0021BD70 /* RAPresentationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 422DA1BF2134FA7D0021BD70 /* RAPresentationController.m */; };
@@ -264,6 +266,9 @@
 		421C417821719F8100835447 /* RALoginBackgroundView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RALoginBackgroundView.m; sourceTree = "<group>"; };
 		421C43EB217EEF0600D80B82 /* RAReachability.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RAReachability.h; path = ../../common/RAReachability.h; sourceTree = "<group>"; };
 		421C43EC217EEF0600D80B82 /* RAReachability.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = RAReachability.m; path = ../../common/RAReachability.m; sourceTree = "<group>"; };
+		42248A2F218C35B4002CBCC9 /* RABadgeButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RABadgeButton.h; sourceTree = "<group>"; };
+		42248A30218C35B4002CBCC9 /* RABadgeButton.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RABadgeButton.m; sourceTree = "<group>"; };
+		42248A32218C35D1002CBCC9 /* badge_button.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = badge_button.xib; sourceTree = "<group>"; };
 		422B06BA21743ABE003DA2DA /* NSData+RAImageType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSData+RAImageType.h"; sourceTree = "<group>"; };
 		422B06BB21743ABE003DA2DA /* NSData+RAImageType.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSData+RAImageType.m"; sourceTree = "<group>"; };
 		422BD95D213CE2E600DF8E89 /* RABadgeNumberView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RABadgeNumberView.h; sourceTree = "<group>"; };
@@ -722,6 +727,16 @@
 			path = Cell;
 			sourceTree = "<group>";
 		};
+		42248A2E218C3586002CBCC9 /* BadgeButton */ = {
+			isa = PBXGroup;
+			children = (
+				42248A2F218C35B4002CBCC9 /* RABadgeButton.h */,
+				42248A30218C35B4002CBCC9 /* RABadgeButton.m */,
+				42248A32218C35D1002CBCC9 /* badge_button.xib */,
+			);
+			path = BadgeButton;
+			sourceTree = "<group>";
+		};
 		422DA1BD2134FA510021BD70 /* PresentationController */ = {
 			isa = PBXGroup;
 			children = (
@@ -1382,6 +1397,7 @@
 		71EAA33020B9571B002F003C /* Apex And Drivers */ = {
 			isa = PBXGroup;
 			children = (
+				42248A2E218C3586002CBCC9 /* BadgeButton */,
 				42DCCC4821818CF90027A5BB /* DatePicker */,
 				42C6074921536E59003E5379 /* ExceptionHandler */,
 				42DFE267213F81F8000213C2 /* EmptyView */,
@@ -1524,6 +1540,7 @@
 				42F3A3342182A53E00AB0D3D /* setting.json in Resources */,
 				4235FAB8213E581E000B6672 /* Signature.xcassets in Resources */,
 				42F3A32C21829EAC00AB0D3D /* date.storyboard in Resources */,
+				42248A33218C35D1002CBCC9 /* badge_button.xib in Resources */,
 				71EAA33920B9571B002F003C /* Main.storyboard in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -1542,6 +1559,7 @@
 				4280034520C0F146004D4F50 /* NSString+Base64.m in Sources */,
 				424204F320C68E02005AEED9 /* RAProgressHUD.m in Sources */,
 				42D8B8BF20C24A92001C125F /* RADetailSingleLineModel.m in Sources */,
+				42248A31218C35B4002CBCC9 /* RABadgeButton.m in Sources */,
 				42D8B8D820C273AC001C125F /* RADetailActionsCell+CollectionViewDataSource.m in Sources */,
 				42C1B2742134F24C00637085 /* RADatePickerViewController.m in Sources */,
 				4243C8C2218829C40019A070 /* RAPhotoCell.m in Sources */,

+ 26 - 0
Redant Drivers/Apex And Drivers/AppDelegate.m

@@ -92,6 +92,14 @@
 //    self.locationManager = nil;
 }
 
+- (void)sendUploadCountNotification {
+    dispatch_async(dispatch_get_main_queue(), ^{
+        
+        NSUInteger count = self.uploadManager.arr_queue.count;
+        [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationChangeUpload object:nil userInfo:@{@"upload_count" : @(count)}];
+    });
+}
+
 - (void)receiveLogoutNotification:(NSNotification *)notification {
     [self showLoginVC];
 }
@@ -104,11 +112,29 @@
     [self stopLocation];
 }
 
+- (void)receiveUploadFinishNotification:(NSNotification *)notification {
+    
+    [self sendUploadCountNotification];
+}
+
+- (void)receiveUploadCountChangeNotification:(NSNotification *)notification {
+    
+    [self sendUploadCountNotification];
+}
+
+- (void)receiveRequestUploadCountNotification:(NSNotification *)notification {
+    
+    [self sendUploadCountNotification];
+}
+
 - (void)registActionNotification {
     
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveLogoutNotification:) name:RANotificationLogout object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveStartLocationNotification:) name:RANotificationStartLocation object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveStopLocationNotification:) name:RANotificationStopLocation object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveUploadFinishNotification:) name:UPLOAD_FINISH_NOTIFICATION object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveUploadFinishNotification:) name:UPLOAD_COUNT_CHANGE_NOTIFICATION object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveRequestUploadCountNotification:) name:RANotificationRequestUploadCount object:nil];
 }
 
 #pragma mark - AppDelegate

+ 25 - 0
Redant Drivers/Apex And Drivers/BadgeButton/RABadgeButton.h

@@ -0,0 +1,25 @@
+//
+//  RABadgeButton.h
+//  Apex And Drivers
+//
+//  Created by Jack on 2018/11/2.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface RABadgeButton : UIView
+
++ (instancetype)badgeButton;
+
+- (void)setImage:(UIImage *)image forState:(UIControlState)state;
+
+- (void)setNumber:(NSUInteger)number;
+
+- (void)setNumberColor:(UIColor *)color;
+
+- (void)setNumberBackgroundColor:(UIColor *)color;
+
+@end
+

+ 60 - 0
Redant Drivers/Apex And Drivers/BadgeButton/RABadgeButton.m

@@ -0,0 +1,60 @@
+//
+//  RABadgeButton.m
+//  Apex And Drivers
+//
+//  Created by Jack on 2018/11/2.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import "RABadgeButton.h"
+
+@interface RABadgeButton ()
+
+@property (nonatomic,strong) IBOutlet UILabel *numberLabel;
+@property (nonatomic,strong) IBOutlet UIButton *itemButton;
+
+@end
+
+@implementation RABadgeButton
+
++ (instancetype)badgeButton {
+    
+    RABadgeButton *btn = [[[NSBundle mainBundle] loadNibNamed:@"badge_button" owner:nil options:nil] objectAtIndex:0];
+    
+    return btn;
+}
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    
+    self.numberLabel.text = nil;
+    self.numberLabel.backgroundColor = UIColorFromRGB(0x299D4D);
+    self.numberLabel.layer.cornerRadius = 7.5f;
+    self.numberLabel.layer.masksToBounds = YES;
+}
+
+- (void)setImage:(UIImage *)image forState:(UIControlState)state {
+    [self.itemButton setImage:image forState:state];
+}
+
+- (void)setTintColor:(UIColor *)tintColor {
+    [self.itemButton setTintColor:tintColor];
+}
+
+- (void)setNumber:(NSUInteger)number {
+    self.numberLabel.text = [NSString stringWithFormat:@"%lu",(unsigned long)number];
+}
+
+- (void)setNumberColor:(UIColor *)color {
+    self.numberLabel.textColor = color;
+}
+
+- (void)setNumberBackgroundColor:(UIColor *)color {
+    self.numberLabel.backgroundColor = color;
+}
+
+- (IBAction)itemButtonClick:(id)sender {
+    
+}
+
+@end

+ 54 - 0
Redant Drivers/Apex And Drivers/BadgeButton/badge_button.xib

@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
+        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="Fia-ja-bkx" customClass="RABadgeButton">
+            <rect key="frame" x="0.0" y="0.0" width="40" height="40"/>
+            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+            <subviews>
+                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7ix-Zh-qWW">
+                    <rect key="frame" x="0.0" y="0.0" width="40" height="40"/>
+                    <connections>
+                        <action selector="itemButtonClick:" destination="Fia-ja-bkx" eventType="touchUpInside" id="iAk-sT-lsf"/>
+                    </connections>
+                </button>
+                <label opaque="NO" clearsContextBeforeDrawing="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="8" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="W69-8t-pXI">
+                    <rect key="frame" x="30" y="-5" width="15" height="15"/>
+                    <constraints>
+                        <constraint firstAttribute="height" constant="15" id="DqP-Q8-WsU"/>
+                        <constraint firstAttribute="width" constant="15" id="mds-rh-nUy"/>
+                    </constraints>
+                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                    <color key="textColor" red="0.098965144643472502" green="0.1902306239211119" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                    <nil key="highlightedColor"/>
+                </label>
+            </subviews>
+            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+            <constraints>
+                <constraint firstItem="W69-8t-pXI" firstAttribute="leading" secondItem="Fia-ja-bkx" secondAttribute="trailing" constant="-10" id="4QH-0u-ae4"/>
+                <constraint firstItem="7ix-Zh-qWW" firstAttribute="top" secondItem="dxr-7c-xmI" secondAttribute="top" id="7jJ-fH-13q"/>
+                <constraint firstItem="7ix-Zh-qWW" firstAttribute="trailing" secondItem="dxr-7c-xmI" secondAttribute="trailing" id="GR3-t8-lS8"/>
+                <constraint firstItem="7ix-Zh-qWW" firstAttribute="leading" secondItem="dxr-7c-xmI" secondAttribute="leading" id="NQS-Qk-Ty2"/>
+                <constraint firstItem="W69-8t-pXI" firstAttribute="bottom" secondItem="Fia-ja-bkx" secondAttribute="top" constant="10" id="QSV-sN-eUQ"/>
+                <constraint firstItem="dxr-7c-xmI" firstAttribute="bottom" secondItem="7ix-Zh-qWW" secondAttribute="bottom" id="hKm-SR-gcy"/>
+            </constraints>
+            <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
+            <viewLayoutGuide key="safeArea" id="dxr-7c-xmI"/>
+            <connections>
+                <outlet property="itemButton" destination="7ix-Zh-qWW" id="hp5-Ry-nfy"/>
+                <outlet property="numberLabel" destination="W69-8t-pXI" id="mne-LE-MHW"/>
+            </connections>
+            <point key="canvasLocation" x="-49.600000000000001" y="-22.488755622188908"/>
+        </view>
+    </objects>
+</document>

+ 24 - 7
Redant Drivers/Apex And Drivers/Home/RAHomeViewController.m

@@ -18,6 +18,7 @@
 #import "RAMessageViewController.h"
 #import "RASettingViewController.h"
 #import <CoreLocation/CoreLocation.h>
+#import "RABadgeButton.h"
 
 @implementation RAHomeSectionModel
 
@@ -182,14 +183,10 @@
                                                                        style:UIBarButtonItemStylePlain
                                                                        target:self
                                                                       action:@selector(uploadListItemClick:)];
-
+    
     self.navigationItem.rightBarButtonItems = @[uploadListItem];
-//    UIBarButtonItem *logoutItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"logout"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
-//                                                                   style:UIBarButtonItemStylePlain
-//                                                                  target:self
-//                                                                  action:@selector(logoutItemClick:)];
-//
-//    self.navigationItem.rightBarButtonItems = @[logoutItem,uploadListItem];
+
+    [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationRequestUploadCount object:nil];
     
     self.title = [NSString stringWithFormat:@"%@ %@",RASingleton.sharedInstance.user,RASingleton.sharedInstance.firstName];
 }
@@ -199,6 +196,7 @@
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveNewOrderNotification:) name:RANotificationHandleOrder object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveReloadNotification:) name:RANotificationReloadHome object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveCheckDetailNofitication:) name:RANotificationCheckDetail object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveUploadFinishNotification:) name:RANotificationChangeUpload object:nil];
 }
 
 - (void)checkPermission {
@@ -272,6 +270,18 @@
     }
 }
 
+- (void)_updateUploadItem:(UIBarButtonItem *)item withUploadCount:(NSUInteger)count {
+    
+    if (item) {
+        
+        if (count > 0) {
+            item.tintColor = UIColorFromRGB(0x299D4D);
+        } else {
+            item.tintColor = ApexDriverWhiteColor;
+        }
+    }
+}
+
 #pragma mark - Action
 
 - (void)uploadListItemClick:(UIBarButtonItem *)sender {
@@ -577,6 +587,13 @@
     
 }
 
+- (void)receiveUploadFinishNotification:(NSNotification *)notification {
+    
+    NSUInteger count = [notification.userInfo[@"upload_count"] integerValue];
+    UIBarButtonItem *item = self.navigationItem.rightBarButtonItem;
+    [self _updateUploadItem:item withUploadCount:count];
+}
+
 #pragma mark - Header Delegate
 
 - (void)signoutClick:(UIButton *)sender {

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

@@ -15,3 +15,5 @@ FOUNDATION_EXTERN NSString * const RANotificationLogout;
 FOUNDATION_EXTERN NSString * const RANotificationStopLocation;
 FOUNDATION_EXTERN NSString * const RANotificationStartLocation;
 FOUNDATION_EXTERN NSString * const RANotificationCheckDetail;
+FOUNDATION_EXTERN NSString * const RANotificationChangeUpload;
+FOUNDATION_EXTERN NSString * const RANotificationRequestUploadCount;

+ 2 - 0
Redant Drivers/Apex And Drivers/RANotificationNameCenter.m

@@ -15,3 +15,5 @@ NSString * const RANotificationLogout           = @"RANotificationLogout";
 NSString * const RANotificationStartLocation    = @"RANotificationStartLocation";
 NSString * const RANotificationStopLocation     = @"RANotificationStopLocation";
 NSString * const RANotificationCheckDetail      = @"RANotificationCheckDetail";
+NSString * const RANotificationChangeUpload      = @"RANotificationChangeUpload";
+NSString * const RANotificationRequestUploadCount      = @"RANotificationRequestUploadCount";

+ 2 - 2
Redant Drivers/Apex And Drivers/config.h

@@ -17,8 +17,8 @@
 #define ApexDriverWhiteColor UIColorFromRGB(0xffffff)
 #define ApexDriverRedColor UIColorFromRGB(0xAE2838)
 
-//#define URL_HOST                @"http://192.168.0.124:8080/t"
-#define URL_HOST                @"https://ra.apexshipping.com/t"
+#define URL_HOST                @"http://192.168.0.124:8080/t"
+//#define URL_HOST                @"https://ra.apexshipping.com/t"
 
 
 #define APPENDING_STR(var)      [URL_HOST stringByAppendingString:var]