|
|
import { View, Text, Image, Pressable, FlatList, Platform } from "react-native"; |
|
|
import { useNavigation } from "@react-navigation/native"; |
|
|
import tw from "tailwind-rn"; |
|
|
import { connect } from "react-redux"; |
|
|
|
|
|
//components |
|
|
import Progress from "../../../components/Progress"; |
|
|
import Header from "../components/Header"; |
|
|
|
|
|
//style |
|
|
import Colors from "../../../constants/Colors"; |
|
|
import fontSize from "../../../constants/fontSize"; |
|
|
|
|
|
const ios = Platform.OS === "ios"; |
|
|
|
|
|
function Videos({ videos, grades, mobile, theme }) { |
|
|
return ( |
|
|
<View style={[tw("w-full mb-0")]}> |
|
|
<View style={[tw("w-full flex rounded-md pt-2 overflow-hidden")]}> |
|
|
{videos.length ? ( |
|
|
<> |
|
|
<View style={tw("flex px-4")}> |
|
|
<Header title="دورههای ویدئویی شما" route={"VOD"} /> |
|
|
</View> |
|
|
<FlatList |
|
|
showsHorizontalScrollIndicator={false} |
|
|
style={[tw("py-3")]} |
|
|
horizontal={true} |
|
|
inverted={true} |
|
|
data={videos.slice(0, 7)} |
|
|
renderItem={({ item }) => ( |
|
|
<Video |
|
|
video={item} |
|
|
grades={grades} |
|
|
mobile={mobile} |
|
|
theme={theme} |
|
|
/> |
|
|
)} |
|
|
keyExtractor={(item) => item.id} |
|
|
/> |
|
|
</> |
|
|
) : null} |
|
|
</View> |
|
|
</View> |
|
|
); |
|
|
} |
|
|
|
|
|
const Video = ({ video, mobile, grades, theme }) => { |
|
|
const navigation = useNavigation(); |
|
|
return ( |
|
|
<Pressable |
|
|
style={[ |
|
|
tw(`flex relative ${mobile ? "mr-4" : "ml-5"}`), |
|
|
{ width: mobile ? 200 : 200, height: mobile ? 210 : 210 }, |
|
|
]} |
|
|
onPress={() => navigation.navigate("Video", { id: video.id })} |
|
|
> |
|
|
<Image |
|
|
source={{ uri: `https://dnvn.ir/api/v1/file/${video.fileIds}` }} |
|
|
// resizeMode="contain" |
|
|
style={[ |
|
|
tw("bg-gray-100"), |
|
|
{ |
|
|
height: mobile ? 130 : 130, |
|
|
}, |
|
|
]} |
|
|
/> |
|
|
<Text |
|
|
style={[ |
|
|
tw("mt-2 px-1"), |
|
|
{ |
|
|
color: |
|
|
theme === "light" ? Colors.theme1.gray20 : Colors.theme1.white, |
|
|
fontFamily: "bold", |
|
|
fontSize: mobile ? fontSize.sm : fontSize.xl, |
|
|
textAlign: ios ? "right" : "auto", |
|
|
}, |
|
|
]} |
|
|
> |
|
|
{"دوره ویدئویی" + " " + video.name} |
|
|
</Text> |
|
|
<Text |
|
|
style={[ |
|
|
tw("mt-1 pr-1"), |
|
|
{ |
|
|
color: |
|
|
theme === "light" ? Colors.theme1.gray20 : Colors.theme1.white, |
|
|
fontFamily: "regular", |
|
|
fontSize: mobile ? fontSize.xs : fontSize.base, |
|
|
textAlign: ios ? "right" : "auto", |
|
|
}, |
|
|
]} |
|
|
> |
|
|
{"پایه" + " " + grades[video.gradeId]} |
|
|
</Text> |
|
|
<View style={tw("absolute bottom-0 left-0 w-full")}> |
|
|
<Progress percent={60} alignItems={"items-end"} /> |
|
|
</View> |
|
|
</Pressable> |
|
|
); |
|
|
}; |
|
|
|
|
|
const mapStateToProps = (state) => ({ |
|
|
grades: state.publicApi.grades, |
|
|
mobile: state.publicApi.mobile, |
|
|
theme: state.publicApi.theme, |
|
|
}); |
|
|
|
|
|
export default connect(mapStateToProps, {})(Videos);
|
|
|
|