Procházet zdrojové kódy

170623 임시비번 변경 로직 추가, 규칙 ui 수정

eunmi.kim před 8 roky
rodič
revize
508926559f
24 změnil soubory, kde provedl 2372 přidání a 332 odebrání
  1. 6 0
      OneCable.xcodeproj/project.pbxproj
  2. 50 0
      OneCable/Assets.xcassets/images/img_input_round_bg_active_slicing.imageset/Contents.json
  3. binární
      OneCable/Assets.xcassets/images/img_input_round_bg_active_slicing.imageset/img_input_round_bg_active@2x.png
  4. binární
      OneCable/Assets.xcassets/images/img_input_round_bg_active_slicing.imageset/img_input_round_bg_active@3x.png
  5. 50 0
      OneCable/Assets.xcassets/images/img_input_round_bg_default_slicing.imageset/Contents.json
  6. binární
      OneCable/Assets.xcassets/images/img_input_round_bg_default_slicing.imageset/img_input_round_bg_default@2x.png
  7. binární
      OneCable/Assets.xcassets/images/img_input_round_bg_default_slicing.imageset/img_input_round_bg_default@3x.png
  8. 50 0
      OneCable/Assets.xcassets/images/img_input_round_bg_disable_slicing.imageset/Contents.json
  9. binární
      OneCable/Assets.xcassets/images/img_input_round_bg_disable_slicing.imageset/img_input_round_bg_disable@2x.png
  10. binární
      OneCable/Assets.xcassets/images/img_input_round_bg_disable_slicing.imageset/img_input_round_bg_disable@3x.png
  11. 1 0
      OneCable/Base.lproj/Main.storyboard
  12. 1662 222
      OneCable/Base.lproj/Rules.storyboard
  13. 12 7
      OneCable/Base.lproj/SignUp.storyboard
  14. 29 0
      OneCable/Classes/Categories/Responder+Keyboard.h
  15. 162 0
      OneCable/Classes/Categories/Responder+Keyboard.m
  16. 1 0
      OneCable/Classes/CustomUI/CustomTextView.h
  17. 3 2
      OneCable/Classes/CustomUI/CustomTextView.m
  18. 1 0
      OneCable/Classes/JDFacade.h
  19. 1 0
      OneCable/Classes/JDFacade.m
  20. 2 1
      OneCable/Classes/ViewControllers/MainScreens/HomeModeSettingsViewController.h
  21. 11 3
      OneCable/Classes/ViewControllers/MainScreens/LoginViewController.m
  22. 12 0
      OneCable/Classes/ViewControllers/RuelsScreens/RulesAddViewController.h
  23. 250 88
      OneCable/Classes/ViewControllers/RuelsScreens/RulesAddViewController.m
  24. 69 9
      OneCable/Classes/ViewControllers/SignUpScreens/TempPwViewController.m

+ 6 - 0
OneCable.xcodeproj/project.pbxproj

@@ -193,6 +193,7 @@
 		E216555E1EB0681500090EB6 /* ChangePhotoPopupView.m in Sources */ = {isa = PBXBuildFile; fileRef = E216555C1EB0681500090EB6 /* ChangePhotoPopupView.m */; };
 		E21655611EB0693E00090EB6 /* ChangePhotoPopupView.xib in Resources */ = {isa = PBXBuildFile; fileRef = E21655601EB0693E00090EB6 /* ChangePhotoPopupView.xib */; };
 		E2295F0B1E83857A008C5915 /* ThingsGeneralDelStartViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E2295F0A1E83857A008C5915 /* ThingsGeneralDelStartViewController.m */; };
+		E232B20F1EFBC166008B1D32 /* Responder+Keyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = E232B20E1EFBC166008B1D32 /* Responder+Keyboard.m */; };
 		E243CB4E1EF8C7B1001E8777 /* UIView+FindUIViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E243CB4D1EF8C7B1001E8777 /* UIView+FindUIViewController.m */; };
 		E251A87B1E933966004A70CF /* FaqViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E251A87A1E933966004A70CF /* FaqViewController.m */; };
 		E292EB101ECD839900D9542C /* ConditionSelectPopupView.m in Sources */ = {isa = PBXBuildFile; fileRef = E292EB0E1ECD839900D9542C /* ConditionSelectPopupView.m */; };
@@ -587,6 +588,8 @@
 		E21655601EB0693E00090EB6 /* ChangePhotoPopupView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ChangePhotoPopupView.xib; sourceTree = "<group>"; };
 		E2295F091E83857A008C5915 /* ThingsGeneralDelStartViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThingsGeneralDelStartViewController.h; sourceTree = "<group>"; };
 		E2295F0A1E83857A008C5915 /* ThingsGeneralDelStartViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ThingsGeneralDelStartViewController.m; sourceTree = "<group>"; };
+		E232B20D1EFBC166008B1D32 /* Responder+Keyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Responder+Keyboard.h"; sourceTree = "<group>"; };
+		E232B20E1EFBC166008B1D32 /* Responder+Keyboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Responder+Keyboard.m"; sourceTree = "<group>"; };
 		E243CB4C1EF8C7B1001E8777 /* UIView+FindUIViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+FindUIViewController.h"; sourceTree = "<group>"; };
 		E243CB4D1EF8C7B1001E8777 /* UIView+FindUIViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+FindUIViewController.m"; sourceTree = "<group>"; };
 		E251A8791E933966004A70CF /* FaqViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FaqViewController.h; sourceTree = "<group>"; };
@@ -789,6 +792,8 @@
 		A13BCEB01C3B491300C76527 /* Categories */ = {
 			isa = PBXGroup;
 			children = (
+				E232B20D1EFBC166008B1D32 /* Responder+Keyboard.h */,
+				E232B20E1EFBC166008B1D32 /* Responder+Keyboard.m */,
 				E243CB4C1EF8C7B1001E8777 /* UIView+FindUIViewController.h */,
 				E243CB4D1EF8C7B1001E8777 /* UIView+FindUIViewController.m */,
 				A5EFE0D61ED276C200B0DA05 /* CBUUID+String.h */,
@@ -1602,6 +1607,7 @@
 				A13BCFE21C3B491400C76527 /* UIDevice-Reachability.m in Sources */,
 				A13BD01E1C3B491400C76527 /* SceneModel.m in Sources */,
 				E2E34E1B1E827B4D00BB8C96 /* ThingsForcedDelCompleteViewController.m in Sources */,
+				E232B20F1EFBC166008B1D32 /* Responder+Keyboard.m in Sources */,
 				E2E08CF91E8DDA5E0034D6F7 /* TempPwViewController.m in Sources */,
 				A191B48E1C4639F900DEBA91 /* AdminAuthPopupView.m in Sources */,
 				A13BCFFB1C3B491400C76527 /* OptionPopOverViewController.m in Sources */,

+ 50 - 0
OneCable/Assets.xcassets/images/img_input_round_bg_active_slicing.imageset/Contents.json

@@ -0,0 +1,50 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "resizing" : {
+        "mode" : "9-part",
+        "center" : {
+          "mode" : "tile",
+          "width" : 1,
+          "height" : 1
+        },
+        "cap-insets" : {
+          "bottom" : 33,
+          "top" : 36,
+          "right" : 45,
+          "left" : 51
+        }
+      },
+      "idiom" : "universal",
+      "filename" : "img_input_round_bg_active@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "resizing" : {
+        "mode" : "9-part",
+        "center" : {
+          "mode" : "tile",
+          "width" : 1,
+          "height" : 1
+        },
+        "cap-insets" : {
+          "bottom" : 53,
+          "top" : 51,
+          "right" : 49,
+          "left" : 50
+        }
+      },
+      "idiom" : "universal",
+      "filename" : "img_input_round_bg_active@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

binární
OneCable/Assets.xcassets/images/img_input_round_bg_active_slicing.imageset/img_input_round_bg_active@2x.png


binární
OneCable/Assets.xcassets/images/img_input_round_bg_active_slicing.imageset/img_input_round_bg_active@3x.png


+ 50 - 0
OneCable/Assets.xcassets/images/img_input_round_bg_default_slicing.imageset/Contents.json

@@ -0,0 +1,50 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "resizing" : {
+        "mode" : "9-part",
+        "center" : {
+          "mode" : "tile",
+          "width" : 1,
+          "height" : 1
+        },
+        "cap-insets" : {
+          "bottom" : 31,
+          "top" : 38,
+          "right" : 47,
+          "left" : 50
+        }
+      },
+      "idiom" : "universal",
+      "filename" : "img_input_round_bg_default@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "resizing" : {
+        "mode" : "9-part",
+        "center" : {
+          "mode" : "tile",
+          "width" : 1,
+          "height" : 1
+        },
+        "cap-insets" : {
+          "bottom" : 43,
+          "top" : 61,
+          "right" : 53,
+          "left" : 46
+        }
+      },
+      "idiom" : "universal",
+      "filename" : "img_input_round_bg_default@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

binární
OneCable/Assets.xcassets/images/img_input_round_bg_default_slicing.imageset/img_input_round_bg_default@2x.png


binární
OneCable/Assets.xcassets/images/img_input_round_bg_default_slicing.imageset/img_input_round_bg_default@3x.png


+ 50 - 0
OneCable/Assets.xcassets/images/img_input_round_bg_disable_slicing.imageset/Contents.json

@@ -0,0 +1,50 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "resizing" : {
+        "mode" : "9-part",
+        "center" : {
+          "mode" : "tile",
+          "width" : 1,
+          "height" : 1
+        },
+        "cap-insets" : {
+          "bottom" : 31,
+          "top" : 38,
+          "right" : 46,
+          "left" : 53
+        }
+      },
+      "idiom" : "universal",
+      "filename" : "img_input_round_bg_disable@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "resizing" : {
+        "mode" : "9-part",
+        "center" : {
+          "mode" : "tile",
+          "width" : 1,
+          "height" : 1
+        },
+        "cap-insets" : {
+          "bottom" : 62,
+          "top" : 42,
+          "right" : 57,
+          "left" : 42
+        }
+      },
+      "idiom" : "universal",
+      "filename" : "img_input_round_bg_disable@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

binární
OneCable/Assets.xcassets/images/img_input_round_bg_disable_slicing.imageset/img_input_round_bg_disable@2x.png


binární
OneCable/Assets.xcassets/images/img_input_round_bg_disable_slicing.imageset/img_input_round_bg_disable@3x.png


+ 1 - 0
OneCable/Base.lproj/Main.storyboard

@@ -5903,6 +5903,7 @@
                         </constraints>
                     </view>
                     <connections>
+                        <outlet property="lbTitle" destination="C4H-Ry-rJa" id="usi-jZ-QGc"/>
                         <outlet property="tableView" destination="RL5-0v-UoE" id="ov2-n5-5MH"/>
                     </connections>
                 </viewController>

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1662 - 222
OneCable/Base.lproj/Rules.storyboard


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12 - 7
OneCable/Base.lproj/SignUp.storyboard


+ 29 - 0
OneCable/Classes/Categories/Responder+Keyboard.h

@@ -0,0 +1,29 @@
+//
+//  Responder+Keyboard.h
+//  UIKitSupport
+//
+//  Created by RICHWARE SYSTEMS.
+//  Copyright © 2016년 RICHWARE SYSTEMS. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+typedef void(^KeyboardDisplayBlock)(CGRect frame, CGFloat duration, BOOL display);
+
+@interface UIResponder(Keyboard)
+
++ (void)cacheKeyboard;
++ (void)cacheKeyboard:(BOOL)onNextRunloop;
+
+- (void)addObserverKeyboardFrameChanged:(id)delegate ;//Delegate사용
+- (void)addObserverKeyboardDisplay:(KeyboardDisplayBlock)keyboardDisplayBlock ;//Block사용
+- (void)removeObserverKeyboard ;
+
+@end
+
+@protocol KeyboardFrameChangedDelegate <NSObject>
+@optional
+
+- (void)keyboardFrameChanged:(CGRect)frame duration:(CGFloat)duration display:(BOOL)display ;
+
+@end

+ 162 - 0
OneCable/Classes/Categories/Responder+Keyboard.m

@@ -0,0 +1,162 @@
+//
+//  Responder+Keyboard.m
+//  UIKitSupport
+//
+//  Created by RICHWARE SYSTEMS.
+//  Copyright © 2016년 RICHWARE SYSTEMS. All rights reserved.
+//
+#import <objc/runtime.h>
+#import "Responder+Keyboard.h"
+
+static BOOL hasAlreadyCachedKeyboard;
+
+@interface UIResponder (Keyboard_Private)
+
++(void) __cacheKeyboard;
+
+//@property (strong, nonatomic) id keyboardFrameChangedDelegate ;
+
+@end
+
+@implementation UIResponder(Keyboard)
+
++(void) cacheKeyboard {
+    [[self class] cacheKeyboard:NO];
+}
+
++(void) cacheKeyboard:(BOOL)onNextRunloop {
+    if (! hasAlreadyCachedKeyboard)
+    {
+        hasAlreadyCachedKeyboard = YES;
+        if (onNextRunloop)
+            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.0), dispatch_get_main_queue(), ^(void){ [[self class] __cacheKeyboard]; });
+        else
+            [[self class] __cacheKeyboard];
+    }
+}
+
++(void) __cacheKeyboard {
+    UITextField *field = [UITextField new];
+    [[[[UIApplication sharedApplication] windows] lastObject] addSubview:field];
+    [field becomeFirstResponder];
+    [field resignFirstResponder];
+    [field removeFromSuperview];
+}
+
+//Delegate
+//- (id)keyboardFrameChangedDelegate {
+//    
+//    return objc_getAssociatedObject(self, @selector(keyboardFrameChangedDelegate));
+//    
+//}
+//
+//- (void)setKeyboardFrameChangedDelegate:(id)keyboardFrameChangedDelegate {
+//    
+//    objc_setAssociatedObject(self, @selector(keyboardFrameChangedDelegate), keyboardFrameChangedDelegate, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+//    
+//}
+
+//Keyboard
+- (void)addObserverKeyboardDisplay:(KeyboardDisplayBlock)keyboardDisplayBlock {
+    
+    [[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillShowNotification
+                                                      object:nil
+                                                       queue:[NSOperationQueue mainQueue]
+                                                  usingBlock:^(NSNotification * _Nonnull noti) {
+                                                      
+                                                      [self __keyboardWillChange:noti
+                                                                         display:YES
+                                                            keyboardDisplayBlock:keyboardDisplayBlock] ;
+                                                      
+                                                  }] ;
+    
+    [[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillHideNotification
+                                                      object:nil
+                                                       queue:[NSOperationQueue mainQueue]
+                                                  usingBlock:^(NSNotification * _Nonnull noti) {
+                                                      
+                                                      [self __keyboardWillChange:noti
+                                                                         display:NO
+                                                            keyboardDisplayBlock:keyboardDisplayBlock] ;
+                                                      
+                                                  }] ;
+    
+}
+
+
+- (void)__keyboardWillChange:(NSNotification*)noti display:(BOOL)display keyboardDisplayBlock:(KeyboardDisplayBlock)keyboardDisplayBlock {
+    
+    NSDictionary* info = [noti userInfo];
+    
+    NSTimeInterval duration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey]floatValue] ;
+    CGRect keyboardFrame = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
+    
+    if( keyboardDisplayBlock != nil ) {
+        keyboardDisplayBlock(keyboardFrame, duration, display) ;
+    }
+    
+}
+
+//Keyboard by delegate
+- (void)addObserverKeyboardFrameChanged:(id)delegate {
+    
+    //self.keyboardFrameChangedDelegate = delegate ;
+    
+    [[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillShowNotification
+                                                      object:nil
+                                                       queue:[NSOperationQueue mainQueue]
+                                                  usingBlock:^(NSNotification * _Nonnull noti) {
+                                                      
+                                                      [self __keyboardWillChangeByDelegate:delegate
+                                                                                      noti:noti
+                                                                                   display:YES] ;
+                                                      
+                                                  }] ;
+    
+    [[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillHideNotification
+                                                      object:nil
+                                                       queue:[NSOperationQueue mainQueue]
+                                                  usingBlock:^(NSNotification * _Nonnull noti) {
+                                                      
+                                                      [self __keyboardWillChangeByDelegate:delegate
+                                                                                      noti:noti
+                                                                                   display:NO] ;
+                                                      
+                                                  }] ;
+    
+}
+
+
+- (void)__keyboardWillChangeByDelegate:(id)delegate noti:(NSNotification*)noti display:(BOOL)display {
+    
+    NSDictionary* info = [noti userInfo];
+    
+    NSTimeInterval duration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey]floatValue] ;
+    CGRect keyboardFrame = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
+    
+    if( delegate && [delegate respondsToSelector:@selector(keyboardFrameChanged:duration:display:)] ) {
+        
+        [delegate keyboardFrameChanged:keyboardFrame
+                              duration:duration
+                               display:display] ;
+        
+    }
+    
+}
+
+
+- (void)removeObserverKeyboard {
+    
+    [[NSNotificationCenter defaultCenter] removeObserver:self
+                                                    name:UIKeyboardWillShowNotification
+                                                  object:nil] ;
+    
+    [[NSNotificationCenter defaultCenter] removeObserver:self
+                                                    name:UIKeyboardWillHideNotification
+                                                  object:nil] ;
+    
+}
+
+
+
+@end

+ 1 - 0
OneCable/Classes/CustomUI/CustomTextView.h

@@ -56,4 +56,5 @@ extern CGRect gKeyboardRect;
 
 @property (nonatomic, assign) CustomTextViewSuperview customTextViewSuperview;
 
+
 @end

+ 3 - 2
OneCable/Classes/CustomUI/CustomTextView.m

@@ -44,7 +44,7 @@
         _customTextViewSuperview = CustomTextViewSuperviewIsViewController;
         self.inputAccessoryView = [self generateAccessoryView];
 
-        _bgImageName = @"img_input_line_bg_default";
+        _bgImageName = @"";
         UIImage *bgImage = [UIImage imageNamed:_bgImageName];
 
         if (bgImage) {
@@ -64,7 +64,7 @@
     self.customTextViewSuperview = CustomTextViewSuperviewIsViewController;
     self.inputAccessoryView = [self generateAccessoryView];
 
-    _bgImageName = _bgImageName && ![_bgImageName isEmptyString] ? _bgImageName : @"img_input_line_bg_default";
+    _bgImageName = _bgImageName && ![_bgImageName isEmptyString] ? _bgImageName : @"";
     _bgImage = [UIImage imageNamed:_bgImageName];
     if (_bgImage) {
         if (!CGRectEqualToRect(_rectForCapBackground, CGRectZero)) {//rectForCap이 설정된 경우, 이미지를 리사이즈함.
@@ -108,6 +108,7 @@
 }
 
 
+
 - (UIView *)generateAccessoryView {
 
     CGFloat width = [UIScreen mainScreen].bounds.size.width;

+ 1 - 0
OneCable/Classes/JDFacade.h

@@ -25,6 +25,7 @@
 #import "UIView+FindUIViewController.h"
 #import "UITableView+EnumarateCells.h"
 #import "TargetConditionals.h"
+#import "Responder+Keyboard.h"
 
 //Common UI
 #import "CustomAlertView.h"

+ 1 - 0
OneCable/Classes/JDFacade.m

@@ -866,6 +866,7 @@ static NSString *const ksKeychainArchiveData = @"_archiveData";
 }
 
 - (void)observeKeyboardRect {
+    
     if (CGRectEqualToRect(gKeyboardRect, CGRectZero)) {
         [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
         [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];

+ 2 - 1
OneCable/Classes/ViewControllers/MainScreens/HomeModeSettingsViewController.h

@@ -20,6 +20,7 @@
 @property (strong, nonatomic) NSMutableArray<ItemModel> *items;
 
 @property (weak, nonatomic) IBOutlet CustomTableView *tableView;
+@property (weak, nonatomic) IBOutlet CustomLabel *lbTitle;
 
 
 #pragma mark - Instance Methods
@@ -51,4 +52,4 @@
 
 @property (weak, nonatomic) IBOutlet CustomButton *btnAppend;
 
-@end
+@end

+ 11 - 3
OneCable/Classes/ViewControllers/MainScreens/LoginViewController.m

@@ -25,6 +25,7 @@
 #import "CustomImageView.h"
 #import "PwdPopupView.h"
 #import "QuizSetViewController.h"
+#import "TempPwViewController.h"
 
 //#import "MobilesOverViewController.h"
 //#import "InvitationListViewController.h"
@@ -242,7 +243,7 @@ ID / PW Input Box Text Color
 //        [JDFacade facade].loginUser.gradeCode = KNEET_MEMBER_MASTER;
 //        [JDFacade facade].loginUser.level = 90;
         
-        NSLog(@"%@", [JDFacade facade].loginUser);
+        NSLog(@"loginUser : %@", [JDFacade facade].loginUser);
         
         if ([[JDFacade facade].loginUser.emailId isEqualToString:[JDFacade facade].tmpEmailId]) {
             [JDFacade facade].tmpEmailId = ksEmptyString;
@@ -278,7 +279,6 @@ ID / PW Input Box Text Color
             }
 
         }
-        
 
         [self actionAfterLogin];
     }
@@ -291,7 +291,7 @@ ID / PW Input Box Text Color
 
 //홈그룹 체크 및 대시보드 이동
 - (void)actionAfterLogin {
-
+    
     if ([[JDFacade facade].loginUser.quiz isEqualToString:@""]) {
         QuizSetViewController *vc = (QuizSetViewController *)[CommonUtil instantiateViewControllerWithIdentifier:@"QuizSetViewController" storyboardName:@"Main"];
         vc.delegate = self;
@@ -304,6 +304,14 @@ ID / PW Input Box Text Color
         return;
     }
 
+    //임시 비밀번호 체크 후 이동
+    if ([JDFacade facade].loginUser.tempPasswordYn && [[JDFacade facade].loginUser.tempPasswordYn boolValue]) {
+        
+        TempPwViewController *vc = (TempPwViewController *)[CommonUtil instantiateViewControllerWithIdentifier:@"TempPwSetViewController" storyboardName:@"SignUp"];
+        [self presentViewController:vc animated:YES completion:nil];
+        return;
+    }
+    
     [self actionAfterInvitaion];
 }
 

+ 12 - 0
OneCable/Classes/ViewControllers/RuelsScreens/RulesAddViewController.h

@@ -46,6 +46,7 @@
 
 @interface RulesAddHeaderTableViewCell : KNTableViewCell2
 
+@property (weak, nonatomic) IBOutlet UIImageView *imgBg;
 @property (weak, nonatomic) IBOutlet CustomLabel *lblTitle;
 @property (weak, nonatomic) IBOutlet CustomButton *btnAdd;
 
@@ -62,6 +63,17 @@
 
 @end
 
+@interface RulesAddTextTableViewCell : KNTableViewCell2
+
+@property (weak, nonatomic) IBOutlet UIImageView *imgTxtBg;
+@property (weak, nonatomic) IBOutlet CustomTextView *txtView;
+@property (weak, nonatomic) IBOutlet CustomButton *btnAdd;
+@property (weak, nonatomic) IBOutlet CustomButton *btnDelete;
+@property (weak, nonatomic) IBOutlet CustomButton *btnConfirm;
+
+- (void)registHeightChangeBlock:(void (^)(CGFloat height)) heightChangeBlock ;
+
+@end
 
 @interface RulesAddPushTableViewCell : KNTableViewCell2
 

+ 250 - 88
OneCable/Classes/ViewControllers/RuelsScreens/RulesAddViewController.m

@@ -38,6 +38,7 @@
 #import "DaylightPopupView.h"
 #import "ExternHeatPopupView.h"
 
+//규칙이름
 @implementation RulesAddTitleTableViewCell
 
 #pragma mark - textfield delegate
@@ -60,43 +61,116 @@
 
 @end
 
-@implementation RulesAddHeaderTableViewCell
 
-@end
+//알림 메시지
+@interface RulesAddTextTableViewCell() <UITextViewDelegate>
 
+@property (nonatomic, strong) void (^heightChangeBlock)(CGFloat height) ;
 
-@implementation RulesAddTableViewCell
+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *constTxtHeight;
+@property CGRect previousRect;
 
 @end
 
+@implementation RulesAddTextTableViewCell
 
-@implementation RulesAddPushTableViewCell
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    
+    _previousRect = CGRectZero;
+    _previousRect.origin.y = 11.f;
+}
+
+
+- (void)registHeightChangeBlock:(void (^)(CGFloat height)) heightChangeBlock {
+    
+    _heightChangeBlock = heightChangeBlock ;
+}
+
+- (void)invokeChangeHeight:(CGFloat)height {
+    
+    if( _heightChangeBlock != nil )
+        _heightChangeBlock(height) ;
+}
 
+#pragma mark - textView delegate
+- (void)textViewDidChange:(UITextView *)textView {
+    
+    UITextPosition* pos = _txtView.endOfDocument;
+    CGRect currentRect = [_txtView caretRectForPosition:pos];
+    CGFloat previousY = _previousRect.origin.y;
+    
+    
+    if (previousY != currentRect.origin.y) {
+        
+        CGFloat height = currentRect.origin.y - previousY;
+
+        _constTxtHeight.constant = _constTxtHeight.constant + height < 48.f ? 48.f : _constTxtHeight.constant + height;
+        [self invokeChangeHeight:height];
+    }
+    
+    _previousRect = currentRect;
+}
+
+- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
+    
+    NSString *string = [textView.text stringByReplacingCharactersInRange:range withString:text];
+
+    BOOL input = string.length == 0;
+    
+    _btnConfirm.hidden = input;
+    _btnAdd.hidden = !input;
+    
+    return YES;
+}
+
+- (void)textViewDidBeginEditing:(UITextView *)textView {
+    
+    _imgTxtBg.highlighted = YES;
+}
+
+- (void)textViewDidEndEditing:(UITextView *)textView {
+    
+    _imgTxtBg.highlighted = NO;
+}
 
 @end
 
-@implementation RulesAddConditionHeaderTableViewCell
 
 
+@implementation RulesAddHeaderTableViewCell
 @end
 
-@implementation RulesAddConditionTableViewCell
+@implementation RulesAddTableViewCell
+@end
 
+@implementation RulesAddPushTableViewCell
+@end
 
+@implementation RulesAddConditionHeaderTableViewCell
 @end
 
-@implementation RulesAddFooterTableViewCell
+@implementation RulesAddConditionTableViewCell
+@end
 
+@implementation RulesAddFooterTableViewCell
 @end
 
 
 
-@interface RulesAddViewController () <CustomTextViewDelegate, UITextFieldDelegate> {
+
+
+
+
+@interface RulesAddViewController () <KeyboardFrameChangedDelegate> {
+    
     
     NSMutableArray<ItemModel> *_triggerDevices, *_actionDevices, *_conditionDevices;
     
     BOOL _isNotFirstLoading, _hasCondition;
     NSMutableArray *_arrayForHeader, *_arrayForFooter;
+    CGFloat textCellChangeHeight; //알림 메세지 셀 사이즈 변동
+    
     
     CustomTextField *_txtRuleTitle;
     CustomTextView *_txvMessage;
@@ -106,8 +180,12 @@
     
     RulesConditionHomeModePopupView *_mpopup;
     RulesConditionViewController *_rcv;
+    
+    __weak IBOutlet NSLayoutConstraint *constTableBottom;
+    
 }
 
+
 @property (strong, nonatomic) NSMutableArray<ItemModel> *triggers;
 @property (strong, nonatomic) NSMutableArray<ItemModel> *actions;
 @property (strong, nonatomic) NSMutableArray<ItemModel> *conditions;
@@ -126,58 +204,44 @@
     [self prepareViewDidLoad];
 }
 
-
-- (void)cloneSubItemsForItemSubType:(NSArray<ItemModel> *)items {
+- (void)viewWillAppear:(BOOL)animated {
+    [super viewWillAppear:animated];
     
-    for (ItemModel *item in items) {
-        if ([item.itemSubTypeCode isEqualToString:ksItemSubTypeCodeDevice]) {//디바이스일 경우,
-            //기존 아이템을 그대로 사용함.
-            for (ItemSubModel *subItem in item.subItems) {
-                [[JDFacade facade] setRadioButtonStatus:@YES object:subItem];
-                [[JDFacade facade] setCheckBoxStatus:@YES object:subItem];
-            }
-        } else if ([item.itemSubTypeCode isEqualToString:ksItemSubTypeCodeAppPush]) {//푸시일 경우,
-            item.pushes = (NSMutableArray<ItemSubModel> *)[[NSMutableArray alloc] initWithArray:item.subItems copyItems:YES];
-            item.subItems = nil;
-
-        } else if ([item.itemSubTypeCode isEqualToString:ksItemSubTypeCodeTimer]) {//타이머일 경우,
-            item.timers = (NSMutableArray<ItemSubModel> *)[[NSMutableArray alloc] initWithArray:item.subItems copyItems:YES];
-            item.subItems = nil;
-        } else if ([item.itemSubTypeCode isEqualToString:ksItemSubTypeCodeDaylight]) {//해뜰때/질때 경우,
-            item.daylights = (NSMutableArray<ItemSubModel> *)[[NSMutableArray alloc] initWithArray:item.subItems copyItems:YES];
-            item.subItems = nil;
-        } else if ([item.itemSubTypeCode isEqualToString:ksItemSubTypeCodeHeat]) {//더울때/추울때 경우,
-            item.heats = (NSMutableArray<ItemSubModel> *)[[NSMutableArray alloc] initWithArray:item.subItems copyItems:YES];
-            item.subItems = nil;
-        } else if ([item.itemSubTypeCode isEqualToString:ksItemSubTypeCodeMode]) {//더울때/추울때 경우,
-            //기존 아이템을 그대로 사용함.
-        }
-    }
+    [self addObserverKeyboardFrameChanged:self] ;
 }
 
-- (void)setRefRuleDetail:(RuleDetailModel *)refRuleDetail {
-
-    
-    _refRuleDetail = refRuleDetail;
+- (void)viewWillDisappear:(BOOL)animated {
+    [self viewWillDisappear:animated];
     
-    _triggers = (NSMutableArray<ItemModel> *)[[NSMutableArray alloc] initWithArray:_refRuleDetail.triggers copyItems:YES];
-    _actions = (NSMutableArray<ItemModel> *)[[NSMutableArray alloc] initWithArray:_refRuleDetail.actions copyItems:YES];
-    _conditions = (NSMutableArray<ItemModel> *)[[NSMutableArray alloc] initWithArray:_refRuleDetail.conditions copyItems:YES];
+    [self removeObserverKeyboard] ;
+}
+
+#pragma mark - Keyboard Frame Changed Delegate
+- (void)keyboardFrameChanged:(CGRect)frame duration:(CGFloat)duration display:(BOOL)display {
     
-    [self cloneSubItemsForItemSubType:_triggers];
-    [self cloneSubItemsForItemSubType:_actions];
-    [self cloneSubItemsForItemSubType:_conditions];
+    NSLog(@"call keyboardFrameChanged!!");
     
-    _hasCondition = [_conditions objectKey:@"itemSubTypeCode" eqaulToString:ksConditionSubTypeCodeHomeMode];
-    _hasCondition = [_conditions objectKey:@"itemSubTypeCode" eqaulToString:ksConditionSubTypeCodeDueDate] ? YES : _hasCondition;
-    _hasCondition = [_conditions objectKey:@"itemSubTypeCode" eqaulToString:ksItemSubTypeCodeDevice] ? YES : _hasCondition;
+    [UIView animateWithDuration:duration animations:^{
+        
+        if( display ) {
+            constTableBottom.constant = frame.size.height;
+        }
+        else {
+            constTableBottom.constant = 50.0f;
+        }
+
+        [self.view layoutIfNeeded];
+        
+    }] ;
 }
 
 
+
+#pragma mark - init
 - (void)initProperties {
     _arrayForHeader = [[NSMutableArray alloc] init];
     _arrayForFooter = [[NSMutableArray alloc] init];
-
+    
     if (!_triggers) {
         _triggers = (NSMutableArray<ItemModel> *)[[NSMutableArray alloc] init];
     }
@@ -192,9 +256,9 @@
 
 
 - (void)initUI {
-
+    
     [self initTableViewAsDefaultStyle:_tableView];
-
+    
     if (_refRuleDetail) {
         _lblTitle.text = @"규칙 편집";
     }
@@ -207,6 +271,7 @@
 }
 
 
+
 #pragma mark - Main Logic
 - (void)requestDeviceListForAction:(NSString *)typeCode {
     //parameters
@@ -391,6 +456,7 @@
     }];
 }
 
+
 //아이템 배열을 리턴함.
 - (NSArray *)items:(NSArray<ItemModel> *)items {
     
@@ -549,6 +615,55 @@
     return rConditions;
 }
 
+
+- (void)cloneSubItemsForItemSubType:(NSArray<ItemModel> *)items {
+    
+    for (ItemModel *item in items) {
+        if ([item.itemSubTypeCode isEqualToString:ksItemSubTypeCodeDevice]) {//디바이스일 경우,
+            //기존 아이템을 그대로 사용함.
+            for (ItemSubModel *subItem in item.subItems) {
+                [[JDFacade facade] setRadioButtonStatus:@YES object:subItem];
+                [[JDFacade facade] setCheckBoxStatus:@YES object:subItem];
+            }
+        } else if ([item.itemSubTypeCode isEqualToString:ksItemSubTypeCodeAppPush]) {//푸시일 경우,
+            item.pushes = (NSMutableArray<ItemSubModel> *)[[NSMutableArray alloc] initWithArray:item.subItems copyItems:YES];
+            item.subItems = nil;
+            
+        } else if ([item.itemSubTypeCode isEqualToString:ksItemSubTypeCodeTimer]) {//타이머일 경우,
+            item.timers = (NSMutableArray<ItemSubModel> *)[[NSMutableArray alloc] initWithArray:item.subItems copyItems:YES];
+            item.subItems = nil;
+        } else if ([item.itemSubTypeCode isEqualToString:ksItemSubTypeCodeDaylight]) {//해뜰때/질때 경우,
+            item.daylights = (NSMutableArray<ItemSubModel> *)[[NSMutableArray alloc] initWithArray:item.subItems copyItems:YES];
+            item.subItems = nil;
+        } else if ([item.itemSubTypeCode isEqualToString:ksItemSubTypeCodeHeat]) {//더울때/추울때 경우,
+            item.heats = (NSMutableArray<ItemSubModel> *)[[NSMutableArray alloc] initWithArray:item.subItems copyItems:YES];
+            item.subItems = nil;
+        } else if ([item.itemSubTypeCode isEqualToString:ksItemSubTypeCodeMode]) {//더울때/추울때 경우,
+            //기존 아이템을 그대로 사용함.
+        }
+    }
+}
+
+- (void)setRefRuleDetail:(RuleDetailModel *)refRuleDetail {
+    
+    
+    _refRuleDetail = refRuleDetail;
+    
+    _triggers = (NSMutableArray<ItemModel> *)[[NSMutableArray alloc] initWithArray:_refRuleDetail.triggers copyItems:YES];
+    _actions = (NSMutableArray<ItemModel> *)[[NSMutableArray alloc] initWithArray:_refRuleDetail.actions copyItems:YES];
+    _conditions = (NSMutableArray<ItemModel> *)[[NSMutableArray alloc] initWithArray:_refRuleDetail.conditions copyItems:YES];
+    
+    [self cloneSubItemsForItemSubType:_triggers];
+    [self cloneSubItemsForItemSubType:_actions];
+    [self cloneSubItemsForItemSubType:_conditions];
+    
+    _hasCondition = [_conditions objectKey:@"itemSubTypeCode" eqaulToString:ksConditionSubTypeCodeHomeMode];
+    _hasCondition = [_conditions objectKey:@"itemSubTypeCode" eqaulToString:ksConditionSubTypeCodeDueDate] ? YES : _hasCondition;
+    _hasCondition = [_conditions objectKey:@"itemSubTypeCode" eqaulToString:ksItemSubTypeCodeDevice] ? YES : _hasCondition;
+}
+
+
+
 #pragma mark - UITableView DataSource & Delegate
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
     return 5;
@@ -568,8 +683,7 @@
         count = deviceItem.subItems && deviceItem.subItems.count ? deviceItem.subItems.count : 0;
         
     } else if (section == 3) {//push-message
-        ItemModel *pushItem = [_actions objectKey:@"itemSubTypeCode" eqaulToString:ksItemSubTypeCodeAppPush];
-        count = pushItem.pushes && pushItem.pushes.count ? pushItem.pushes.count : 0;
+        count = 1;
         
     } else if (section == 4) {//conditions
         count = _chkConditions.checked || _hasCondition ? 1 : 0;
@@ -600,9 +714,6 @@
     } else if (section == 2) {//action
         title = @"동작할 장치";
 //        title = _actions && _actions.count ? @"선택됨" : title;
-    } else if (section == 3) {//pushes
-        title = @"알림 메시지";
-//        title = _pushes && _pushes.count ? @"선택됨" : title;
     }
     
 //    else if (section == 3) {//conditions
@@ -623,9 +734,6 @@
     } else if (section == 2) {
         [btnAdd addTarget:self action:@selector(btnAddActionTouched:) forControlEvents:UIControlEventTouchUpInside];
         
-    } else if (section == 3) {
-        _btnPushAdd = btnAdd;
-        [btnAdd addTarget:self action:@selector(btnAddPushMessageTouched:) forControlEvents:UIControlEventTouchUpInside];
     }
 }
 
@@ -635,9 +743,9 @@
     UIView *view = _arrayForHeader.count > section ? _arrayForHeader[section] : nil;
     
     if (!view) {
-        if (section == 0) {//title
+        if (section == 0 || section == 3) {//title
             view = [[UIView alloc] init];
-        } else if (section == 1 || section == 2 || section == 3) {//hide add button or not;
+        } else if (section == 1 || section == 2) {//hide add button or not;
 
             RulesAddHeaderTableViewCell *hcell = (RulesAddHeaderTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"HeaderCellIdentifier"];
             hcell.width = IPHONE_WIDTH;
@@ -646,6 +754,7 @@
             [view addSubview:hcell];
 
             hcell.lblTitle.text = [self headerTitleForSection:section];
+            hcell.imgBg.hidden = section % 2 == 0;
             
             if (![hcell.btnAdd actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
                 [self addTargetToHeaderAddButton:hcell.btnAdd section:section];
@@ -680,7 +789,7 @@
         }
     } else {
         
-         if (section == 1 || section == 2 || section == 3) {
+         if (section == 1 || section == 2) {
              RulesAddHeaderTableViewCell *hcell = (RulesAddHeaderTableViewCell *)view.subviews[0];
              hcell.lblTitle.text = hcell.lblTitle.text = [self headerTitleForSection:section];
              
@@ -698,11 +807,7 @@
     
     if (section == 1) {
         _btnTriggerAdd.hidden = self.triggers.count > 0;
-    } else if (section == 3) {
-        ItemModel *pushItem = [_actions objectKey:@"itemSubTypeCode" eqaulToString:ksItemSubTypeCodeAppPush];
-        NSInteger pcount = pushItem.pushes && pushItem.pushes.count ? pushItem.pushes.count : 0;
-        _btnPushAdd.hidden = pcount > 0;
-    }
+    } 
 }
 
 - (void)chkConditionsTouched:(id)sender {
@@ -745,16 +850,18 @@
 }
 
 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
-    if (section == 0) {
+    
+    if (section == 0 || section == 3) {
         return 0.01f;
-    } else if (section == 4) {
+    }
+    else if (section == 4) {
         return 56.0f;
     }
+    
     return 56.0f;
 }
 
 
-
 - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
     
     UIView *view = _arrayForFooter.count > section ? _arrayForFooter[section] : nil;
@@ -796,7 +903,7 @@
         
     } else if (section == 3) {//push-message
 //        height = UITableViewAutomaticDimension;
-        height = 123;
+        height = 122 + textCellChangeHeight;
         
     } else if (section == 4) {//conditions
         if (!_rcv) {
@@ -947,8 +1054,7 @@
             _txtRuleTitle = tcell.txtRuleTitle;
         }
         
-        tcell.btnDelete.hidden = YES;
-        tcell.btnConfirm.hidden = YES;
+        [self insertActionAddButton:tcell.btnAdd];
         
         cell = tcell;
         
@@ -962,6 +1068,7 @@
         tcell.lblItem.textColor = kUITextColor04;
         
         tcell.btnDelete.value = item;
+        
         if (![tcell.btnDelete actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
             [tcell.btnDelete addTarget:self action:@selector(btnDeleteTriggerTouched:) forControlEvents:UIControlEventTouchUpInside];
         }
@@ -1010,20 +1117,22 @@
         ItemModel *pushItem = [_actions objectKey:@"itemSubTypeCode" eqaulToString:ksItemSubTypeCodeAppPush];
         ItemSubModel *subItem = pushItem.pushes[indexPath.row];
         
-        RulesAddPushTableViewCell *tcell = (RulesAddPushTableViewCell *)[_tableView dequeueReusableCellWithIdentifier:@"PushCellIdentifier"];
+        RulesAddTextTableViewCell *tcell = (RulesAddTextTableViewCell *)[_tableView dequeueReusableCellWithIdentifier:@"TextCellIdentifier"];
+        
+        //높이변경
+        [tcell registHeightChangeBlock:^(CGFloat height) {
+            textCellChangeHeight += height;
+            [self tableView:_tableView reloadRowWhileShowingKeyboard:indexPath];
+        }];
+        
         if (!_txvMessage) {
-            _txvMessage = tcell.txvMessage;
+            _txvMessage = tcell.txtView;
         }
-//        [self textViewDidChange:tcell.txvMessage];
 
-        _txvMessage.delegate = self;
         _txvMessage.text = [_txvMessage.text isEqualToString:_txvMessage.placeHolder] && _refRuleDetail ? subItem.cmdclsValue : _txvMessage.text;
-        
-        tcell.btnDelete.value = subItem;
-        [tcell.btnDelete addTarget:self action:@selector(btnDeletePushActionTouched:) forControlEvents:UIControlEventTouchUpInside];
-        
-        tcell.btnConfirm.hidden = YES;
-    
+
+        [self insertActionAddButton:tcell.btnAdd];
+       
         cell = tcell;
 
     } else if (section == 4) {//conditions
@@ -1051,6 +1160,15 @@
     return cell;
 }
 
+//키보드 유지 셀 높이 변경
+- (void)tableView:(UITableView *)tableView reloadRowWhileShowingKeyboard:(NSIndexPath *)indexPath {
+    
+    [tableView beginUpdates];
+    [tableView endUpdates];
+    
+    [tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
+}
+
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     [tableView deselectRowAtIndexPath:indexPath animated:YES];
     
@@ -1080,6 +1198,8 @@
     }
 }
 
+
+#pragma mark
 - (void)modifyTriggerOfTimer:(ItemModel *)item {
     
     TimePickerPopupView *tpopup = [[TimePickerPopupView alloc] initFromNib];
@@ -1193,9 +1313,8 @@
     }];
 }
 
-#pragma mark - TableView UI Events
-
 
+#pragma mark - TableView UI Events
 - (void)btnAddTriggerTouched:(id)sender {
     
     TriggerSelectPopupView *tpopup = [[TriggerSelectPopupView alloc] initFromNib];
@@ -1322,14 +1441,57 @@
     
 }
 
+- (void)btnAddTouched:(id)sender {
 
-#pragma mark - CustomTextView Delegate
+    UIButton *btn = sender;
+    
+    //1001:규칙add, 2001:알림add
+    
+    UIControl *control;
+    
+    if ([btn tag] > 2000) {
+        
+        control = [self.view viewWithTag:2000];
+    }
+    else {
+        
+        control = [self.view viewWithTag:1000];
+        
+    }
+    
+    [control becomeFirstResponder];
+    
+}
+
+//- (void)btnInputConfirmTouched:(id)sender {
+//    
+//    UIButton *btn = sender;
+//    
+//    //1002:규칙add, 2002:알림add
+//    if ([btn tag] > 2000) {
+//        
+//        
+//    }
+//    else {
+//        
+//    }
+//    
+//}
 
-- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
-    NSLog(@"%s\n %zd", __PRETTY_FUNCTION__, textView.text.length);
-    return textView.text.length < 120;
+- (void)insertActionAddButton:(UIButton*)button {
+    
+    if (![button actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
+        [button addTarget:self action:@selector(btnAddTouched:) forControlEvents:UIControlEventTouchUpInside];
+    }
 }
 
+//- (void)insertActionInputConfirmButton:(UIButton*)button {
+//    
+//    if (![button actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
+//        [button addTarget:self action:@selector(btnInputConfirmTouched:) forControlEvents:UIControlEventTouchUpInside];
+//    }
+//}
+
 
 
 

+ 69 - 9
OneCable/Classes/ViewControllers/SignUpScreens/TempPwViewController.m

@@ -10,6 +10,9 @@
 #import "CustomLabel.h"
 #import "CustomButton.h"
 #import "CustomTextField.h"
+#import "RequestHandler.h"
+#import "JDJSONModel.h"
+#import "ValidateUtil.h"
 
 @interface TempPwViewController ()<CustomTextFieldDelegate> {
 }
@@ -33,23 +36,80 @@
     _txtPwInput.customTextFieldSuperview = CustomTextFieldSuperviewIsScrollView;
     _txtPwReInput.customTextFieldSuperview = CustomTextFieldSuperviewIsScrollView;
     
-    _txtPwInput.secureTextEntry = YES;
-    _txtPwReInput.secureTextEntry = YES;
+}
+
+#pragma mark - API
+- (void)requestSetNewPassword {
     
-    _txtPwInput.keyboardType = UIKeyboardTypeDefault;
-    _txtPwReInput.keyboardType = UIKeyboardTypeDefault;
+    NSDictionary *parameter = @{@"type": @"password",
+                                @"password": _txtPwInput.text};
     
-    _txtPwInput.returnKeyType = UIReturnKeyNext;
-    _txtPwReInput.returnKeyType = UIReturnKeyDone;
+    NSString *path = [[JDFacade facade] getUrlWithCustGroupIDAndMemberID:API_PUT_MEMBER_UPDATE];
+
     
-    _txtPwReInput.delegate = self;
+    [[RequestHandler handler] sendAsyncPutRequestAPIPath:path parameters:parameter modelClass:[JDJSONModel class] completion:^(id responseObject) {
+
+        [JDFacade facade].tmpPassword = nil;
+        [JDFacade facade].loginUser.tempPasswordYn = @"N";
+        
+        [[JDFacade facade] toast:@"비밀번호를 변경했습니다"];
+        
+        [self moveNext];
+   
+    } failure:^(id errorObject) {
+        
+        JDErrorModel *error = (JDErrorModel *)errorObject;
+        [[JDFacade facade] alert:error.errorMessage];
+    }];
 }
 
+#pragma mark - textfield delegate
+- (BOOL)textFieldShouldReturn:(UITextField *)textField {
+  
+    if ([textField isEqual:_txtPwInput]) {
+
+        [_txtPwReInput becomeFirstResponder];
+        
+    }
+    else {
+        
+        [self.view endEditing:YES];
+        
+    }
+    
+    return YES;
+}
+
+
+#pragma mark - user event
 - (IBAction)btnCancelTouched:(id)sender {
-    NSLog(@"로그인 페이지로 이동");
+    
+    [self dismissViewControllerAnimated:YES completion:nil];
+    
 }
+
 - (IBAction)btnConfirmTouched:(id)sender {
-    NSLog(@"패스워드 변경 완료");
+    
+    if (![ValidateUtil validateTextfiled:_txtPwInput type:ValidateTypePassword title:NSLocalizedString(@"비밀번호", @"비밀번호")]) {
+        return;
+    }
+    
+    if (![_txtPwInput.text isEqualToString:_txtPwReInput.text]) {
+        [[JDFacade facade] alert:@"두 비밀번호가 일치하지 않습니다"];
+        return;
+    }
+    
+    [self requestSetNewPassword];
+    
+}
+
+
+- (void)moveNext {
+    
+    UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"MainViewController" storyboardName:@"Main"];
+    
+    [JDFacade facade].mainViewController = (MainViewController *)vc;
+    [[JDFacade facade].appDelegate.window setRootViewController:vc];
 }
 
 @end