Skip to content

Commit 07b975b

Browse files
committed
Mostly prettify
1 parent cdc3cee commit 07b975b

File tree

6 files changed

+42
-37
lines changed

6 files changed

+42
-37
lines changed

lib/components/Keyboard/KeyboardInput/KeyboardAccessoryView.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
3-
import {StyleSheet, Platform, NativeModules, NativeEventEmitter, DeviceEventEmitter, processColor, BackHandler} from 'react-native';
3+
import {
4+
StyleSheet,
5+
Platform,
6+
NativeModules,
7+
NativeEventEmitter,
8+
DeviceEventEmitter,
9+
processColor,
10+
BackHandler
11+
} from 'react-native';
412
import KeyboardTrackingView from '../KeyboardTracking/KeyboardTrackingView';
513
import CustomKeyboardView from './CustomKeyboardView';
614
import KeyboardUtils from './utils/KeyboardUtils';
@@ -28,15 +36,15 @@ class KeyboardAccessoryView extends Component {
2836
manageScrollView: PropTypes.bool,
2937
requiresSameParentToManageScrollView: PropTypes.bool,
3038
addBottomView: PropTypes.bool,
31-
allowHitsOutsideBounds: PropTypes.bool,
39+
allowHitsOutsideBounds: PropTypes.bool
3240
};
3341
static defaultProps = {
3442
iOSScrollBehavior: -1,
3543
revealKeyboardInteractive: false,
3644
manageScrollView: true,
3745
requiresSameParentToManageScrollView: false,
3846
addBottomView: false,
39-
allowHitsOutsideBounds: false,
47+
allowHitsOutsideBounds: false
4048
};
4149

4250
constructor(props) {
@@ -133,7 +141,7 @@ class KeyboardAccessoryView extends Component {
133141
render() {
134142
return (
135143
<KeyboardTrackingView
136-
ref={r => this.trackingViewRef = r}
144+
ref={r => (this.trackingViewRef = r)}
137145
style={styles.trackingToolbarContainer}
138146
onLayout={this.onContainerComponentHeightChanged}
139147
scrollBehavior={this.getIOSTrackingScrollBehavior()}
@@ -160,13 +168,11 @@ const styles = StyleSheet.create({
160168
trackingToolbarContainer: {
161169
...Platform.select({
162170
ios: {
163-
position: 'absolute',
164-
bottom: 0,
165-
left: 0,
166-
right: 0,
167-
},
168-
}),
169-
},
171+
...StyleSheet.absoluteFillObject,
172+
top: undefined
173+
}
174+
})
175+
}
170176
});
171177

172178
export default KeyboardAccessoryView;

lib/components/Keyboard/KeyboardInput/KeyboardRegistry.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import _ from 'lodash';
33
import EventEmitterManager from './utils/EventEmitterManager';
44

55
/*
6-
* Tech debt: how to deal with multiple registries in the app?
7-
*/
6+
* Tech debt: how to deal with multiple registries in the app?
7+
*/
88

9-
const getKeyboardsWithIDs = (keyboardIDs) => {
10-
return keyboardIDs.map((keyboardId) => {
9+
const getKeyboardsWithIDs = keyboardIDs => {
10+
return keyboardIDs.map(keyboardId => {
1111
return {
1212
id: keyboardId,
13-
...KeyboardRegistry.registeredKeyboards[keyboardId].params,
13+
...KeyboardRegistry.registeredKeyboards[keyboardId].params
1414
};
1515
});
1616
};
@@ -21,17 +21,17 @@ export default class KeyboardRegistry {
2121

2222
static registerKeyboard = (componentID, generator, params = {}) => {
2323
if (!_.isFunction(generator)) {
24-
console.error(`KeyboardRegistry.registerKeyboard: ${componentID} you must register a generator function`);//eslint-disable-line
24+
console.error(`KeyboardRegistry.registerKeyboard: ${componentID} you must register a generator function`);
2525
return;
2626
}
2727
KeyboardRegistry.registeredKeyboards[componentID] = {generator, params, componentID};
2828
AppRegistry.registerComponent(componentID, generator);
2929
};
3030

31-
static getKeyboard = (componentID) => {
31+
static getKeyboard = componentID => {
3232
const res = KeyboardRegistry.registeredKeyboards[componentID];
3333
if (!res || !res.generator) {
34-
console.error(`KeyboardRegistry.getKeyboard: ${componentID} used but not yet registered`);//eslint-disable-line
34+
console.error(`KeyboardRegistry.getKeyboard: ${componentID} used but not yet registered`);
3535
return undefined;
3636
}
3737
return res.generator();
@@ -54,22 +54,22 @@ export default class KeyboardRegistry {
5454
KeyboardRegistry.eventEmitter.emitEvent(globalID, args);
5555
};
5656

57-
static removeListeners = (globalID) => {
57+
static removeListeners = globalID => {
5858
KeyboardRegistry.eventEmitter.removeListeners(globalID);
5959
};
6060

6161
static onItemSelected = (globalID, args) => {
6262
KeyboardRegistry.notifyListeners(`${globalID}.onItemSelected`, args);
6363
};
6464

65-
static requestShowKeyboard = (globalID) => {
65+
static requestShowKeyboard = globalID => {
6666
KeyboardRegistry.notifyListeners('onRequestShowKeyboard', {keyboardId: globalID});
6767
};
6868

6969
/**
7070
* iOS only
7171
*/
72-
static toggleExpandedKeyboard = (globalID) => {
72+
static toggleExpandedKeyboard = globalID => {
7373
KeyboardRegistry.notifyListeners('onToggleExpandedKeyboard', {keyboardId: globalID});
7474
};
7575
}

lib/components/Keyboard/KeyboardInput/TextInputKeyboardManager.ios.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import ReactNative, {NativeModules, LayoutAnimation} from 'react-native';
33
const CustomInputController = NativeModules.CustomInputController;
44

55
export default class TextInputKeyboardManager {
6-
76
static setInputComponent = (textInputRef, {component, initialProps}) => {
87
if (!textInputRef || !CustomInputController) {
98
return;
@@ -14,7 +13,7 @@ export default class TextInputKeyboardManager {
1413
}
1514
};
1615

17-
static removeInputComponent = (textInputRef) => {
16+
static removeInputComponent = textInputRef => {
1817
if (!textInputRef || !CustomInputController) {
1918
return;
2019
}
@@ -51,14 +50,14 @@ const springAnimation = {
5150
duration: 400,
5251
create: {
5352
type: LayoutAnimation.Types.linear,
54-
property: LayoutAnimation.Properties.opacity,
53+
property: LayoutAnimation.Properties.opacity
5554
},
5655
update: {
5756
type: LayoutAnimation.Types.spring,
58-
springDamping: 1.0,
57+
springDamping: 1.0
5958
},
6059
delete: {
6160
type: LayoutAnimation.Types.linear,
62-
property: LayoutAnimation.Properties.opacity,
63-
},
61+
property: LayoutAnimation.Properties.opacity
62+
}
6463
};

lib/components/Keyboard/KeyboardInput/__tests__/KeyboardRegistry.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('KeyboardRegistry - components', () => {
1212

1313
beforeEach(() => {
1414
AppRegistry.registerComponent = jest.fn(AppRegistry.registerComponent);
15-
console.error = jest.fn(); //eslint-disable-line
15+
console.error = jest.fn();
1616
});
1717

1818
it('should register the component in the keyboard registry', () => {
@@ -31,18 +31,18 @@ describe('KeyboardRegistry - components', () => {
3131
it('should fail if generator is not provided and produce an error', () => {
3232
KeyboardRegistry.registerKeyboard(mockComponent);
3333
expect(AppRegistry.registerComponent).not.toHaveBeenCalled();
34-
expect(console.error).toHaveBeenCalledTimes(1); //eslint-disable-line
34+
expect(console.error).toHaveBeenCalledTimes(1);
3535
});
3636

3737
it('should only allow to register a generator function and produce an error', () => {
3838
KeyboardRegistry.registerKeyboard(mockComponent, MockElement);
3939
expect(AppRegistry.registerComponent).not.toHaveBeenCalled();
40-
expect(console.error).toHaveBeenCalledTimes(1); //eslint-disable-line
40+
expect(console.error).toHaveBeenCalledTimes(1);
4141
});
4242

4343
it('should produce an error if component was not and return undefined', () => {
4444
const res = KeyboardRegistry.getKeyboard('not_existing_component');
45-
expect(console.error).toHaveBeenCalledTimes(1); //eslint-disable-line
45+
expect(console.error).toHaveBeenCalledTimes(1);
4646
expect(res).toBe(undefined);
4747
});
4848

@@ -85,7 +85,7 @@ describe('KeyboardRegistry - components', () => {
8585
KeyboardRegistry.registerKeyboard(mockComponent, mockGenerator);
8686
KeyboardRegistry.registerKeyboard(anotherMockComponent, anotherMockGenerator);
8787

88-
let keyboards = KeyboardRegistry.getKeyboards([anotherMockComponent, mockComponent]);
88+
const keyboards = KeyboardRegistry.getKeyboards([anotherMockComponent, mockComponent]);
8989
expect(keyboards).toEqual([{id: anotherMockComponent}, {id: mockComponent}]);
9090
});
9191
});
@@ -99,7 +99,7 @@ describe('KeyboardRegistry - listeners', () => {
9999
KeyboardRegistry.eventEmitter = {
100100
listenOn: jest.fn(),
101101
emitEvent: jest.fn(),
102-
removeListeners: jest.fn(),
102+
removeListeners: jest.fn()
103103
};
104104
});
105105

lib/components/Keyboard/KeyboardInput/utils/EventEmitterManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default class EventEmitterManager {
1616

1717
emitEvent(eventName, params = {}) {
1818
if (this.handlerCallbacks[eventName]) {
19-
(this.handlerCallbacks[eventName]).forEach(callback => callback(params));
19+
this.handlerCallbacks[eventName].forEach(callback => callback(params));
2020
}
2121
}
2222

@@ -28,7 +28,7 @@ export default class EventEmitterManager {
2828
const handlers = this.handlerCallbacks[eventName];
2929

3030
if (handlers) {
31-
(handlers).forEach((handler, index) => {
31+
handlers.forEach((handler, index) => {
3232
if (handler === listener) {
3333
handlers.splice(index, 1);
3434
}

lib/components/Keyboard/KeyboardTracking/KeyboardTrackingView.ios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class KeyboardTrackingView extends PureComponent {
2626
* you still get the keyboard events and the view just hovers when you focus the input.
2727
* Also, if you're not using interactive style of dismissing the keyboard
2828
* (or if you don't have an input inside this view) it doesn't make sense to track it anyway.
29-
* (This is caused because of the usage of inputAccessory to be able to track the
29+
* (This is caused because of the usage of inputAccessory to be able to track the
3030
* keyboard interactive change and it introduces this bug)
3131
*/
3232
trackInteractive: PropTypes.bool

0 commit comments

Comments
 (0)