|
@@ -0,0 +1,129 @@
|
|
1
|
+import React from 'react';
|
|
2
|
+import { Linking, StyleSheet } from 'react-native';
|
|
3
|
+import {
|
|
4
|
+ Avatar,
|
|
5
|
+ Button,
|
|
6
|
+ Card,
|
|
7
|
+ Paragraph,
|
|
8
|
+ Text,
|
|
9
|
+ useTheme,
|
|
10
|
+} from 'react-native-paper';
|
|
11
|
+import TimeAgo from 'react-native-timeago';
|
|
12
|
+import i18n from 'i18n-js';
|
|
13
|
+import { useNavigation } from '@react-navigation/core';
|
|
14
|
+import { MainRoutes } from '../../../navigation/MainNavigator';
|
|
15
|
+import ProxiwashConstants from '../../../constants/ProxiwashConstants';
|
|
16
|
+import { ProxiwashInfoType } from '../../../screens/Proxiwash/ProxiwashScreen';
|
|
17
|
+import * as Animatable from 'react-native-animatable';
|
|
18
|
+
|
|
19
|
+let moment = require('moment'); //load moment module to set local language
|
|
20
|
+require('moment/locale/fr'); // import moment local language file during the application build
|
|
21
|
+moment.locale('fr');
|
|
22
|
+
|
|
23
|
+type Props = {
|
|
24
|
+ date?: Date;
|
|
25
|
+ selectedWash: 'tripodeB' | 'washinsa';
|
|
26
|
+ info?: ProxiwashInfoType;
|
|
27
|
+};
|
|
28
|
+
|
|
29
|
+const styles = StyleSheet.create({
|
|
30
|
+ card: {
|
|
31
|
+ marginHorizontal: 5,
|
|
32
|
+ },
|
|
33
|
+ messageCard: {
|
|
34
|
+ marginTop: 50,
|
|
35
|
+ marginBottom: 10,
|
|
36
|
+ },
|
|
37
|
+ actions: {
|
|
38
|
+ justifyContent: 'center',
|
|
39
|
+ },
|
|
40
|
+});
|
|
41
|
+
|
|
42
|
+function ProxiwashListHeader(props: Props) {
|
|
43
|
+ const navigation = useNavigation();
|
|
44
|
+ const theme = useTheme();
|
|
45
|
+ const { date, selectedWash } = props;
|
|
46
|
+ let title = i18n.t('screens.proxiwash.washinsa.title');
|
|
47
|
+ let icon = ProxiwashConstants.washinsa.icon;
|
|
48
|
+ if (selectedWash === 'tripodeB') {
|
|
49
|
+ title = i18n.t('screens.proxiwash.tripodeB.title');
|
|
50
|
+ icon = ProxiwashConstants.tripodeB.icon;
|
|
51
|
+ }
|
|
52
|
+ const message = props.info?.message;
|
|
53
|
+ return (
|
|
54
|
+ <>
|
|
55
|
+ <Card style={styles.card}>
|
|
56
|
+ <Card.Title
|
|
57
|
+ title={title}
|
|
58
|
+ subtitle={
|
|
59
|
+ date ? (
|
|
60
|
+ <Text>
|
|
61
|
+ {i18n.t('screens.proxiwash.updated')}
|
|
62
|
+ <TimeAgo time={date} interval={2000} />
|
|
63
|
+ </Text>
|
|
64
|
+ ) : null
|
|
65
|
+ }
|
|
66
|
+ left={(iconProps) => (
|
|
67
|
+ <Avatar.Icon icon={icon} size={iconProps.size} />
|
|
68
|
+ )}
|
|
69
|
+ />
|
|
70
|
+ <Card.Actions style={styles.actions}>
|
|
71
|
+ <Button
|
|
72
|
+ mode={'contained'}
|
|
73
|
+ onPress={() => navigation.navigate(MainRoutes.Settings)}
|
|
74
|
+ icon={'swap-horizontal'}
|
|
75
|
+ >
|
|
76
|
+ {i18n.t('screens.proxiwash.switch')}
|
|
77
|
+ </Button>
|
|
78
|
+ </Card.Actions>
|
|
79
|
+ </Card>
|
|
80
|
+ {message ? (
|
|
81
|
+ <Card
|
|
82
|
+ style={{
|
|
83
|
+ ...styles.card,
|
|
84
|
+ ...styles.messageCard,
|
|
85
|
+ }}
|
|
86
|
+ >
|
|
87
|
+ <Animatable.View
|
|
88
|
+ useNativeDriver={false}
|
|
89
|
+ animation={'flash'}
|
|
90
|
+ iterationCount={'infinite'}
|
|
91
|
+ duration={2000}
|
|
92
|
+ >
|
|
93
|
+ <Card.Title
|
|
94
|
+ title={i18n.t('screens.proxiwash.errors.title')}
|
|
95
|
+ titleStyle={{
|
|
96
|
+ color: theme.colors.primary,
|
|
97
|
+ }}
|
|
98
|
+ left={(iconProps) => (
|
|
99
|
+ <Avatar.Icon icon={'alert'} size={iconProps.size} />
|
|
100
|
+ )}
|
|
101
|
+ />
|
|
102
|
+ </Animatable.View>
|
|
103
|
+ <Card.Content>
|
|
104
|
+ <Paragraph
|
|
105
|
+ style={{
|
|
106
|
+ color: theme.colors.warning,
|
|
107
|
+ }}
|
|
108
|
+ >
|
|
109
|
+ {message}
|
|
110
|
+ </Paragraph>
|
|
111
|
+ </Card.Content>
|
|
112
|
+ <Card.Actions style={styles.actions}>
|
|
113
|
+ <Button
|
|
114
|
+ mode={'contained'}
|
|
115
|
+ onPress={() =>
|
|
116
|
+ Linking.openURL(ProxiwashConstants[selectedWash].webPageUrl)
|
|
117
|
+ }
|
|
118
|
+ icon={'open-in-new'}
|
|
119
|
+ >
|
|
120
|
+ {i18n.t('screens.proxiwash.errors.button')}
|
|
121
|
+ </Button>
|
|
122
|
+ </Card.Actions>
|
|
123
|
+ </Card>
|
|
124
|
+ ) : null}
|
|
125
|
+ </>
|
|
126
|
+ );
|
|
127
|
+}
|
|
128
|
+
|
|
129
|
+export default ProxiwashListHeader;
|