Преглед на файлове

Safeguard Container style when used cross-platform

master
Bettenbuk Zoltan преди 6 години
родител
ревизия
31638133b7

+ 9
- 1
react/features/base/react/components/AbstractContainer.js Целия файл

@@ -2,6 +2,8 @@
2 2
 
3 3
 import React, { Component } from 'react';
4 4
 
5
+import { getFixedPlatformStyle } from '../../styles';
6
+
5 7
 /**
6 8
  * {@code AbstractContainer} component's property types.
7 9
  */
@@ -80,6 +82,7 @@ export default class AbstractContainer<P: Props> extends Component<P> {
80 82
     _render(type, props?: P) {
81 83
         const {
82 84
             children,
85
+            style,
83 86
 
84 87
             /* eslint-disable no-unused-vars */
85 88
 
@@ -94,7 +97,12 @@ export default class AbstractContainer<P: Props> extends Component<P> {
94 97
             ...filteredProps
95 98
         } = props || this.props;
96 99
 
100
+        const _style = getFixedPlatformStyle(style);
101
+
97 102
         // $FlowFixMe
98
-        return React.createElement(type, filteredProps, children);
103
+        return React.createElement(type, {
104
+            style: _style,
105
+            ...filteredProps
106
+        }, children);
99 107
     }
100 108
 }

react/features/base/styles/functions.js → react/features/base/styles/functions.any.js Целия файл


+ 18
- 0
react/features/base/styles/functions.native.js Целия файл

@@ -0,0 +1,18 @@
1
+// @flow
2
+
3
+import { type StyleType } from './functions.any';
4
+
5
+export * from './functions.any';
6
+
7
+/**
8
+ * Fixes the style prop that is passed to a platform generic component based on platform specific
9
+ * format requirements.
10
+ *
11
+ * @param {StyleType} style - The passed style prop to the component.
12
+ * @returns {StyleType}
13
+ */
14
+export function getFixedPlatformStyle(style: StyleType): StyleType {
15
+    // There is nothing to do on mobile - yet.
16
+
17
+    return style;
18
+}

+ 26
- 0
react/features/base/styles/functions.web.js Целия файл

@@ -0,0 +1,26 @@
1
+// @flow
2
+
3
+import { type StyleType } from './functions.any';
4
+
5
+export * from './functions.any';
6
+
7
+/**
8
+ * Fixes the style prop that is passed to a platform generic component based on platform specific
9
+ * format requirements.
10
+ *
11
+ * @param {StyleType} style - The passed style prop to the component.
12
+ * @returns {StyleType}
13
+ */
14
+export function getFixedPlatformStyle(style: StyleType): StyleType {
15
+    if (Array.isArray(style)) {
16
+        const _style = {};
17
+
18
+        for (const component of style) {
19
+            Object.assign(_style, component);
20
+        }
21
+
22
+        return _style;
23
+    }
24
+
25
+    return style;
26
+}

Loading…
Отказ
Запис