Browse Source

Update ui proxiwash settings go to general Settings

Remove proxiwash settings screen
move setings in setings screen
docjyJ 3 years ago
parent
commit
5b6176a361

+ 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
 }

+ 65
- 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';
@@ -12,6 +19,7 @@ import AsyncStorageManager from '../../../managers/AsyncStorageManager';
12 19
 import CustomSlider from '../../../components/Overrides/CustomSlider';
13 20
 import CollapsibleScrollView from '../../../components/Collapsible/CollapsibleScrollView';
14 21
 import type {ListIconPropsType} from '../../../constants/PaperStyles';
22
+import {PROXIWASH_DATA} from '../../Proxiwash/ProxiwashAboutScreen';
15 23
 
16 24
 type PropsType = {
17 25
   navigation: StackNavigationProp,
@@ -22,6 +30,7 @@ type StateType = {
22 30
   nightMode: boolean,
23 31
   nightModeFollowSystem: boolean,
24 32
   startScreenPickerSelected: string,
33
+  selectedWash: string,
25 34
   isDebugUnlocked: boolean,
26 35
 };
27 36
 
@@ -52,6 +61,9 @@ class SettingsScreen extends React.Component<PropsType, StateType> {
52 61
       startScreenPickerSelected: AsyncStorageManager.getString(
53 62
         AsyncStorageManager.PREFERENCES.defaultStartScreen.key,
54 63
       ),
64
+      selectedWash: AsyncStorageManager.getString(
65
+        AsyncStorageManager.PREFERENCES.selectedWash.key,
66
+      ),
55 67
       isDebugUnlocked: AsyncStorageManager.getBool(
56 68
         AsyncStorageManager.PREFERENCES.debugUnlocked.key,
57 69
       ),
@@ -107,6 +119,29 @@ class SettingsScreen extends React.Component<PropsType, StateType> {
107 119
   }
108 120
 
109 121
   /**
122
+   * Returns a radio picker allowing the user to select the proxiwash
123
+   *
124
+   * @returns {React.Node}
125
+   */
126
+  getProxiwashChangePicker(): React.Node {
127
+    const {selectedWash} = this.state;
128
+    return (
129
+      <RadioButton.Group
130
+        onValueChange={this.onSelectWashValueChange}
131
+        value={selectedWash}>
132
+        <RadioButton.Item
133
+          label={PROXIWASH_DATA.washinsa.title}
134
+          value={PROXIWASH_DATA.washinsa.id}
135
+        />
136
+        <RadioButton.Item
137
+          label={PROXIWASH_DATA.tripodeB.title}
138
+          value={PROXIWASH_DATA.tripodeB.id}
139
+        />
140
+      </RadioButton.Group>
141
+    );
142
+  }
143
+
144
+  /**
110 145
    * Returns a picker allowing the user to select the start screen
111 146
    *
112 147
    * @returns {React.Node}
@@ -213,6 +248,21 @@ class SettingsScreen extends React.Component<PropsType, StateType> {
213 248
   }
214 249
 
215 250
   /**
251
+   * Saves the value for the proxiwash selected wash
252
+   *
253
+   * @param value The value to store
254
+   */
255
+  onSelectWashValueChange = (value: string) => {
256
+    if (value != null) {
257
+      this.setState({selectedWash: value});
258
+      AsyncStorageManager.set(
259
+        AsyncStorageManager.PREFERENCES.selectedWash.key,
260
+        value,
261
+      );
262
+    }
263
+  };
264
+
265
+  /**
216 266
    * Unlocks debug mode and saves its state to user preferences
217 267
    */
218 268
   unlockDebugMode = () => {
@@ -288,6 +338,20 @@ class SettingsScreen extends React.Component<PropsType, StateType> {
288 338
             <View style={{marginLeft: 30}}>
289 339
               {this.getProxiwashNotifPicker()}
290 340
             </View>
341
+            <List.Item
342
+              title="Test"
343
+              description="Test"
344
+              left={(props: ListIconPropsType): React.Node => (
345
+                <List.Icon
346
+                  color={props.color}
347
+                  style={props.style}
348
+                  icon="washing-machine"
349
+                />
350
+              )}
351
+            />
352
+            <View style={{marginLeft: 30}}>
353
+              {this.getProxiwashChangePicker()}
354
+            </View>
291 355
           </List.Section>
292 356
         </Card>
293 357
         <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: i18n.t('screens.proxiwash.washinsa.title'),
27
+    subtitle: i18n.t('screens.proxiwash.washinsa.subtitle'),
28
+    description: i18n.t('screens.proxiwash.washinsa.description'),
29
+    tarif: i18n.t('screens.proxiwash.washinsa.tariff'),
30
+    paymentMethods: i18n.t('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: i18n.t('screens.proxiwash.tripodeB.title'),
38
+    subtitle: i18n.t('screens.proxiwash.tripodeB.subtitle'),
39
+    description: i18n.t('screens.proxiwash.tripodeB.description'),
40
+    tarif: i18n.t('screens.proxiwash.tripodeB.tariff'),
41
+    paymentMethods: i18n.t('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={item.title}
57
+          subtitle={item.subtitle}
58
+          left={(iconProps: CardTitleIconPropsType): React.Node => (
59
+            <Avatar.Icon size={iconProps.size} icon={item.icon} />
60
+          )}
61
+        />
62
+        <Card.Content>
63
+          <Paragraph>{item.description}</Paragraph>
64
+          <Title>{i18n.t('screens.proxiwash.tariffs')}</Title>
65
+          <Paragraph>{item.tarif}</Paragraph>
66
+          <Title>{i18n.t('screens.proxiwash.paymentMethods')}</Title>
67
+          <Paragraph>{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')}

+ 1
- 15
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
 
@@ -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);

Loading…
Cancel
Save