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.
 
 
 
 
 

110 lines
2.6 KiB

import React, { useState, useEffect } from "react";
import {
View,
Text,
Image,
TouchableOpacity,
Dimensions,
FlatList,
} from "react-native";
import tw from "tailwind-rn";
import fontSize from '../../../constants/fontSize';
import {useNavigation} from '@react-navigation/native';
import { connect } from "react-redux";
import Progress from "../../../components/Progress";
//assets
//Color
import Color from "../../../constants/Colors";
const width = Dimensions.get("window").width;
const height = Dimensions.get("window").height;
function MyBooks({ books, grades }) {
return (
<View style={[tw("w-full px-4 mb-5")]}>
<View
style={[
tw("w-full flex flex-col rounded-md pt-2 px-2 overflow-hidden"),
{
backgroundColor: Color.theme1.light.blue1,
borderColor: Color.theme1.light.blue2,
borderWidth: 1,
},
]}
>
<Text
style={[
{
color: Color.theme1.light.blue5,
fontFamily: "bold",
fontSize: fontSize.base,
},
]}
>
کتابهای من
</Text>
<FlatList
showsHorizontalScrollIndicator={false}
style={[tw("py-3")]}
horizontal={true}
inverted={true}
data={books}
renderItem={({ item }) => <Book book={item} grades={grades} />}
keyExtractor={(book) => book.name}
/>
</View>
</View>
);
}
const Book = ({ book, grades }) => {
const navigation = useNavigation();
return (
<TouchableOpacity
style={tw("flex flex-col ml-3")}
onPress={() => navigation.navigate("Product")}
>
<Image
source={{uri : `https://dnvn.ir/api/v1/file/${book.product.book.fileIds}` }}
style={[
tw("rounded-md"),
{
height: 160,
width: 110,
},
]}
/>
<Text
style={[
tw("mt-2 pr-1"),
{
color: Color.theme1.light.blue6,
fontFamily: "bold",
fontSize: fontSize.sm,
},
]}
>
{book.product.book.name}
</Text>
<Text
style={[
tw("mt-1 pr-1"),
{
color: Color.theme1.light.blue5,
fontFamily: "light",
fontSize: fontSize.xs,
},
]}
>{'پایه' + ' ' + grades[book.product.book.gradeId]}</Text>
<Progress percent={60} alignItems={'items-end'} />
</TouchableOpacity>
);
};
const mapStateToProps = (state) => ({
grades : state.publicApi.grades
});
export default connect(mapStateToProps)(MyBooks);