Browse Source

- 장치 삭제 작업 완료
- 장치 추가시 장치 초기화 로직 추가

KaRam Kim 8 years ago
parent
commit
b37ba8ca0d

+ 1 - 1
OneCable/Classes/ViewControllers/ThingsScreens/ThingsAddFailViewController.h

@@ -12,7 +12,7 @@
 
 
 #pragma mark - Properties
-@property (weak, nonatomic) DeviceModel *addDevice;
+@property (copy, nonatomic) DeviceModel *addDevice;
 
 @property (weak, nonatomic) IBOutlet UIView *maskView;
 @property (weak, nonatomic) IBOutlet UIView *popView;

+ 1 - 13
OneCable/Classes/ViewControllers/ThingsScreens/ThingsAddFailViewController.m

@@ -70,19 +70,7 @@
     vc.addDevice = _addDevice;
     
     [self showTransparencyModalView:vc];
-//    
-//    vc.providesPresentationContextTransitionStyle = YES;
-//    vc.definesPresentationContext = YES;
-//    
-//    [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
-//    
-////    [self presentViewController:vc animated:YES completion:^{
-////        _maskView.alpha = 0.0f;
-////    }];
-//    UIViewController *pvc = self.presentingViewController;
-//    [self dismissViewControllerAnimated:NO completion:^{//TODO : UI Confirm with Mr.Mo
-//        [pvc presentViewController:vc animated:YES completion:nil];
-//    }];
+
 }
 
 - (IBAction)btnCancelTouched:(id)sender {

+ 1 - 1
OneCable/Classes/ViewControllers/ThingsScreens/ThingsAddIncludeViewController.h

@@ -17,7 +17,7 @@
 
 
 #pragma mark - Properties
-@property (weak, nonatomic) DeviceModel *addDevice;
+@property (copy, nonatomic) DeviceModel *addDevice;
 
 @property (weak, nonatomic) NSDictionary *addableDevice;
 @property (weak, nonatomic) DeviceModel *removableDevice;

+ 30 - 26
OneCable/Classes/ViewControllers/ThingsScreens/ThingsAddIncludeViewController.m

@@ -83,6 +83,7 @@
     _lblTitle.text = [NSString stringWithFormat:@"%@ 추가", _addDevice.prdName];
     _imgThings.image = [_addDevice imgaeForAddDel];
     _lblDesc.text = [_addDevice manufacturerName];
+    [self requestIncludeDevice:YES];
 }
 
 #pragma mark - Main Logic
@@ -165,15 +166,16 @@
     
     vc.addDevice = _addDevice;
     
-    vc.providesPresentationContextTransitionStyle = YES;
-    vc.definesPresentationContext = YES;
-    
-    [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
-    
-    UIViewController *pvc = self.presentingViewController;
-    [self dismissViewControllerAnimated:NO completion:^{//TODO : UI Confirm with Mr.Mo
-        [pvc presentViewController:vc animated:YES completion:nil];
-    }];
+//    vc.providesPresentationContextTransitionStyle = YES;
+//    vc.definesPresentationContext = YES;
+//    
+//    [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
+//    
+//    UIViewController *pvc = self.presentingViewController;
+//    [self dismissViewControllerAnimated:NO completion:^{//TODO : UI Confirm with Mr.Mo
+//        [pvc presentViewController:vc animated:YES completion:nil];
+//    }];
+    [self showTransparencyModalView:vc];
 }
 
 
@@ -185,15 +187,16 @@
     
     vc.addDevice = _addDevice;
     
-    vc.providesPresentationContextTransitionStyle = YES;
-    vc.definesPresentationContext = YES;
-    
-    [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
-    
-    UIViewController *pvc = self.presentingViewController;
-    [self dismissViewControllerAnimated:NO completion:^{//TODO : UI Confirm with Mr.Mo
-        [pvc presentViewController:vc animated:YES completion:nil];
-    }];
+//    vc.providesPresentationContextTransitionStyle = YES;
+//    vc.definesPresentationContext = YES;
+//    
+//    [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
+//    
+//    UIViewController *pvc = self.presentingViewController;
+//    [self dismissViewControllerAnimated:NO completion:^{//TODO : UI Confirm with Mr.Mo
+//        [pvc presentViewController:vc animated:YES completion:nil];
+//    }];
+    [self showTransparencyModalView:vc];
 }
 
 
@@ -269,14 +272,15 @@
                 ThingsAddCompleteViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddCompleteViewController" storyboardName:@"Things"];
                 vc.isDeleteMode = NO;
                 
-                vc.providesPresentationContextTransitionStyle = YES;
-                vc.definesPresentationContext = YES;
-                
-                [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
-                
-                [self presentViewController:vc animated:YES completion:^{
-                    _maskView.alpha = 0.0f;
-                }];
+//                vc.providesPresentationContextTransitionStyle = YES;
+//                vc.definesPresentationContext = YES;
+//                
+//                [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
+//                
+//                [self presentViewController:vc animated:YES completion:^{
+//                    _maskView.alpha = 0.0f;
+//                }];
+                [self showTransparencyModalView:vc];
             }
             if ([response.commandType isEquestToIgnoreCase:CMD_TYPE_UNPAIRING_START]) {
                 if ([response.commandId isEqualToString:_startCommand.commandId]) {

+ 1 - 1
OneCable/Classes/ViewControllers/ThingsScreens/ThingsAddInitCompleteViewController.h

@@ -15,7 +15,7 @@
 @interface ThingsAddInitCompleteViewController : JDViewController
 
 
-@property (weak, nonatomic) DeviceModel *addDevice;
+@property (copy, nonatomic) DeviceModel *addDevice;
 
 @property (weak, nonatomic) IBOutlet UIView *maskView;
 @property (weak, nonatomic) IBOutlet UIView *popUpView;

+ 9 - 1
OneCable/Classes/ViewControllers/ThingsScreens/ThingsAddInitCompleteViewController.m

@@ -11,6 +11,8 @@
 #import "CustomImageView.h"
 #import "CustomLabel.h"
 
+#import "ThingsAddIncludeViewController.h"
+
 @interface ThingsAddInitCompleteViewController ()
 
 @end
@@ -28,10 +30,16 @@
 }
 
 - (IBAction)btnCancelTouched:(id)sender {
-    
+    [[JDFacade facade] dismissModalStack:YES completion:^{
+        [[JDFacade facade] gotoWishMenu:KNMenuIdThings];
+    }];
 }
 - (IBAction)btnNextTouched:(id)sender {
+    ThingsAddIncludeViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddIncludeViewController" storyboardName:@"Things"];
+    vc.addDevice = _addDevice;
+    
     
+    [self showTransparencyModalView:vc];
 }
 
 @end

+ 1 - 1
OneCable/Classes/ViewControllers/ThingsScreens/ThingsAddInitFailViewController.h

@@ -14,7 +14,7 @@
 
 @interface ThingsAddInitFailViewController : JDViewController
 
-@property (weak, nonatomic) DeviceModel *addDevice;
+@property (copy, nonatomic) DeviceModel *addDevice;
 
 @property (weak, nonatomic) IBOutlet UIView *maskView;
 @property (weak, nonatomic) IBOutlet UIView *popUpView;

+ 7 - 1
OneCable/Classes/ViewControllers/ThingsScreens/ThingsAddInitFailViewController.m

@@ -8,9 +8,11 @@
 
 #import "ThingsAddInitFailViewController.h"
 #import "CustomLabel.h"
-#import "CustomImageVIew.h"
+#import "CustomImageView.h"
 #import "CustomButton.h"
 
+#import "ThingsAddStartViewController.h"
+
 @interface ThingsAddInitFailViewController ()
 
 @end
@@ -33,6 +35,10 @@
 }
 
 - (IBAction)btnRetryTouched:(id)sender {
+    ThingsAddStartViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddStartViewController" storyboardName:@"Things"];
+    vc.addDevice = _addDevice;
+
     
+    [self showTransparencyModalView:vc];
 }
 @end

+ 1 - 1
OneCable/Classes/ViewControllers/ThingsScreens/ThingsAddInitViewController.h

@@ -14,7 +14,7 @@
 
 @interface ThingsAddInitViewController : JDViewController
 
-@property (weak, nonatomic) DeviceModel *addDevice;
+@property (copy, nonatomic) DeviceModel *addDevice;
 
 @property (weak, nonatomic) IBOutlet UIView *maskView;
 @property (weak, nonatomic) IBOutlet UIView *popUpView;

+ 40 - 13
OneCable/Classes/ViewControllers/ThingsScreens/ThingsAddInitViewController.m

@@ -11,7 +11,14 @@
 #import "CustomLabel.h"
 #import "CustomImageView.h"
 
+#import "ThingsAddStartViewController.h"
+#import "ThingsAddInitCompleteViewController.h"
+#import "ThingsAddInitFailViewController.h"
+
+
+
 @interface ThingsAddInitViewController (){
+    
     NSTimer *_timer;
     NSInteger _elapsedSeconds;
     
@@ -46,7 +53,7 @@
         _maskView.alpha = 0.7;
     } completion:^(BOOL finished) {
         
-        //        _constraintPopViewTop.constant = (IPHONE_HEIGHT - _popView.height) / 2;
+//                _constraintPopViewTop.constant = (IPHONE_HEIGHT - _popView.height) / 2;
         
         [UIView animateWithDuration:kfAnimationDur animations:^{
             [self.view layoutIfNeeded];
@@ -61,9 +68,12 @@
 }
 
 - (void)prepareViewDidLoad {
-    //    [self startLoading:NO];
+   
     _imgThings.image = [_addDevice imgaeForAddDel];
     _lblTitle.text = [NSString stringWithFormat:@"%@ 초기화", _addDevice.prdName];
+    _lblComment.text = [_addDevice description];
+    
+    [self requestExcludeDevice:YES];
 }
 
 #pragma mark - Main Logic
@@ -80,11 +90,12 @@
 
 
 -(void)startLoading:(BOOL)isStart {
+    _lblElapsedTime.hidden = !isStart;
     _imgLoading.hidden = !isStart;
     if (isStart) {
         _elapsedSeconds = kMaxTimeOut;
         NSLog(@"ElapsedSecond : %zd", _elapsedSeconds);
-        
+        _lblElapsedTime.text = [NSString stringWithFormat:@"%zd", _elapsedSeconds];
         if (!_timer) {
             _timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(updateInclusionStatus) userInfo:nil repeats:YES];
         }
@@ -115,14 +126,14 @@
 
 - (void)updateInclusionStatus {
     
-    //    dispatch_async(dispatch_get_main_queue(), ^(void) {
-    //
-    //        _elapsedSeconds--;
-    //
-    //        if (_elapsedSeconds == 0) {
-    //            [self finishDeviceDel:NO];
-    //        }
-    //    });
+    dispatch_async(dispatch_get_main_queue(), ^(void) {
+        _lblElapsedTime.text = [NSString stringWithFormat:@"%zd", _elapsedSeconds];
+        _elapsedSeconds--;
+        
+        if (_elapsedSeconds == 0) {
+            [self finishDeviceDel:NO];
+        }
+    });
 }
 
 - (void)finishDeviceDel:(BOOL)isSuccess {
@@ -134,10 +145,26 @@
 //    //    vc.addableDevice = _addableDevice;
 //    
 //    [self showTransparencyModalView:vc];
+    
+    if (isSuccess) {
+        ThingsAddInitCompleteViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddInitCompleteViewController" storyboardName:@"Things"];
+        vc.addDevice = _addDevice;
+        [self showTransparencyModalView:vc];
+    } else {
+        ThingsAddInitFailViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddInitFailViewController" storyboardName:@"Things"];
+        vc.addDevice = _addDevice;
+        [self showTransparencyModalView:vc];
+    }
 }
 
 
 - (IBAction)btnCancelTouched:(id)sender {
+    
+    ThingsAddStartViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddStartViewController" storyboardName:@"Things"];
+    vc.addDevice = _addDevice;
+    
+    
+    [self showTransparencyModalView:vc];
 }
 
 #pragma mark - SocketService
@@ -186,7 +213,7 @@
                 }
             }
             else if ([response.commandType isEquestToIgnoreCase:CMD_TYPE_UNPAIRING_STOP]) {
-                [self startLoading:NO];
+//                [self startLoading:NO];
                 
                 [self finishDeviceDel:YES];
             }
@@ -196,7 +223,7 @@
         }
     }
     else if ([result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_DELETE_RES]) {
-        [self finishDeviceDel:YES];
+        [self requestExcludeDevice:NO];
     }
 }
 

+ 1 - 1
OneCable/Classes/ViewControllers/ThingsScreens/ThingsAddStartViewController.h

@@ -17,7 +17,7 @@
 
 
 #pragma mark - Properties
-@property (weak, nonatomic) DeviceModel   *addDevice;
+@property (copy, nonatomic) DeviceModel   *addDevice;
 
 @property (weak, nonatomic) NSDictionary *addableDevice;
 @property (weak, nonatomic) DeviceModel *removableDevice;

+ 5 - 6
OneCable/Classes/ViewControllers/ThingsScreens/ThingsAddStartViewController.m

@@ -117,12 +117,11 @@
         return;
     }
     
-    ThingsAddIncludeViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddIncludeViewController" storyboardName:@"Things"];
-    vc.addableDevice = _addableDevice;
-    vc.removableDevice = _removableDevice;
-    
-    vc.providesPresentationContextTransitionStyle = YES;
-    vc.definesPresentationContext = YES;
+    ThingsAddInitViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddInitViewController" storyboardName:@"Things"];
+//    vc.addableDevice = _addableDevice;
+//    vc.removableDevice = _removableDevice;
+    vc.addDevice = _addDevice;
+
     
     [self showTransparencyModalView:vc];
 }

+ 1 - 0
OneCable/Prefix.pch

@@ -17,6 +17,7 @@
     #import <Foundation/Foundation.h>
     #import "CocoaLumberjack.h"
     #import "Common.h"
+    #import "Definitions.h"
     #import "SocketServiceHandler.h"
 #endif