Skip to content

Commit e6fefd6

Browse files
Merge pull request #328 from OpenDTU-App/290-highlight-where-the-user-can-report-bugs-and-leave-feedback-oss-playstore
Add infos for feedback and bug reporting
2 parents 3cf0f8f + 3200dec commit e6fefd6

File tree

7 files changed

+164
-3
lines changed

7 files changed

+164
-3
lines changed

src/components/AppInfos.tsx

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import type { FC } from 'react';
2+
import { useTranslation } from 'react-i18next';
3+
import { Box } from 'react-native-flex-layout';
4+
import { Icon, IconButton, Text } from 'react-native-paper';
5+
6+
import {
7+
setBugreportInfoDismissed,
8+
setFeedbackInfoDismissed,
9+
} from '@/slices/settings';
10+
11+
import { colors } from '@/constants';
12+
import { useAppDispatch, useAppSelector } from '@/store';
13+
14+
const AppInfos: FC = () => {
15+
const { t } = useTranslation();
16+
17+
const feedbackInfoDismissed = useAppSelector(
18+
store => store.settings.feedbackInfoDismissed,
19+
);
20+
const bugreportInfoDismissed = useAppSelector(
21+
store => store.settings.bugreportInfoDismissed,
22+
);
23+
24+
const dispatch = useAppDispatch();
25+
26+
const handleHideFeedbackInfo = () => {
27+
dispatch(setFeedbackInfoDismissed());
28+
};
29+
30+
const handleHideBugreportInfo = () => {
31+
dispatch(setBugreportInfoDismissed());
32+
};
33+
34+
return (
35+
<>
36+
{!feedbackInfoDismissed ? (
37+
<Box
38+
style={{
39+
marginHorizontal: 12,
40+
padding: 8,
41+
backgroundColor: colors.info,
42+
borderRadius: 16,
43+
marginBottom: 8,
44+
display: 'flex',
45+
flexDirection: 'row',
46+
alignItems: 'center',
47+
}}
48+
>
49+
<Box
50+
style={{
51+
display: 'flex',
52+
flexDirection: 'row',
53+
flex: 1,
54+
alignItems: 'center',
55+
gap: 8,
56+
}}
57+
>
58+
<Box mh={8}>
59+
<Icon size={24} source="file-document" />
60+
</Box>
61+
<Box style={{ flex: 1 }}>
62+
<Text variant="titleMedium">{t('appInfos.feedback')}</Text>
63+
<Text style={{ color: colors.onInfo }}>
64+
{t('appInfos.feedbackDescription')}
65+
</Text>
66+
</Box>
67+
</Box>
68+
<IconButton icon="close" onPress={handleHideFeedbackInfo} />
69+
</Box>
70+
) : null}
71+
{!bugreportInfoDismissed ? (
72+
<Box
73+
style={{
74+
marginHorizontal: 12,
75+
padding: 8,
76+
backgroundColor: colors.info,
77+
borderRadius: 16,
78+
marginBottom: 8,
79+
display: 'flex',
80+
flexDirection: 'row',
81+
alignItems: 'center',
82+
}}
83+
>
84+
<Box
85+
style={{
86+
display: 'flex',
87+
flexDirection: 'row',
88+
flex: 1,
89+
alignItems: 'center',
90+
gap: 8,
91+
}}
92+
>
93+
<Box mh={8}>
94+
<Icon size={24} source="bug" />
95+
</Box>
96+
<Box style={{ flex: 1 }}>
97+
<Text variant="titleMedium">{t('appInfos.bugReporting')}</Text>
98+
<Text style={{ color: colors.onInfo, flex: 1 }}>
99+
{t('appInfos.bugReportingDescription')}
100+
</Text>
101+
</Box>
102+
<IconButton icon="close" onPress={handleHideBugreportInfo} />
103+
</Box>
104+
</Box>
105+
) : null}
106+
</>
107+
);
108+
};
109+
110+
export default AppInfos;

src/constants.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
export const colors = {
22
success: '#4caf50',
3+
onSuccess: '#fff',
34
error: '#f44336',
5+
onError: '#fff',
46
warning: '#ff9800',
7+
onWarning: '#fff',
8+
info: '#0a5591',
9+
onInfo: '#fff',
510
dark: {
611
successSurface: '#164016',
712
onSuccessSurface: '#c0e5c0',
@@ -28,3 +33,6 @@ export const maximumTestedOpenDtuFirmwareVersion = 'v24.4.12';
2833

2934
export const weblateUrl =
3035
'https://weblate.commanderred.xyz/engage/opendtu-react-native/';
36+
37+
export const bugreportUrl =
38+
'https://github.com/OpenDTU-App/opendtu-react-native/issues/new';

src/slices/settings.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ const initialState: SettingsState = {
4141
enableFetchOpenDTUReleases: DidNotAskYet,
4242
debugEnabled: false,
4343
lastAppVersion: packageJson.version,
44+
feedbackInfoDismissed: false,
45+
bugreportInfoDismissed: false,
4446
};
4547

4648
const log = rootLogging.extend('SettingsSlice');
@@ -267,6 +269,12 @@ const settingsSlice = createSlice({
267269
setLastAppVersion: (state, action: SetLastAppVersionAction) => {
268270
state.lastAppVersion = action.payload.version;
269271
},
272+
setFeedbackInfoDismissed: state => {
273+
state.feedbackInfoDismissed = true;
274+
},
275+
setBugreportInfoDismissed: state => {
276+
state.bugreportInfoDismissed = true;
277+
},
270278
},
271279
});
272280

@@ -295,6 +303,8 @@ export const {
295303
setEnableFetchOpenDTUReleases,
296304
updateLastAppVersion,
297305
setLastAppVersion,
306+
setFeedbackInfoDismissed,
307+
setBugreportInfoDismissed,
298308
} = settingsSlice.actions;
299309

300310
export const { reducer: SettingsReducer } = settingsSlice;

src/translations

src/types/settings.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ export interface SettingsState {
5151

5252
// database
5353
databaseConfigs: DatabaseConfig[];
54+
55+
// modals & infos
56+
feedbackInfoDismissed: boolean;
57+
bugreportInfoDismissed: boolean;
5458
}
5559

5660
// Redux Actions

src/views/navigation/tabs/LivedataTab.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useTheme } from 'react-native-paper';
22

3+
import AppInfos from '@/components/AppInfos';
34
import DeviceOfflineWrapper from '@/components/DeviceOfflineWrapper';
45
import DeviceStatus from '@/components/DeviceStatus';
56
import ImportantStatusValues from '@/components/ImportantStatusValues';
@@ -13,6 +14,7 @@ const LivedataTab = () => {
1314
<StyledView theme={theme}>
1415
<DeviceOfflineWrapper>
1516
<StyledScrollView theme={theme} disableSafeBottomMargin>
17+
<AppInfos />
1618
<DeviceStatus />
1719
<ImportantStatusValues />
1820
</StyledScrollView>

src/views/navigation/tabs/MainSettingsTab.tsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import { useCallback, useMemo, useState } from 'react';
33
import { useTranslation } from 'react-i18next';
44
import { Box } from 'react-native-flex-layout';
55
import { Badge, List, Text, useTheme } from 'react-native-paper';
6+
import Toast from 'react-native-toast-message';
67
import { useDispatch } from 'react-redux';
78

8-
import { ScrollView, View } from 'react-native';
9+
import { Linking, ScrollView, View } from 'react-native';
910

1011
import { setDebugEnabled } from '@/slices/settings';
1112

@@ -21,13 +22,17 @@ import useIsConnected from '@/hooks/useIsConnected';
2122
import useRequireMultiplePresses from '@/hooks/useRequireMultiplePresses';
2223
import useSettings from '@/hooks/useSettings';
2324

24-
import { spacing } from '@/constants';
25+
import { rootLogging } from '@/utils/log';
26+
27+
import { bugreportUrl, spacing } from '@/constants';
2528
import { StyledView } from '@/style';
2629

2730
import type { NavigationProp, ParamListBase } from '@react-navigation/native';
2831
import { useNavigation } from '@react-navigation/native';
2932
import packageJson from '@root/package.json';
3033

34+
const log = rootLogging.extend('MainSettingsTab');
35+
3136
const MainSettingsTab: FC = () => {
3237
const navigation = useNavigation() as NavigationProp<ParamListBase>;
3338
const { t } = useTranslation();
@@ -123,6 +128,22 @@ const MainSettingsTab: FC = () => {
123128
navigation.navigate('LicensesScreen');
124129
}, [navigation]);
125130

131+
const handleBugReporting = useCallback(async () => {
132+
// open github issues
133+
const url = bugreportUrl;
134+
135+
// open url in browser
136+
if (await Linking.canOpenURL(url)) {
137+
await Linking.openURL(url);
138+
} else {
139+
log.error(`Cannot open URL: ${url}`);
140+
Toast.show({
141+
type: 'error',
142+
text1: t('cannotOpenUrl'),
143+
});
144+
}
145+
}, [t]);
146+
126147
const handleDebugScreen = useCallback(() => {
127148
navigation.navigate('DebugScreen');
128149
}, [navigation]);
@@ -295,6 +316,12 @@ const MainSettingsTab: FC = () => {
295316
}
296317
onPress={handleAbout}
297318
/>
319+
<List.Item
320+
title={t('settings.bugReporting')}
321+
description={t('settings.bugReportingDescription')}
322+
left={props => <List.Icon {...props} icon="bug" />}
323+
onPress={handleBugReporting}
324+
/>
298325
<List.Item
299326
title={t('settings.licenses')}
300327
description={t('settings.licensesDescription')}

0 commit comments

Comments
 (0)