|
|
|
@ -1,7 +1,9 @@ |
|
|
|
|
import React, { useState } from "react"; |
|
|
|
|
import { connect } from "react-redux"; |
|
|
|
|
import { blog, book, user, userProduct } from "../../redux/actions"; |
|
|
|
|
import { blog, book, user, userProduct, publicApi } from "../../redux/actions"; |
|
|
|
|
import AsyncStorage from "@react-native-async-storage/async-storage"; |
|
|
|
|
import { useNavigation } from "@react-navigation/native"; |
|
|
|
|
import { copilot, walkthroughable, CopilotStep } from "react-native-copilot"; |
|
|
|
|
|
|
|
|
|
import { |
|
|
|
|
View, |
|
|
|
@ -38,6 +40,9 @@ const Home = ({ |
|
|
|
|
getBooks, |
|
|
|
|
getUserProducts, |
|
|
|
|
bottomNavigation, |
|
|
|
|
setFirstLogin, |
|
|
|
|
firstLogin, |
|
|
|
|
...props |
|
|
|
|
}) => { |
|
|
|
|
const navigation = useNavigation(); |
|
|
|
|
const [position, setPosition] = useState("100%"); |
|
|
|
@ -47,6 +52,16 @@ const Home = ({ |
|
|
|
|
setPosition(position === "100%" ? "0%" : "100%"); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const getFirstLogin = React.useCallback(async () => { |
|
|
|
|
const firstLoginFlag = await AsyncStorage.getItem("firstLogin"); |
|
|
|
|
if (!firstLoginFlag) { |
|
|
|
|
AsyncStorage.setItem('firstLogin', JSON.stringify(true)); |
|
|
|
|
setTimeout(() => { |
|
|
|
|
props.start(); |
|
|
|
|
}, 800); |
|
|
|
|
} |
|
|
|
|
}, [firstLogin]); |
|
|
|
|
|
|
|
|
|
React.useEffect(() => { |
|
|
|
|
if (!blogs) { |
|
|
|
|
getBlogs(); |
|
|
|
@ -57,6 +72,8 @@ const Home = ({ |
|
|
|
|
if (!userProducts) { |
|
|
|
|
getUserProducts(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getFirstLogin(); |
|
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
@ -107,8 +124,7 @@ const styles = StyleSheet.create({ |
|
|
|
|
}, |
|
|
|
|
container: { |
|
|
|
|
flexDirection: "column", |
|
|
|
|
paddingBottom: 0, |
|
|
|
|
paddingTop: 64,
|
|
|
|
|
paddingVertical: 0, |
|
|
|
|
paddingHorizontal: 0, |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
@ -119,12 +135,23 @@ const mapStateToProps = (state) => ({ |
|
|
|
|
userProducts: state.userProduct.list, |
|
|
|
|
mobile: state.publicApi.isMobile, |
|
|
|
|
bottomNavigation: state.config.bottomNavigation, |
|
|
|
|
firstLogin: state.publicApi.firstLogin, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
|
getBlogs: blog.list, |
|
|
|
|
getBooks: book.list, |
|
|
|
|
getUserProducts: userProduct.list, |
|
|
|
|
setFirstLogin: publicApi.setFirstLogin, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Home); |
|
|
|
|
const component = copilot({ |
|
|
|
|
labels: { |
|
|
|
|
previous: "قبلی", |
|
|
|
|
next: "بعدی", |
|
|
|
|
skip: "رد کردن", |
|
|
|
|
finish: "پایان", |
|
|
|
|
}, |
|
|
|
|
})(Home); |
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(component); |
|
|
|
|