Skip to content

Commit

Permalink
fix: mark methods as private (#1419)
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 authored and Trancever committed Oct 24, 2019
1 parent 03c9bfd commit 43517dc
Show file tree
Hide file tree
Showing 22 changed files with 1,494 additions and 1,224 deletions.
30 changes: 15 additions & 15 deletions docs/package.json
Expand Up @@ -3,29 +3,29 @@
"version": "0.0.1",
"description": "Documentation for React Native Paper",
"private": true,
"author": "",
"license": "MIT",
"scripts": {
"start": "component-docs serve",
"build": "component-docs build",
"clean": "del dist/",
"prestart": "yarn clean"
},
"devDependencies": {
"@babel/node": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/preset-env": "^7.4.5",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"del-cli": "^1.1.0",
"file-loader": "^1.1.11",
"metro-react-native-babel-preset": "^0.54.1",
"url-loader": "^1.0.1"
},
"author": "",
"license": "MIT",
"dependencies": {
"color": "^3.1.2",
"component-docs": "^0.20.2",
"component-docs": "^0.20.3",
"linaria": "^1.2.4"
},
"devDependencies": {
"@babel/node": "^7.6.3",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/preset-env": "^7.6.3",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.6.3",
"@babel/preset-typescript": "^7.6.0",
"del-cli": "^3.0.0",
"file-loader": "^4.2.0",
"metro-react-native-babel-preset": "^0.56.0",
"url-loader": "^2.2.0"
}
}
2,214 changes: 1,242 additions & 972 deletions docs/yarn.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/components/ActivityIndicator.tsx
Expand Up @@ -93,7 +93,7 @@ class ActivityIndicator extends React.Component<Props, State> {
});

if (animating) {
this._startRotation();
this.startRotation();
}
}

Expand All @@ -103,22 +103,22 @@ class ActivityIndicator extends React.Component<Props, State> {

if (animating !== prevProps.animating) {
if (animating) {
this._startRotation();
this.startRotation();
} else if (hidesWhenStopped) {
// Hide indicator first and then stop rotation
Animated.timing(fade, {
duration: 200,
toValue: 0,
useNativeDriver: true,
isInteraction: false,
}).start(this._stopRotation.bind(this));
}).start(this.stopRotation.bind(this));
} else {
this._stopRotation();
this.stopRotation();
}
}
}

_startRotation = () => {
private startRotation = () => {
const { fade, timer } = this.state;

// Show indicator
Expand All @@ -137,7 +137,7 @@ class ActivityIndicator extends React.Component<Props, State> {
}
};

_stopRotation = () => {
private stopRotation = () => {
if (this.rotation) {
this.rotation.stop();
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/Appbar/AppbarHeader.tsx
Expand Up @@ -61,9 +61,9 @@ type Props = React.ComponentProps<typeof Appbar> & {
* export default class MyComponent extends React.Component {
* _goBack = () => console.log('Went back');
*
* _onSearch = () => console.log('Searching');
* _handleSearch = () => console.log('Searching');
*
* _onMore = () => console.log('Shown more');
* _handleMore = () => console.log('Shown more');
*
* render() {
* return (
Expand All @@ -75,8 +75,8 @@ type Props = React.ComponentProps<typeof Appbar> & {
* title="Title"
* subtitle="Subtitle"
* />
* <Appbar.Action icon="search" onPress={this._onSearch} />
* <Appbar.Action icon="more-vert" onPress={this._onMore} />
* <Appbar.Action icon="search" onPress={this._handleSearch} />
* <Appbar.Action icon="more-vert" onPress={this._handleMore} />
* </Appbar.Header>
* );
* }
Expand Down
18 changes: 9 additions & 9 deletions src/components/Banner.tsx
Expand Up @@ -128,32 +128,32 @@ class Banner extends React.Component<Props, State> {

componentDidUpdate(prevProps: Props) {
if (prevProps.visible !== this.props.visible) {
this._toggle();
this.toggle();
}
}

_handleLayout = ({ nativeEvent }: NativeEvent) => {
private handleLayout = ({ nativeEvent }: NativeEvent) => {
const { height } = nativeEvent.layout;

this.setState({ layout: { height, measured: true } });
};

_toggle = () => {
private toggle = () => {
if (this.props.visible) {
this._show();
this.show();
} else {
this._hide();
this.hide();
}
};

_show = () => {
private show = () => {
Animated.timing(this.state.position, {
duration: 250,
toValue: 1,
}).start();
};

_hide = () => {
private hide = () => {
Animated.timing(this.state.position, {
duration: 200,
toValue: 0,
Expand Down Expand Up @@ -195,7 +195,7 @@ class Banner extends React.Component<Props, State> {
<View style={[styles.wrapper, contentStyle]}>
<Animated.View style={{ height }} />
<Animated.View
onLayout={this._handleLayout}
onLayout={this.handleLayout}
style={[
layout.measured || !visible
? // If we have measured banner's height or it's invisible,
Expand All @@ -213,7 +213,7 @@ class Banner extends React.Component<Props, State> {
<View style={styles.content}>
{icon ? (
<View style={styles.icon}>
{/*
{/*
// @ts-ignore */}
<Icon source={icon} size={40} />
</View>
Expand Down
44 changes: 22 additions & 22 deletions src/components/BottomNavigation.tsx
Expand Up @@ -416,14 +416,14 @@ class BottomNavigation extends React.Component<Props, State> {
componentDidMount() {
// Workaround for native animated bug in react-native@^0.57
// Context: https://github.com/callstack/react-native-paper/pull/637
this._animateToCurrentIndex();
this.animateToCurrentIndex();

if (Platform.OS === 'ios') {
Keyboard.addListener('keyboardWillShow', this._handleKeyboardShow);
Keyboard.addListener('keyboardWillHide', this._handleKeyboardHide);
Keyboard.addListener('keyboardWillShow', this.handleKeyboardShow);
Keyboard.addListener('keyboardWillHide', this.handleKeyboardHide);
} else {
Keyboard.addListener('keyboardDidShow', this._handleKeyboardShow);
Keyboard.addListener('keyboardDidHide', this._handleKeyboardHide);
Keyboard.addListener('keyboardDidShow', this.handleKeyboardShow);
Keyboard.addListener('keyboardDidHide', this.handleKeyboardHide);
}
}

Expand All @@ -442,20 +442,20 @@ class BottomNavigation extends React.Component<Props, State> {
}
});

this._animateToCurrentIndex();
this.animateToCurrentIndex();
}

componentWillUnmount() {
if (Platform.OS === 'ios') {
Keyboard.removeListener('keyboardWillShow', this._handleKeyboardShow);
Keyboard.removeListener('keyboardWillHide', this._handleKeyboardHide);
Keyboard.removeListener('keyboardWillShow', this.handleKeyboardShow);
Keyboard.removeListener('keyboardWillHide', this.handleKeyboardHide);
} else {
Keyboard.removeListener('keyboardDidShow', this._handleKeyboardShow);
Keyboard.removeListener('keyboardDidHide', this._handleKeyboardHide);
Keyboard.removeListener('keyboardDidShow', this.handleKeyboardShow);
Keyboard.removeListener('keyboardDidHide', this.handleKeyboardHide);
}
}

_handleKeyboardShow = () =>
private handleKeyboardShow = () =>
this.setState({ keyboard: true }, () =>
Animated.timing(this.state.visible, {
toValue: 0,
Expand All @@ -464,7 +464,7 @@ class BottomNavigation extends React.Component<Props, State> {
}).start()
);

_handleKeyboardHide = () =>
private handleKeyboardHide = () =>
Animated.timing(this.state.visible, {
toValue: 1,
duration: 100,
Expand All @@ -473,8 +473,8 @@ class BottomNavigation extends React.Component<Props, State> {
this.setState({ keyboard: false });
});

_animateToCurrentIndex = () => {
const shifting = this._isShifting();
private animateToCurrentIndex = () => {
const shifting = this.isShifting();
const { routes, index } = this.props.navigationState;

// Reset the ripple to avoid glitch if it's currently animating
Expand Down Expand Up @@ -515,7 +515,7 @@ class BottomNavigation extends React.Component<Props, State> {
});
};

_handleLayout = (e: LayoutChangeEvent) => {
private handleLayout = (e: LayoutChangeEvent) => {
const { layout } = this.state;
const { height, width } = e.nativeEvent.layout;

Expand All @@ -532,7 +532,7 @@ class BottomNavigation extends React.Component<Props, State> {
});
};

_handleTabPress = (index: number) => {
private handleTabPress = (index: number) => {
const { navigationState, onTabPress, onIndexChange } = this.props;

if (onTabPress) {
Expand All @@ -546,15 +546,15 @@ class BottomNavigation extends React.Component<Props, State> {
}
};

_jumpTo = (key: string) => {
private jumpTo = (key: string) => {
const index = this.props.navigationState.routes.findIndex(
route => route.key === key
);

this.props.onIndexChange(index);
};

_isShifting = () =>
private isShifting = () =>
typeof this.props.shifting === 'boolean'
? this.props.shifting
: this.props.navigationState.routes.length > 3;
Expand Down Expand Up @@ -584,7 +584,7 @@ class BottomNavigation extends React.Component<Props, State> {
const { routes } = navigationState;
const { colors, dark: isDarkTheme, mode } = theme;

const shifting = this._isShifting();
const shifting = this.isShifting();

const { backgroundColor: customBackground, elevation = 4 }: ViewStyle =
StyleSheet.flatten(barStyle) || {};
Expand Down Expand Up @@ -669,7 +669,7 @@ class BottomNavigation extends React.Component<Props, State> {
<Animated.View style={[styles.content, { top }]}>
{renderScene({
route,
jumpTo: this._jumpTo,
jumpTo: this.jumpTo,
})}
</Animated.View>
</Animated.View>
Expand Down Expand Up @@ -702,7 +702,7 @@ class BottomNavigation extends React.Component<Props, State> {
pointerEvents={
keyboardHidesNavigationBar && this.state.keyboard ? 'none' : 'auto'
}
onLayout={this._handleLayout}
onLayout={this.handleLayout}
>
<Animated.View style={[styles.barContent, { backgroundColor }]}>
<SafeAreaView
Expand Down Expand Up @@ -785,7 +785,7 @@ class BottomNavigation extends React.Component<Props, State> {
borderless
centered
rippleColor={touchColor}
onPress={() => this._handleTabPress(index)}
onPress={() => this.handleTabPress(index)}
testID={getTestID({ route })}
accessibilityLabel={getAccessibilityLabel({ route })}
accessibilityTraits={
Expand Down
8 changes: 4 additions & 4 deletions src/components/Button.tsx
Expand Up @@ -129,7 +129,7 @@ class Button extends React.Component<Props, State> {
elevation: new Animated.Value(this.props.mode === 'contained' ? 2 : 0),
};

_handlePressIn = () => {
private handlePressIn = () => {
if (this.props.mode === 'contained') {
Animated.timing(this.state.elevation, {
toValue: 8,
Expand All @@ -138,7 +138,7 @@ class Button extends React.Component<Props, State> {
}
};

_handlePressOut = () => {
private handlePressOut = () => {
if (this.props.mode === 'contained') {
Animated.timing(this.state.elevation, {
toValue: 2,
Expand Down Expand Up @@ -255,8 +255,8 @@ class Button extends React.Component<Props, State> {
borderless
delayPressIn={0}
onPress={onPress}
onPressIn={this._handlePressIn}
onPressOut={this._handlePressOut}
onPressIn={this.handlePressIn}
onPressOut={this.handlePressOut}
accessibilityLabel={accessibilityLabel}
accessibilityTraits={disabled ? ['button', 'disabled'] : 'button'}
accessibilityComponentType="button"
Expand Down
8 changes: 4 additions & 4 deletions src/components/Card/Card.tsx
Expand Up @@ -103,14 +103,14 @@ class Card extends React.Component<Props, State> {
elevation: new Animated.Value(this.props.elevation),
};

_handlePressIn = () => {
private handlePressIn = () => {
Animated.timing(this.state.elevation, {
toValue: 8,
duration: 150,
}).start();
};

_handlePressOut = () => {
private handlePressOut = () => {
Animated.timing(this.state.elevation, {
// @ts-ignore
toValue: this.props.elevation,
Expand Down Expand Up @@ -149,8 +149,8 @@ class Card extends React.Component<Props, State> {
disabled={!(onPress || onLongPress)}
onLongPress={onLongPress}
onPress={onPress}
onPressIn={onPress ? this._handlePressIn : undefined}
onPressOut={onPress ? this._handlePressOut : undefined}
onPressIn={onPress ? this.handlePressIn : undefined}
onPressOut={onPress ? this.handlePressOut : undefined}
testID={testID}
accessible={accessible}
>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Chip.tsx
Expand Up @@ -123,14 +123,14 @@ class Chip extends React.Component<Props, State> {
elevation: new Animated.Value(0),
};

_handlePressIn = () => {
private handlePressIn = () => {
Animated.timing(this.state.elevation, {
toValue: 4,
duration: 200,
}).start();
};

_handlePressOut = () => {
private handlePressOut = () => {
Animated.timing(this.state.elevation, {
toValue: 0,
duration: 150,
Expand Down Expand Up @@ -241,8 +241,8 @@ class Chip extends React.Component<Props, State> {
style={{ borderRadius }}
onPress={onPress}
onLongPress={onLongPress}
onPressIn={this._handlePressIn}
onPressOut={this._handlePressOut}
onPressIn={this.handlePressIn}
onPressOut={this.handlePressOut}
underlayColor={underlayColor}
disabled={disabled}
accessibilityLabel={accessibilityLabel}
Expand Down

0 comments on commit 43517dc

Please sign in to comment.