Kaynağa Gözat

- 멤버 초대 관련 작업중
- 날짜 입력 팝업 공통 모듈화 작업

KaRam Kim 8 yıl önce
ebeveyn
işleme
7e41b45889

+ 5 - 3
OneCable/Classes/CommonUI/CommandClassControlView.m

@@ -379,12 +379,14 @@
 
 
 - (void)setSwitchBinary {
-    
+
     if (_isOpened) {//Unlocked
-        [_btnOpen setImage:[UIImage imageNamed:@"img_things_list_btn_lockunlock_unlock"] forState:UIControlStateNormal];
+//        [_btnOpen setImage:[UIImage imageNamed:@"img_things_list_btn_lockunlock_unlock"] forState:UIControlStateNormal];
+            [_btnOpen setImage:[UIImage imageNamed:@"img_things_list_btn_onoff_off"] forState:UIControlStateNormal];
         
     } else {//Locked
-        [_btnOpen setImage:[UIImage imageNamed:@"img_things_list_btn_lockunlock_lock"] forState:UIControlStateNormal];
+//        [_btnOpen setImage:[UIImage imageNamed:@"img_things_list_btn_lockunlock_lock"] forState:UIControlStateNormal];
+            [_btnOpen setImage:[UIImage imageNamed:@"img_things_list_btn_onoff_on"] forState:UIControlStateNormal];
     }
 }
 

+ 2 - 2
OneCable/Classes/CommonUI/CommandClassControlView.xib

@@ -366,10 +366,10 @@
                     </variation>
                 </label>
                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="J4Z-6u-PRA" userLabel="Button - On" customClass="CustomButton">
-                    <rect key="frame" x="158" y="6.5" width="42" height="32"/>
+                    <rect key="frame" x="158" y="1.5" width="42" height="42"/>
                     <constraints>
                         <constraint firstAttribute="height" constant="32" id="Cu0-ma-uDZ">
-                            <variation key="heightClass=regular-widthClass=compact" constant="32"/>
+                            <variation key="heightClass=regular-widthClass=compact" constant="42"/>
                         </constraint>
                         <constraint firstAttribute="width" constant="100" id="W6K-KQ-JfY">
                             <variation key="heightClass=regular-widthClass=compact" constant="42"/>

+ 2 - 0
OneCable/Classes/CustomUI/DatePickerButton.h

@@ -24,4 +24,6 @@ typedef enum {
 
 @property (assign, nonatomic) IBInspectable DatePickerMode pickerMode;
 
+@property (nonatomic, assign) BOOL isHidePicker;
+
 @end

+ 29 - 2
OneCable/Classes/CustomUI/DatePickerButton.m

@@ -7,6 +7,9 @@
 //
 #import "CommonUtil.h"
 #import "DatePickerButton.h"
+
+#import "CustomDatePopupView.h"
+
 #import "UIViewController-ActionSheetSimulation.h"
 
 #define kfToolBarHeight 44.0f
@@ -16,6 +19,8 @@
 
 @interface DatePickerButtonDatePicker : UIDatePicker {
     BOOL changed;
+    
+
 }
 
 @end
@@ -49,7 +54,8 @@
     UIToolbar *_actionToolbar;
     NSDateFormatter *_dateFormmater;
     UIView *_simulatedActionSheetView;
-    
+
+    CustomDatePopupView *_popDate;
 }
 
 @end
@@ -66,6 +72,7 @@
 - (void)awakeFromNib {
     
     [super awakeFromNib];
+    
     [self addTarget:self action:@selector(didTouchButton) forControlEvents:UIControlEventTouchUpInside];
 }
 
@@ -73,7 +80,12 @@
 #pragma mark - UIActionSheet Delegate
 
 - (void)didTouchButton {
-    [self showPicker];
+    if (!_isHidePicker) {
+        [self showPicker];
+    }
+    else {
+        [self showPopUp];
+    }
 }
 
 - (void)generateActionSheet {
@@ -106,8 +118,23 @@
     [_actionToolbar setItems:[NSArray arrayWithObjects:fixedSpace, cancelButton, flexSpace, doneBtn, fixedSpace, nil] animated:YES];
     
     _simulatedActionSheetView = [[CommonUtil currentViewController] actionSheetSimulationWithPickerView:_datePicker withToolbar:_actionToolbar];
+    
+    
+}
+
+- (void)showPopUp {
+    if (_popDate == nil) {
+        _popDate = [[CustomDatePopupView alloc] initWithTitle:@"정답 날짜 입력"];
+    }
+    
+    [_popDate showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
+        if (buttonIndex == 0) {//OK
+            NSLog(@"Input Date : %@.%@.%@", _popDate.txtYear.text, _popDate.txtMonth.text, _popDate.txtDay.text);
+        }
+    }];
 }
 
+
 - (void)showPicker {
     [[CommonUtil currentViewController].view endEditing:YES];
     

+ 3 - 0
OneCable/Classes/ViewControllers/HomeMemberScreens/CustomDatePopupView.h

@@ -8,6 +8,7 @@
 
 @import UIKit;
 #import "CustomAlertView.h"
+#import "CustomTextField.h"
 
 @class CustomTextField;
 
@@ -20,5 +21,7 @@
 
 - (void)setTitle:(NSString *)title;
 - (id)initFromNib;
+- (id)initWithTitle:(NSString *)title;
+
 
 @end

+ 51 - 26
OneCable/Classes/ViewControllers/HomeMemberScreens/CustomDatePopupView.m

@@ -9,7 +9,7 @@
 #import "JDObject.h"
 #import "CustomLabel.h"
 #import "CustomButton.h"
-#import "CustomTextField.h"
+
 #import "CustomDatePopupView.h"
 
 @interface CustomDatePopupView () <CustomTextFieldDelegate>
@@ -21,6 +21,13 @@
 
 @implementation CustomDatePopupView
 
+- (id)initWithTitle:(NSString *)title
+{
+    [self setTitle:title];
+    
+    return [self initFromNib];
+}
+
 - (id)initFromNib {
     for (UIView *view in [CommonUtil nibViews:@"CustomDatePopupView"]) {
         if ([view isKindOfClass:[CustomDatePopupView class]]) {
@@ -29,17 +36,17 @@
             //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함.
             self.frame = [UIScreen mainScreen].bounds;
             
-//            _txtYear.delegate = self;
-//            _txtYear.keyboardType = UIKeyboardTypePhonePad;
-//            _txtYear.returnKeyType = UIReturnKeyNext;
-//            
-//            _txtMonth.delegate = self;
-//            _txtMonth.keyboardType = UIKeyboardTypePhonePad;
-//            _txtMonth.returnKeyType = UIReturnKeyNext;
-//            
-//            _txtDay.delegate = self;
-//            _txtMonth.keyboardType = UIKeyboardTypePhonePad;
-//            _txtMonth.returnKeyType = UIReturnKeyDone;
+            _txtYear.delegate = self;
+            _txtYear.keyboardType = UIKeyboardTypeNumberPad;
+            _txtYear.returnKeyType = UIReturnKeyNext;
+            
+            _txtMonth.delegate = self;
+            _txtMonth.keyboardType = UIKeyboardTypeNumberPad;
+            _txtMonth.returnKeyType = UIReturnKeyNext;
+            
+            _txtDay.delegate = self;
+            _txtDay.keyboardType = UIKeyboardTypeNumberPad;
+            _txtDay.returnKeyType = UIReturnKeyDone;
             
             [self.imgTitleBar setImage:[UIImage imageNamed:@"img_popup_bg_head"]inset:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
             
@@ -69,28 +76,46 @@
     if (!self.superview) {
         return;
     }
-//    _txtYear.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
-//    _txtMonth.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
-//    _txtDay.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
+    _txtYear.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
+    _txtMonth.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
+    _txtDay.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
 }
 
-- (void)btnConfirmTouched:(id)sender {
+- (IBAction)btnConfirmTouched:(id)sender {
     
-    NSLog(@"확인");
+//    NSLog(@"확인");
+    [super btnConfirmTouched:sender];
 }
 
 #pragma mark - CustomTextField
 
+
+
 - (BOOL)textFieldShouldReturn:(UITextField *)textField {
-//    if ([textField isEqual:_txtDay]) {
-//        [self btnConfirmTouched:nil];
-//    }
-//    if ([textField isEqual:_txtMonth]) {
-//        [_txtDay becomeFirstResponder];
-//    }
-//    if ([textField isEqual:_txtYear]) {
-//        [_txtMonth becomeFirstResponder];
-//    }
+    if ([textField isEqual:_txtDay]) {
+        [self btnConfirmTouched:nil];
+    }
+    if ([textField isEqual:_txtMonth]) {
+        [_txtDay becomeFirstResponder];
+    }
+    if ([textField isEqual:_txtYear]) {
+        [_txtMonth becomeFirstResponder];
+    }
+    return YES;
+}
+
+- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
+    if ([textField isEqual:_txtYear]) {
+        if (textField.text.length >= 4 && range.length == 0) {
+            return NO;
+        }
+    }
+    else {
+        if (textField.text.length >= 2 && range.length == 0) {
+            return NO;
+        }
+    }
     return YES;
 }
+
 @end

+ 1 - 1
OneCable/Classes/ViewControllers/HomeMemberScreens/CustomDatePopupView.xib

@@ -401,7 +401,7 @@
                     </constraints>
                 </view>
             </subviews>
-            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
             <constraints>
                 <constraint firstItem="msZ-wh-3zf" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="3gK-Sd-jX3"/>
                 <constraint firstItem="eSV-eh-PVb" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="7hN-dF-P1q"/>

+ 21 - 1
OneCable/Classes/ViewControllers/HomeMemberScreens/HomeMemberAddViewController.m

@@ -14,6 +14,8 @@
 #import "CustomLabel.h"
 #import "DatePickerButton.h"
 
+#import "CustomDatePopupView.h"
+
 #import "CustomTextField.h"
 #import "ValidateUtil.h"
 
@@ -104,6 +106,8 @@
     
     DataSelectListModel *_quizList;
     DataSelectModel *_selectedQuiz;
+    
+    CustomDatePopupView *_popDate;
 }
 @end
 
@@ -289,6 +293,9 @@
         _txtQuestion.delegate = self;
         _btnDate = !_btnDate ? tcell.btnDate : _btnDate;
         
+        tcell.btnDate.isHidePicker = YES;
+//        [tcell.btnDate addTarget:self action:@selector(showDatePopup) forControlEvents:UIControlEventTouchUpInside];
+        
         _txtDirectQuiz = !_txtDirectQuiz ? tcell.txtSelfQuiz : _txtDirectQuiz;
         _txtDirectQuiz.delegate = self;
         
@@ -296,12 +303,12 @@
             QuizModel *info = (QuizModel *)_selectedQuiz.value;
             [tcell showDirectInputArea:[info isUserEditQuiz]];
             _txtQuestion.text = _selectedQuiz.title;
-            NSLog(@"표시");
         }
         else {
             [tcell showDirectInputArea:NO];
         }
         
+        
 //        if (_txtQuestion.customTextFieldSuperview != CustomTextFieldSuperviewIsScrollView) {
 //            _txtQuestion.customTextFieldSuperview = CustomTextFieldSuperviewIsScrollView;
 //        }
@@ -385,6 +392,7 @@
     [_tableView reloadData];
 }
 
+
 - (IBAction)btnSendTouched:(id)sender {
     //1.validate
 
@@ -430,6 +438,18 @@
 }
 
 
+-(void)showDatePopup {
+//    if (_popDate == nil) {
+//        _popDate = [[CustomDatePopupView alloc] initWithTitle:@"정답 날짜 입력"];
+//    }
+//    
+//    [_popDate showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
+//        if (buttonIndex == 0) {//OK
+//            NSLog(@"Input Date : %@.%@.%@", _popDate.txtYear.text, _popDate.txtMonth.text, _popDate.txtDay.text);
+//        }
+//    }];
+}
+
 
 #pragma mark - UITextField Delegate