MCPcopy
hub / github.com/callstack/react-native-paper / Card

Function Card

src/components/Card/Card.tsx:140–343  ·  view source on GitHub ↗
(
  {
    elevation: cardElevation = 1,
    delayLongPress,
    onPress,
    onLongPress,
    onPressOut,
    onPressIn,
    mode: cardMode = 'elevated',
    children,
    style,
    contentStyle,
    theme: themeOverrides,
    testID = 'card',
    accessible,
    disabled,
    ...rest
  }: (OutlinedCardProps | ElevatedCardProps | ContainedCardProps) & Props,
  ref: React.ForwardedRef<View>
)

Source from the content-addressed store, hash-verified

138 */
139
140const Card = (
141 {
142 elevation: cardElevation = 1,
143 delayLongPress,
144 onPress,
145 onLongPress,
146 onPressOut,
147 onPressIn,
148 mode: cardMode = 'elevated',
149 children,
150 style,
151 contentStyle,
152 theme: themeOverrides,
153 testID = 'card',
154 accessible,
155 disabled,
156 ...rest
157 }: (OutlinedCardProps | ElevatedCardProps | ContainedCardProps) & Props,
158 ref: React.ForwardedRef<View>
159) => {
160 const theme = useInternalTheme(themeOverrides);
161 const isMode = React.useCallback(
162 (modeToCompare: Mode) => {
163 return cardMode === modeToCompare;
164 },
165 [cardMode]
166 );
167
168 const hasPassedTouchHandler = hasTouchHandler({
169 onPress,
170 onLongPress,
171 onPressIn,
172 onPressOut,
173 });
174
175 // Default animated value
176 const { current: elevation } = React.useRef<Animated.Value>(
177 new Animated.Value(cardElevation)
178 );
179 // Dark adaptive animated value, used in case of toggling the theme,
180 // it prevents animating the background with native drivers inside Surface
181 const { current: elevationDarkAdaptive } = React.useRef<Animated.Value>(
182 new Animated.Value(cardElevation)
183 );
184 const { animation, dark, mode, roundness, isV3 } = theme;
185
186 const prevDarkRef = React.useRef<boolean>(dark);
187 React.useEffect(() => {
188 prevDarkRef.current = dark;
189 });
190
191 const prevDark = prevDarkRef.current;
192 const isAdaptiveMode = mode === 'adaptive';
193 const animationDuration = 150 * animation.scale;
194
195 React.useEffect(() => {
196 /**
197 * Resets animations values if updating to dark adaptive mode,

Callers

nothing calls this directly

Calls 6

useInternalThemeFunction · 0.90
getCardColorsFunction · 0.90
splitStylesFunction · 0.90
hasTouchHandlerFunction · 0.85
runElevationAnimationFunction · 0.85
isModeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…