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.
118 lines
2.8 KiB
118 lines
2.8 KiB
import { |
|
View, |
|
Text, |
|
Image, |
|
Pressable, |
|
FlatList, |
|
Appearance, |
|
Platform, |
|
} from "react-native"; |
|
import { useNavigation } from "@react-navigation/native"; |
|
import { connect } from "react-redux"; |
|
|
|
//components |
|
import Progress from "../../../components/Progress"; |
|
|
|
//Color |
|
import Colors from "../../../constants/Colors"; |
|
import tw from "tailwind-rn"; |
|
import fontSize from "../../../constants/fontSize"; |
|
|
|
const ios = Platform.OS === "ios"; |
|
|
|
function MyBooks({ books, grades }) { |
|
const colorScheme = Appearance.getColorScheme(); |
|
return ( |
|
<View style={[tw("flex w-full mb-5")]}> |
|
<View |
|
style={[ |
|
tw(`w-full flex rounded-md pt-3 overflow-hidden`), |
|
{ |
|
backgroundColor: Colors.theme1[colorScheme].greenCF + "0F", |
|
borderColor: Colors.theme1[colorScheme].greenD9 + "", |
|
borderWidth: 1, |
|
}, |
|
]} |
|
> |
|
<Text |
|
style={[ |
|
tw(`pr-4 ${ios ? "text-right" : ""} w-full`), |
|
{ |
|
color: Colors.theme1[colorScheme].green79, |
|
fontFamily: "demi", |
|
fontSize: fontSize.lg, |
|
}, |
|
]} |
|
> |
|
کتابهای من |
|
</Text> |
|
<FlatList |
|
showsHorizontalScrollIndicator={false} |
|
style={[tw("py-3")]} |
|
horizontal={true} |
|
inverted={true} |
|
data={books} |
|
renderItem={({ item }) => <Book book={item} grades={grades} />} |
|
keyExtractor={(book) => book?.id} |
|
/> |
|
</View> |
|
</View> |
|
); |
|
} |
|
|
|
const Book = ({ book, grades }) => { |
|
const colorScheme = Appearance.getColorScheme(); |
|
const navigation = useNavigation(); |
|
return ( |
|
<Pressable |
|
style={tw(`flex mr-4 ${ios ? "items-end" : ""}`)} |
|
onPress={() => {}} |
|
> |
|
<View style={{ height: 165 }}> |
|
<Image |
|
source={{ |
|
uri: `https://dnvn.ir/api/v1/file/${book.product.book.fileIds}`, |
|
}} |
|
resizeMode="contain" |
|
style={[ |
|
{ |
|
width: 110, |
|
flex: 1, |
|
}, |
|
]} |
|
/> |
|
</View> |
|
<Text |
|
style={[ |
|
tw("mt-2 pr-1"), |
|
{ |
|
color: Colors.theme1[colorScheme].gray20, |
|
fontFamily: "bold", |
|
fontSize: fontSize.sm, |
|
}, |
|
]} |
|
> |
|
{book.product.book.name} |
|
</Text> |
|
<Text |
|
style={[ |
|
tw("pr-1"), |
|
{ |
|
color: Colors.theme1[colorScheme].gray20, |
|
fontFamily: "light", |
|
fontSize: fontSize.sm, |
|
}, |
|
]} |
|
> |
|
{"پایه" + " " + grades[book.product.book.gradeId]} |
|
</Text> |
|
<Progress percent={60} alignItems={"items-end"} /> |
|
</Pressable> |
|
); |
|
}; |
|
|
|
const mapStateToProps = (state) => ({ |
|
grades: state.publicApi.grades, |
|
}); |
|
|
|
export default connect(mapStateToProps)(MyBooks);
|
|
|