diff --git a/src/components/BottomSheet.tsx b/src/components/BottomSheet.tsx index 032ef619..3620059d 100644 --- a/src/components/BottomSheet.tsx +++ b/src/components/BottomSheet.tsx @@ -12,6 +12,7 @@ import { import { useSafeAreaInsets } from 'react-native-safe-area-context' import { useTheme } from 'src/utils/styles/ThemeManager' import { StyleConstants } from 'src/utils/styles/constants' +import Button from './Button' export interface Props { children: React.ReactNode @@ -85,12 +86,10 @@ const BottomSheet: React.FC = ({ children, visible, handleDismiss }) => { style={[styles.handle, { backgroundColor: theme.background }]} /> {children} - closeModal.start(() => handleDismiss())} - style={[styles.cancel, { borderColor: theme.primary }]} - > - 取消 - + text='取消' + /> @@ -111,17 +110,6 @@ const styles = StyleSheet.create({ height: StyleConstants.Spacing.S / 2, borderRadius: 100, top: -StyleConstants.Spacing.M * 2 - }, - cancel: { - padding: StyleConstants.Spacing.S, - marginLeft: StyleConstants.Spacing.L, - marginRight: StyleConstants.Spacing.L, - borderWidth: 1, - borderRadius: 100 - }, - text: { - fontSize: StyleConstants.Font.Size.L, - textAlign: 'center' } }) diff --git a/src/components/Button.tsx b/src/components/Button.tsx index d6a1c36b..48ccd4c9 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -1,38 +1,74 @@ +import { Feather } from '@expo/vector-icons' import React from 'react' import { Pressable, StyleSheet, Text } from 'react-native' import { StyleConstants } from 'src/utils/styles/constants' import { useTheme } from 'src/utils/styles/ThemeManager' -export interface Props { +type PropsBase = { onPress: () => void - text: string - fontSize?: 'S' | 'M' | 'L' + disabled?: boolean + buttonSize?: 'S' | 'M' } -const Button: React.FC = ({ onPress, text, fontSize = 'M' }) => { +export interface PropsText extends PropsBase { + text: string + icon?: string + size?: 'S' | 'M' | 'L' +} + +export interface PropsIcon extends PropsBase { + text?: string + icon: string + size?: 'S' | 'M' | 'L' +} + +const Button: React.FC = ({ + onPress, + disabled = false, + buttonSize = 'M', + text, + icon, + size = 'M' +}) => { const { theme } = useTheme() return ( - - {text} - + {icon ? ( + + ) : ( + + {text} + + )} ) } const styles = StyleSheet.create({ button: { - paddingTop: StyleConstants.Spacing.S, - paddingBottom: StyleConstants.Spacing.S, paddingLeft: StyleConstants.Spacing.M, paddingRight: StyleConstants.Spacing.M, borderWidth: 1, diff --git a/src/components/Timelines/Timeline/Shared/Card.tsx b/src/components/Timelines/Timeline/Shared/Card.tsx index 1aa8ff10..fbe980f3 100644 --- a/src/components/Timelines/Timeline/Shared/Card.tsx +++ b/src/components/Timelines/Timeline/Shared/Card.tsx @@ -58,7 +58,7 @@ const styles = StyleSheet.create({ flexDirection: 'row', height: StyleConstants.Avatar.L, marginTop: StyleConstants.Spacing.M, - borderWidth: 0.5, + borderWidth: StyleSheet.hairlineWidth, borderRadius: 6 }, left: { diff --git a/src/screens/Me/Root/Login.tsx b/src/screens/Me/Root/Login.tsx index f3b0b07d..1a88db33 100644 --- a/src/screens/Me/Root/Login.tsx +++ b/src/screens/Me/Root/Login.tsx @@ -1,5 +1,5 @@ import React, { useCallback, useEffect, useState } from 'react' -import { Button, StyleSheet, Text, TextInput, View } from 'react-native' +import { StyleSheet, Text, TextInput, View } from 'react-native' import { useQuery } from 'react-query' import { debounce } from 'lodash' @@ -13,6 +13,7 @@ import { useTheme } from 'src/utils/styles/ThemeManager' import { useTranslation } from 'react-i18next' import { StyleConstants } from 'src/utils/styles/constants' +import Button from 'src/components/Button' const Login: React.FC = () => { const { t } = useTranslation('meRoot') @@ -145,9 +146,9 @@ const Login: React.FC = () => { returnKeyType='go' />