Эх сурвалжийг харах

1.修改iOS Apex Mobile Tools,增加清除登陆信息。

Pen Li 8 жил өмнө
parent
commit
25850dee7d

+ 2 - 0
Apex Mobile/Apex Mobile/Apex Mobile-Prefix.pch

@@ -15,7 +15,9 @@
     #import <Foundation/Foundation.h>
 #endif
 
+
 #define APREDCOLOR [UIColor colorWithRed:168 / 255.0 green:9 / 255.0 blue:26 / 255.0 alpha:1.0]
 #define APGRAYCOLOR [UIColor colorWithRed:53 / 255.0 green:53 / 255.0 blue:55 / 255.0 alpha:1.0]
 #define APGRAYCOLOR_HALF_ALPHA [UIColor colorWithRed:53 / 255.0 green:53 / 255.0 blue:55 / 255.0 alpha:0.4]
 
+#define NotificationTypeLogout @"NotificationTypeLogout"

+ 1 - 1
Apex Mobile/Apex Mobile/AppDelegate.h

@@ -18,7 +18,7 @@ UIKIT_EXTERN NSString * const APLogoutNotification;
 @property (strong,nonatomic) NSString * password;
 //@property (strong,nonatomic) NSString * sessionid;
 @property (strong,nonatomic) NSString * duid;
-
+@property (nonatomic,assign) BOOL isLogin;
 
 @property (nonatomic,assign) long authVer;
 @property (strong,nonatomic) NSString* build;

+ 1 - 0
Apex Mobile/Apex Mobile/AppDelegate.m

@@ -199,6 +199,7 @@ void UncaughtExceptionHandler(NSException *exception) {
 }
 -(void)Logout
 {
+    self.isLogin = NO;
     self.user = nil;
     self.password=nil;
 //    self.sessionid=nil;

+ 3 - 0
Apex Mobile/Apex Mobile/LoginViewController.h

@@ -23,5 +23,8 @@
 @property (strong, nonatomic) IBOutlet UIButton *btnRetrievePassword;
 @property bool resize;
 @property int ioffset;
+
+- (void)clear;
+
 @end
 

+ 5 - 0
Apex Mobile/Apex Mobile/LoginViewController.m

@@ -16,6 +16,11 @@
 
 @implementation LoginViewController
 
+- (void)clear {
+    self.editPassword.text = nil;
+    self.editUser.text = nil;
+}
+
 - (IBAction)RetrieveButtonClick:(UIButton *)sender {
 //    [self performSegueWithIdentifier:@"RETRIEVE" sender:self];
     

+ 23 - 0
Apex Mobile/Apex Mobile/NewImages.xcassets/mode_clear_login.imageset/Contents.json

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

BIN
Apex Mobile/Apex Mobile/NewImages.xcassets/mode_clear_login.imageset/mode_clear_login.png


BIN
Apex Mobile/Apex Mobile/NewImages.xcassets/mode_clear_login.imageset/mode_clear_login@2x.png


BIN
Apex Mobile/Apex Mobile/NewImages.xcassets/mode_clear_login.imageset/mode_clear_login@3x.png


+ 27 - 0
Apex Mobile/Apex Mobile/RootViewController.m

@@ -24,6 +24,7 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
     
+    [self registForNotification];
     
     self.automaticallyAdjustsScrollViewInsets = NO;
 //    self.navigationItem.navi
@@ -35,10 +36,12 @@
     backItem.title = @"Back";
     self.navigationItem.backBarButtonItem = backItem;
     
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
     
     LoginViewController * loginVC = [ [UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginPanel"];
     loginVC.loginSuccessful = ^(void)
     {
+        appDelegate.isLogin = YES;
       // 登陆成功后重新刷新tabbar
         self.viewControllers = self.loginbar;
     };
@@ -57,6 +60,7 @@
     
     myVC.logoutSuccessful = ^(void)
     {
+        appDelegate.isLogin = NO;
         // 登陆成功后重新刷新tabbar
         self.viewControllers = self.logoutbar;
     };
@@ -93,4 +97,27 @@
 }
 */
 
+- (void)dealloc {
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
+- (void)registForNotification {
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:NotificationTypeLogout object:nil];
+    
+}
+
+- (void)handleNotification:(NSNotification *)notification {
+    
+    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+    if ([notification.name isEqualToString:NotificationTypeLogout]) {
+        
+        [appDelegate Logout];
+        [(LoginViewController *)self.logoutbar.firstObject clear];
+        self.viewControllers = self.logoutbar;
+        self.selectedIndex = 0;
+        
+    }
+}
+
 @end

+ 27 - 1
Apex Mobile/Apex Mobile/ToolslistViewController.m

@@ -136,7 +136,33 @@
         //        newsview.module_name = @"Market news";
         [self.navigationController pushViewController:viewcontroller animated:YES];
     }
-    
+    else if([type isEqualToString:@"clear_login"])
+    {
+        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+        NSString *msg = @"It will clear your account and password,are your sure?";
+        if (appDelegate.isLogin) {
+            msg = @"It will clear your account and password then logout,are your sure?";
+        }
+        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:msg preferredStyle:UIAlertControllerStyleAlert];
+        
+        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+            
+        }];
+        
+        UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            
+            NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+            [defaults removeObjectForKey:@"user"];
+            [defaults removeObjectForKey:@"password"];
+            [[NSNotificationCenter defaultCenter] postNotificationName:NotificationTypeLogout object:nil];
+            
+        }];
+        
+        [alertVC addAction:cancelAction];
+        [alertVC addAction:sureAction];
+        
+        [self presentViewController:alertVC animated:YES completion:nil];
+    }
     else if([type isEqualToString:@"about"])
     {
         AboutViewController *viewcontroller=[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"About"];

+ 4 - 4
Apex Mobile/Apex Mobile/tools.json

@@ -26,10 +26,10 @@
                  "type": "service_location"
                  },
                  {
-                 "name": "Clear Password",
-                 "detail": "Clear password",
-                 "icon": "mode_about",
-                 "type": "about"
+                 "name": "Clear Login Info",
+                 "detail": "Clear your account and password",
+                 "icon": "mode_clear_login",
+                 "type": "clear_login"
                  },
                  {
                  "name": "About",