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.
 
 
 
 
 

133 lines
3.8 KiB

import React from "react";
import { View, Text, Dimensions, Pressable, Appearance } from "react-native";
import { connect } from "react-redux";
import { publicApi } from "../../../../redux/actions";
import { useNavigation } from "@react-navigation/native";
//style
import tw from "tailwind-rn";
import fontSize from "../../../../constants/fontSize";
import Colors from "../../../../constants/Colors";
const { width } = Dimensions.get("window");
const Season = ({ season, activeUnit, name, setVideoActive }) => {
const colorScheme = Appearance.getColorScheme();
const navigation = useNavigation();
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 Unit = ({ unit }) => {
const selectVideo = () => {
setVideoActive(unit);
navigation.navigate("VideoDisplay", {
season: season,
unit: unit,
name: name,
});
};
return (
<View
style={[
tw("w-full flex flex-col rounded-md overflow-hidden mb-3"),
{
borderWidth: 1,
borderColor: Colors.theme1[colorScheme].greenD9,
backgroundColor:
activeUnit === unit
? Colors.theme1[colorScheme].greenCF
: "transparent",
},
]}
>
<View
style={[
tw(
"w-full flex flex-row-reverse justify-between items-center py-2 px-3"
),
{
borderBottomWidth: 1,
borderColor: Colors.theme1[colorScheme].greenD9,
},
]}
>
<Text
style={[
{
fontFamily: "bold",
fontSize: fontSize.xl,
color:
activeUnit === unit ? "white" : Colors.theme1[colorScheme].green79,
},
]}
>
{unit.name}
</Text>
<Text
style={[
{
fontFamily: "bold",
fontSize: fontSize.base,
color: activeUnit === unit ? "white" : Colors.theme1[colorScheme].green79,
borderRightWidth: 1,
borderColor: activeUnit === unit ? "white" : Colors.theme1[colorScheme].green79,
paddingRight: 8,
},
]}
>
{duration(unit.duration)}
</Text>
</View>
<View style={[tw("w-full flex flex-row-reverse")]}>
<Pressable
style={[
tw("flex flex-1 flex-row items-center py-2 px-2"),
]}
onPress={() => selectVideo()}
>
<Text
style={{
width: "100%",
textAlign: "center",
fontFamily: "bold",
fontSize: fontSize.lg,
color: activeUnit === unit ? "white" : Colors.theme1[colorScheme].green79,
}}
>
نمایش
</Text>
</Pressable>
</View>
</View>
);
};
return (
<View style={tw("w-full flex flex-col")}>
{season.map((unit, index) => (
<Unit unit={unit} key={index} />
))}
</View>
);
};
const mapStateToProps = (state) => ({
selectedVideo: state.publicApi.selectedVideo,
realSeasons: state.publicApi.bookInfo?.categories,
vods: state.publicApi.bookSection?.vods,
userid: state.user.status.id,
});
const mapDispatchToProps = {
setVideoActive: publicApi.setVideoActive,
};
export default connect(mapStateToProps, mapDispatchToProps)(Season);