Skip to content

Commit

Permalink
Added autocomplete for icon names
Browse files Browse the repository at this point in the history
  • Loading branch information
Revolt9k committed May 5, 2023
1 parent 11df297 commit 4abbb6f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/components/icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import {View, Colors, ViewProps} from 'react-native-ui-lib';
import {Ionicons} from '@expo/vector-icons';
import {Bounceable} from 'rn-bounceable';

export type IconName = keyof typeof Ionicons.glyphMap;

type IconProps = {
name: string;
name: IconName;
size?: number;
color?: string;
viewProps?: ViewProps;
Expand All @@ -26,7 +28,7 @@ export const Icon: React.FC<IconProps> = ({
const Icon = useMemo(
() => (
<View {...viewProps}>
<IconComponent name={name as any} size={size} color={color} />
<IconComponent name={name} size={size} color={color} />
</View>
),
[viewProps, name, size, color],
Expand Down
4 changes: 2 additions & 2 deletions src/utils/designSystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {Appearance as RNAppearance, Platform} from 'react-native';
import {Colors, Typography} from 'react-native-ui-lib';

import {stores} from '@app/stores';
import {Icon} from '@app/components/icon';
import {Icon, IconName} from '@app/components/icon';
import {Appearance} from '@app/utils/types/enums';

// =============
Expand Down Expand Up @@ -164,7 +164,7 @@ export const getTabBarIcon =
({focused, color, size}: {focused: boolean; color: string; size: number}) =>
<Icon name={getTabIconName(tabName, focused)} size={size} color={color} />;

const getTabIconName = (tabName: string, focused: boolean): string => {
const getTabIconName = (tabName: string, focused: boolean): IconName => {
if (tabName === 'MainTab') {
return focused ? 'home' : 'home-outline';
}
Expand Down

0 comments on commit 4abbb6f

Please sign in to comment.