20 Commits

Author SHA1 Message Date
  docjyJ 82f7af58bd Translate subtitle ans description key 3 years ago
  docjyJ c5b6e128ee Bug Correction 3 years ago
  docjyJ 5b6176a361 Update ui proxiwash settings go to general Settings 3 years ago
  docjyJ 02e30f87cf Update ui to go to proxiwash Settings 3 years ago
  docjyJ 83a3354d1e Update tariff language key for washinsa and tripode B 3 years ago
  docjyJ ce1227901c Update Docs 3 years ago
  docjyJ 5a92b5096a Update Proxiwash About Screen 3 years ago
  docjyJ 115c90b712 Add new Screen to select wash 3 years ago
  docjyJ 41a17a9a91 Update Language File 3 years ago
  docjyJ 7867e12a49 Update Settigns Screen 3 years ago
  docjyJ f8f5749478 add settings selection 3 years ago
  Arnaud Vergnet 3de49732b9 Improve local management 3 years ago
  docjyJ b7bc46f800 Update ui to go to proxiwash Settings 3 years ago
  docjyJ f3e6bfe583 Update tariff language key for washinsa and tripode B 3 years ago
  docjyJ 775fac4e5c Update Docs 3 years ago
  docjyJ 8199a27f87 Update Proxiwash About Screen 3 years ago
  docjyJ 6ff17ffde2 Add new Screen to select wash 3 years ago
  docjyJ 2f75309f4e Update Language File 3 years ago
  docjyJ c9e1d0bba2 Update Settigns Screen 3 years ago
  docjyJ e8ad955d28 add settings selection 3 years ago

+ 2
- 2
App.js View File

@@ -7,7 +7,6 @@ import {Provider as PaperProvider} from 'react-native-paper';
7 7
 import {setSafeBounceHeight} from 'react-navigation-collapsible';
8 8
 import SplashScreen from 'react-native-splash-screen';
9 9
 import {OverflowMenuProvider} from 'react-navigation-header-buttons';
10
-import LocaleManager from './src/managers/LocaleManager';
11 10
 import AsyncStorageManager from './src/managers/AsyncStorageManager';
12 11
 import CustomIntroSlider from './src/components/Overrides/CustomIntroSlider';
13 12
 import type {CustomThemeType} from './src/managers/ThemeManager';
@@ -19,6 +18,7 @@ import ConnectionManager from './src/managers/ConnectionManager';
19 18
 import type {ParsedUrlDataType} from './src/utils/URLHandler';
20 19
 import URLHandler from './src/utils/URLHandler';
21 20
 import {setupStatusBar} from './src/utils/Utils';
21
+import initLocales from './src/utils/Locales';
22 22
 
23 23
 // Native optimizations https://reactnavigation.org/docs/react-native-screens
24 24
 // Crashes app when navigating away from webview on android 9+
@@ -56,7 +56,7 @@ export default class App extends React.Component<null, StateType> {
56 56
       showAprilFools: false,
57 57
       currentTheme: null,
58 58
     };
59
-    LocaleManager.initTranslations();
59
+    initLocales();
60 60
     this.navigatorRef = React.createRef();
61 61
     this.defaultHomeRoute = null;
62 62
     this.defaultHomeData = {};

+ 2
- 2
locales/en.json View File

@@ -62,8 +62,8 @@
62 62
       },
63 63
       "tripodeB": {
64 64
         "title": "Tripode B laundromat",
65
-        "subtitle": "[A TRADUIRE] Celle de ceux qui habite prés du métro.",
66
-        "description": "[A TRADUIRE] C'est le service de laverie proposé par le crous pour les résidences Tripode B et C ainsi que Thalès et Pythagore. Le local situé au pied du Tripode B en face de de la résidence Pythagore avec ses 2 sèche-linges et 6 machines est ouvert 7J/7 de 7h à 23h. En plus des machine 6kg il y as une machine de 10kg.",
65
+        "subtitle": "That of those who live near the metro.",
66
+        "description": "This is the washing service operated by the CROUS for the Tripode B and C residences as well as Thalès and Pythagore. The room is at the foot of Tripod B in front of the Pythagore residence, with 2 dryers and 6 washers, is open 7d/7 from 7am to 11pm. In addition to the 6kg washers there is one 10kg washers",
67 67
         "tariff": "Washers 6kg: 2.60€ the washer + 0.90€ with detergent.\nWashers 10kg: 4.90€ the washer + 1.50€ with detergent.\nDryers 14kg: 0.40€ for 5min of dryer usage.",
68 68
         "paymentMethods": "Carte bancaire acceptée."
69 69
       },

+ 1
- 1
locales/fr.json View File

@@ -63,7 +63,7 @@
63 63
       "tripodeB": {
64 64
         "title": "Laverie Tripode B",
65 65
         "subtitle": "Celle de ceux qui habite prés du métro.",
66
-        "description": "C'est le service de laverie proposé par le crous pour les résidences Tripode B et C ainsi que Thalès et Pythagore. Le local situé au pied du Tripode B en face de de la résidence Pythagore avec ses 2 sèche-linges et 6 machines est ouvert 7J/7 de 7h à 23h. En plus des machine 6kg il y as une machine de 10kg.",
66
+        "description": "C'est le service de laverie proposé par le CROUS pour les résidences Tripode B et C ainsi que Thalès et Pythagore. Le local situé au pied du Tripode B en face de de la résidence Pythagore avec ses 2 sèche-linges et 6 machines est ouvert 7J/7 de 7h à 23h. En plus des machine 6kg il y as une machine de 10kg.",
67 67
         "tariff": "Lave-Linges 6kg: 2.60€ la machine + 0.90€ avec la lessive.\nLave-Linges 10kg: 4.90€ la machine + 1.50€ avec la lessive.\nSèche-Linges 14kg: 0.40€ pour 5min de sèche linge.",
68 68
         "paymentMethods": "Carte bancaire acceptée."
69 69
       },

+ 1
- 1
src/components/Lists/Proxiwash/ProxiwashListItem.js View File

@@ -69,7 +69,7 @@ class ProxiwashListItem extends React.Component<PropsType> {
69 69
     this.updateStateStrings();
70 70
 
71 71
     let displayNumber = props.item.number;
72
-    const displayMaxWeight = props.item['maxWeight '];
72
+    const displayMaxWeight = props.item.maxWeight;
73 73
     if (AprilFoolsManager.getInstance().isAprilFoolsEnabled())
74 74
       displayNumber = AprilFoolsManager.getProxiwashMachineDisplayNumber(
75 75
         parseInt(props.item.number, 10),

+ 0
- 24
src/managers/LocaleManager.js View File

@@ -1,24 +0,0 @@
1
-// @flow
2
-
3
-import i18n from 'i18n-js';
4
-import * as RNLocalize from 'react-native-localize';
5
-
6
-import en from '../../locales/en.json';
7
-import fr from '../../locales/fr.json';
8
-
9
-/**
10
- * Static class used to manage locales
11
- */
12
-export default class LocaleManager {
13
-  /**
14
-   * Initialize translations using language files
15
-   */
16
-  static initTranslations() {
17
-    i18n.fallbacks = true;
18
-    i18n.translations = {fr, en};
19
-    i18n.locale = RNLocalize.findBestAvailableLanguage([
20
-      'en',
21
-      'fr',
22
-    ]).languageTag;
23
-  }
24
-}

+ 0
- 7
src/navigation/TabNavigator.js View File

@@ -29,7 +29,6 @@ import {
29 29
   getWebsiteStack,
30 30
 } from '../utils/CollapsibleUtils';
31 31
 import Mascot, {MASCOT_STYLE} from '../components/Mascot/Mascot';
32
-import ProxiwashSettingsScreen from '../screens/Proxiwash/ProxiwashSettingsScreen';
33 32
 
34 33
 const modalTransition =
35 34
   Platform.OS === 'ios'
@@ -92,12 +91,6 @@ function ProxiwashStackComponent(): React.Node {
92 91
         ProxiwashAboutScreen,
93 92
         i18n.t('screens.proxiwash.title'),
94 93
       )}
95
-      {createScreenCollapsibleStack(
96
-        'proxiwash-settings',
97
-        ProxiwashStack,
98
-        ProxiwashSettingsScreen,
99
-        i18n.t('screens.proxiwash.title'),
100
-      )}
101 94
     </ProxiwashStack.Navigator>
102 95
   );
103 96
 }

+ 64
- 1
src/screens/Other/Settings/SettingsScreen.js View File

@@ -3,7 +3,14 @@
3 3
 import * as React from 'react';
4 4
 import {View} from 'react-native';
5 5
 import i18n from 'i18n-js';
6
-import {Card, List, Switch, ToggleButton, withTheme} from 'react-native-paper';
6
+import {
7
+  RadioButton,
8
+  Card,
9
+  List,
10
+  Switch,
11
+  ToggleButton,
12
+  withTheme,
13
+} from 'react-native-paper';
7 14
 import {Appearance} from 'react-native-appearance';
8 15
 import {StackNavigationProp} from '@react-navigation/stack';
9 16
 import type {CustomThemeType} from '../../../managers/ThemeManager';
@@ -22,6 +29,7 @@ type StateType = {
22 29
   nightMode: boolean,
23 30
   nightModeFollowSystem: boolean,
24 31
   startScreenPickerSelected: string,
32
+  selectedWash: string,
25 33
   isDebugUnlocked: boolean,
26 34
 };
27 35
 
@@ -52,6 +60,9 @@ class SettingsScreen extends React.Component<PropsType, StateType> {
52 60
       startScreenPickerSelected: AsyncStorageManager.getString(
53 61
         AsyncStorageManager.PREFERENCES.defaultStartScreen.key,
54 62
       ),
63
+      selectedWash: AsyncStorageManager.getString(
64
+        AsyncStorageManager.PREFERENCES.selectedWash.key,
65
+      ),
55 66
       isDebugUnlocked: AsyncStorageManager.getBool(
56 67
         AsyncStorageManager.PREFERENCES.debugUnlocked.key,
57 68
       ),
@@ -107,6 +118,29 @@ class SettingsScreen extends React.Component<PropsType, StateType> {
107 118
   }
108 119
 
109 120
   /**
121
+   * Returns a radio picker allowing the user to select the proxiwash
122
+   *
123
+   * @returns {React.Node}
124
+   */
125
+  getProxiwashChangePicker(): React.Node {
126
+    const {selectedWash} = this.state;
127
+    return (
128
+      <RadioButton.Group
129
+        onValueChange={this.onSelectWashValueChange}
130
+        value={selectedWash}>
131
+        <RadioButton.Item
132
+          label={i18n.t('screens.proxiwash.washinsa.title')}
133
+          value="washinsa"
134
+        />
135
+        <RadioButton.Item
136
+          label={i18n.t('screens.proxiwash.tripodeB.title')}
137
+          value="tripodeB"
138
+        />
139
+      </RadioButton.Group>
140
+    );
141
+  }
142
+
143
+  /**
110 144
    * Returns a picker allowing the user to select the start screen
111 145
    *
112 146
    * @returns {React.Node}
@@ -213,6 +247,21 @@ class SettingsScreen extends React.Component<PropsType, StateType> {
213 247
   }
214 248
 
215 249
   /**
250
+   * Saves the value for the proxiwash selected wash
251
+   *
252
+   * @param value The value to store
253
+   */
254
+  onSelectWashValueChange = (value: string) => {
255
+    if (value != null) {
256
+      this.setState({selectedWash: value});
257
+      AsyncStorageManager.set(
258
+        AsyncStorageManager.PREFERENCES.selectedWash.key,
259
+        value,
260
+      );
261
+    }
262
+  };
263
+
264
+  /**
216 265
    * Unlocks debug mode and saves its state to user preferences
217 266
    */
218 267
   unlockDebugMode = () => {
@@ -288,6 +337,20 @@ class SettingsScreen extends React.Component<PropsType, StateType> {
288 337
             <View style={{marginLeft: 30}}>
289 338
               {this.getProxiwashNotifPicker()}
290 339
             </View>
340
+            <List.Item
341
+              title="Test"
342
+              description="Test"
343
+              left={(props: ListIconPropsType): React.Node => (
344
+                <List.Icon
345
+                  color={props.color}
346
+                  style={props.style}
347
+                  icon="washing-machine"
348
+                />
349
+              )}
350
+            />
351
+            <View style={{marginLeft: 30}}>
352
+              {this.getProxiwashChangePicker()}
353
+            </View>
291 354
           </List.Section>
292 355
         </Card>
293 356
         <Card style={{margin: 5}}>

+ 61
- 1
src/screens/Proxiwash/ProxiwashAboutScreen.js View File

@@ -9,11 +9,67 @@ import type {CardTitleIconPropsType} from '../../constants/PaperStyles';
9 9
 
10 10
 const LOGO = 'https://etud.insa-toulouse.fr/~amicale_app/images/Proxiwash.png';
11 11
 
12
+export type LaverieType = {
13
+  id: string,
14
+  title: string,
15
+  subtitle: string,
16
+  description: string,
17
+  tarif: string,
18
+  paymentMethods: string,
19
+  icon: string,
20
+  url: string,
21
+};
22
+
23
+export const PROXIWASH_DATA = {
24
+  washinsa: {
25
+    id: 'washinsa',
26
+    title: 'screens.proxiwash.washinsa.title',
27
+    subtitle: 'screens.proxiwash.washinsa.subtitle',
28
+    description: 'screens.proxiwash.washinsa.description',
29
+    tarif: 'screens.proxiwash.washinsa.tariff',
30
+    paymentMethods: 'screens.proxiwash.washinsa.paymentMethods',
31
+    icon: 'school-outline',
32
+    url:
33
+      'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/washinsa_data.json',
34
+  },
35
+  tripodeB: {
36
+    id: 'tripodeB',
37
+    title: 'screens.proxiwash.tripodeB.title',
38
+    subtitle: 'screens.proxiwash.tripodeB.subtitle',
39
+    description: 'screens.proxiwash.tripodeB.description',
40
+    tarif: 'screens.proxiwash.tripodeB.tariff',
41
+    paymentMethods: 'screens.proxiwash.tripodeB.paymentMethods',
42
+    icon: 'domain',
43
+    url:
44
+      'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/tripode_b_data.json',
45
+  },
46
+};
47
+
12 48
 /**
13 49
  * Class defining the proxiwash about screen.
14 50
  */
15
-// eslint-disable-next-line react/prefer-stateless-function
16 51
 export default class ProxiwashAboutScreen extends React.Component<null> {
52
+  static getCardItem(item: LaverieType): React.Node {
53
+    return (
54
+      <Card style={{margin: 5}}>
55
+        <Card.Title
56
+          title={i18n.t(item.title)}
57
+          subtitle={i18n.t(item.subtitle)}
58
+          left={(iconProps: CardTitleIconPropsType): React.Node => (
59
+            <Avatar.Icon size={iconProps.size} icon={item.icon} />
60
+          )}
61
+        />
62
+        <Card.Content>
63
+          <Paragraph>{i18n.t(item.description)}</Paragraph>
64
+          <Title>{i18n.t('screens.proxiwash.tariffs')}</Title>
65
+          <Paragraph>{i18n.t(item.tarif)}</Paragraph>
66
+          <Title>{i18n.t('screens.proxiwash.paymentMethods')}</Title>
67
+          <Paragraph>{i18n.t(item.paymentMethods)}</Paragraph>
68
+        </Card.Content>
69
+      </Card>
70
+    );
71
+  }
72
+
17 73
   render(): React.Node {
18 74
     return (
19 75
       <CollapsibleScrollView style={{padding: 5}} hasTab>
@@ -32,6 +88,10 @@ export default class ProxiwashAboutScreen extends React.Component<null> {
32 88
           />
33 89
         </View>
34 90
 
91
+        {ProxiwashAboutScreen.getCardItem(PROXIWASH_DATA.washinsa)}
92
+
93
+        {ProxiwashAboutScreen.getCardItem(PROXIWASH_DATA.tripodeB)}
94
+
35 95
         <Card style={{margin: 5}}>
36 96
           <Card.Title
37 97
             title={i18n.t('screens.proxiwash.dryer')}

+ 2
- 16
src/screens/Proxiwash/ProxiwashScreen.js View File

@@ -27,7 +27,7 @@ import {MASCOT_STYLE} from '../../components/Mascot/Mascot';
27 27
 import MascotPopup from '../../components/Mascot/MascotPopup';
28 28
 import type {SectionListDataType} from '../../components/Screens/WebSectionList';
29 29
 import type {ListIconPropsType} from '../../constants/PaperStyles';
30
-import {PROXIWASH_DATA} from './ProxiwashSettingsScreen';
30
+import {PROXIWASH_DATA} from './ProxiwashAboutScreen';
31 31
 
32 32
 const modalStateStrings = {};
33 33
 
@@ -37,7 +37,7 @@ const LIST_ITEM_HEIGHT = 64;
37 37
 export type ProxiwashMachineType = {
38 38
   number: string,
39 39
   state: string,
40
-  'maxWeight ': number,
40
+  maxWeight: number,
41 41
   startTime: string,
42 42
   endTime: string,
43 43
   donePercent: string,
@@ -128,11 +128,6 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
128 128
             iconName="information"
129 129
             onPress={this.onAboutPress}
130 130
           />
131
-          <Item
132
-            title="settings"
133
-            iconName="settings"
134
-            onPress={this.onSettingsPress}
135
-          />
136 131
         </MaterialHeaderButtons>
137 132
       ),
138 133
     });
@@ -148,15 +143,6 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
148 143
   };
149 144
 
150 145
   /**
151
-   * Callback used when pressing the settings button.
152
-   * This will open the ProxiwashSettingsScreen.
153
-   */
154
-  onSettingsPress = () => {
155
-    const {navigation} = this.props;
156
-    navigation.navigate('proxiwash-settings');
157
-  };
158
-
159
-  /**
160 146
    * Callback used when the user clicks on enable notifications for a machine
161 147
    *
162 148
    * @param machine The machine to set notifications for

+ 0
- 135
src/screens/Proxiwash/ProxiwashSettingsScreen.js View File

@@ -1,135 +0,0 @@
1
-// @flow
2
-
3
-import * as React from 'react';
4
-import {
5
-  Title,
6
-  Button,
7
-  Card,
8
-  Avatar,
9
-  withTheme,
10
-  Paragraph,
11
-} from 'react-native-paper';
12
-import i18n from 'i18n-js';
13
-import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView';
14
-import type {CardTitleIconPropsType} from '../../constants/PaperStyles';
15
-import AsyncStorageManager from '../../managers/AsyncStorageManager';
16
-import ThemeManager from '../../managers/ThemeManager';
17
-import type {CustomThemeType} from '../../managers/ThemeManager';
18
-
19
-export type LaverieType = {
20
-  id: string,
21
-  title: string,
22
-  subtitle: string,
23
-  description: string,
24
-  tarif: string,
25
-  paymentMethods: string,
26
-  icon: string,
27
-  url: string,
28
-};
29
-
30
-export const PROXIWASH_DATA = {
31
-  washinsa: {
32
-    id: 'washinsa',
33
-    title: i18n.t('screens.proxiwash.washinsa.title'),
34
-    subtitle: i18n.t('screens.proxiwash.washinsa.subtitle'),
35
-    description: i18n.t('screens.proxiwash.washinsa.description'),
36
-    tarif: i18n.t('screens.proxiwash.washinsa.tariff'),
37
-    paymentMethods: i18n.t('screens.proxiwash.washinsa.paymentMethods'),
38
-    icon: 'school-outline',
39
-    url:
40
-      'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/washinsa_data.json',
41
-  },
42
-  tripodeB: {
43
-    id: 'tripodeB',
44
-    title: i18n.t('screens.proxiwash.tripodeB.title'),
45
-    subtitle: i18n.t('screens.proxiwash.tripodeB.subtitle'),
46
-    description: i18n.t('screens.proxiwash.tripodeB.description'),
47
-    tarif: i18n.t('screens.proxiwash.tripodeB.tariff'),
48
-    paymentMethods: i18n.t('screens.proxiwash.tripodeB.paymentMethods'),
49
-    icon: 'domain',
50
-    url:
51
-      'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/tripode_b_data.json',
52
-  },
53
-};
54
-
55
-type StateType = {
56
-  selectedWash: string,
57
-  currentTheme: CustomThemeType,
58
-};
59
-
60
-/**
61
- * Class defining the proxiwash settings screen.
62
- */
63
-class ProxiwashSettingsScreen extends React.Component<null, StateType> {
64
-  constructor() {
65
-    super();
66
-    this.state = {
67
-      selectedWash: AsyncStorageManager.getString(
68
-        AsyncStorageManager.PREFERENCES.selectedWash.key,
69
-      ),
70
-    };
71
-  }
72
-
73
-  /**
74
-   * Saves the value for the proxiwash selected wash
75
-   *
76
-   * @param value The value to store
77
-   */
78
-  onSelectWashValueChange = (value: string) => {
79
-    if (value != null) {
80
-      this.setState({selectedWash: value});
81
-      AsyncStorageManager.set(
82
-        AsyncStorageManager.PREFERENCES.selectedWash.key,
83
-        value,
84
-      );
85
-    }
86
-  };
87
-
88
-  getCardItem(item: LaverieType): React.Node {
89
-    const {selectedWash} = this.state;
90
-    const onSelectWashValueChange = (): void =>
91
-      this.onSelectWashValueChange(item.id);
92
-    let cardStyle = {
93
-      margin: 5,
94
-    };
95
-    if (selectedWash === item.id) {
96
-      cardStyle = {
97
-        margin: 5,
98
-        backgroundColor: ThemeManager.getCurrentTheme().colors
99
-          .proxiwashUnknownColor,
100
-      };
101
-    }
102
-    return (
103
-      <Card style={cardStyle}>
104
-        <Card.Title
105
-          title={item.title}
106
-          subtitle={item.subtitle}
107
-          left={(iconProps: CardTitleIconPropsType): React.Node => (
108
-            <Avatar.Icon size={iconProps.size} icon={item.icon} />
109
-          )}
110
-        />
111
-        <Card.Content>
112
-          <Paragraph>{item.description}</Paragraph>
113
-          <Title>{i18n.t('screens.proxiwash.tariffs')}</Title>
114
-          <Paragraph>{item.tarif}</Paragraph>
115
-          <Title>{i18n.t('screens.proxiwash.paymentMethods')}</Title>
116
-          <Paragraph>{item.paymentMethods}</Paragraph>
117
-        </Card.Content>
118
-        <Card.Actions>
119
-          <Button onPress={onSelectWashValueChange}>Select</Button>
120
-        </Card.Actions>
121
-      </Card>
122
-    );
123
-  }
124
-
125
-  render(): React.Node {
126
-    return (
127
-      <CollapsibleScrollView style={{padding: 5}} hasTab>
128
-        {this.getCardItem(PROXIWASH_DATA.washinsa)}
129
-        {this.getCardItem(PROXIWASH_DATA.tripodeB)}
130
-      </CollapsibleScrollView>
131
-    );
132
-  }
133
-}
134
-
135
-export default withTheme(ProxiwashSettingsScreen);

+ 17
- 0
src/utils/Locales.js View File

@@ -0,0 +1,17 @@
1
+// @flow
2
+
3
+import i18n from 'i18n-js';
4
+import * as RNLocalize from 'react-native-localize';
5
+
6
+import en from '../../locales/en.json';
7
+import fr from '../../locales/fr.json';
8
+
9
+const initLocales = () => {
10
+  i18n.fallbacks = true;
11
+  i18n.translations = {fr, en};
12
+  i18n.locale = RNLocalize.findBestAvailableLanguage([
13
+    'en',
14
+    'fr',
15
+  ]).languageTag;
16
+}
17
+export default initLocales;

Loading…
Cancel
Save