Skip to content

Commit 19664c4

Browse files
authored
fix: use material community icon for hard coded names (#1630)
1 parent d159659 commit 19664c4

File tree

6 files changed

+37
-18
lines changed

6 files changed

+37
-18
lines changed

src/components/CheckboxAndroid.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
2-
import { Animated, View, StyleSheet } from 'react-native';
2+
import { Animated, View, StyleSheet, I18nManager } from 'react-native';
33
import color from 'color';
4-
import Icon from './Icon';
4+
import MaterialCommunityIcon from './MaterialCommunityIcon';
55
import TouchableRipple from './TouchableRipple';
66
import { withTheme } from '../core/theming';
77
import { Theme, $RemoveChildren } from '../types';
@@ -138,11 +138,12 @@ class CheckboxAndroid extends React.Component<Props, State> {
138138
style={styles.container}
139139
>
140140
<Animated.View style={{ transform: [{ scale: this.state.scaleAnim }] }}>
141-
<Icon
141+
<MaterialCommunityIcon
142142
allowFontScaling={false}
143-
source={icon}
143+
name={icon}
144144
size={24}
145145
color={checkboxColor}
146+
direction={I18nManager.isRTL ? 'rtl' : 'ltr'}
146147
/>
147148
<View style={[StyleSheet.absoluteFill, styles.fillContainer]}>
148149
<Animated.View

src/components/CheckboxIOS.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
2-
import { StyleSheet, View } from 'react-native';
2+
import { StyleSheet, View, I18nManager } from 'react-native';
33
import color from 'color';
4-
import Icon from './Icon';
4+
import MaterialCommunityIcon from './MaterialCommunityIcon';
55
import TouchableRipple from './TouchableRipple';
66
import { withTheme } from '../core/theming';
77
import { Theme, $RemoveChildren } from '../types';
@@ -87,11 +87,12 @@ class CheckboxIOS extends React.Component<Props> {
8787
style={styles.container}
8888
>
8989
<View style={{ opacity: indeterminate || checked ? 1 : 0 }}>
90-
<Icon
90+
<MaterialCommunityIcon
9191
allowFontScaling={false}
92-
source={icon}
92+
name={icon}
9393
size={24}
9494
color={checkedColor}
95+
direction={I18nManager.isRTL ? 'rtl' : 'ltr'}
9596
/>
9697
</View>
9798
</TouchableRipple>

src/components/DataTable/DataTableTitle.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import {
66
TouchableWithoutFeedback,
77
View,
88
ViewStyle,
9+
I18nManager,
910
} from 'react-native';
1011
import color from 'color';
11-
import Icon from '../Icon';
12+
import MaterialCommunityIcon from '../MaterialCommunityIcon';
1213
import Text from '../Typography/Text';
1314
import { withTheme } from '../../core/theming';
1415
import { Theme } from '../../types';
@@ -94,7 +95,12 @@ class DataTableTitle extends React.Component<Props, State> {
9495

9596
const icon = sortDirection ? (
9697
<Animated.View style={[styles.icon, { transform: [{ rotate: spin }] }]}>
97-
<Icon source="arrow-down" size={16} color={theme.colors.text} />
98+
<MaterialCommunityIcon
99+
name="arrow-down"
100+
size={16}
101+
color={theme.colors.text}
102+
direction={I18nManager.isRTL ? 'rtl' : 'ltr'}
103+
/>
98104
</Animated.View>
99105
) : null;
100106

src/components/List/ListAccordion.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import {
66
StyleSheet,
77
StyleProp,
88
TextStyle,
9+
I18nManager,
910
} from 'react-native';
1011
import TouchableRipple from '../TouchableRipple';
11-
import Icon from '../Icon';
12+
import MaterialCommunityIcon from '../MaterialCommunityIcon';
1213
import Text from '../Typography/Text';
1314
import { withTheme } from '../../core/theming';
1415
import { Theme } from '../../types';
@@ -251,10 +252,11 @@ class ListAccordion extends React.Component<Props, State> {
251252
description ? styles.multiline : undefined,
252253
]}
253254
>
254-
<Icon
255-
source={expanded ? 'chevron-up' : 'chevron-down'}
255+
<MaterialCommunityIcon
256+
name={expanded ? 'chevron-up' : 'chevron-down'}
256257
color={titleColor}
257258
size={24}
259+
direction={I18nManager.isRTL ? 'rtl' : 'ltr'}
258260
/>
259261
</View>
260262
</View>

src/components/MaterialCommunityIcon.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export type IconProps = {
66
color: string;
77
size: number;
88
direction: 'rtl' | 'ltr';
9+
allowFontScaling?: boolean;
910
};
1011

1112
let MaterialCommunityIcons: any;
@@ -75,8 +76,15 @@ export const accessibilityProps =
7576
importantForAccessibility: 'no-hide-descendants' as 'no-hide-descendants',
7677
};
7778

78-
const defaultIcon = ({ name, color, size, direction }: IconProps) => (
79+
const defaultIcon = ({
80+
name,
81+
color,
82+
size,
83+
direction,
84+
allowFontScaling,
85+
}: IconProps) => (
7986
<MaterialCommunityIcons
87+
allowFontScaling={allowFontScaling}
8088
name={name}
8189
color={color}
8290
size={size}

src/components/RadioButton/RadioButtonIOS.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as React from 'react';
2-
import { StyleSheet, View } from 'react-native';
2+
import { StyleSheet, View, I18nManager } from 'react-native';
33
import color from 'color';
44
import { RadioButtonContext, RadioButtonContextType } from './RadioButtonGroup';
55
import { handlePress, isChecked } from './utils';
6-
import Icon from '../Icon';
6+
import MaterialCommunityIcon from '../MaterialCommunityIcon';
77
import TouchableRipple from '../TouchableRipple';
88
import { withTheme } from '../../core/theming';
99
import { Theme, $RemoveChildren } from '../../types';
@@ -110,11 +110,12 @@ class RadioButtonIOS extends React.Component<Props> {
110110
style={styles.container}
111111
>
112112
<View style={{ opacity: checked ? 1 : 0 }}>
113-
<Icon
113+
<MaterialCommunityIcon
114114
allowFontScaling={false}
115-
source="check"
115+
name="check"
116116
size={24}
117117
color={checkedColor}
118+
direction={I18nManager.isRTL ? 'rtl' : 'ltr'}
118119
/>
119120
</View>
120121
</TouchableRipple>

0 commit comments

Comments
 (0)