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.
55 lines
1.5 KiB
55 lines
1.5 KiB
import { Pressable, Text, Image, Dimensions, Appearance } from "react-native"; |
|
import React from "react"; |
|
import { connect } from "react-redux"; |
|
import { useNavigation } from "@react-navigation/native"; |
|
import * as Linking from 'expo-linking'; |
|
|
|
//style |
|
import tw from "tailwind-rn"; |
|
import fontSize from "../../../constants/fontSize"; |
|
import Colors from "../../../constants/Colors"; |
|
|
|
const { width, height } = Dimensions.get("window"); |
|
|
|
const Book = ({ book, mobile }) => { |
|
const navigation = useNavigation(); |
|
const colorScheme = Appearance.getColorScheme(); |
|
return ( |
|
<Pressable |
|
style={[ |
|
tw("flex flex-col items-end rounded-md p-2 my-2"), |
|
{ width: mobile ? "48%" : width / 4.2 }, |
|
]} |
|
onPress={() => Linking.openURL(`https://ar.dnvn.ir/lunch?id=${book.id}`)} |
|
> |
|
<Image |
|
source={{ uri: `https://dnvn.ir/api/v1/file/${book.fileId}` }} |
|
style={[ |
|
tw("rounded-md"), |
|
{ |
|
width: "100%", |
|
height: ((mobile ? width / 2 - 36 : width / 4.2) * 4) / 3, |
|
}, |
|
]} |
|
/> |
|
<Text |
|
style={[ |
|
{ |
|
fontFamily: "bold", |
|
fontSize: fontSize.lg, |
|
marginTop: 10, |
|
color: Colors.theme1[colorScheme].green79, |
|
}, |
|
]} |
|
> |
|
{book.title} |
|
</Text> |
|
</Pressable> |
|
); |
|
}; |
|
|
|
const mapStateToProps = (state) => ({ |
|
mobile: state.publicApi.mobile, |
|
}); |
|
|
|
export default connect(mapStateToProps)(Book);
|
|
|