-
Notifications
You must be signed in to change notification settings - Fork 18
/
ViewerLivestreamControls.tsx
78 lines (73 loc) · 1.96 KB
/
ViewerLivestreamControls.tsx
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, ViewProps } from 'react-native';
import {
ViewerLeaveStreamButton as DefaultViewerLeaveStreamButton,
ViewerLeaveStreamButtonProps,
} from './ViewerLeaveStreamButton';
import { useTheme } from '../../../contexts';
import { Z_INDEX } from '../../../constants';
/**
* Props for the ViewerLivestreamControls component.
*/
export type ViewerLivestreamControlsProps = ViewerLeaveStreamButtonProps & {
/**
* Component to customize the leave stream button on the viewer's end live stream.
*/
ViewerLeaveStreamButton?: React.ComponentType<ViewerLeaveStreamButtonProps> | null;
onLayout?: ViewProps['onLayout'];
};
/**
* The ViewerLivestreamControls component displays the call controls for the live stream at viewer's end.
*/
export const ViewerLivestreamControls = ({
ViewerLeaveStreamButton = DefaultViewerLeaveStreamButton,
onLeaveStreamHandler,
onLayout,
}: ViewerLivestreamControlsProps) => {
const {
theme: { colors, viewerLivestreamControls },
} = useTheme();
return (
<View
style={[
styles.container,
{
backgroundColor: colors.static_overlay,
},
viewerLivestreamControls.container,
]}
onLayout={onLayout}
>
<View style={[styles.leftElement, viewerLivestreamControls.leftElement]}>
{ViewerLeaveStreamButton && (
<ViewerLeaveStreamButton
onLeaveStreamHandler={onLeaveStreamHandler}
/>
)}
</View>
<View
style={[styles.rightElement, viewerLivestreamControls.rightElement]}
/>
</View>
);
};
const styles = StyleSheet.create({
container: {
position: 'absolute',
bottom: 0,
flexDirection: 'row',
alignItems: 'center',
paddingVertical: 16,
paddingHorizontal: 8,
zIndex: Z_INDEX.IN_FRONT,
},
content: {},
leftElement: {
flex: 1,
alignItems: 'flex-start',
},
rightElement: {
flex: 1,
alignItems: 'flex-end',
},
});