MCPcopy Create free account
hub / github.com/callstack/react-native-paper / DataTableTitle

Function DataTableTitle

src/components/DataTable/DataTableTitle.tsx:83–160  ·  view source on GitHub ↗
({
  numeric,
  children,
  onPress,
  sortDirection,
  textStyle,
  style,
  theme: themeOverrides,
  numberOfLines = 1,
  maxFontSizeMultiplier,
  ...rest
}: Props)

Source from the content-addressed store, hash-verified

81 */
82
83const DataTableTitle = ({
84 numeric,
85 children,
86 onPress,
87 sortDirection,
88 textStyle,
89 style,
90 theme: themeOverrides,
91 numberOfLines = 1,
92 maxFontSizeMultiplier,
93 ...rest
94}: Props) => {
95 const theme = useInternalTheme(themeOverrides);
96 const { current: spinAnim } = React.useRef<Animated.Value>(
97 new Animated.Value(sortDirection === 'ascending' ? 0 : 1)
98 );
99
100 React.useEffect(() => {
101 Animated.timing(spinAnim, {
102 toValue: sortDirection === 'ascending' ? 0 : 1,
103 duration: 150,
104 useNativeDriver: true,
105 }).start();
106 }, [sortDirection, spinAnim]);
107
108 const textColor = theme.isV3 ? theme.colors.onSurface : theme?.colors?.text;
109
110 const alphaTextColor = color(textColor).alpha(0.6).rgb().string();
111
112 const spin = spinAnim.interpolate({
113 inputRange: [0, 1],
114 outputRange: ['0deg', '180deg'],
115 });
116
117 const icon = sortDirection ? (
118 <Animated.View style={[styles.icon, { transform: [{ rotate: spin }] }]}>
119 <MaterialCommunityIcon
120 name="arrow-up"
121 size={16}
122 color={textColor}
123 direction={I18nManager.getConstants().isRTL ? 'rtl' : 'ltr'}
124 />
125 </Animated.View>
126 ) : null;
127
128 return (
129 <Pressable
130 disabled={!onPress}
131 onPress={onPress}
132 {...rest}
133 style={[styles.container, numeric && styles.right, style]}
134 >
135 {icon}
136
137 <Text
138 style={[
139 styles.cell,
140 // height must scale with numberOfLines

Callers

nothing calls this directly

Calls 1

useInternalThemeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…