/
Muip
/
ProBody
Обзор
Документация
Войти
/
Muip
/
ProBody
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
components/AText.tsx
51 строка
1 KB
chmerev
new
14 авг 2024, 12:02
14 авг 2024, 12:02
595f266
Код
Авторство
О чём код?
import React from 'react'; import { Text, TextProps, StyleSheet, TextStyle } from 'react-native'; import AppStyle from '../constants/AppStyle'; import Colors from '../constants/Colors'; const AText: React.FC<TextProps> = (props) => { let newStyle: TextStyle = {}; if (props.style) { newStyle = { ...props.style as TextStyle }; if (!newStyle.fontFamily) { switch (newStyle.fontWeight) { case '100': case '200': case '300': case '400': newStyle.fontFamily = AppStyle.fontFamily; break; case '500': case '600': newStyle.fontFamily = AppStyle.fontFamily; break; case 'bold': case '700': case '800': newStyle.fontFamily = AppStyle.fontFamilyBold; break; case 'normal': newStyle.fontFamily = AppStyle.fontFamily; break; default: newStyle.fontFamily = AppStyle.fontFamily; } } } return <Text {...props} style={[{ ...styles.generalText }, { ...newStyle }]}>{props.children}</Text> } const styles = StyleSheet.create({ generalText: { fontFamily: AppStyle.fontFamily, fontSize: AppStyle.fontSize, color: Colors.text, } }); export default AText;