From d212d9bee293739c37a84f420e5f5ac42392dee5 Mon Sep 17 00:00:00 2001 From: Batyr Kanzitdinov Date: Mon, 29 Aug 2022 22:35:23 +0200 Subject: [PATCH] `components` added --- ...onent-sample.tsx => _component-sample.tsx} | 6 +- src/components/action.tsx | 63 ------------------- src/components/button.tsx | 10 +-- src/components/icon.tsx | 44 ------------- src/components/reanimated2.tsx | 20 +----- src/components/section.tsx | 42 ++++--------- 6 files changed, 20 insertions(+), 165 deletions(-) rename src/components/{component-sample.tsx => _component-sample.tsx} (54%) delete mode 100644 src/components/action.tsx delete mode 100644 src/components/icon.tsx diff --git a/src/components/component-sample.tsx b/src/components/_component-sample.tsx similarity index 54% rename from src/components/component-sample.tsx rename to src/components/_component-sample.tsx index b16a634..64f9775 100644 --- a/src/components/component-sample.tsx +++ b/src/components/_component-sample.tsx @@ -1,13 +1,11 @@ import React from 'react'; import {View, Text} from 'react-native-ui-lib'; -type ExampleComponentProps = { +type Props = { title?: string; }; -export const ExampleComponent: React.FC = ({ - title, -}: ExampleComponentProps) => { +export const ExampleComponent: React.FC = ({title}) => { return ( {title} diff --git a/src/components/action.tsx b/src/components/action.tsx deleted file mode 100644 index 45ad2e0..0000000 --- a/src/components/action.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import React from 'react'; -import {View, Text, Colors} from 'react-native-ui-lib'; -import {Bounceable} from 'rn-bounceable'; -import {Icon} from './icon'; - -import {Row} from './row'; - -type ActionProps = { - title: string; - icon?: string; - rightIcon?: string; - info?: string; - disabled?: boolean; - onPress?: () => void; -}; - -export const Action: React.FC = ({ - title, - icon, - rightIcon, - info, - disabled, - onPress, -}: ActionProps) => { - const b = {disabled, onPress}; - const iconSize = 22; - - return ( - - - - - {icon ? ( - - - - ) : null} - - {title ? ( - - {title} - - ) : null} - - - - {info ? ( - - {info} - - ) : null} - - {rightIcon ? ( - - - - ) : null} - - - - - ); -}; diff --git a/src/components/button.tsx b/src/components/button.tsx index ab137c6..fa19229 100644 --- a/src/components/button.tsx +++ b/src/components/button.tsx @@ -2,21 +2,17 @@ import React from 'react'; import {View, Text, MarginModifiers} from 'react-native-ui-lib'; import {Bounceable} from 'rn-bounceable'; -type ButtonProps = MarginModifiers & { +type Props = MarginModifiers & { label?: string; onPress?: PureFunc; }; -export const BButton: React.FC = ({ - label, - onPress, - ...modifiers -}: ButtonProps) => { +export const BButton: React.FC = ({label, onPress, ...modifiers}) => { return ( - + {label} diff --git a/src/components/icon.tsx b/src/components/icon.tsx deleted file mode 100644 index 0862458..0000000 --- a/src/components/icon.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import React, {useMemo} from 'react'; -import {View, Colors, ViewProps} from 'react-native-ui-lib'; -import {Ionicons} from '@expo/vector-icons'; -import {Bounceable} from 'rn-bounceable'; - -type IconProps = { - name: string; - size?: number; - color?: string; - viewProps?: ViewProps; - onPress?: PureFunc; - bounceable?: boolean; -}; - -const ICON_SIZE = 26; - -export const IconComponent = Ionicons; -export const Icon: React.FC = ({ - name, - size = ICON_SIZE, - color = Colors.textColor, - viewProps, - onPress, - bounceable = true, -}: IconProps) => { - const _Icon = useMemo( - () => ( - - - - ), - [viewProps, name, size, color], - ); - - if (!bounceable) { - return _Icon; - } - - return ( - - {_Icon} - - ); -}; diff --git a/src/components/reanimated2.tsx b/src/components/reanimated2.tsx index f76200a..84f40c1 100644 --- a/src/components/reanimated2.tsx +++ b/src/components/reanimated2.tsx @@ -7,16 +7,7 @@ import Animated, { } from 'react-native-reanimated'; import {Bounceable} from 'rn-bounceable'; -import {genNativeId} from '../services/navigation/sharedTransition'; -import {SharedTransitionId} from '../services/navigation/types'; - -type Reanimated2Props = { - stID?: SharedTransitionId; -}; - -export const Reanimated2: React.FC = ({ - stID, -}: Reanimated2Props) => { +export const Reanimated2: React.FC = () => { const offset = useSharedValue(0); const animatedStyles = useAnimatedStyle(() => ({ @@ -32,13 +23,8 @@ export const Reanimated2: React.FC = ({ - - Bounceable + + Bounceable diff --git a/src/components/section.tsx b/src/components/section.tsx index 23a1523..5eb6631 100644 --- a/src/components/section.tsx +++ b/src/components/section.tsx @@ -1,36 +1,18 @@ -import React from 'react'; -import {View, Text} from 'react-native-ui-lib'; - -type SectionProps = { - children: React.ReactNode; - title: string; - bg?: boolean; -}; - -export const Section: React.FC = ({ - children, - title, - bg, -}: SectionProps) => { - const S = { - 'bg-bg2Color': bg, - 'paddingH-s1': bg, - 'paddingV-s2': bg, - }; +import React, {PropsWithChildren} from 'react'; +import {Text, View} from 'react-native-ui-lib'; +export const Section: React.FC< + PropsWithChildren<{ + title: string; + }> +> = ({children, title}) => { return ( - - - - {title} - - + + + {title} + - - - {children} - - + {children} ); };