-
Notifications
You must be signed in to change notification settings - Fork 374
Expand file tree
/
Copy pathScrollToBottomButton.tsx
More file actions
78 lines (69 loc) · 2 KB
/
ScrollToBottomButton.tsx
File metadata and controls
78 lines (69 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import React from 'react';
import { StyleSheet, View } from 'react-native';
import Animated, { ZoomIn, ZoomOut } from 'react-native-reanimated';
import { useTheme } from '../../contexts/themeContext/ThemeContext';
import { Down } from '../../icons/Down';
import { primitives } from '../../theme';
import { BadgeNotification } from '../ui';
import { Button } from '../ui/Button';
export type ScrollToBottomButtonProps = {
/** onPress handler */
onPress: () => void;
/** If we should show the notification or not */
showNotification?: boolean;
unreadCount?: number;
};
export const ScrollToBottomButton = (props: ScrollToBottomButtonProps) => {
const { onPress, showNotification = true, unreadCount } = props;
const {
theme: { semantics },
} = useTheme();
if (!showNotification) {
return null;
}
return (
<Animated.View
entering={ZoomIn.duration(200)}
exiting={ZoomOut.duration(200)}
style={styles.container}
key='scroll-to-bottom-button'
>
<View
style={[
styles.floatingButtonContainer,
primitives.lightElevation1,
{ backgroundColor: semantics.backgroundCoreElevation1 },
]}
>
<Button
variant='secondary'
type='outline'
LeadingIcon={Down}
onPress={onPress}
size='md'
testID='scroll-to-bottom-button'
iconOnly
/>
</View>
<View style={styles.unreadCountNotificationContainer}>
{unreadCount ? (
<BadgeNotification count={unreadCount} size='xs' type='primary' testID='unread-count' />
) : null}
</View>
</Animated.View>
);
};
const styles = StyleSheet.create({
unreadCountNotificationContainer: {
position: 'absolute',
right: 0,
top: 0,
},
floatingButtonContainer: {
borderRadius: primitives.radiusMax,
},
container: {
padding: primitives.spacingXxs,
},
});
ScrollToBottomButton.displayName = 'ScrollToBottomButton{messageList{scrollToBottomButton}}';