Skip to content

Commit 26b81ab

Browse files
authored
Infra/keyboard fixes (#1913)
* lib - remove unused code and unnecessary changes * demo - rename screen to reflect the component used * Demo - renaming sub-folder * demo - clean screen errors * dependencies - removing `react-native-keyboard-tracking-view` from dev's * Demo screens cleanup * reverting and updating comment * migrating TextField
1 parent 850dadb commit 26b81ab

File tree

8 files changed

+52
-79
lines changed

8 files changed

+52
-79
lines changed

demo/src/screens/MenuStructure.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export const navigationData = {
135135
tags: 'KeyboardTracking',
136136
screen: 'unicorn.nativeComponents.KeyboardTrackingViewScreen'
137137
},
138-
{title: 'KeyboardAccessoryView', tags: 'KeyboardInput', screen: 'unicorn.nativeComponents.KeyboardInputViewScreen'}
138+
{title: 'KeyboardAccessoryView', tags: 'KeyboardInput', screen: 'unicorn.nativeComponents.KeyboardAccessoryViewScreen'}
139139
]
140140
},
141141
AnimationsAndGestures: {

demo/src/screens/nativeComponentScreens/KeyboardTrackingViewScreen.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1+
import _ from 'lodash';
12
import React, {PureComponent} from 'react';
23
import {ScrollView, StyleSheet} from 'react-native';
34
import {
5+
Constants,
6+
Colors,
7+
Spacings,
48
Keyboard,
5-
Text,
69
View,
10+
Text,
711
TextField,
8-
Image,
912
Button,
10-
Colors,
11-
Switch,
12-
Constants,
13-
Spacings
13+
Switch
1414
} from 'react-native-ui-lib';
15-
import _ from 'lodash';
1615

1716
const KeyboardTrackingView = Keyboard.KeyboardTrackingView;
18-
1917
const messages = [
2018
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
2119
'integer feugiat scelerisque varius morbi enim nunc faucibus a pellentesque sit amet porttitor eget dolor',
@@ -68,6 +66,7 @@ export default class KeyboardTrackingViewScreen extends PureComponent {
6866
<ScrollView
6967
contentContainerStyle={styles.scrollContainer}
7068
keyboardDismissMode={trackInteractive ? 'interactive' : 'none'}
69+
showsVerticalScrollIndicator={false}
7170
>
7271
<Text h1 grey10 marginB-s1>
7372
Keyboard Tracking View
@@ -88,23 +87,18 @@ export default class KeyboardTrackingViewScreen extends PureComponent {
8887
<KeyboardTrackingView
8988
style={styles.trackingToolbarContainer}
9089
trackInteractive={trackInteractive}
90+
useSafeArea
9191
>
9292
<View bg-white row spread centerV paddingH-s5 paddingV-s3>
9393
<TextField
94-
containerStyle={{
95-
flex: 1,
96-
backgroundColor: Colors.grey60,
97-
paddingVertical: Spacings.s2,
98-
paddingHorizontal: Spacings.s4,
99-
borderRadius: 8
100-
}}
101-
hideUnderline
94+
migrate
95+
containerStyle={styles.textField}
96+
preset={null}
10297
placeholder={'Message'}
10398
floatingPlaceholder={false}
104-
floatOnFocus
10599
enableErrors={false}
106100
/>
107-
<Button label="Send" link marginL-s4 />
101+
<Button label="Send" link marginL-s4/>
108102
</View>
109103
</KeyboardTrackingView>
110104
</View>
@@ -116,15 +110,18 @@ const styles = StyleSheet.create({
116110
scrollContainer: {
117111
paddingHorizontal: Spacings.s5
118112
},
119-
image: {
120-
height: 250,
121-
marginBottom: Spacings.s3
122-
},
123113
trackingToolbarContainer: {
124114
position: Constants.isIOS ? 'absolute' : 'relative',
125115
bottom: 0,
126116
width: '100%',
127117
borderWidth: 1,
128118
borderColor: Colors.grey60
119+
},
120+
textField: {
121+
flex: 1,
122+
backgroundColor: Colors.grey60,
123+
paddingVertical: Spacings.s2,
124+
paddingHorizontal: Spacings.s4,
125+
borderRadius: 8
129126
}
130127
});

demo/src/screens/nativeComponentScreens/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ export function registerScreens(registrar) {
33
registrar('unicorn.nativeComponents.SafeAreaSpacerViewScreen', () => require('./SafeAreaSpacerViewScreen').default);
44
registrar('unicorn.nativeComponents.WheelPickerViewScreen', () => require('./WheelPickerViewScreen').default);
55
registrar('unicorn.nativeComponents.KeyboardTrackingViewScreen', () => require('./KeyboardTrackingViewScreen').default);
6-
registrar('unicorn.nativeComponents.KeyboardInputViewScreen', () => require('./keyboardInput/KeyboardInputViewScreen').default);
6+
registrar('unicorn.nativeComponents.KeyboardAccessoryViewScreen', () => require('./keyboardAccessory/KeyboardAccessoryViewScreen').default);
77
}
8-

demo/src/screens/nativeComponentScreens/keyboardInput/KeyboardInputViewScreen.js renamed to demo/src/screens/nativeComponentScreens/keyboardAccessory/KeyboardAccessoryViewScreen.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1+
import _ from 'lodash';
12
import React, {PureComponent} from 'react';
2-
import {ScrollView, StyleSheet, TextInput} from 'react-native';
3+
import {ScrollView, StyleSheet} from 'react-native';
34
import {
4-
Keyboard,
5-
Text,
6-
View,
5+
Constants,
6+
Assets,
77
Colors,
88
Spacings,
9-
Constants,
10-
Typography,
9+
Keyboard,
10+
View,
11+
Text,
12+
TextField,
1113
Button,
12-
Switch,
13-
Assets
14+
Switch
1415
} from 'react-native-ui-lib';
15-
import _ from 'lodash';
1616
import './demoKeyboards';
1717

1818
const KeyboardAccessoryView = Keyboard.KeyboardAccessoryView;
1919
const KeyboardUtils = Keyboard.KeyboardUtils;
2020
const KeyboardRegistry = Keyboard.KeyboardRegistry;
2121
const TrackInteractive = true;
2222

23-
const keyboards = [
23+
const demoKeyboards = [
2424
{
2525
id: 'unicorn.ImagesKeyboard',
2626
icon: Assets.icons.demo.image
@@ -31,7 +31,7 @@ const keyboards = [
3131
}
3232
];
3333

34-
export default class KeyboardInputViewScreen extends PureComponent {
34+
export default class KeyboardAccessoryViewScreen extends PureComponent {
3535
state = {
3636
customKeyboard: {
3737
component: undefined,
@@ -105,21 +105,24 @@ export default class KeyboardInputViewScreen extends PureComponent {
105105
renderKeyboardAccessoryViewContent = () => {
106106
return (
107107
<View style={styles.keyboardContainer} paddingV-s4>
108-
<View row paddingH-s4>
109-
<TextInput
110-
style={styles.textInput}
108+
<View bg-white row spread centerV paddingH-s5 paddingV-s3>
109+
<TextField
110+
migrate
111111
ref={r => {
112112
this.textInputRef = r;
113113
}}
114+
containerStyle={styles.textField}
115+
preset={null}
114116
placeholder={'Message'}
115-
underlineColorAndroid="transparent"
117+
floatingPlaceholder={false}
118+
enableErrors={false}
116119
onFocus={this.resetKeyboardView}
117120
/>
118121
<Button link grey10 iconSource={Assets.icons.demo.close} onPress={KeyboardUtils.dismiss} marginL-s2/>
119122
</View>
120123
<View row paddingH-s4 marginT-s2 spread>
121124
<View row>
122-
{keyboards.map(keyboard => (
125+
{demoKeyboards.map(keyboard => (
123126
<Button
124127
key={keyboard.id}
125128
grey10
@@ -170,7 +173,7 @@ export default class KeyboardInputViewScreen extends PureComponent {
170173
};
171174

172175
render() {
173-
const {message, isModal} = this.props;
176+
const {message/* , isModal */} = this.props;
174177
const {receivedKeyboardData, customKeyboard, useSafeArea} = this.state;
175178

176179
return (
@@ -181,6 +184,7 @@ export default class KeyboardInputViewScreen extends PureComponent {
181184
<ScrollView
182185
contentContainerStyle={styles.scrollContainer}
183186
keyboardDismissMode={TrackInteractive ? 'interactive' : 'none'}
187+
showsVerticalScrollIndicator={false}
184188
>
185189
<Text text40 grey10 marginV-20 center>
186190
{message}
@@ -202,7 +206,7 @@ export default class KeyboardInputViewScreen extends PureComponent {
202206
revealKeyboardInteractive
203207
onRequestShowKeyboard={this.onRequestShowKeyboard}
204208
useSafeArea={useSafeArea}
205-
usesBottomTabs={!isModal}
209+
// usesBottomTabs={!isModal}
206210
/>
207211
</View>
208212
);
@@ -215,13 +219,11 @@ const styles = StyleSheet.create({
215219
flex: 1,
216220
justifyContent: 'center'
217221
},
218-
textInput: {
222+
textField: {
219223
flex: 1,
220-
paddingVertical: Spacings.s2,
221-
paddingHorizontal: Spacings.s3,
222-
...Typography.text70,
223-
lineHeight: undefined,
224224
backgroundColor: Colors.grey60,
225+
paddingVertical: Spacings.s2,
226+
paddingHorizontal: Spacings.s4,
225227
borderRadius: 8
226228
},
227229
button: {

demo/src/screens/nativeComponentScreens/keyboardInput/demoKeyboards.js renamed to demo/src/screens/nativeComponentScreens/keyboardAccessory/demoKeyboards.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import _ from 'lodash';
12
import React from 'react';
23
import {ScrollView} from 'react-native';
34
import {Keyboard, View, Text, Image, Spacings} from 'react-native-ui-lib';
4-
import _ from 'lodash';
5-
const KeyboardRegistry = Keyboard.KeyboardRegistry;
65

6+
const KeyboardRegistry = Keyboard.KeyboardRegistry;
77
const images = [
88
'https://images.pexels.com/photos/1148521/pexels-photo-1148521.jpeg?auto=compress&cs=tinysrgb&dpr=1&h=200',
99
'https://images.pexels.com/photos/1528975/pexels-photo-1528975.jpeg?auto=compress&cs=tinysrgb&dpr=1&h=200',
@@ -43,11 +43,5 @@ function CustomKeyboard() {
4343
);
4444
}
4545

46-
KeyboardRegistry.registerKeyboard(
47-
'unicorn.ImagesKeyboard',
48-
() => ImagesKeyboard
49-
);
50-
KeyboardRegistry.registerKeyboard(
51-
'unicorn.CustomKeyboard',
52-
() => CustomKeyboard
53-
);
46+
KeyboardRegistry.registerKeyboard('unicorn.ImagesKeyboard', () => ImagesKeyboard);
47+
KeyboardRegistry.registerKeyboard('unicorn.CustomKeyboard', () => CustomKeyboard);

lib/components/Keyboard/KeyboardInput/KeyboardAccessoryView.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,11 @@ export type KeyboardAccessoryViewProps = {
113113
* default: true
114114
*/
115115
useSafeArea?: boolean;
116+
116117
/**
117118
* iOS only.
118119
* Whether or not to include bottom tab bat inset
119-
* default: true
120+
* default: false
120121
*/
121122
usesBottomTabs?: boolean;
122123

lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -505,30 +505,11 @@ - (void) rctContentDidAppearNotification:(NSNotification*)notification
505505
});
506506
}
507507

508-
#pragma mark - root view controller and presenting style
509-
510-
511-
- (BOOL)isModal {
512-
UIWindow *window = UIApplication.sharedApplication.windows.firstObject;
513-
UIViewController *presentedViewController = window.rootViewController.presentedViewController;
514-
515-
if (presentedViewController != nil) {
516-
if ([presentedViewController isKindOfClass:[UINavigationController class]]) {
517-
UINavigationController *presented = (UINavigationController*)presentedViewController;
518-
if (presented.visibleViewController) {
519-
return YES;
520-
}
521-
}
522-
}
523-
return NO;
524-
}
525-
526508
#pragma mark - TabBarController
527509

528510
-(CGFloat)getTabBarHeight
529511
{
530512
if (@available(iOS 11.0, *)) {
531-
NSLog(@"INBAL usesBottomTabs: %d", self.usesBottomTabs);
532513
if (self.usesBottomTabs == YES)
533514
{
534515
UITabBarController *tabBarController = [UITabBarController new];

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
"react-native": "0.66.4",
104104
"react-native-gesture-handler": "2.1.1",
105105
"react-native-haptic-feedback": "^1.11.0",
106-
"react-native-keyboard-tracking-view": "^5.6.1",
107106
"react-native-linear-gradient": "2.5.6",
108107
"react-native-navigation": "^7.19.1",
109108
"react-native-reanimated": "2.4.1",

0 commit comments

Comments
 (0)