Parcourir la source

Introduce Platform in React

React Native provides Platform.
master
Lyubomir Marinov il y a 8 ans
Parent
révision
5f21e4c5b6

+ 3
- 1
react/features/app/components/App.native.js Voir le fichier

1
 /* global __DEV__ */
1
 /* global __DEV__ */
2
 
2
 
3
 import React from 'react';
3
 import React from 'react';
4
-import { Linking, Navigator, Platform } from 'react-native';
4
+import { Linking, Navigator } from 'react-native';
5
 import { Provider } from 'react-redux';
5
 import { Provider } from 'react-redux';
6
 
6
 
7
+import { Platform } from '../../base/react';
8
+
7
 import { _getRouteToRender } from '../functions';
9
 import { _getRouteToRender } from '../functions';
8
 import { AbstractApp } from './AbstractApp';
10
 import { AbstractApp } from './AbstractApp';
9
 
11
 

+ 2
- 5
react/features/base/lib-jitsi-meet/native/RTCPeerConnection.js Voir le fichier

1
-import { Platform } from 'react-native';
2
-import {
3
-    RTCPeerConnection,
4
-    RTCSessionDescription
5
-} from 'react-native-webrtc';
1
+import { RTCPeerConnection, RTCSessionDescription } from 'react-native-webrtc';
6
 
2
 
3
+import { Platform } from '../../react';
7
 import { POSIX } from '../../react-native';
4
 import { POSIX } from '../../react-native';
8
 
5
 
9
 // XXX At the time of this writing extending RTCPeerConnection using ES6 'class'
6
 // XXX At the time of this writing extending RTCPeerConnection using ES6 'class'

+ 3
- 1
react/features/base/media/components/native/Video.js Voir le fichier

1
 import React, { Component } from 'react';
1
 import React, { Component } from 'react';
2
-import { Platform, View } from 'react-native';
2
+import { View } from 'react-native';
3
 import { RTCView } from 'react-native-webrtc';
3
 import { RTCView } from 'react-native-webrtc';
4
 
4
 
5
+import { Platform } from '../../../react';
6
+
5
 import { styles } from './styles';
7
 import { styles } from './styles';
6
 
8
 
7
 /**
9
 /**

+ 4
- 0
react/features/base/react/Platform.native.js Voir le fichier

1
+// Re-export react-native's Platform because we want to provide a minimal
2
+// equivalent on Web.
3
+import { Platform } from 'react-native';
4
+export default Platform;

+ 20
- 0
react/features/base/react/Platform.web.js Voir le fichier

1
+const userAgent = navigator.userAgent;
2
+let OS;
3
+
4
+if (userAgent.match(/Android/i)) {
5
+    OS = 'android';
6
+} else if (userAgent.match(/iP(ad|hone|od)/i)) {
7
+    OS = 'ios';
8
+}
9
+
10
+/**
11
+ * Provides a minimal equivalent of react-native's Platform abstraction.
12
+ */
13
+export default {
14
+    /**
15
+     * The operating system on which the application is executing.
16
+     *
17
+     * @type {string}
18
+     */
19
+    OS
20
+};

+ 1
- 0
react/features/base/react/index.js Voir le fichier

1
 export * from './components';
1
 export * from './components';
2
 export * from './functions';
2
 export * from './functions';
3
+export { default as Platform } from './Platform';
3
 export { default as Symbol } from './Symbol';
4
 export { default as Symbol } from './Symbol';

Chargement…
Annuler
Enregistrer