CS lib
This commit is contained in:
parent
cec664c8d0
commit
ff2320f08c
13 changed files with 297 additions and 297 deletions
|
@ -1,31 +1,31 @@
|
|||
import React from 'react';
|
||||
import {ViewStyle} from 'react-native';
|
||||
import {ThemedView} from '@/components/ThemedView';
|
||||
import { ViewStyle } from 'react-native';
|
||||
import { ThemedView } from '@/components/ThemedView';
|
||||
|
||||
interface ListProps {
|
||||
data: any;
|
||||
renderItem: Function;
|
||||
viewStyle?: ViewStyle;
|
||||
data: any;
|
||||
renderItem: Function;
|
||||
viewStyle?: ViewStyle;
|
||||
}
|
||||
|
||||
const CustomList: React.FC<ListProps> = ({ data, renderItem, viewStyle }) => {
|
||||
const renderList = () => {
|
||||
let list: any[] = [];
|
||||
const renderList = () => {
|
||||
let list: any[] = [];
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const item = data[i];
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const item = data[ i ];
|
||||
|
||||
list[i] = renderItem(item, i);
|
||||
}
|
||||
list[ i ] = renderItem( item, i );
|
||||
}
|
||||
|
||||
return list;
|
||||
};
|
||||
return list;
|
||||
};
|
||||
|
||||
return (
|
||||
<ThemedView style={viewStyle ? viewStyle : undefined}>
|
||||
{renderList()}
|
||||
</ThemedView>
|
||||
);
|
||||
return (
|
||||
<ThemedView style={viewStyle ? viewStyle : undefined}>
|
||||
{renderList()}
|
||||
</ThemedView>
|
||||
);
|
||||
};
|
||||
|
||||
export default CustomList;
|
|
@ -3,58 +3,58 @@ import { Text, type TextProps, StyleSheet } from 'react-native';
|
|||
import { useThemeColor } from '@/hooks/useThemeColor';
|
||||
|
||||
export type ThemedTextProps = TextProps & {
|
||||
lightColor?: string;
|
||||
darkColor?: string;
|
||||
type?: 'default' | 'title' | 'defaultSemiBold' | 'subtitle' | 'link';
|
||||
lightColor?: string;
|
||||
darkColor?: string;
|
||||
type?: 'default' | 'title' | 'defaultSemiBold' | 'subtitle' | 'link';
|
||||
};
|
||||
|
||||
export function ThemedText({
|
||||
style,
|
||||
lightColor,
|
||||
darkColor,
|
||||
type = 'default',
|
||||
...rest
|
||||
style,
|
||||
lightColor,
|
||||
darkColor,
|
||||
type = 'default',
|
||||
...rest
|
||||
}: ThemedTextProps) {
|
||||
const color = useThemeColor({ light: lightColor, dark: darkColor }, 'text');
|
||||
const color = useThemeColor( { light: lightColor, dark: darkColor }, 'text' );
|
||||
|
||||
return (
|
||||
<Text
|
||||
style={[
|
||||
{ color },
|
||||
type === 'default' ? styles.default : undefined,
|
||||
type === 'title' ? styles.title : undefined,
|
||||
type === 'defaultSemiBold' ? styles.defaultSemiBold : undefined,
|
||||
type === 'subtitle' ? styles.subtitle : undefined,
|
||||
type === 'link' ? styles.link : undefined,
|
||||
style,
|
||||
]}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<Text
|
||||
style={[
|
||||
{ color },
|
||||
type === 'default' ? styles.default : undefined,
|
||||
type === 'title' ? styles.title : undefined,
|
||||
type === 'defaultSemiBold' ? styles.defaultSemiBold : undefined,
|
||||
type === 'subtitle' ? styles.subtitle : undefined,
|
||||
type === 'link' ? styles.link : undefined,
|
||||
style,
|
||||
]}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
default: {
|
||||
fontSize: 16,
|
||||
lineHeight: 24,
|
||||
},
|
||||
defaultSemiBold: {
|
||||
fontSize: 16,
|
||||
lineHeight: 24,
|
||||
fontWeight: '600',
|
||||
},
|
||||
title: {
|
||||
fontSize: 32,
|
||||
fontWeight: 'bold',
|
||||
lineHeight: 32,
|
||||
},
|
||||
subtitle: {
|
||||
fontSize: 20,
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
link: {
|
||||
lineHeight: 30,
|
||||
fontSize: 16,
|
||||
color: '#0a7ea4',
|
||||
},
|
||||
});
|
||||
const styles = StyleSheet.create( {
|
||||
default: {
|
||||
fontSize: 16,
|
||||
lineHeight: 24,
|
||||
},
|
||||
defaultSemiBold: {
|
||||
fontSize: 16,
|
||||
lineHeight: 24,
|
||||
fontWeight: '600',
|
||||
},
|
||||
title: {
|
||||
fontSize: 32,
|
||||
fontWeight: 'bold',
|
||||
lineHeight: 32,
|
||||
},
|
||||
subtitle: {
|
||||
fontSize: 20,
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
link: {
|
||||
lineHeight: 30,
|
||||
fontSize: 16,
|
||||
color: '#0a7ea4',
|
||||
},
|
||||
} );
|
||||
|
|
|
@ -3,12 +3,12 @@ import { View, type ViewProps } from 'react-native';
|
|||
import { useThemeColor } from '@/hooks/useThemeColor';
|
||||
|
||||
export type ThemedViewProps = ViewProps & {
|
||||
lightColor?: string;
|
||||
darkColor?: string;
|
||||
lightColor?: string;
|
||||
darkColor?: string;
|
||||
};
|
||||
|
||||
export function ThemedView({ style, lightColor, darkColor, ...otherProps }: ThemedViewProps) {
|
||||
const backgroundColor = useThemeColor({ light: lightColor, dark: darkColor }, 'background');
|
||||
const backgroundColor = useThemeColor( { light: lightColor, dark: darkColor }, 'background' );
|
||||
|
||||
return <View style={[{ backgroundColor }, style]} {...otherProps} />;
|
||||
return <View style={[ { backgroundColor }, style ]} {...otherProps} />;
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ import renderer from 'react-test-renderer';
|
|||
|
||||
import { ThemedText } from '../ThemedText';
|
||||
|
||||
it(`renders correctly`, () => {
|
||||
const tree = renderer.create(<ThemedText>Snapshot test!</ThemedText>).toJSON();
|
||||
it( `renders correctly`, () => {
|
||||
const tree = renderer.create( <ThemedText>Snapshot test!</ThemedText> ).toJSON();
|
||||
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
expect( tree ).toMatchSnapshot();
|
||||
} );
|
||||
|
|
|
@ -5,5 +5,5 @@ import { type IconProps } from '@expo/vector-icons/build/createIconSet';
|
|||
import { type ComponentProps } from 'react';
|
||||
|
||||
export function TabBarIcon({ style, ...rest }: IconProps<ComponentProps<typeof Ionicons>['name']>) {
|
||||
return <Ionicons size={28} style={[style]} {...rest} />;
|
||||
return <Ionicons size={28} style={[ style ]} {...rest} />;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue