Jelajahi Sumber

06.13 hub wifi password view > image loading 추가

eunmi.kim 8 tahun lalu
induk
melakukan
2d2a0b0373

+ 22 - 0
OneCable/Base.lproj/HomeHub.storyboard

@@ -3553,6 +3553,25 @@
                                             <constraint firstAttribute="height" constant="48" id="zrb-ZJ-g7z"/>
                                         </constraints>
                                     </view>
+                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Am2-Zt-8r5">
+                                        <rect key="frame" x="132.5" y="256" width="55" height="55"/>
+                                        <subviews>
+                                            <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="loading_count" translatesAutoresizingMaskIntoConstraints="NO" id="QZa-Ly-BbS" customClass="CustomImageView">
+                                                <rect key="frame" x="0.0" y="0.0" width="55" height="55"/>
+                                                <constraints>
+                                                    <constraint firstAttribute="width" constant="55" id="Fc2-uG-QoR"/>
+                                                </constraints>
+                                            </imageView>
+                                        </subviews>
+                                        <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
+                                        <constraints>
+                                            <constraint firstItem="QZa-Ly-BbS" firstAttribute="centerX" secondItem="Am2-Zt-8r5" secondAttribute="centerX" id="GXB-aV-7iK"/>
+                                            <constraint firstAttribute="height" constant="55" id="TCH-j5-cCb"/>
+                                            <constraint firstItem="QZa-Ly-BbS" firstAttribute="top" secondItem="Am2-Zt-8r5" secondAttribute="top" id="UcR-9j-6tx"/>
+                                            <constraint firstAttribute="width" constant="55" id="uqR-sq-bO5"/>
+                                            <constraint firstAttribute="bottom" secondItem="QZa-Ly-BbS" secondAttribute="bottom" id="yA5-S9-fy7"/>
+                                        </constraints>
+                                    </view>
                                     <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="G58-uh-jqN">
                                         <rect key="frame" x="0.0" y="224" width="320" height="25"/>
                                         <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
@@ -3577,6 +3596,7 @@
                                     <constraint firstItem="ezw-VV-aTX" firstAttribute="leading" secondItem="dsV-hC-2n2" secondAttribute="leading" id="OeF-EV-0Zd"/>
                                     <constraint firstAttribute="trailing" secondItem="6yL-XF-YUf" secondAttribute="trailing" id="Ofd-vp-Q10"/>
                                     <constraint firstItem="g9r-0m-uhi" firstAttribute="leading" secondItem="dsV-hC-2n2" secondAttribute="leading" id="PGe-ez-Nzc"/>
+                                    <constraint firstItem="Am2-Zt-8r5" firstAttribute="centerX" secondItem="dsV-hC-2n2" secondAttribute="centerX" id="PQa-yS-iCa"/>
                                     <constraint firstAttribute="trailing" secondItem="g9r-0m-uhi" secondAttribute="trailing" id="PpY-Vv-SPs"/>
                                     <constraint firstItem="TXY-Yd-h0J" firstAttribute="leading" secondItem="dsV-hC-2n2" secondAttribute="leading" id="Swo-xX-hZ8"/>
                                     <constraint firstItem="3eL-ns-Cs9" firstAttribute="leading" secondItem="dsV-hC-2n2" secondAttribute="leading" id="Txc-bZ-ie9"/>
@@ -3586,6 +3606,7 @@
                                     <constraint firstItem="TXY-Yd-h0J" firstAttribute="top" secondItem="XfO-eZ-e1m" secondAttribute="bottom" id="ZkB-yd-7us"/>
                                     <constraint firstItem="aQT-cN-4aZ" firstAttribute="top" secondItem="XfO-eZ-e1m" secondAttribute="bottom" id="bpi-Ni-hrK"/>
                                     <constraint firstItem="6yL-XF-YUf" firstAttribute="leading" secondItem="dsV-hC-2n2" secondAttribute="leading" id="bxp-zW-ezH"/>
+                                    <constraint firstItem="Am2-Zt-8r5" firstAttribute="centerY" secondItem="dsV-hC-2n2" secondAttribute="centerY" id="dSP-i8-3NN"/>
                                     <constraint firstAttribute="trailing" secondItem="XfO-eZ-e1m" secondAttribute="trailing" id="fKr-aN-9PV"/>
                                     <constraint firstItem="HjG-Z5-uJe" firstAttribute="top" secondItem="XfO-eZ-e1m" secondAttribute="bottom" id="ixL-Xa-Le3"/>
                                     <constraint firstAttribute="trailing" secondItem="boA-qP-u3f" secondAttribute="trailing" id="jHA-gR-5hc"/>
@@ -3619,6 +3640,7 @@
                         <outlet property="btnAgainSearch" destination="d0C-YF-cCi" id="NmE-Iq-PO2"/>
                         <outlet property="btnCancel" destination="r20-cX-dsB" id="x3W-Ov-zH5"/>
                         <outlet property="btnConnect" destination="bwE-NK-kdt" id="17r-3u-7YT"/>
+                        <outlet property="imgvLoading" destination="QZa-Ly-BbS" id="Zt4-Fs-xH7"/>
                         <outlet property="lblSSID" destination="I1t-bf-fka" id="cev-NQ-Y3t"/>
                         <outlet property="txtInputPasswd" destination="vKi-MT-6va" id="evn-js-D4w"/>
                     </connections>

+ 1 - 0
OneCable/Classes/ViewControllers/HomeHubScreens/HomeHubWifiPasswdInputViewController.h

@@ -18,6 +18,7 @@
 @property (weak, nonatomic) IBOutlet CustomTextField *txtInputPasswd;  // Passwd 입력 필드
 @property (weak, nonatomic) IBOutlet CustomButton *btnCancel;  // 취소 버튼
 @property (weak, nonatomic) IBOutlet CustomButton *btnConnect;  // 연결 버튼
+@property (weak, nonatomic) IBOutlet CustomImageView *imgvLoading;  // 로딩 이미지
 
 @property (strong, nonatomic) BLEWLanModel *selectedWLanModel;
 

+ 61 - 2
OneCable/Classes/ViewControllers/HomeHubScreens/HomeHubWifiPasswdInputViewController.m

@@ -11,6 +11,9 @@
 
 @interface HomeHubWifiPasswdInputViewController ()<UITextFieldDelegate> {
     
+    NSTimer *_timer;
+    NSInteger _elapsedSeconds;
+    
     BLEServiceHandler *bleService;
 
     BOOL updateSSID;
@@ -36,6 +39,7 @@
 - (void)initUI {
     
     _lblSSID.text = [NSString stringWithFormat:@"SSID : %@", _selectedWLanModel.ssid];
+    _imgvLoading.hidden = YES;
     
 }
 
@@ -54,6 +58,58 @@
     
 }
 
+-(void)startLoading:(BOOL)isStart {
+    
+    _imgvLoading.hidden = !isStart;
+    
+    if (isStart) {
+        
+        _elapsedSeconds = kMaxTimeOut;
+       
+        if (!_timer) {
+            _timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(updateInclusionStatus) userInfo:nil repeats:YES];
+        }
+        
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+            if ([_imgvLoading.layer animationForKey:@"SpinAnimation"] == nil) {
+                CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
+                animation.fromValue = [NSNumber numberWithFloat:0.0f];
+                animation.toValue = [NSNumber numberWithFloat: 2*M_PI];
+                animation.duration = 2.0f;
+                animation.repeatCount = INFINITY;
+                [_imgvLoading.layer addAnimation:animation forKey:@"SpinAnimation"];
+            }
+        });
+    }
+    else {
+        
+        _elapsedSeconds = kMaxTimeOut;
+        
+        if (_timer) {
+            [_timer invalidate];
+            _timer = nil;
+        }
+        if ([_imgvLoading.layer animationForKey:@"SpinAnimation"] != nil) {
+            [_imgvLoading.layer removeAnimationForKey:@"SpinAnimation"];
+        }
+        
+    }
+    
+}
+
+- (void)updateInclusionStatus {
+    
+        dispatch_async(dispatch_get_main_queue(), ^(void) {
+    
+            _elapsedSeconds--;
+    
+            if (_elapsedSeconds == 0) {
+                
+                [self startLoading:NO];
+            }
+        });
+}
+
 #pragma mark - User Event
 - (IBAction)btnAgainTouched:(id)sender {
     
@@ -86,7 +142,7 @@
         return;
     }
     
- 
+    [self startLoading:YES];
     [bleService setWiFiPwd:pass];
     [bleService enableDHCP];
     [bleService readAndNotifyCharacteristicUUID:kBLEChrStDHCPArg isNotify:NO];
@@ -106,6 +162,7 @@
     
     if (textField.text.length > 0) {
         
+        [self.view endEditing:YES];
         [self btnConnectTouched:nil];
     }
     
@@ -162,7 +219,9 @@
     
     // 연결 확인 완료
     if (updateSSID && updateBSSID && updateIPSet && updateIPAddr) {
- 
+        
+        [self startLoading:NO];
+        
         UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubUpdateCompleteViewController" storyboardName:@"HomeHub"];
         
         [self.navigationController pushViewController:vc animated:YES];