Chore: Clean Check component - TypeScript (#3919)
* chore: clear Check component * chore: update tests
This commit is contained in:
parent
571afcaab8
commit
6f31a00e90
|
@ -3,11 +3,8 @@ import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
import { CustomIcon } from '../lib/Icons';
|
import { CustomIcon } from '../lib/Icons';
|
||||||
import { themes } from '../constants/colors';
|
import { themes } from '../constants/colors';
|
||||||
|
import { useTheme } from '../theme';
|
||||||
|
|
||||||
interface ICheck {
|
|
||||||
style?: object;
|
|
||||||
theme: string;
|
|
||||||
}
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
icon: {
|
icon: {
|
||||||
width: 22,
|
width: 22,
|
||||||
|
@ -16,8 +13,9 @@ const styles = StyleSheet.create({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const Check = React.memo(({ theme, style }: ICheck) => (
|
const Check = React.memo(() => {
|
||||||
<CustomIcon style={[styles.icon, style]} color={themes[theme].tintColor} size={22} name='check' />
|
const { theme } = useTheme();
|
||||||
));
|
return <CustomIcon style={styles.icon} color={themes[theme].tintColor} size={22} name='check' />;
|
||||||
|
});
|
||||||
|
|
||||||
export default Check;
|
export default Check;
|
||||||
|
|
|
@ -41,7 +41,7 @@ const Item = ({ item, selected, onSelect, theme }: IItem) => {
|
||||||
<>
|
<>
|
||||||
{item.imageUrl ? <FastImage style={styles.itemImage} source={{ uri: item.imageUrl }} /> : null}
|
{item.imageUrl ? <FastImage style={styles.itemImage} source={{ uri: item.imageUrl }} /> : null}
|
||||||
<Text style={{ color: themes[theme].titleText }}>{textParser([item.text])}</Text>
|
<Text style={{ color: themes[theme].titleText }}>{textParser([item.text])}</Text>
|
||||||
{selected ? <Check theme={theme} /> : null}
|
{selected ? <Check /> : null}
|
||||||
</>
|
</>
|
||||||
</Touchable>
|
</Touchable>
|
||||||
);
|
);
|
||||||
|
|
|
@ -59,7 +59,7 @@ const ServerItem = React.memo(({ item, onPress, onLongPress, hasCheck, theme }:
|
||||||
{item.id}
|
{item.id}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
{hasCheck ? <Check theme={theme!} /> : null}
|
{hasCheck ? <Check /> : null}
|
||||||
</View>
|
</View>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
));
|
));
|
||||||
|
|
|
@ -71,7 +71,7 @@ export default class DirectoryOptions extends PureComponent<IDirectoryOptionsPro
|
||||||
<View style={styles.dropdownItemContainer}>
|
<View style={styles.dropdownItemContainer}>
|
||||||
<CustomIcon style={[styles.dropdownItemIcon, { color: themes[theme].bodyText }]} size={22} name={icon} />
|
<CustomIcon style={[styles.dropdownItemIcon, { color: themes[theme].bodyText }]} size={22} name={icon} />
|
||||||
<Text style={[styles.dropdownItemText, { color: themes[theme].bodyText }]}>{I18n.t(text)}</Text>
|
<Text style={[styles.dropdownItemText, { color: themes[theme].bodyText }]}>{I18n.t(text)}</Text>
|
||||||
{propType === itemType ? <Check theme={theme} /> : null}
|
{propType === itemType ? <Check /> : null}
|
||||||
</View>
|
</View>
|
||||||
</Touch>
|
</Touch>
|
||||||
);
|
);
|
||||||
|
|
|
@ -19,7 +19,18 @@ const item = {
|
||||||
iconURL: 'https://open.rocket.chat/images/logo/android-chrome-512x512.png'
|
iconURL: 'https://open.rocket.chat/images/logo/android-chrome-512x512.png'
|
||||||
};
|
};
|
||||||
|
|
||||||
const ServerItem = props => <ServerItemComponent item={item} hasCheck={false} {...props} />;
|
const ServerItem = ({ theme = themes.light, ...props }) => (
|
||||||
|
<ThemeContext.Provider
|
||||||
|
value={{
|
||||||
|
theme,
|
||||||
|
themePreferences: {
|
||||||
|
currentTheme: theme,
|
||||||
|
darkLevel: theme
|
||||||
|
}
|
||||||
|
}}>
|
||||||
|
<ServerItemComponent item={item} hasCheck={false} {...props} />
|
||||||
|
</ThemeContext.Provider>
|
||||||
|
);
|
||||||
|
|
||||||
stories.add('content', () => (
|
stories.add('content', () => (
|
||||||
<>
|
<>
|
||||||
|
@ -47,16 +58,10 @@ stories.add('touchable', () => (
|
||||||
</>
|
</>
|
||||||
));
|
));
|
||||||
|
|
||||||
const ThemeStory = ({ theme }) => (
|
|
||||||
<ThemeContext.Provider value={theme}>
|
|
||||||
<ServerItem theme={theme} hasCheck />
|
|
||||||
</ThemeContext.Provider>
|
|
||||||
);
|
|
||||||
|
|
||||||
stories.add('themes', () => (
|
stories.add('themes', () => (
|
||||||
<>
|
<>
|
||||||
<ThemeStory theme={themes.light} />
|
<ServerItem theme={themes.light} />
|
||||||
<ThemeStory theme={themes.dark} />
|
<ServerItem theme={themes.dark} />
|
||||||
<ThemeStory theme={themes.black} />
|
<ServerItem theme={themes.black} />
|
||||||
</>
|
</>
|
||||||
));
|
));
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue