@wereform/pkgm-video 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -1
- package/src/components/Thumbnail.jsx +21 -0
- package/src/components/VideoPlayer.jsx +47 -0
- package/src/index.js +4 -0
- package/src/layout/VideoCardHorizontalLayout.jsx +52 -0
- package/src/layout/VideoCardLayout.jsx +75 -0
- package/src/layout/VideoViewLayout.jsx +107 -0
- package/src/styles/VideoCardLayoutStyles.js +54 -0
- package/src/styles/VideoPlayerStyles.js +16 -0
- package/src/styles/globalStyles.js +28 -0
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Image, View } from "react-native";
|
|
2
|
+
|
|
3
|
+
export function Thumbnail({ thumbnailURL, thumbHeight }) {
|
|
4
|
+
return (
|
|
5
|
+
<View style={{ width: "auto" }}>
|
|
6
|
+
<Image
|
|
7
|
+
source={{
|
|
8
|
+
uri:
|
|
9
|
+
thumbnailURL ||
|
|
10
|
+
"https://begenone-images.s3.us-east-1.amazonaws.com/let+Me+Love+you.jpg",
|
|
11
|
+
}}
|
|
12
|
+
style={{
|
|
13
|
+
width: "100%",
|
|
14
|
+
height: thumbHeight,
|
|
15
|
+
aspectRatio: 16 / 9,
|
|
16
|
+
borderRadius: 5,
|
|
17
|
+
}}
|
|
18
|
+
/>
|
|
19
|
+
</View>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useEvent } from "expo";
|
|
2
|
+
import { useVideoPlayer, VideoView } from "expo-video";
|
|
3
|
+
import { View, useWindowDimensions } from "react-native";
|
|
4
|
+
import { VideoPlayerStyles } from "../styles/VideoPlayerStyles";
|
|
5
|
+
import { useCallback, useRef } from "react";
|
|
6
|
+
import { useFocusEffect } from "@react-navigation/native";
|
|
7
|
+
|
|
8
|
+
export function VideoPlayer({ videoSource }) {
|
|
9
|
+
const { width } = useWindowDimensions(); // Dynamically get device width
|
|
10
|
+
|
|
11
|
+
const playerRef = useRef(null);
|
|
12
|
+
|
|
13
|
+
const player = useVideoPlayer(videoSource, p => {
|
|
14
|
+
p.loop = true;
|
|
15
|
+
p.play();
|
|
16
|
+
playerRef.current = p; // store instance
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
useFocusEffect(
|
|
20
|
+
useCallback(() => {
|
|
21
|
+
if (playerRef.current) {
|
|
22
|
+
playerRef.current.play();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return () => {
|
|
26
|
+
if (playerRef.current) {
|
|
27
|
+
playerRef.current.pause();
|
|
28
|
+
// Optional: fully unload the video
|
|
29
|
+
// playerRef.current.unloadAsync?.();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}, [])
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
useEvent(player, "playingChange");
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<View style={VideoPlayerStyles.contentContainer}>
|
|
39
|
+
<VideoView
|
|
40
|
+
style={[VideoPlayerStyles.video, { width, height: width * (9 / 16) }]} // 16:9 ratio
|
|
41
|
+
player={player}
|
|
42
|
+
// allowsFullscreen
|
|
43
|
+
allowsPictureInPicture
|
|
44
|
+
/>
|
|
45
|
+
</View>
|
|
46
|
+
);
|
|
47
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Text, TouchableOpacity, View } from "react-native";
|
|
2
|
+
import { Thumbnail } from "../components/Thumbnail";
|
|
3
|
+
import { CustomizedTitle, DateViews } from "@wereform/pkgm-shared";
|
|
4
|
+
|
|
5
|
+
export function VideoCardHorizontalLayout({
|
|
6
|
+
eyeIcon,
|
|
7
|
+
timeAgo,
|
|
8
|
+
viewsText,
|
|
9
|
+
titleText,
|
|
10
|
+
contentThumbUrl,
|
|
11
|
+
navigateToVideo,
|
|
12
|
+
}) {
|
|
13
|
+
return (
|
|
14
|
+
<TouchableOpacity
|
|
15
|
+
onPress={navigateToVideo}
|
|
16
|
+
style={{
|
|
17
|
+
flexDirection: "row",
|
|
18
|
+
padding: 8,
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
<Thumbnail thumbHeight={90} thumbnailURL={contentThumbUrl} />
|
|
22
|
+
<View style={{ flex: 1, marginLeft: 12 }}>
|
|
23
|
+
<CustomizedTitle
|
|
24
|
+
title={titleText || "This is a dummy text title for the video"}
|
|
25
|
+
fontSize={18}
|
|
26
|
+
textColor="white"
|
|
27
|
+
style={{ width: "100%" }}
|
|
28
|
+
/>
|
|
29
|
+
|
|
30
|
+
<DateViews
|
|
31
|
+
eyeIcon={eyeIcon}
|
|
32
|
+
timeAgo={timeAgo}
|
|
33
|
+
viewsText={viewsText}
|
|
34
|
+
containerStyles={{
|
|
35
|
+
flexDirection: "column",
|
|
36
|
+
justifyContent: "start",
|
|
37
|
+
height: 40,
|
|
38
|
+
}}
|
|
39
|
+
dateContainerStyles={{
|
|
40
|
+
paddingBottom: 4,
|
|
41
|
+
}}
|
|
42
|
+
dateTextStyles={{
|
|
43
|
+
fontSize: 12,
|
|
44
|
+
}}
|
|
45
|
+
viewsTextStyles={{
|
|
46
|
+
fontSize: 12,
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
</View>
|
|
50
|
+
</TouchableOpacity>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Image, Text, TouchableOpacity, View } from "react-native";
|
|
2
|
+
import { VideoCardLayoutStyles } from "../styles/VideoCardLayoutStyles";
|
|
3
|
+
import { DateViews } from "@wereform/pkgm-shared";
|
|
4
|
+
|
|
5
|
+
export const VideoCardLayout = ({
|
|
6
|
+
timeAgo,
|
|
7
|
+
viewsText,
|
|
8
|
+
titleText,
|
|
9
|
+
userNameText,
|
|
10
|
+
contentThumbUrl,
|
|
11
|
+
channelLogo,
|
|
12
|
+
containerStyles,
|
|
13
|
+
dateViewsContainerStyle,
|
|
14
|
+
userImageStyles,
|
|
15
|
+
titleNameContainerStyles,
|
|
16
|
+
userNameTextStyles,
|
|
17
|
+
titleTextStyles,
|
|
18
|
+
thumbnailImageStyles,
|
|
19
|
+
customMetaDataStyles,
|
|
20
|
+
navigateToVideo,
|
|
21
|
+
}) => {
|
|
22
|
+
return (
|
|
23
|
+
<View
|
|
24
|
+
style={[VideoCardLayoutStyles.container, containerStyles]}
|
|
25
|
+
onPress={navigateToVideo}
|
|
26
|
+
>
|
|
27
|
+
<View style={VideoCardLayoutStyles.imageWrapper}>
|
|
28
|
+
<Image
|
|
29
|
+
source={{
|
|
30
|
+
uri:
|
|
31
|
+
contentThumbUrl ||
|
|
32
|
+
"https://begenone-images.s3.us-east-1.amazonaws.com/let+Me+Love+you.jpg",
|
|
33
|
+
}}
|
|
34
|
+
style={[VideoCardLayoutStyles.image, thumbnailImageStyles]}
|
|
35
|
+
/>
|
|
36
|
+
</View>
|
|
37
|
+
|
|
38
|
+
<DateViews
|
|
39
|
+
timeAgo={timeAgo}
|
|
40
|
+
viewsText={viewsText}
|
|
41
|
+
containerStyles={dateViewsContainerStyle}
|
|
42
|
+
/>
|
|
43
|
+
|
|
44
|
+
<View style={[VideoCardLayoutStyles.metaData, customMetaDataStyles]}>
|
|
45
|
+
<Image
|
|
46
|
+
source={{
|
|
47
|
+
uri:
|
|
48
|
+
channelLogo ||
|
|
49
|
+
"https://begenone-images.s3.us-east-1.amazonaws.com/default-user-photo.jpg",
|
|
50
|
+
}}
|
|
51
|
+
style={[VideoCardLayoutStyles.userImage, userImageStyles]}
|
|
52
|
+
/>
|
|
53
|
+
<View
|
|
54
|
+
style={[
|
|
55
|
+
VideoCardLayoutStyles.titleNameContainer,
|
|
56
|
+
titleNameContainerStyles,
|
|
57
|
+
]}
|
|
58
|
+
>
|
|
59
|
+
<Text
|
|
60
|
+
style={[VideoCardLayoutStyles.titleText, titleTextStyles]}
|
|
61
|
+
numberOfLines={2}
|
|
62
|
+
>
|
|
63
|
+
{titleText ||
|
|
64
|
+
"This is a Default Title Text in case of nothing being passed in."}
|
|
65
|
+
</Text>
|
|
66
|
+
<Text
|
|
67
|
+
style={[VideoCardLayoutStyles.userNameText, userNameTextStyles]}
|
|
68
|
+
>
|
|
69
|
+
{userNameText || "Default Username"}
|
|
70
|
+
</Text>
|
|
71
|
+
</View>
|
|
72
|
+
</View>
|
|
73
|
+
</View>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ScrollView, View } from "react-native";
|
|
2
|
+
import { VideoPlayer } from "../components/VideoPlayer";
|
|
3
|
+
import {
|
|
4
|
+
CustomizedTitle,
|
|
5
|
+
MenuChannelMeta,
|
|
6
|
+
MenuInteraction,
|
|
7
|
+
} from "@wereform/pkgm-shared";
|
|
8
|
+
import { Ionicons } from "@expo/vector-icons";
|
|
9
|
+
import { VideoCardLayout } from "./VideoCardLayout";
|
|
10
|
+
|
|
11
|
+
export function VideoViewLayout({
|
|
12
|
+
videoSource,
|
|
13
|
+
CustomizedTitleText,
|
|
14
|
+
MenuChannelMetaTimeAgo,
|
|
15
|
+
MenuChannelMetaViews,
|
|
16
|
+
MenuChannelMetaUserName,
|
|
17
|
+
MenuChannelMetaSubCount,
|
|
18
|
+
MenuChannelMetaChannelLogo,
|
|
19
|
+
suggestedVideos,
|
|
20
|
+
}) {
|
|
21
|
+
console.log(
|
|
22
|
+
"SUGGESTED VIDEOS FROM VIDEO VIEWS LAYOUT: =>\n" +
|
|
23
|
+
JSON.stringify(suggestedVideos[0].videos, null, 2)
|
|
24
|
+
);
|
|
25
|
+
return (
|
|
26
|
+
<ScrollView>
|
|
27
|
+
<View>
|
|
28
|
+
<VideoPlayer videoSource={videoSource} />
|
|
29
|
+
</View>
|
|
30
|
+
<CustomizedTitle
|
|
31
|
+
title={CustomizedTitleText}
|
|
32
|
+
fontSize={22}
|
|
33
|
+
fontFamily="Inter"
|
|
34
|
+
textColor="white"
|
|
35
|
+
style={{
|
|
36
|
+
paddingTop: 18,
|
|
37
|
+
paddingLeft: 22,
|
|
38
|
+
paddingRight: 22,
|
|
39
|
+
paddingBottom: 18,
|
|
40
|
+
alignSelf: "start",
|
|
41
|
+
}}
|
|
42
|
+
textStyle={{
|
|
43
|
+
lineHeight: 28,
|
|
44
|
+
}}
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
<MenuInteraction
|
|
48
|
+
likeIcon={<Ionicons name="thumbs-up-outline" size={24} color="white" />}
|
|
49
|
+
dislikeIcon={
|
|
50
|
+
<Ionicons name="thumbs-down-outline" size={24} color="white" />
|
|
51
|
+
}
|
|
52
|
+
shareIcon={
|
|
53
|
+
<Ionicons name="arrow-redo-outline" size={24} color="white" />
|
|
54
|
+
}
|
|
55
|
+
commentIcon={
|
|
56
|
+
<Ionicons
|
|
57
|
+
name="chatbubble-ellipses-outline"
|
|
58
|
+
size={24}
|
|
59
|
+
color="white"
|
|
60
|
+
/>
|
|
61
|
+
}
|
|
62
|
+
containerStyles={{
|
|
63
|
+
marginLeft: 12,
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
|
|
67
|
+
<MenuChannelMeta
|
|
68
|
+
calendarIcon={
|
|
69
|
+
<Ionicons name="calendar-clear-outline" size={18} color="white" />
|
|
70
|
+
}
|
|
71
|
+
timeAgo={MenuChannelMetaTimeAgo}
|
|
72
|
+
eyeIcon={<Ionicons name="eye-outline" size={18} color="white" />}
|
|
73
|
+
viewsText={MenuChannelMetaViews}
|
|
74
|
+
userName={MenuChannelMetaUserName}
|
|
75
|
+
subscribersCount={MenuChannelMetaSubCount}
|
|
76
|
+
channelLogo={MenuChannelMetaChannelLogo}
|
|
77
|
+
containerStyles={{
|
|
78
|
+
marginTop: 12,
|
|
79
|
+
}}
|
|
80
|
+
/>
|
|
81
|
+
|
|
82
|
+
{suggestedVideos[0].videos.map(video => {
|
|
83
|
+
return (
|
|
84
|
+
<View style={{ marginTop: 24 }} key={video._id}>
|
|
85
|
+
<VideoCardLayout
|
|
86
|
+
key={video._id}
|
|
87
|
+
titleText={video.title}
|
|
88
|
+
contentThumbUrl={video.thumbUrl}
|
|
89
|
+
userNameText={video.channel?.name || "Unknown"}
|
|
90
|
+
channelLogo={video.channelLogo}
|
|
91
|
+
timeAgo={video.videoTimeAgo}
|
|
92
|
+
viewsText={String(video.views)}
|
|
93
|
+
calendarIcon={
|
|
94
|
+
<Ionicons
|
|
95
|
+
name="calendar-clear-outline"
|
|
96
|
+
size={18}
|
|
97
|
+
color="white"
|
|
98
|
+
/>
|
|
99
|
+
}
|
|
100
|
+
eyeIcon={<Ionicons name="eye-outline" size={18} color="white" />}
|
|
101
|
+
/>
|
|
102
|
+
</View>
|
|
103
|
+
);
|
|
104
|
+
})}
|
|
105
|
+
</ScrollView>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { globalStyles } from "./globalStyles";
|
|
2
|
+
|
|
3
|
+
export const VideoCardLayoutStyles = {
|
|
4
|
+
container: {
|
|
5
|
+
width: "auto",
|
|
6
|
+
flexDirection: "column",
|
|
7
|
+
marginRight: 12,
|
|
8
|
+
marginLeft: 12,
|
|
9
|
+
marginBottom: 40,
|
|
10
|
+
},
|
|
11
|
+
imageWrapper: {
|
|
12
|
+
width: "100%",
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
image: {
|
|
16
|
+
width: "100%",
|
|
17
|
+
resizeMode: "contain",
|
|
18
|
+
aspectRatio: 16 / 9,
|
|
19
|
+
borderRadius: globalStyles.borders.borderPrimary100,
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
metaData: {
|
|
23
|
+
flexDirection: "row",
|
|
24
|
+
marginTop: 16,
|
|
25
|
+
paddingLeft: 8,
|
|
26
|
+
paddingRight: 8,
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
userImage: {
|
|
30
|
+
width: 40,
|
|
31
|
+
height: 40,
|
|
32
|
+
borderRadius: globalStyles.borders.borderPrimary50,
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
titleNameContainer: {
|
|
36
|
+
width: "100%",
|
|
37
|
+
flexDirection: "column",
|
|
38
|
+
paddingLeft: 16,
|
|
39
|
+
flexShrink: 1,
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
titleText: {
|
|
43
|
+
fontSize: 22,
|
|
44
|
+
paddingBottom: 12,
|
|
45
|
+
lineHeight: 30,
|
|
46
|
+
fontWeight: "bold",
|
|
47
|
+
color: "#fff",
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
userNameText: {
|
|
51
|
+
color: globalStyles.colors.colorPrimary400,
|
|
52
|
+
fontWeight: "bold",
|
|
53
|
+
},
|
|
54
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
|
|
3
|
+
export const VideoPlayerStyles = StyleSheet.create({
|
|
4
|
+
contentContainer: {
|
|
5
|
+
// flex: 1,
|
|
6
|
+
alignItems: "center",
|
|
7
|
+
justifyContent: "flex-start",
|
|
8
|
+
// backgroundColor: "#000",
|
|
9
|
+
},
|
|
10
|
+
video: {
|
|
11
|
+
// borderRadius: 10,
|
|
12
|
+
},
|
|
13
|
+
controlsContainer: {
|
|
14
|
+
padding: 10,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
|
|
3
|
+
export const globalStyles = StyleSheet.create({
|
|
4
|
+
colors: {
|
|
5
|
+
colorPrimary50: "rgba(21, 21, 21, .7)",
|
|
6
|
+
colorPrimary100: "#151515",
|
|
7
|
+
|
|
8
|
+
colorPrimary200: "#252525",
|
|
9
|
+
|
|
10
|
+
colorPrimary300: "#3C3C3C",
|
|
11
|
+
colorPrimary350: "rgba(60,60,60,.2)",
|
|
12
|
+
|
|
13
|
+
colorPrimary400: "#7F7F7F",
|
|
14
|
+
|
|
15
|
+
colorPrimary500: "#D3D3D3",
|
|
16
|
+
|
|
17
|
+
colorPrimary600: "#ff6600ff",
|
|
18
|
+
|
|
19
|
+
colorPrimary700: "#FF8800",
|
|
20
|
+
},
|
|
21
|
+
borders: {
|
|
22
|
+
borderPrimary50: 8,
|
|
23
|
+
borderPrimary100: 10,
|
|
24
|
+
borderPrimary200: 12,
|
|
25
|
+
borderPrimary300: 15,
|
|
26
|
+
borderPrimary400: 30,
|
|
27
|
+
},
|
|
28
|
+
});
|