Skip to content

Commit 1f71eda

Browse files
committed
styles: Rename uses of context styles, for distinctness.
Mostly this is to help further steps of automated refactoring. Done with: perl -i -0pe 'if (s(const \{ styles \} = this\.context) (const { styles: contextStyles } = this.context)) { s/\bstyles\./contextStyles./g }' \ src/**/*.js tools/test prettier --fix and then a manual fixup for the one case that didn't fit the pattern, a `this.context.styles.color` in SmartUrlInput.js .
1 parent f4f29a5 commit 1f71eda

37 files changed

+119
-107
lines changed

src/account-info/AccountDetails.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default class AccountDetails extends PureComponent<Props, void> {
3131
};
3232

3333
render() {
34-
const { styles } = this.context;
34+
const { styles: contextStyles } = this.context;
3535
const { user, presence } = this.props;
3636
const screenWidth = Dimensions.get('window').width;
3737

@@ -44,18 +44,21 @@ export default class AccountDetails extends PureComponent<Props, void> {
4444
size={screenWidth}
4545
shape="square"
4646
/>
47-
<ComponentList outerSpacing itemStyle={[styles.row, styles.center]}>
47+
<ComponentList outerSpacing itemStyle={[contextStyles.row, contextStyles.center]}>
4848
<View>
4949
<UserStatusIndicator presence={presence} hideIfOffline={false} />
50-
<RawLabel style={[styles.largerText, styles.halfMarginLeft]} text={user.email} />
50+
<RawLabel
51+
style={[contextStyles.largerText, contextStyles.halfMarginLeft]}
52+
text={user.email}
53+
/>
5154
</View>
5255
<View>
53-
<ActivityText style={styles.largerText} email={user.email} />
56+
<ActivityText style={contextStyles.largerText} email={user.email} />
5457
</View>
5558
{user.timezone ? (
5659
<View>
5760
<RawLabel
58-
style={styles.largerText}
61+
style={contextStyles.largerText}
5962
text={`${nowInTimeZone(user.timezone)} Local time`}
6063
/>
6164
</View>

src/chat/Chat.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ export default class Chat extends PureComponent<Props> {
3232
scrollOffset: number = 0;
3333

3434
render() {
35-
const { styles } = this.context;
35+
const { styles: contextStyles } = this.context;
3636
const { narrow } = this.props;
3737

3838
return (
39-
<KeyboardAvoider style={styles.flexed} behavior="padding">
40-
<View style={styles.flexed}>
39+
<KeyboardAvoider style={contextStyles.flexed} behavior="padding">
40+
<View style={contextStyles.flexed}>
4141
<View style={componentStyles.reverse}>
4242
<MessageList narrow={narrow} />
4343
<NoMessages narrow={narrow} />

src/chat/ChatScreen.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ export default class ChatScreen extends PureComponent<Props> {
3535
};
3636

3737
render() {
38-
const { styles } = this.context;
38+
const { styles: contextStyles } = this.context;
3939
const { narrow } = this.props.navigation.state.params;
4040

4141
return (
4242
<ActionSheetProvider>
43-
<View style={styles.screen}>
43+
<View style={contextStyles.screen}>
4444
<ZulipStatusBar narrow={narrow} />
4545
<View style={componentStyles.reverse}>
4646
<Chat narrow={narrow} />

src/common/Centerer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ export default class Centerer extends PureComponent<Props> {
4343
};
4444

4545
render() {
46-
const { styles } = this.context;
46+
const { styles: contextStyles } = this.context;
4747
const { children, padding, style } = this.props;
4848

4949
return (
50-
<View style={[componentStyles.centerer, padding && styles.padding, style]}>
50+
<View style={[componentStyles.centerer, padding && contextStyles.padding, style]}>
5151
<View style={componentStyles.inner}>{children}</View>
5252
</View>
5353
);

src/common/Input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default class Input extends PureComponent<Props, State> {
6666
};
6767

6868
render() {
69-
const { styles } = this.context;
69+
const { styles: contextStyles } = this.context;
7070
const { style, placeholder, textInputRef, ...restProps } = this.props;
7171
const { isFocused } = this.state;
7272
const fullPlaceholder =
@@ -82,7 +82,7 @@ export default class Input extends PureComponent<Props, State> {
8282
>
8383
{(text: string) => (
8484
<TextInput
85-
style={[styles.input, style]}
85+
style={[contextStyles.input, style]}
8686
placeholder={text}
8787
placeholderTextColor={HALF_COLOR}
8888
underlineColorAndroid={isFocused ? BORDER_COLOR : HALF_COLOR}

src/common/InputWithClearButton.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ export default class InputWithClearButton extends PureComponent<Props, State> {
5858
};
5959

6060
render() {
61-
const { styles } = this.context;
61+
const { styles: contextStyles } = this.context;
6262
const { canBeCleared, text } = this.state;
6363

6464
return (
65-
<View style={styles.row}>
65+
<View style={contextStyles.row}>
6666
<Input
6767
{...this.props}
6868
textInputRef={textInput => {

src/common/Label.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ export default class Label extends PureComponent<Props> {
3131
};
3232

3333
render() {
34-
const { styles } = this.context;
34+
const { styles: contextStyles } = this.context;
3535
const { text, style, ...restProps } = this.props;
3636

3737
return (
38-
<Text style={[styles.label, style]} {...restProps}>
38+
<Text style={[contextStyles.label, style]} {...restProps}>
3939
<TranslatedText text={text} />
4040
</Text>
4141
);

src/common/OptionButton.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ export default class OptionButton extends PureComponent<Props> {
2222

2323
render() {
2424
const { label, onPress, Icon } = this.props;
25-
const { styles } = this.context;
25+
const { styles: contextStyles } = this.context;
2626

2727
return (
2828
<Touchable onPress={onPress}>
29-
<View style={styles.listItem}>
30-
{Icon && <Icon size={18} style={[styles.icon, styles.settingsIcon]} />}
29+
<View style={contextStyles.listItem}>
30+
{Icon && <Icon size={18} style={[contextStyles.icon, contextStyles.settingsIcon]} />}
3131
<Label text={label} />
32-
<View style={styles.rightItem}>
33-
<IconRight size={18} style={[styles.icon, styles.settingsIcon]} />
32+
<View style={contextStyles.rightItem}>
33+
<IconRight size={18} style={[contextStyles.icon, contextStyles.settingsIcon]} />
3434
</View>
3535
</View>
3636
</Touchable>

src/common/OptionDivider.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export default class OptionDivider extends PureComponent<{}> {
1212
};
1313

1414
render() {
15-
const { styles } = this.context;
15+
const { styles: contextStyles } = this.context;
1616

17-
return <View style={styles.divider} />;
17+
return <View style={contextStyles.divider} />;
1818
}
1919
}

src/common/OptionRow.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ export default class OptionRow extends PureComponent<Props> {
2323

2424
render() {
2525
const { label, defaultValue, onValueChange, style, Icon } = this.props;
26-
const { styles } = this.context;
26+
const { styles: contextStyles } = this.context;
2727

2828
return (
29-
<View style={[styles.listItem, style]}>
30-
{Icon && <Icon size={18} style={[styles.icon, styles.settingsIcon]} />}
31-
<Label text={label} style={styles.flexed} />
32-
<View style={styles.rightItem}>
29+
<View style={[contextStyles.listItem, style]}>
30+
{Icon && <Icon size={18} style={[contextStyles.icon, contextStyles.settingsIcon]} />}
31+
<Label text={label} style={contextStyles.flexed} />
32+
<View style={contextStyles.rightItem}>
3333
<ZulipSwitch defaultValue={defaultValue} onValueChange={onValueChange} />
3434
</View>
3535
</View>

0 commit comments

Comments
 (0)