Skip to content

Commit 9cd34fe

Browse files
chore: hide export data (#624)
* chore: hide export data * chore: update devmode on focus effect
1 parent 016a712 commit 9cd34fe

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

app/src/scenes/settings/settings-modal.tsx

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { useEffect, useState } from "react";
22
import { View, StyleSheet, Modal, TouchableOpacity, ScrollView, useWindowDimensions } from "react-native";
33
import SettingItem from "./setting-item";
44
import Bell from "@assets/svg/icon/Bell";
@@ -11,14 +11,24 @@ import { useBottomSheet } from "@/context/BottomSheetContext";
1111
import { DrugsBottomSheet } from "@/components/DrugsBottomSheet";
1212
import localStorage from "@/utils/localStorage";
1313
import logEvents from "@/services/logEvents";
14+
import AsyncStorage from "@react-native-async-storage/async-storage";
15+
import { useFocusEffect } from "@react-navigation/native";
1416

1517
const SettingsModal = ({ navigation, visible, onClick }) => {
1618
const { showBottomSheet, closeBottomSheet } = useBottomSheet();
1719
const { width, height } = useWindowDimensions();
1820
const isLandscape = width > height;
19-
2021
const ContentWrapper = isLandscape ? ScrollView : View;
2122

23+
const [isDevMode, setIsDevMode] = useState(false);
24+
25+
useFocusEffect(() => {
26+
(async () => {
27+
const devMode = await AsyncStorage.getItem("devMode");
28+
setIsDevMode(devMode === "true");
29+
})();
30+
});
31+
2232
return (
2333
<Modal animationType="slide" visible={visible} transparent={true} supportedOrientations={["portrait", "landscape"]}>
2434
<TouchableOpacity activeOpacity={1} style={styles.container} onPressOut={onClick}>
@@ -84,16 +94,18 @@ const SettingsModal = ({ navigation, visible, onClick }) => {
8494
}}
8595
icon={<Download />}
8696
/>
87-
<SettingItem
88-
title="Sauvegarder mes données"
89-
path="data-export-import"
90-
navigation={navigation}
91-
onClick={() => {
92-
onClick();
93-
logEvents.logOpenExportSummary();
94-
}}
95-
icon={<Save />}
96-
/>
97+
{isDevMode && (
98+
<SettingItem
99+
title="Sauvegarder mes données"
100+
path="data-export-import"
101+
navigation={navigation}
102+
onClick={() => {
103+
onClick();
104+
logEvents.logOpenExportSummary();
105+
}}
106+
icon={<Save />}
107+
/>
108+
)}
97109
</ContentWrapper>
98110
</TouchableOpacity>
99111
</Modal>

0 commit comments

Comments
 (0)