diff --git a/navigation/index.js b/navigation/index.js index ac6a331..9739705 100644 --- a/navigation/index.js +++ b/navigation/index.js @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect } from "react"; import { NavigationContainer } from "@react-navigation/native"; import { createNativeStackNavigator } from "@react-navigation/native-stack"; import { createBottomTabNavigator } from "@react-navigation/bottom-tabs"; @@ -27,6 +27,7 @@ import Exams from "../src/screens/Exams"; import ShoppingCart from "../src/screens/ShoppingCart"; import Video from "../src/screens/Video"; import VideoDisplay from "../src/screens/VideoDisplay"; +import { user } from "../src/redux/actions"; const width = Dimensions.get("window").width; @@ -41,6 +42,7 @@ const BottomTabNavigator = () => { tabBarInactiveTintColor: "grey", tabBarStyle: { backgroundColor: "#CCE6FF", + zIndex: 10, }, tabBarLabelStyle: { fontSize: width / 39, @@ -50,15 +52,6 @@ const BottomTabNavigator = () => { // tabBarLabel : 'reza' }} > - {/* ( - - ), - }} - /> */} { initialRouteName="Home" > - - - - ); }; @@ -133,11 +122,7 @@ const ProductsStackScreen = () => { return ( - - - - ); }; @@ -149,10 +134,6 @@ const VODStackScreen = () => { - - - - ); }; @@ -171,21 +152,12 @@ const AuthStackScreen = () => { ); }; -const OrderStack = createNativeStackNavigator(); -const OrderStackScreen = () => { - return ( - - - - - ); -}; const Stack = createNativeStackNavigator(); -const Navigation = ({}) => { +const Navigation = ({ getStatus, isLogin }) => { + useEffect(() => { + getStatus(); + }, []); return ( { screenOptions={{ headerShown: false }} > + + - - + + + + ); }; -const mapStateToProps = (state) => { - return {}; +const mapStateToProps = (state) => ({ + isLogin: state.user.status, +}); +const mapDispatchToProps = { + getStatus: user.getStatus, }; - -export default connect(mapStateToProps)(Navigation); +export default connect(mapStateToProps, mapDispatchToProps)(Navigation); diff --git a/package.json b/package.json index 0a2a98f..1e6eecc 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "expo-camera": "~12.1.0", "expo-device": "~4.1.0", "expo-font": "^10.0.4", + "expo-screen-orientation": "~4.1.1", "expo-status-bar": "~1.2.0", "i18next": "^21.6.3", "install": "^0.13.0", diff --git a/src/assets/sound.mp3 b/src/assets/sound.mp3 deleted file mode 100644 index 2a658cf..0000000 Binary files a/src/assets/sound.mp3 and /dev/null differ diff --git a/src/assets/video.mp4 b/src/assets/video.mp4 deleted file mode 100644 index fd6954b..0000000 Binary files a/src/assets/video.mp4 and /dev/null differ diff --git a/src/components/MusicPlayer.js b/src/components/MusicPlayer.js index 2417f6c..653aa6b 100644 --- a/src/components/MusicPlayer.js +++ b/src/components/MusicPlayer.js @@ -2,14 +2,13 @@ import React, { useState, useEffect } from "react"; import { StyleSheet, TouchableOpacity, View, Image, Text } from "react-native"; import { Ionicons } from "@expo/vector-icons"; import { Audio } from "expo-av"; -import sound from '../assets/sound.mp3'; const audioBookPlaylist = [ { title: "Hamlet - Act I", author: "William Shakespeare", source: "Librivox", - uri: sound, + uri: "", imageSource: "http://www.archive.org/download/LibrivoxCdCoverArt8/hamlet_1104.jpg", }, diff --git a/src/components/Pressable.js b/src/components/Pressable.js index 665eb59..ddd4af5 100644 --- a/src/components/Pressable.js +++ b/src/components/Pressable.js @@ -10,9 +10,11 @@ export default function Pressable1({ color, border, width, + onPress, }) { return ( onPress()} style={[ tw.style('rounded-md py-3 flex flex-row justify-center mb-3'), { diff --git a/src/constants/fontSize.js b/src/constants/fontSize.js new file mode 100644 index 0000000..78eaeea --- /dev/null +++ b/src/constants/fontSize.js @@ -0,0 +1,21 @@ +import { Dimensions } from "react-native" +import { fontSizeHandler } from "../utils/fontSizeResponsive" + +const {width} = Dimensions.get("window"); +const minWidth = 320; +const maxWidth = 1200; + +const fontSize = { + xs : fontSizeHandler(width, 10, 12, minWidth, maxWidth), + sm : fontSizeHandler(width,12, 14, minWidth, maxWidth), + base : fontSizeHandler(width, 14, 16, minWidth, maxWidth), + lg : fontSizeHandler(width, 16 , 18, minWidth, maxWidth), + xl : fontSizeHandler(width, 18, 20, minWidth, maxWidth), + xl2 : fontSizeHandler(width, 20, 22, minWidth, maxWidth), + xl3 : fontSizeHandler(width, 22, 24, minWidth, maxWidth), + xl4 : fontSizeHandler(width, 24, 26, minWidth, maxWidth), + xl5 : fontSizeHandler(width, 26, 28, minWidth, maxWidth), + xl6 : fontSizeHandler(width, 28, 30, minWidth, maxWidth) +}; + +export default fontSize; \ No newline at end of file diff --git a/src/redux/actions/user.js b/src/redux/actions/user.js index effe838..9723b12 100644 --- a/src/redux/actions/user.js +++ b/src/redux/actions/user.js @@ -1,13 +1,16 @@ import proxy from "../proxy"; const user = { + getStatus: () => async (dispatch) => { + await proxy.getStatus({ dispatch }); + }, otp: (data) => async (dispatch) => { - console.log(data); await proxy.post("public/sendOTP", data, { dispatch }); }, - otp_login: (data) => async (dispatch) => - await proxy.login("user/otp/login", data, { dispatch }), + otp_login: (data = {}) => async (dispatch) => { + await proxy.login("user/otp/login", data, { dispatch }); + }, login: (data) => async (dispatch) => await proxy.login("user/login", data, { dispatch }), diff --git a/src/redux/proxy.js b/src/redux/proxy.js index 2c79aa9..d7aa0f6 100644 --- a/src/redux/proxy.js +++ b/src/redux/proxy.js @@ -33,12 +33,7 @@ class Proxy { post = (url, params, opt, data) => { try { - this.check( - url, - opt, - () => Axios.post(url, params, opt), - data || params - ); + this.check(url, opt, () => Axios.post(url, params, opt), data || params); } catch (error) { console.log("proxy post error! : ", error); } @@ -46,12 +41,7 @@ class Proxy { put = (url, params, opt, data) => { try { - this.check( - url, - opt, - () => Axios.put(url, params, opt), - data || params - ); + this.check(url, opt, () => Axios.put(url, params, opt), data || params); } catch (error) { console.log("proxy put error! : ", error); } @@ -70,11 +60,11 @@ class Proxy { } }; - check = (url, { dispatch }, fetch, params) => { + check = async (url, { dispatch }, fetch, params) => { try { dispatch = dispatch || (() => {}); dispatch({ type: url.split("/")[0] + "/" + "loading" }); - let response = fetch(); + let response = await fetch(); switch (response.status) { case 200: dispatch({ type: url, data: response.data.data, params }); @@ -82,6 +72,7 @@ class Proxy { case 401: if (this.refresh()) { let response = fetch(); + console.log('check 401', response ) dispatch({ type: url, data: response.data.data, params }); return response.data.data; } @@ -116,13 +107,14 @@ class Proxy { }; login = (url, params, { dispatch }) => { + console.log('login called'); try { - console.log('------------------------------login---------------------------------'); this.post(url, params, { dispatch: (obj) => { let login = obj.data; - console.log('login data: ',login); - if (!login || !login.refreshToken) return false; + if (!login || !login.refreshToken){ + return false; + } const refresh = ["refresh", login.refreshToken]; const access = ["access", login.accessToken]; const userData = ["userData", JSON.stringify(login.profile)]; @@ -163,9 +155,13 @@ class Proxy { return userData || null; } catch (error) { console.log("proxy status error : ", error); + return nulll; } }; + getStatus = async ({ dispatch }) => { + let status = await this.status(); + dispatch({ type: "user/getStatus", data: {status}}) + } } const _proxy = new Proxy(); - -export default _proxy; \ No newline at end of file +export default _proxy; diff --git a/src/redux/reducers/public.js b/src/redux/reducers/public.js index ebcc014..8b90f6c 100644 --- a/src/redux/reducers/public.js +++ b/src/redux/reducers/public.js @@ -105,6 +105,7 @@ const publicApi = (state = initialState, action) => { allCats = Array.from( new Set(data.vods.map((item) => item.categoryId && item.categoryId)) ); + allCats.sort((a , b) => a - b); return { ...state, loading: false, diff --git a/src/redux/reducers/user.js b/src/redux/reducers/user.js index 65e57fd..b4966ce 100644 --- a/src/redux/reducers/user.js +++ b/src/redux/reducers/user.js @@ -1,13 +1,8 @@ import proxy from "../proxy"; import AsyncStorage from "@react-native-async-storage/async-storage"; -const checkStatus = async () => { - let status = await proxy.status(); - return status; -} - let initialState = { - status: checkStatus(), + status: null, loading: false, error: null, list: null, @@ -16,7 +11,7 @@ let initialState = { profileStatus: false, setDone: false, setLogin: false, - check : 'check' + check: "check", }; const user = (state = initialState, action) => { @@ -27,6 +22,8 @@ const user = (state = initialState, action) => { // case "user/switchRole": case "public/sendOTP": return { ...state, loading: false, error: null }; + case "user/getStatus": + return { ...state, status: data.status, error: null }; case "user/login": case "user/otp/login": return { @@ -38,10 +35,10 @@ const user = (state = initialState, action) => { }; case "user/getProfile": const myData = JSON.stringify(data); - try{ + try { AsyncStorage.setItem("userData", myData); - }catch(error){ - console.log('user/getProfile', error); + } catch (error) { + console.log("user/getProfile", error); } return { ...state, @@ -51,7 +48,7 @@ const user = (state = initialState, action) => { setDone: false, }; case "user/logout": - return { ...state, loading: false, status: proxy.status(), error: null }; + return { ...state, loading: false, status: null, error: null }; case "user/getUserRole": return { ...state, loading: false, userRoles: data, error: null }; case "user/setProfile": @@ -64,6 +61,6 @@ const user = (state = initialState, action) => { default: return state; } -} +}; -export default user; \ No newline at end of file +export default user; diff --git a/src/redux/store.js b/src/redux/store.js index 6b40c8e..a107d7f 100644 --- a/src/redux/store.js +++ b/src/redux/store.js @@ -25,10 +25,10 @@ const initialState = {}; const middleWare = [thunk]; -const loggerMiddleware = createLogger({ - predicate: () => process.env.NODE_ENV === "development", -}); -middleWare.push(loggerMiddleware); +// const loggerMiddleware = createLogger({ +// predicate: () => process.env.NODE_ENV === "development", +// }); +// middleWare.push(loggerMiddleware); const store = createStore( persistReducer( @@ -59,6 +59,6 @@ try { // console.log(e); } -console.disableYellowBox = true; +// console.disableYellowBox = true; export default store; diff --git a/src/screens/Home/assets/ar.png b/src/screens/Home/assets/ar.png deleted file mode 100644 index e22649b..0000000 Binary files a/src/screens/Home/assets/ar.png and /dev/null differ diff --git a/src/screens/Home/assets/arrow.png b/src/screens/Home/assets/arrow.png deleted file mode 100644 index 61a0a75..0000000 Binary files a/src/screens/Home/assets/arrow.png and /dev/null differ diff --git a/src/screens/Home/assets/bookFeatureIcon.png b/src/screens/Home/assets/bookFeatureIcon.png deleted file mode 100644 index fb43325..0000000 Binary files a/src/screens/Home/assets/bookFeatureIcon.png and /dev/null differ diff --git a/src/screens/Home/assets/food.png b/src/screens/Home/assets/food.png deleted file mode 100644 index eaf90b9..0000000 Binary files a/src/screens/Home/assets/food.png and /dev/null differ diff --git a/src/screens/Home/assets/olum1.png b/src/screens/Home/assets/olum1.png deleted file mode 100644 index ddaa069..0000000 Binary files a/src/screens/Home/assets/olum1.png and /dev/null differ diff --git a/src/screens/Home/assets/packageFeatureIcon.png b/src/screens/Home/assets/packageFeatureIcon.png deleted file mode 100644 index 973a1a5..0000000 Binary files a/src/screens/Home/assets/packageFeatureIcon.png and /dev/null differ diff --git a/src/screens/Home/assets/qr.png b/src/screens/Home/assets/qr.png deleted file mode 100644 index ac4d0d2..0000000 Binary files a/src/screens/Home/assets/qr.png and /dev/null differ diff --git a/src/screens/Home/assets/responsive-bg.png b/src/screens/Home/assets/responsive-bg.png deleted file mode 100644 index 31b0dac..0000000 Binary files a/src/screens/Home/assets/responsive-bg.png and /dev/null differ diff --git a/src/screens/Home/assets/shoe.png b/src/screens/Home/assets/shoe.png deleted file mode 100644 index a24f63e..0000000 Binary files a/src/screens/Home/assets/shoe.png and /dev/null differ diff --git a/src/screens/Home/assets/testFeatureIcon.png b/src/screens/Home/assets/testFeatureIcon.png deleted file mode 100644 index a8f4e47..0000000 Binary files a/src/screens/Home/assets/testFeatureIcon.png and /dev/null differ diff --git a/src/screens/Home/assets/videoFeatureIcon.png b/src/screens/Home/assets/videoFeatureIcon.png deleted file mode 100644 index 92a6def..0000000 Binary files a/src/screens/Home/assets/videoFeatureIcon.png and /dev/null differ diff --git a/src/screens/Home/components/Blogs.js b/src/screens/Home/components/Blogs.js index 44e2431..681fda0 100644 --- a/src/screens/Home/components/Blogs.js +++ b/src/screens/Home/components/Blogs.js @@ -7,35 +7,32 @@ import { TouchableOpacity, FlatList, } from "react-native"; - -const width = Dimensions.get("window").width; -const height = Dimensions.get("window").height; - +import { connect } from "react-redux"; import Header from "../components/Header"; +import fontSize from "../../../constants/fontSize"; import tw from "tailwind-rn"; -import { connect } from "react-redux"; - //asssets -import foodImage from "../assets/food.png"; import userImage from "../assets/user.png"; import messageIcon from "../assets/message.png"; //Color import Color from "../../../constants/Colors"; -function Blogs({ products }) { +const { width} = Dimensions.get("window"); +function Blogs({ blogs }) { return (
} - keyExtractor={item => item.id} + keyExtractor={(item) => item.id} /> ); @@ -44,10 +41,16 @@ function Blogs({ products }) { const Blog = ({ blog }) => { return ( navigation.navigate('Product')} > - + { { color: Color.theme1.light.blue7, fontFamily: "bold", - fontSize: width / 36, + fontSize: fontSize.sm, }, ]} > - آیا مواد غذای پر فیبر مفید هستند؟ + {blog.title} @@ -77,7 +80,7 @@ const Blog = ({ blog }) => { { color: Color.theme1.light.blue5, fontFamily: "light", - fontSize: width / 40, + fontSize: fontSize.xs, }, ]} > @@ -90,7 +93,7 @@ const Blog = ({ blog }) => { { color: Color.theme1.light.blue5, fontFamily: "light", - fontSize: width / 40, + fontSize: fontSize.xs, }, ]} > @@ -112,39 +115,3 @@ const mapStateToProps = (state) => ({ }); export default connect(mapStateToProps, {})(Blogs); -Blogs.defaultProps = { - products: [ - { - imageUrl: foodImage, - id: 0, - }, - { - imageUrl: foodImage, - id: 1, - }, - { - imageUrl: foodImage, - id: 2, - }, - { - imageUrl: foodImage, - id: 3, - }, - { - imageUrl: foodImage, - id: 4, - }, - { - imageUrl: foodImage, - id: 5, - }, - { - imageUrl: foodImage, - id: 6, - }, - { - imageUrl: foodImage, - id: 7, - }, - ], -}; diff --git a/src/screens/Home/components/Header.js b/src/screens/Home/components/Header.js index affa8ef..0dbfa0b 100644 --- a/src/screens/Home/components/Header.js +++ b/src/screens/Home/components/Header.js @@ -1,15 +1,13 @@ import React from "react"; -import { View, Text, Image, Pressable, Dimensions } from "react-native"; +import { View, Text, Pressable } from "react-native"; import {Entypo} from '@expo/vector-icons'; import { useNavigation } from "@react-navigation/native"; +import fontSize from '../../../constants/fontSize'; import tw from "tailwind-rn"; -//assets -import arrowIcon from "../assets/arrow.png"; + //Color import Color from "../../../constants/Colors"; -const width = Dimensions.get('window').width; - const Header = ({ title, route }) => { const navigation = useNavigation(); return ( @@ -19,7 +17,7 @@ const Header = ({ title, route }) => { { color: Color.theme1.light.blue5, fontFamily : 'bold', - fontSize : width / 30 + fontSize : fontSize.base }, ]} > diff --git a/src/screens/Home/components/MyBooks.js b/src/screens/Home/components/MyBooks.js index c923949..d7a95ee 100644 --- a/src/screens/Home/components/MyBooks.js +++ b/src/screens/Home/components/MyBooks.js @@ -8,12 +8,12 @@ import { 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 -import bookImage from "../assets/zist11.png"; //Color import Color from "../../../constants/Colors"; @@ -21,7 +21,7 @@ import Color from "../../../constants/Colors"; const width = Dimensions.get("window").width; const height = Dimensions.get("window").height; -function MyBooks({ getList, list, grades }) { +function MyBooks({ books, grades }) { return ( کتابهای من } + data={books} + renderItem={({ item }) => } keyExtractor={(book) => book.name} /> @@ -66,7 +67,7 @@ const Book = ({ book, grades }) => { onPress={() => navigation.navigate("Product")} > { { color: Color.theme1.light.blue6, fontFamily: "bold", - fontSize: width / 36, + fontSize: fontSize.sm, }, ]} > - {"نام کتاب"} + {book.product.book.name} { { color: Color.theme1.light.blue5, fontFamily: "light", - fontSize: width / 40, + fontSize: fontSize.xs, }, ]} - >{`پایه ${"اول"}`} + >{'پایه' + ' ' + grades[book.product.book.gradeId]} ); }; const mapStateToProps = (state) => ({ - // list: state.book.list, - // grades : state.publicApi.grades + grades : state.publicApi.grades }); -export default connect(mapStateToProps, {})(MyBooks); - -MyBooks.defaultProps = { - list: [{ name: 1 }, { name: 2 }, { name: 3 }, { name: 4 }, { name: 5 }], -}; +export default connect(mapStateToProps)(MyBooks); diff --git a/src/screens/Home/components/Scroll.js b/src/screens/Home/components/Scroll.js index bbe34c6..e89963c 100644 --- a/src/screens/Home/components/Scroll.js +++ b/src/screens/Home/components/Scroll.js @@ -2,7 +2,6 @@ import React from "react"; import { View, Image, - Dimensions, TouchableOpacity, FlatList, } from "react-native"; @@ -12,28 +11,24 @@ import tw from "tailwind-rn"; import { connect } from "react-redux"; -import olum1Image from "../assets/olum1.png"; - -const width = Dimensions.get("window").width; -const height = Dimensions.get("window").height; - -function Scroll({ products }) { +function Scroll({ books }) { return (
} + data={[{ id: 0 }]} + renderItem={({}) => } keyExtractor={(item) => item.id} /> ); } -const Box = ({ products }) => { +const Box = ({ books }) => { return ( { { height: 245, direction: "rtl" }, ]} > - {products.map((item, index) => ( - + {books.map((book, index) => ( + ))} ); }; -const Product = ({ product, position }) => { +const Product = ({ book, position }) => { const navigation = useNavigation(); return ( navigation.navigate('Product')} + onPress={() => navigation.navigate("Product")} style={[ tw("rounded-md mx-1 overflow-hidden rounded-md"), { @@ -60,9 +55,12 @@ const Product = ({ product, position }) => { height: position === 0 ? 245 : 118, }, ]} - // onPress={() => navigation.navigate('Product')} + onPress={() => navigation.navigate('Product')} > - + ); }; @@ -71,40 +69,3 @@ const mapStateToProps = (state) => ({ // features: state.publicApi.home?.features, }); export default connect(mapStateToProps, {})(Scroll); - -Scroll.defaultProps = { - products: [ - { - imageUrl: olum1Image, - id: 0, - }, - { - imageUrl: olum1Image, - id: 1, - }, - { - imageUrl: olum1Image, - id: 2, - }, - { - imageUrl: olum1Image, - id: 3, - }, - { - imageUrl: olum1Image, - id: 4, - }, - { - imageUrl: olum1Image, - id: 5, - }, - { - imageUrl: olum1Image, - id: 6, - }, - { - imageUrl: olum1Image, - id: 7, - }, - ], -}; diff --git a/src/screens/Home/components/Videos.js b/src/screens/Home/components/Videos.js index 1b45572..2dd4548 100644 --- a/src/screens/Home/components/Videos.js +++ b/src/screens/Home/components/Videos.js @@ -1,57 +1,49 @@ -import React, {useState, useEffect} from 'react'; import { View, Text, Image, TouchableOpacity, - Dimensions, FlatList, -} from 'react-native'; -import tw from 'tailwind-rn'; -import {connect} from 'react-redux'; -// import { book } from "../../../../../redux/actions"; -import Progress from '../../../components/Progress'; -import Header from '../components/Header'; - -//assets -import bookImage from '../assets/zist11.png'; +} from "react-native"; +import tw from "tailwind-rn"; +import fontSize from "../../../constants/fontSize"; +import { connect } from "react-redux"; +import Progress from "../../../components/Progress"; +import Header from "../components/Header"; //Color -import Color from '../../../constants/Colors'; - -const width = Dimensions.get('window').width; -const height = Dimensions.get('window').height; +import Color from "../../../constants/Colors"; -function Videos({getList, list, grades}) { +function Videos({ videos, grades }) { return ( - + -
+ tw("w-full flex flex-col rounded-md pt-2 px-2 overflow-hidden"), + ]} + > +