Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducting
RCTTextInput
, base class for both text inputs
Summary: Some basic same to both classes functionality was moved to base class, and it is just a beginning. Reviewed By: mmmulani Differential Revision: D5144429 fbshipit-source-id: 56c6400d46f4cf3c0058fe936cba524dd5d490df
- Loading branch information
1 parent
6ba8e29
commit 3364488
Showing
7 changed files
with
116 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
#import <RCTText/RCTBackedTextInputViewProtocol.h> | ||
#import <React/RCTView.h> | ||
|
||
@class RCTBridge; | ||
@class RCTEventDispatcher; | ||
|
||
@interface RCTTextInput : RCTView { | ||
@protected | ||
RCTBridge *_bridge; | ||
RCTEventDispatcher *_eventDispatcher; | ||
} | ||
|
||
- (instancetype)initWithBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER; | ||
|
||
- (instancetype)init NS_UNAVAILABLE; | ||
- (instancetype)initWithCoder:(NSCoder *)decoder NS_UNAVAILABLE; | ||
- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE; | ||
|
||
@property (nonatomic, readonly) UIView<RCTBackedTextInputViewProtocol> *backedTextInputView; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#import "RCTTextInput.h" | ||
|
||
#import <React/RCTBridge.h> | ||
#import <React/RCTConvert.h> | ||
#import <React/RCTEventDispatcher.h> | ||
#import <React/RCTUtils.h> | ||
#import <React/UIView+React.h> | ||
|
||
@implementation RCTTextInput | ||
|
||
- (instancetype)initWithBridge:(RCTBridge *)bridge | ||
{ | ||
RCTAssertParam(bridge); | ||
|
||
if (self = [super initWithFrame:CGRectZero]) { | ||
_bridge = bridge; | ||
_eventDispatcher = bridge.eventDispatcher; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
RCT_NOT_IMPLEMENTED(- (instancetype)init) | ||
RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)decoder) | ||
RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) | ||
|
||
- (id<RCTBackedTextInputViewProtocol>)backedTextInputView | ||
{ | ||
RCTAssert(NO, @"-[RCTTextInput backedTextInputView] must be implemented in subclass."); | ||
return nil; | ||
} | ||
|
||
#pragma mark - Accessibility | ||
|
||
- (UIView *)reactAccessibleView | ||
{ | ||
return self.backedTextInputView; | ||
} | ||
|
||
#pragma mark - Focus Control | ||
|
||
- (void)reactFocus | ||
{ | ||
[self.backedTextInputView reactFocus]; | ||
} | ||
|
||
- (void)reactBlur | ||
{ | ||
[self.backedTextInputView reactBlur]; | ||
} | ||
|
||
- (void)didMoveToWindow | ||
{ | ||
[self.backedTextInputView reactFocusIfNeeded]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters