You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

175 lines
4.9 KiB

import React from "react";
import { View, Text, Pressable, TouchableOpacity } from "react-native";
import {SimpleLineIcons} from '@expo/vector-icons';
import { connect } from "react-redux";
import { publicApi } from "../../../redux/actions";
import tw from "tailwind-rn";
import fontSize from "../../../constants/fontSize";
import Colors from "../../../constants/Colors";
import { useNavigation } from "@react-navigation/native";
const duration = (value) => {
const minute = value % 60;
const hour = Math.round(value / 60);
return (
(hour > 0
? (hour.toString().length === 1 ? "0" + hour.toString() : hour) + ""
: "") +
":" +
(minute.toString().length === 1 ? "0" + minute.toString() : minute)
);
};
const Season = ({ season, toggle, activeSeason, realSeasons, seasonName }) => {
// const [selectedSeason, setSelectedSeason] = useState(null);
const navigation = useNavigation();
const Unit = ({ unit }) => {
return (
<View
style={[
tw("w-full flex flex-col rounded-md overflow-hidden mb-3"),
{ borderWidth: 1, borderColor: Colors.theme1.light.blue3 },
]}
>
<View
style={[
tw(
"w-full flex flex-row-reverse justify-between items-center py-2 px-3"
),
{
borderBottomWidth: 1,
borderColor: Colors.theme1.light.blue3,
},
]}
>
<Text
style={[
{
fontFamily: "regular",
fontSize: fontSize.base,
color: Colors.theme1.light.blue5,
},
]}
>
{unit.name}
</Text>
<Text
style={[
{
fontFamily: "regular",
fontSize: fontSize.base,
color: Colors.theme1.light.blue5,
},
]}
>
{duration(unit.duration)}
</Text>
</View>
<View style={[tw("w-full flex flex-row-reverse")]}>
{1 && (
<Pressable
style={[
tw("flex flex-1 flex-row items-center py-2 px-2"),
{
borderLeftWidth: 1,
borderColor: Colors.theme1.light.blue3,
},
]}
onPress={() =>
navigation.navigate("VideoDisplay", {
season: season,
unit: unit,
name: seasonName,
})
}
>
<Text
style={{
width: "100%",
textAlign: "center",
fontFamily: "regular",
fontSize: fontSize.base,
color: Colors.theme1.light.blue5,
}}
>
نمایش
</Text>
</Pressable>
)}
{/* {0 && (
<Pressable
style={tw("flex flex-1 flex-row items-center py-1.5 px-2")}
>
<Text
style={{
width: "100%",
textAlign: "center",
fontFamily: "regular",
fontSize: fontSize.sm,
color: Colors.theme1.light.blue5,
}}
>
دانلود
</Text>
</Pressable>
)} */}
</View>
</View>
);
};
return (
<View style={tw("w-full flex flex-col")}>
<TouchableOpacity
style={[
tw(
"flex flex-row-reverse justify-between items-center rounded-md py-3 px-3 mb-3"
),
{ backgroundColor: Colors.theme1.light.blue5 },
]}
onPress={() => toggle(season[0].categoryId)}
>
<Text
style={[
{
fontFamily: "regular",
fontSize: fontSize.base,
color: "white",
},
]}
>
{
realSeasons.filter((item) => item.id === season[0].categoryId)[0]
.name
}
</Text>
<SimpleLineIcons name={season[0].categoryId === activeSeason ? "arrow-up" : "arrow-down"} size={14} color="white" />
{/* <Text
style={[
{
fontFamily: "regular",
fontSize: fontSize.sm,
color: "white",
},
]}
>
{season.duration}
</Text> */}
</TouchableOpacity>
{season[0].categoryId === activeSeason &&
season.map((unit, index) => <Unit unit={unit} key={index} />)}
</View>
);
};
const mapStateToProps = (state) => ({
activeSeason: state.publicApi.activeCategory,
realSeasons: state.publicApi.bookInfo?.categories,
vodDuration: state.publicApi.bookInfo?.vodDuration,
});
const mapDispatchToProps = {
toggle: publicApi.activeCategory,
};
export default connect(mapStateToProps, mapDispatchToProps)(Season);