Bläddra i källkod

feat: add column layout to settings fields

master
Bettenbuk Zoltan 5 år sedan
förälder
incheckning
8cc9b78e21

+ 20
- 4
react/features/settings/components/native/FormRow.js Visa fil

@@ -27,6 +27,11 @@ type Props = {
27 27
      */
28 28
     label: string,
29 29
 
30
+    /**
31
+     * One of 'row' (default) or 'column'.
32
+     */
33
+    layout: string,
34
+
30 35
     /**
31 36
      * Invoked to obtain translated strings.
32 37
      */
@@ -60,7 +65,7 @@ class FormRow extends Component<Props> {
60 65
      * @returns {ReactElement}
61 66
      */
62 67
     render() {
63
-        const { t } = this.props;
68
+        const { layout, t } = this.props;
64 69
 
65 70
         // Some field types need additional props to look good and standardized
66 71
         // on a form.
@@ -76,7 +81,8 @@ class FormRow extends Component<Props> {
76 81
                     <Text
77 82
                         style = { [
78 83
                             styles.text,
79
-                            styles.fieldLabelText
84
+                            styles.fieldLabelText,
85
+                            layout === 'column' ? styles.fieldLabelTextColumn : undefined
80 86
                         ] } >
81 87
                         { t(this.props.label) }
82 88
                     </Text>
@@ -108,7 +114,10 @@ class FormRow extends Component<Props> {
108 114
             case 'TextInput':
109 115
                 return {
110 116
                     placeholderTextColor: PLACEHOLDER_COLOR,
111
-                    style: styles.textInputField,
117
+                    style: [
118
+                        styles.textInputField,
119
+                        this.props.layout === 'column' ? styles.textInputFieldColumn : undefined
120
+                    ],
112 121
                     underlineColorAndroid: ANDROID_UNDERLINE_COLOR
113 122
                 };
114 123
             }
@@ -126,14 +135,21 @@ class FormRow extends Component<Props> {
126 135
      * @returns {Array<Object>}
127 136
      */
128 137
     _getRowStyle() {
138
+        const { fieldSeparator, layout } = this.props;
129 139
         const rowStyle = [
130 140
             styles.fieldContainer
131 141
         ];
132 142
 
133
-        if (this.props.fieldSeparator) {
143
+        if (fieldSeparator) {
134 144
             rowStyle.push(styles.fieldSeparator);
135 145
         }
136 146
 
147
+        if (layout === 'column') {
148
+            rowStyle.push(
149
+                styles.fieldContainerColumn
150
+            );
151
+        }
152
+
137 153
         return rowStyle;
138 154
     }
139 155
 }

+ 7
- 3
react/features/settings/components/native/SettingsView.js Visa fil

@@ -361,14 +361,17 @@ class SettingsView extends AbstractSettingsView<Props, State> {
361 361
                         label = 'settingsView.profileSection' />
362 362
                     <FormRow
363 363
                         fieldSeparator = { true }
364
-                        label = 'settingsView.displayName'>
364
+                        label = 'settingsView.displayName'
365
+                        layout = 'column'>
365 366
                         <TextInput
366 367
                             autoCorrect = { false }
367 368
                             onChangeText = { this._onChangeDisplayName }
368 369
                             placeholder = 'John Doe'
369 370
                             value = { displayName } />
370 371
                     </FormRow>
371
-                    <FormRow label = 'settingsView.email'>
372
+                    <FormRow
373
+                        label = 'settingsView.email'
374
+                        layout = 'column'>
372 375
                         <TextInput
373 376
                             autoCapitalize = 'none'
374 377
                             autoCorrect = { false }
@@ -381,7 +384,8 @@ class SettingsView extends AbstractSettingsView<Props, State> {
381 384
                         label = 'settingsView.conferenceSection' />
382 385
                     <FormRow
383 386
                         fieldSeparator = { true }
384
-                        label = 'settingsView.serverURL'>
387
+                        label = 'settingsView.serverURL'
388
+                        layout = 'column'>
385 389
                         <TextInput
386 390
                             autoCapitalize = 'none'
387 391
                             autoCorrect = { false }

+ 30
- 6
react/features/settings/components/native/styles.js Visa fil

@@ -1,7 +1,4 @@
1
-import {
2
-    ColorPalette,
3
-    createStyleSheet
4
-} from '../../../base/styles';
1
+import { ColorPalette } from '../../../base/styles';
5 2
 
6 3
 export const ANDROID_UNDERLINE_COLOR = 'transparent';
7 4
 export const PLACEHOLDER_COLOR = ColorPalette.lightGrey;
@@ -11,7 +8,7 @@ const TEXT_SIZE = 17;
11 8
 /**
12 9
  * The styles of the native components of the feature {@code settings}.
13 10
  */
14
-export default createStyleSheet({
11
+export default {
15 12
     /**
16 13
      * Standardized style for a field container {@code View}.
17 14
      */
@@ -22,6 +19,15 @@ export default createStyleSheet({
22 19
         paddingHorizontal: 8
23 20
     },
24 21
 
22
+    /**
23
+     * * Appended style for column layout fields.
24
+     */
25
+    fieldContainerColumn: {
26
+        alignItems: 'flex-start',
27
+        flexDirection: 'column',
28
+        paddingVertical: 3
29
+    },
30
+
25 31
     /**
26 32
      * Standard container for a {@code View} containing a field label.
27 33
      */
@@ -38,6 +44,13 @@ export default createStyleSheet({
38 44
         fontSize: TEXT_SIZE
39 45
     },
40 46
 
47
+    /**
48
+     * Appended style for column layout fields.
49
+     */
50
+    fieldLabelTextColumn: {
51
+        fontSize: 12
52
+    },
53
+
41 54
     /**
42 55
      * Field container style for all but last row {@code View}.
43 56
      */
@@ -85,5 +98,16 @@ export default createStyleSheet({
85 98
         flex: 1,
86 99
         fontSize: TEXT_SIZE,
87 100
         textAlign: 'right'
101
+    },
102
+
103
+    /**
104
+     * Appended style for column layout fields.
105
+     */
106
+    textInputFieldColumn: {
107
+        backgroundColor: 'rgb(245, 245, 245)',
108
+        borderRadius: 8,
109
+        marginVertical: 5,
110
+        paddingVertical: 3,
111
+        textAlign: 'left'
88 112
     }
89
-});
113
+};

Laddar…
Avbryt
Spara