Skip to content

Commit

Permalink
fix: handle frequency and closing
Browse files Browse the repository at this point in the history
  • Loading branch information
YoanRos committed Sep 12, 2024
1 parent abe35f3 commit c0c60e4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
6 changes: 5 additions & 1 deletion expo/src/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@ const Router = () => {
onReady={() => {
API.navigation = navigationRef.current;
if (alreadyExported) navigationRef.current.navigate("MODAL_EXPORT_DONE");
else navigationRef.current.navigate("MODAL_CLOSE_APP");
const lastShownEndModal = storage.getString("@lastShownEndModal");
if (!lastShownEndModal || dayjsInstance().diff(lastShownEndModal, "day") >= 5) {
storage.set("@lastShownEndModal", dayjsInstance().format("YYYY-MM-DD"));
navigationRef.current.navigate("MODAL_CLOSE_APP");
}
}}
onStateChange={onNavigationStateChange}
linking={deepLinkingConfig}
Expand Down
25 changes: 16 additions & 9 deletions expo/src/scenes/WelcomeScreen/EndOzModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ const EndOzModal = ({ navigation }) => {
const [currentPage, setCurrentPage] = useState(0);
const pagerRef = useRef(null);

const onStartPress = async () => {
storage.set("@OnboardingDoneWithCGU", true);
navigation.navigate("USER_SURVEY_START", { from: "NEW_USER" });
};

const onPressNext = () => {
if (pagerRef.current) {
pagerRef.current.setPage(currentPage + 1);
setCurrentPage(currentPage + 1);
if (currentPage === 3) {
navigation.goBack();
} else {
pagerRef.current.setPage(currentPage + 1);

setCurrentPage(currentPage + 1);
}
} else {
console.warn("Pager ref is not defined");
}
Expand All @@ -40,7 +40,12 @@ const EndOzModal = ({ navigation }) => {
<SafeAreaView className="flex-1 justify-center items-center">
<View className="bg-white rounded-xl w-[90%] h-[70%]">
<View className="h-5 flex flex-row justify-end p-3">
<TouchableOpacity hitSlop={hitSlop(15)} onPress={() => {}}>
<TouchableOpacity
hitSlop={hitSlop(15)}
onPress={() => {
navigation.goBack();
}}
>
<Svg fill="none" viewBox="0 0 24 24" className="h-5 w-5">
<Path
strokeLinecap="round"
Expand Down Expand Up @@ -79,7 +84,9 @@ const EndOzModal = ({ navigation }) => {
onPress={onPressNext}
className="justify-center items-center flex-row rounded-3xl bg-[#DE285E] px-6 py-3"
>
<Text className="font-bold text-white text-center text-base">Suivant</Text>
<Text className="font-bold text-white text-center text-base">
{currentPage === 3 ? "Terminer" : "Suivant"}
</Text>
</TouchableOpacity>
</View>
</View>
Expand Down

0 comments on commit c0c60e4

Please sign in to comment.