Replace js Dimensions with shadow view in InputAccessoryViewExample

Reviewed By: mmmulani

Differential Revision: D7196168

fbshipit-source-id: 031ed5ab24d1075f775ec71e5b78d32e03fe8f6f
This commit is contained in:
Peter Argany 2018-03-15 09:58:16 -07:00 committed by Facebook Github Bot
parent 8e85bf84e8
commit 139d554c48
4 changed files with 29 additions and 3 deletions

View File

@ -0,0 +1,7 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#import <React/RCTShadowView.h>
@interface RCTInputAccessoryShadowView : RCTShadowView
@end

View File

@ -0,0 +1,15 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#import "RCTInputAccessoryShadowView.h"
#import <React/RCTUtils.h>
@implementation RCTInputAccessoryShadowView
- (void)insertReactSubview:(RCTShadowView *)subview atIndex:(NSInteger)atIndex
{
[super insertReactSubview:subview atIndex:atIndex];
subview.width = (YGValue) { RCTScreenSize().width, YGUnitPoint };
}
@end

View File

@ -7,6 +7,7 @@
#import "RCTInputAccessoryViewManager.h" #import "RCTInputAccessoryViewManager.h"
#import "RCTInputAccessoryShadowView.h"
#import "RCTInputAccessoryView.h" #import "RCTInputAccessoryView.h"
@implementation RCTInputAccessoryViewManager @implementation RCTInputAccessoryViewManager
@ -23,6 +24,11 @@ RCT_EXPORT_MODULE()
return [[RCTInputAccessoryView alloc] initWithBridge:self.bridge]; return [[RCTInputAccessoryView alloc] initWithBridge:self.bridge];
} }
- (RCTShadowView *)shadowView
{
return [RCTInputAccessoryShadowView new];
}
RCT_REMAP_VIEW_PROPERTY(backgroundColor, inputAccessoryView.backgroundColor, UIColor) RCT_REMAP_VIEW_PROPERTY(backgroundColor, inputAccessoryView.backgroundColor, UIColor)
@end @end

View File

@ -13,7 +13,6 @@
const Alert = require('Alert'); const Alert = require('Alert');
const Button = require('Button'); const Button = require('Button');
const Dimensions = require('Dimensions');
const InputAccessoryView = require('InputAccessoryView'); const InputAccessoryView = require('InputAccessoryView');
const React = require('React'); const React = require('React');
const ScrollView = require('ScrollView'); const ScrollView = require('ScrollView');
@ -36,9 +35,8 @@ class TextInputBar extends React.PureComponent<*, *> {
state = {text: ''}; state = {text: ''};
render() { render() {
const {width} = Dimensions.get('window');
return ( return (
<View style={[styles.textInputContainer, {width}]}> <View style={styles.textInputContainer}>
<TextInput <TextInput
style={styles.textInput} style={styles.textInput}
onChangeText={text => { onChangeText={text => {