Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary platform sharding in FloatingMessageCounterContainer #40323

Merged
merged 7 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import React, {useCallback, useEffect, useMemo} from 'react';
import {Animated, View} from 'react-native';
import React, {useCallback, useEffect} from 'react';
import {View} from 'react-native';
import Animated, {useAnimatedStyle, useSharedValue, withSpring} from 'react-native-reanimated';
import Button from '@components/Button';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useNativeDriver from '@libs/useNativeDriver';
import CONST from '@src/CONST';
import FloatingMessageCounterContainer from './FloatingMessageCounterContainer';

type FloatingMessageCounterProps = {
/** Whether the New Messages indicator is active */
Expand All @@ -26,20 +25,18 @@ function FloatingMessageCounter({isActive = false, onClick = () => {}}: Floating
const theme = useTheme();
const styles = useThemeStyles();
const {translate} = useLocalize();
const translateY = useMemo(() => new Animated.Value(MARKER_INACTIVE_TRANSLATE_Y), []);
const translateY = useSharedValue(MARKER_INACTIVE_TRANSLATE_Y);

const show = useCallback(() => {
Animated.spring(translateY, {
toValue: MARKER_ACTIVE_TRANSLATE_Y,
useNativeDriver,
}).start();
'worklet';

translateY.value = withSpring(MARKER_ACTIVE_TRANSLATE_Y);
}, [translateY]);

const hide = useCallback(() => {
Animated.spring(translateY, {
toValue: MARKER_INACTIVE_TRANSLATE_Y,
useNativeDriver,
}).start();
'worklet';

translateY.value = withSpring(MARKER_INACTIVE_TRANSLATE_Y);
}, [translateY]);

useEffect(() => {
Expand All @@ -50,10 +47,15 @@ function FloatingMessageCounter({isActive = false, onClick = () => {}}: Floating
}
}, [isActive, show, hide]);

const wrapperStyle = useAnimatedStyle(() => ({
...styles.floatingMessageCounterWrapper,
transform: [{translateY: translateY.value}],
}));

return (
<FloatingMessageCounterContainer
<Animated.View
accessibilityHint={translate('accessibilityHints.scrollToNewestMessages')}
containerStyles={styles.floatingMessageCounterTransformation(translateY)}
style={wrapperStyle}
>
<View style={styles.floatingMessageCounter}>
<View style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter]}>
Expand All @@ -79,7 +81,7 @@ function FloatingMessageCounter({isActive = false, onClick = () => {}}: Floating
</Button>
</View>
</View>
</FloatingMessageCounterContainer>
</Animated.View>
);
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3341,31 +3341,11 @@ const styles = (theme: ThemeColors) =>
...visibility.hidden,
},

floatingMessageCounterWrapperAndroid: {
left: 0,
width: '100%',
alignItems: 'center',
position: 'absolute',
top: 0,
zIndex: 100,
...visibility.hidden,
},

floatingMessageCounterSubWrapperAndroid: {
left: '50%',
width: 'auto',
},

floatingMessageCounter: {
left: '-50%',
...visibility.visible,
},

floatingMessageCounterTransformation: (translateY: AnimatableNumericValue) =>
({
transform: [{translateY}],
} satisfies ViewStyle),

confirmationAnimation: {
height: 180,
width: 180,
Expand Down
Loading