Przeglądaj źródła

Introduce Platform in React

React Native provides Platform.
master
Lyubomir Marinov 8 lat temu
rodzic
commit
5f21e4c5b6

+ 3
- 1
react/features/app/components/App.native.js Wyświetl plik

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

+ 2
- 5
react/features/base/lib-jitsi-meet/native/RTCPeerConnection.js Wyświetl plik

@@ -1,9 +1,6 @@
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 4
 import { POSIX } from '../../react-native';
8 5
 
9 6
 // XXX At the time of this writing extending RTCPeerConnection using ES6 'class'

+ 3
- 1
react/features/base/media/components/native/Video.js Wyświetl plik

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

+ 4
- 0
react/features/base/react/Platform.native.js Wyświetl plik

@@ -0,0 +1,4 @@
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 Wyświetl plik

@@ -0,0 +1,20 @@
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 Wyświetl plik

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

Ładowanie…
Anuluj
Zapisz