Skip to content

Commit

Permalink
feat: Video player (fixes from feat/video-player branch)
Browse files Browse the repository at this point in the history
  • Loading branch information
WaDadidou committed Sep 13, 2023
1 parent a637696 commit e0060f4
Show file tree
Hide file tree
Showing 20 changed files with 1,026 additions and 1,564 deletions.
2 changes: 1 addition & 1 deletion networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
"daoVotingCw4CodeId": 109,
"daoFactoryContractAddress": "tori1r29chp8ufwgx9u3wr4sfk050aardhkzwve7nht6y06gvlaqutr3qt83z6r",
"coreDAOAddress": "tori1dy5h9q9zue4swxe9mzracm8gudp0fcf2ncllch6pfq9d0fq0ftgq546063",
"videoContractAddress": "tori1e4xxwwlpxjpsnrjk4tax7qqf5wepvrqry2yccpkrqh67uurn4s7sk3qr7a"
"videoContractAddress": "tori1m95r73qkq9amntsmr33uz549jdc8284pl0xfqd7mp46c5y8s6ljq7z4q7z"
},
{
"id": "cosmos-hub-theta",
Expand Down
3 changes: 2 additions & 1 deletion packages/components/fileUploader/FileUploader.type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { Dispatch, SetStateAction } from "react";
import { StyleProp, ViewStyle } from "react-native";

import { LocalFileData } from "../../utils/types/files";
Expand All @@ -13,4 +13,5 @@ export interface FileUploaderProps {
mimeTypes?: string[];
children?: ({ onPress }: { onPress: () => void }) => React.ReactNode;
maxUpload?: number;
setIsLoading?: Dispatch<SetStateAction<boolean>>;
}
17 changes: 11 additions & 6 deletions packages/components/fileUploader/FileUploader.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const FileUploader: FC<FileUploaderProps> = ({
maxUpload,
isImageCover,
fileHeight = 256,
setIsLoading,
}) => {
const { setToastError } = useFeedbacks();
const hiddenFileInput = useRef<HTMLInputElement>(null);
Expand Down Expand Up @@ -71,28 +72,32 @@ export const FileUploader: FC<FileUploaderProps> = ({
onUpload(formattedFiles);
};

const handleChange = (event: SyntheticEvent) => {
const handleChange = async (event: SyntheticEvent) => {
setIsLoading?.(true);
const targetEvent = event.target as HTMLInputElement;

if (targetEvent.files && targetEvent.files[0]) {
handleFiles(targetEvent?.files as unknown as File[]);
await handleFiles(targetEvent?.files as unknown as File[]);
}
setIsLoading?.(false);
};

const handleClick = () => {
hiddenFileInput?.current?.click?.();
};

const dropHandler = (ev: any) => {
const dropHandler = async (ev: any) => {
setIsLoading?.(true);
ev.preventDefault();

if (ev.dataTransfer.items) {
const files = [...ev.dataTransfer.items]
.filter((item: any) => item.kind === "file")
.map((item: any) => item.getAsFile());
handleFiles(files);
await handleFiles(files);
} else {
handleFiles(ev.dataTransfer.files);
await handleFiles(ev.dataTransfer.files);
}
setIsLoading?.(false);
};

const dragOverHandler = (ev: SyntheticEvent) => {
Expand Down
1 change: 0 additions & 1 deletion packages/components/fileUploader/formatFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const formatFile = async (file: File): Promise<LocalFileData> => {
} else if (IMAGE_MIME_TYPES.includes(file.type)) {
fileType = "image";
}
console.log(file.path, URL.createObjectURL(file));
return {
file,
fileName: file.name,
Expand Down
115 changes: 43 additions & 72 deletions packages/components/videoPlayer/DetailAlbumMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,106 +1,77 @@
import React from "react";
import { View, StyleSheet } from "react-native";
import { View, ViewStyle, TextStyle } from "react-native";

import { HoverView } from "./HoverView";
import Link from "../../../assets/player/link.svg";
import { neutralA3, neutral33, secondaryColor } from "../../utils/style/colors";
import { neutralA3, neutral33 } from "../../utils/style/colors";
import { fontSemibold13 } from "../../utils/style/fonts";
import { layout } from "../../utils/style/layout";
import { BrandText } from "../BrandText";
import { SVG } from "../SVG";
import { SpacerRow } from "../spacer";

interface DetailAlbumMenuProps {
id: string;
}

const buttonHeight = 36;
export const DetailAlbumMenu: React.FC<DetailAlbumMenuProps> = ({ id }) => {
const shareMenuWidth = 188;
const lineHeight = 18;
const buttonHeight = 36;

const handleCopyLinkTrack = () => {
window.navigator.clipboard.writeText(
`${window.location.origin}/music-player/album/${id}`
);
};

const styles = StyleSheet.create({
menuContainer: {
borderRadius: layout.spacing_x1_5,
position: "absolute",
right: 0,
bottom: buttonHeight + layout.spacing_x0_5,
backgroundColor: "rgba(41, 41, 41, 1)",
padding: layout.spacing_x1_5,
flexDirection: "column",
gap: layout.spacing_x0_75,
zIndex: 999,
},
unitBoxNormal: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
padding: layout.spacing_x0_75,
borderRadius: layout.spacing_x0_75,
},
unitBoxHovered: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
padding: layout.spacing_x0_75,
backgroundColor: neutral33,
borderRadius: layout.spacing_x0_75,
},
oneLine: {
flexDirection: "row",
alignItems: "center",
gap: layout.spacing_x1,
},
text: StyleSheet.flatten([
fontSemibold13,
{
color: neutralA3,
},
]),
divideLine: {
height: 1,
opacity: 0.12,
backgroundColor: secondaryColor,
},
shareMenuContainer: {
borderRadius: layout.spacing_x1_5,
position: "absolute",
left: -(layout.spacing_x1_5 + shareMenuWidth),
bottom: -(
layout.spacing_x1_5 +
lineHeight +
layout.spacing_x1_5 +
1 * layout.spacing_x0_75
),
backgroundColor: "rgba(41, 41, 41, 1)",
padding: layout.spacing_x1_5,
flexDirection: "column",
gap: layout.spacing_x0_75,
width: shareMenuWidth,
},
});

return (
<View style={styles.menuContainer}>
<View style={menuContainerStyle}>
<HoverView
normalStyle={styles.unitBoxNormal}
hoverStyle={styles.unitBoxHovered}
normalStyle={unitBoxNormalStyle}
hoverStyle={unitBoxHoveredStyle}
onPress={() => handleCopyLinkTrack()}
>
<View style={styles.oneLine}>
<View style={oneLineStyle}>
<SVG
source={Link}
width={layout.spacing_x2}
height={layout.spacing_x2}
/>
<BrandText style={styles.text}>Copy link to the track</BrandText>
<SpacerRow size={1} />
<BrandText style={text}>Copy link to the track</BrandText>
</View>
</HoverView>
</View>
);
};

const menuContainerStyle: ViewStyle = {
borderRadius: layout.spacing_x1_5,
position: "absolute",
right: 0,
bottom: buttonHeight + layout.spacing_x0_5,
backgroundColor: "rgba(41, 41, 41, 1)",
padding: layout.spacing_x1_5,
zIndex: 999,
};
const unitBoxNormalStyle: ViewStyle = {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
padding: layout.spacing_x0_75,
borderRadius: layout.spacing_x0_75,
};
const unitBoxHoveredStyle: ViewStyle = {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
padding: layout.spacing_x0_75,
backgroundColor: neutral33,
borderRadius: layout.spacing_x0_75,
};
const oneLineStyle: ViewStyle = {
flexDirection: "row",
alignItems: "center",
};
const text: TextStyle = {
...fontSemibold13,
color: neutralA3,
};
129 changes: 53 additions & 76 deletions packages/components/videoPlayer/MoreVideoCard.tsx
Original file line number Diff line number Diff line change
@@ -1,90 +1,26 @@
import React from "react";
import { View, StyleSheet, Image } from "react-native";
import { View, Image, ViewStyle, TextStyle, ImageStyle } from "react-native";
import { Pressable } from "react-native-hoverable";

import { ipfsURLToHTTPURL } from "../../utils/ipfs";
import { useAppNavigation } from "../../utils/navigation";
import { neutral77, primaryColor } from "../../utils/style/colors";
import { neutral77 } from "../../utils/style/colors";
import { fontSemibold14, fontMedium14 } from "../../utils/style/fonts";
import { layout } from "../../utils/style/layout";
import { VideoInfoWithMeta } from "../../utils/types/video";
import { durationToString } from "../../utils/videoPlayer";
import { BrandText } from "../BrandText";
import { DateTime } from "../socialFeed/SocialThread/DateTime";

const unitWidth = 300;
export const MoreVideoPlayerCard: React.FC<{
item: VideoInfoWithMeta;
}> = ({ item }) => {
const unitWidth = 300;
const navigation = useAppNavigation();

const styles = StyleSheet.create({
unitCard: {
width: unitWidth,
},
contentVideo: {
backgroundColor: "gray",
borderRadius: 10,
aspectRatio: 1.5,
},
contentTitle: StyleSheet.flatten([
fontSemibold14,
{
marginVertical: layout.spacing_x0_5,
},
]),
contentDescription: StyleSheet.flatten([
fontMedium14,
{
color: neutral77,
},
]),
contentDate: StyleSheet.flatten([
fontMedium14,
{
color: neutral77,
marginLeft: "1em",
},
]),
imgBox: {
position: "relative",
},
videoDuration: {
position: "absolute",
left: 10,
top: 10,
backgroundColor: "gray",
color: "white",
borderRadius: layout.spacing_x1,
},
contentDuration: StyleSheet.flatten([
fontSemibold14,
{
padding: layout.spacing_x0_5,
},
]),
contentName: StyleSheet.flatten([
fontSemibold14,
{
color: primaryColor,
},
]),
contentImg: {
width: "100%",
borderRadius: layout.spacing_x1,
aspectRatio: 1.7,
},
titleRow: {
marginLeft: "0.5em",
display: "flex",
flexDirection: "row",
alignItems: "center",
},
});

return (
<View style={styles.unitCard}>
<View style={styles.imgBox}>
<View style={unitCardStyle}>
<View style={imgBoxStyle}>
<Pressable
onPress={() => {
navigation.navigate("VideoShow", { id: item.identifier });
Expand All @@ -93,20 +29,20 @@ export const MoreVideoPlayerCard: React.FC<{
<Image
// @ts-ignore
source={ipfsURLToHTTPURL(item.videoMetaInfo.coverImage)}
style={styles.contentImg}
style={contentImgStyle}
/>
<View style={styles.videoDuration}>
<BrandText style={styles.contentDuration}>
<View style={videoDurationStyle}>
<BrandText style={contentDurationStyle}>
{durationToString(item.videoMetaInfo.duration)}
</BrandText>
</View>
</Pressable>
</View>
<BrandText style={styles.contentTitle}>
<BrandText style={contentTitleStyle}>
{item.videoMetaInfo.title}
</BrandText>
<View style={styles.titleRow}>
<BrandText style={styles.contentDescription}>
<View style={titleRowStyle}>
<BrandText style={contentDescriptionStyle}>
{item.viewCount} views
</BrandText>
{/* A dot separator */}
Expand All @@ -120,8 +56,49 @@ export const MoreVideoPlayerCard: React.FC<{
}}
/>
{/*---- Date */}
<DateTime date={item.createdAt} textStyle={{ color: neutral77 }} />
<DateTime
date={item.createdAt.toString()}
textStyle={{ color: neutral77 }}
/>
</View>
</View>
);
};

const unitCardStyle: ViewStyle = {
width: unitWidth,
};
const contentTitleStyle: TextStyle = {
...fontSemibold14,

marginVertical: layout.spacing_x0_5,
};
const contentDescriptionStyle: TextStyle = {
...fontMedium14,
color: neutral77,
};
const imgBoxStyle: ViewStyle = {
position: "relative",
};
const videoDurationStyle: ViewStyle = {
position: "absolute",
left: 10,
top: 10,
backgroundColor: "gray",
borderRadius: layout.spacing_x1,
};
const contentDurationStyle: TextStyle = {
...fontSemibold14,
padding: layout.spacing_x0_5,
};
const contentImgStyle: ImageStyle = {
width: "100%",
borderRadius: layout.spacing_x1,
aspectRatio: 1.7,
};
const titleRowStyle: ViewStyle = {
marginLeft: "0.5em",
display: "flex",
flexDirection: "row",
alignItems: "center",
};
Loading

0 comments on commit e0060f4

Please sign in to comment.