You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2018/03/06 04:03:49 UTC

incubator-weex git commit: * [iOS] move up WXRootView according to configuraiton

Repository: incubator-weex
Updated Branches:
  refs/heads/master 2fa5833ea -> e9d5e3f2a


* [iOS] move up WXRootView according to configuraiton


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/e9d5e3f2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/e9d5e3f2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/e9d5e3f2

Branch: refs/heads/master
Commit: e9d5e3f2adcae94858af2e5e54ca49f72be82149
Parents: 2fa5833
Author: acton393 <zh...@gmail.com>
Authored: Sun Feb 11 14:09:48 2018 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Tue Mar 6 12:02:16 2018 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Component/WXEditComponent.m | 48 +++++++++++++-------
 1 file changed, 31 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e9d5e3f2/ios/sdk/WeexSDK/Sources/Component/WXEditComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXEditComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXEditComponent.m
index 0cb9039..f2d6c99 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXEditComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXEditComponent.m
@@ -69,6 +69,9 @@
 @property (nonatomic, strong) NSString * recoverReplace;
 @property (nonatomic, strong) NSDictionary * formaterData;
 
+// disable move rootView up as the keyboard show up.
+@property (nonatomic, assign) BOOL disableMoveViewUp;
+
 @end
 
 @implementation WXEditComponent
@@ -118,6 +121,9 @@ WX_EXPORT_METHOD(@selector(setTextFormatter:))
         if (attributes[@"hideDoneButton"]) {
             _hideDoneButton = [attributes[@"hideDoneButton"] boolValue];
         }
+        if (attributes[@"disableMoveViewUp"]) {
+            _disableMoveViewUp = [WXConvert BOOL:attributes[@"disableMoveViewUp"]];
+        }
         
         // handle styles
         if (styles[@"color"]) {
@@ -406,6 +412,10 @@ WX_EXPORT_METHOD(@selector(setTextFormatter:))
     if (attributes[@"maxlength"]) {
         _maxLength = [NSNumber numberWithInteger:[attributes[@"maxlength"] integerValue]];
     }
+    
+    if (attributes[@"disableMoveViewUp"]) {
+        _disableMoveViewUp = [WXConvert BOOL:attributes[@"disableMoveViewUp"]];
+    }
     if (attributes[@"value"]) {
         _value = [WXConvert NSString:attributes[@"value"]]?:@"";
         if (_maxLength && [_value length] > [_maxLength integerValue]&& [_maxLength integerValue] >= 0) {
@@ -849,19 +859,21 @@ WX_EXPORT_METHOD(@selector(setTextFormatter:))
     if(![self.view isFirstResponder]) {
         return;
     }
-    CGRect end = [[[notification userInfo] objectForKey:@"UIKeyboardFrameEndUserInfoKey"] CGRectValue];
-    _keyboardSize = end.size;
-    UIView * rootView = self.weexInstance.rootView;
-    CGRect screenRect = [[UIScreen mainScreen] bounds];
-    CGRect keyboardRect = (CGRect){
-        .origin.x = 0,
-        .origin.y = CGRectGetMaxY(screenRect) - _keyboardSize.height - 54,
-        .size = _keyboardSize
-    };
-    CGRect inputFrame = [self.view.superview convertRect:self.view.frame toView:rootView];
-    if (keyboardRect.origin.y - inputFrame.size.height <= inputFrame.origin.y) {
-        [self setViewMovedUp:YES];
-        self.weexInstance.isRootViewFrozen = YES;
+    if (!_disableMoveViewUp) {
+        CGRect end = [[[notification userInfo] objectForKey:@"UIKeyboardFrameEndUserInfoKey"] CGRectValue];
+        _keyboardSize = end.size;
+        UIView * rootView = self.weexInstance.rootView;
+        CGRect screenRect = [[UIScreen mainScreen] bounds];
+        CGRect keyboardRect = (CGRect){
+            .origin.x = 0,
+            .origin.y = CGRectGetMaxY(screenRect) - _keyboardSize.height - 54,
+            .size = _keyboardSize
+        };
+        CGRect inputFrame = [self.view.superview convertRect:self.view.frame toView:rootView];
+        if (keyboardRect.origin.y - inputFrame.size.height <= inputFrame.origin.y) {
+            [self setViewMovedUp:YES];
+            self.weexInstance.isRootViewFrozen = YES;
+        }
     }
     
     if (_keyboardEvent) {
@@ -874,10 +886,12 @@ WX_EXPORT_METHOD(@selector(setTextFormatter:))
     if (![self.view isFirstResponder]) {
         return;
     }
-    UIView * rootView = self.weexInstance.rootView;
-    if (!CGRectEqualToRect(self.weexInstance.frame, rootView.frame)) {
-        [self setViewMovedUp:NO];
-        self.weexInstance.isRootViewFrozen = NO;
+    if (!_disableMoveViewUp) {
+        UIView * rootView = self.weexInstance.rootView;
+        if (!CGRectEqualToRect(self.weexInstance.frame, rootView.frame)) {
+            [self setViewMovedUp:NO];
+            self.weexInstance.isRootViewFrozen = NO;
+        }
     }
     if (_keyboardEvent) {
         [self fireEvent:@"keyboard" params:@{ @"isShow": @NO }];