Revert "Change to the extracted NetInfo package (#1092)"

This reverts commit f15adab089.
This commit is contained in:
Eric Traut 2019-06-07 13:36:16 -07:00
Родитель f15adab089
Коммит 249f039cf3
42 изменённых файлов: 321 добавлений и 737 удалений

Просмотреть файл

@ -7,4 +7,59 @@ permalink: docs/apis/network.html
next: apis/platform
---
This has been deprecated from ReactXP Core and moved to an extension (reactxp-netinfo) inline with the React Native Lean Core initiative.
This interface provides information about network connectivity.
## Types
``` javascript
enum DeviceNetworkType {
Unknown,
None,
Wifi,
Mobile2G,
Mobile3G,
Mobile4G
}
```
## Methods
``` javascript
// Returns a promise that specifies whether the device currently
// has network connectivity
isConnected(): SyncTasks.Promise<boolean>;
// Returns the type of network
getType(): SyncTasks.Promise<DeviceNetworkType>;
```
## Events
``` javascript
// Triggered when the connectivity changes
connectivityChangedEvent: SubscribableEvent<(isConnected: boolean) => void>;
```
## Sample Usage
``` javascript
private isConnected: boolean;
constructor() {
// Query the initial connectivity state.
this.isConnected = false;
RX.Network.isConnected().then(isConnected => {
this.isConnected = isConnected;
});
RX.Network.connectivityChangedEvent.subscribe(isConnected => {
// Update the connectivity state.
this.isConnected = isConnected;
});
}
```
## Other Notes
On Android, the following permission must be added to make use of the network interfaces.
``` xml
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
```

Просмотреть файл

@ -4,7 +4,7 @@ title: Navigator
layout: docs
category: Extensions
permalink: docs/extensions/navigator.html
next: extensions/netinfo
next: extensions/restclient
---
This component provides a way for the app to present a virtual stack of "cards", allowing the user to push or pop those cards onto the stack in an animated manner. The caller can control the animation type and direction.

Просмотреть файл

@ -1,65 +0,0 @@
---
id: extensions/netinfo
title: NetInfo
layout: docs
category: Extensions
permalink: docs/extensions/navigator.html
next: extensions/restclient
---
This interface provides information about network connectivity.
## Types
``` javascript
enum DeviceNetworkType {
Unknown,
None,
Wifi,
Mobile2G,
Mobile3G,
Mobile4G
}
```
## Methods
``` javascript
// Returns a promise that specifies whether the device currently
// has network connectivity
isConnected(): SyncTasks.Promise<boolean>;
// Returns the type of network
getType(): SyncTasks.Promise<DeviceNetworkType>;
```
## Events
``` javascript
// Triggered when the connectivity changes
connectivityChangedEvent: SubscribableEvent<(isConnected: boolean) => void>;
```
## Sample Usage
``` javascript
private isConnected: boolean;
constructor() {
// Query the initial connectivity state.
this.isConnected = false;
RXNetInfo.isConnected().then(isConnected => {
this.isConnected = isConnected;
});
RXNetInfo.connectivityChangedEvent.subscribe(isConnected => {
// Update the connectivity state.
this.isConnected = isConnected;
});
}
```
## Other Notes
On Android, the following permission must be added to make use of the network interfaces.
``` xml
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
```

20
extensions/netinfo/.gitignore поставляемый
Просмотреть файл

@ -1,20 +0,0 @@
# Logs
logs
*.log
npm-debug.log*
# Dependency directories
node_modules
package-lock.json
# Optional npm cache directory
.npm
# Build artifacts
**/dist
# Miscellaneous user files
*.user
.vscode
.DS_STORE

Просмотреть файл

@ -1,5 +0,0 @@
/node_modules
/src/.vs
/src/bin
/src/obj
*.user

Просмотреть файл

@ -1,21 +0,0 @@
# reactxp-netinfo
This module provides cross-platform support for detecting network ionformation within the [ReactXP](https://microsoft.github.io/reactxp/) library. This used to be a part of ReactXP core, but was extracted to be a standalone module inline with React Native `Lean Core` initiative. This exists as a standalone module to prevent users of ReactXP from having to link native modules when getting started.
## Getting Started
This module relies on [@react-native-community/netinfo](https://www.npmjs.com/packages/@react-native-community/netinfo) and will need to be linked into the react-native project.
This can be done by following the linking instructions in the React Native documentation or by running
```react-native link @react-native-community/netinfo```
## Documentation
For detailed documentation, look [here](https://microsoft.github.io/reactxp/docs/extensions/netinfo.html).
### Prerequisites
* [ReactXP](https://github.com/microsoft/reactxp/)
## Contributing
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
You must sign a Contribution License Agreement (CLA) before your PR will be merged. This a one-time requirement for Microsoft projects in GitHub. You can read more about [Contribution License Agreements (CLA)](https://en.wikipedia.org/wiki/Contributor_License_Agreement) on Wikipedia. You can sign the Microsoft Contribution License Agreement by visiting https://cla.microsoft.com/. Use your GitHub account to login.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

Просмотреть файл

@ -1,3 +0,0 @@
'use strict';
module.exports = require('./dist/android/PluginBase.js');

Просмотреть файл

@ -1,3 +0,0 @@
'use strict';
module.exports = require('./dist/ios/PluginBase.js');

Просмотреть файл

@ -1,4 +0,0 @@
'use strict';
// Export web by default. Other platforms have custom index.[platform].js files
module.exports = require('./dist/web/PluginBase.js');

Просмотреть файл

@ -1,3 +0,0 @@
'use strict';
module.exports = require('./dist/macos/PluginBase.js');

Просмотреть файл

@ -1,3 +0,0 @@
'use strict';
module.exports = require('./dist/windows/PluginBase.js');

Просмотреть файл

@ -1,28 +0,0 @@
{
"name": "reactxp-netinfo",
"version": "0.0.1-alpha.1",
"description": "Plugin for ReactXP that provides information about network connectivity",
"author": "ReactXP Team <reactxp@microsoft.com>",
"license": "MIT",
"scripts": {
"build": "npm run tslint && tsc",
"tslint": "tslint -p tsconfig.json -r tslint.json -r ./node_modules/tslint-microsoft-contrib --fix || true"
},
"dependencies": {
"@react-native-community/netinfo": "^3.2.0",
"synctasks": "^0.3.3"
},
"peerDependencies": {
"reactxp": "^1.6.0",
"react-dom": "^16.4.0",
"react-native": "^0.55.0",
"react-native-windows": "^0.54.0"
},
"devDependencies": {
"reactxp": "^1.6.0",
"typescript": "3.4.5",
"tslint": "5.16.0",
"tslint-microsoft-contrib": "6.1.1"
},
"types": "dist/web/PluginBase.d.ts"
}

Просмотреть файл

@ -1,13 +0,0 @@
/*
* PluginBase.ts
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*
* Base export for the Android implementation of the plugin.
*/
import * as Types from '../common/Types';
import NetInfo from '../native-common/NetInfo';
export { NetInfo as default, Types };

Просмотреть файл

@ -1,26 +0,0 @@
/*
* Interfaces.ts
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*
* Interface definition for cross-platform ReactXP plugin for gathering network/connectivity
* info. This was extracted from the reactxp core
*/
import * as SyncTasks from 'synctasks';
import SubscribableEvent from 'subscribableevent';
import * as Types from './Types';
export abstract class NetInfo {
abstract isConnected(): SyncTasks.Promise<boolean>;
abstract getType(): SyncTasks.Promise<Types.DeviceNetworkType>;
connectivityChangedEvent = new SubscribableEvent<(isConnected: boolean) => void>();
}
export interface PluginInterface {
Types: typeof Types;
default: NetInfo;
}

Просмотреть файл

@ -1,23 +0,0 @@
/*
* PluginBaseChecker.ts
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*
* Type check all the pluginbase exports against the desired interface.
*/
import * as Interfaces from './Interfaces';
import * as AndroidPlugin from '../android/PluginBase';
import * as iOSPlugin from '../ios/PluginBase';
import * as macOSPlugin from '../macos/PluginBase';
import * as WebPlugin from '../web/PluginBase';
import * as WindowsPlugin from '../windows/PluginBase';
/* tslint:disable:no-unused-variable */
const _typeCheckerAndroid: Interfaces.PluginInterface = AndroidPlugin;
const _typeCheckeriOS: Interfaces.PluginInterface = iOSPlugin;
const _typeCheckermacOS: Interfaces.PluginInterface = macOSPlugin;
const _typeCheckerWeb: Interfaces.PluginInterface = WebPlugin;
const _typeCheckerWindows: Interfaces.PluginInterface = WindowsPlugin;
/* tslint:enable:no-unused-variable */

Просмотреть файл

@ -1,17 +0,0 @@
/*
* Types.ts
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*
* Type definitions to support the plugin.
*/
export enum DeviceNetworkType {
Unknown,
None,
Wifi,
Mobile2G,
Mobile3G,
Mobile4G
}

Просмотреть файл

@ -1,13 +0,0 @@
/*
* PluginBase.ts
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*
* Base export for the iOS implementation of the plugin.
*/
import * as Types from '../common/Types';
import NetInfo from '../native-common/NetInfo';
export { NetInfo as default, Types };

Просмотреть файл

@ -1,13 +0,0 @@
/*
* PluginBase.ts
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*
* Base export for the Mac implementation of the plugin.
*/
import * as Types from '../common/Types';
import NetInfo from '../native-common/NetInfo';
export { NetInfo as default, Types };

Просмотреть файл

@ -1,70 +0,0 @@
/**
* NetInfo.ts
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*
* Native implementation of network information APIs.
*/
import * as RNNetInfo from '@react-native-community/netinfo';
import * as SyncTasks from 'synctasks';
import * as Types from '../common/Types';
import * as Interfaces from '../common/Interfaces';
export class NetInfo extends Interfaces.NetInfo {
constructor() {
super();
const onEventOccurredHandler = (state: RNNetInfo.NetInfoState) => {
this.connectivityChangedEvent.fire(state.isConnected);
};
RNNetInfo.addEventListener(onEventOccurredHandler);
}
isConnected(): SyncTasks.Promise<boolean> {
const deferred = SyncTasks.Defer<boolean>();
RNNetInfo.fetch().then((state: RNNetInfo.NetInfoState) => {
deferred.resolve(state.isConnected);
}).catch(() => {
deferred.reject('NetInfo.isConnected.fetch() failed');
});
return deferred.promise();
}
getType(): SyncTasks.Promise<Types.DeviceNetworkType> {
return SyncTasks.fromThenable(RNNetInfo.fetch()).then((state: RNNetInfo.NetInfoState) => {
return NetInfo._getNetworkTypeFromConnectionInfo(state);
});
}
private static _getNetworkTypeFromConnectionInfo(state: RNNetInfo.NetInfoState): Types.DeviceNetworkType {
if (state.type === RNNetInfo.NetInfoStateType.cellular) {
if (state.details === null || state.details.cellularGeneration === null) {
return Types.DeviceNetworkType.Unknown;
} else if (state.details.cellularGeneration === '2g') {
return Types.DeviceNetworkType.Mobile2G;
} else if (state.details.cellularGeneration === '3g') {
return Types.DeviceNetworkType.Mobile3G;
} else if (state.details.cellularGeneration === '4g') {
return Types.DeviceNetworkType.Mobile4G;
}
} else if (state.type === RNNetInfo.NetInfoStateType.wifi ) {
return Types.DeviceNetworkType.Wifi;
} else if (state.type === RNNetInfo.NetInfoStateType.ethernet ) {
return Types.DeviceNetworkType.Wifi;
} else if (state.type === RNNetInfo.NetInfoStateType.wimax ) {
return Types.DeviceNetworkType.Wifi;
} else if (state.type === RNNetInfo.NetInfoStateType.none) {
return Types.DeviceNetworkType.None;
}
return Types.DeviceNetworkType.Unknown;
}
}
export default new NetInfo();

Просмотреть файл

@ -1,13 +0,0 @@
/*
* PluginBase.ts
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*
* Base export for the Web implementation of the plugin.
*/
import * as Types from '../common/Types';
import NetInfo from './NetInfo';
export { NetInfo as default, Types };

Просмотреть файл

@ -1,13 +0,0 @@
/*
* PluginBase.ts
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*
* Base export for the Windows implementation of the plugin.
*/
import * as Types from '../common/Types';
import NetInfo from '../native-common/NetInfo';
export { NetInfo as default, Types };

Просмотреть файл

@ -1,28 +0,0 @@
{
"compilerOptions": {
"declaration": true,
"noResolve": false,
"jsx": "react",
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"noImplicitAny": true,
"skipLibCheck": true,
"strict": true,
"outDir": "dist/",
"lib": [
"es5",
"dom"
],
"types" : ["lodash", "react", "react-dom", "react-native"]
},
"include": [
"src/**/*"
],
"exclude": [
"dist",
"node_modules"
]
}

Просмотреть файл

@ -1,49 +0,0 @@
{
"rules": {
"align": [true, "statements"],
"class-name": true,
"curly": true,
"eofline": true,
"forin": true,
"indent": [true, "spaces"],
"interface-name": [true, "never-prefix"],
"label-position": true,
"max-line-length": [ true, 140 ],
"no-arg": true,
"no-bitwise": false,
"no-console": [true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-consecutive-blank-lines": true,
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-empty": true,
"no-eval": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": false,
"no-unused-expression": true,
"one-line": [true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"quotemark": [true, "single", "jsx-single"],
"radix": true,
"semicolon": true,
"triple-equals": [true, "allow-null-check"],
"variable-name": false,
"whitespace": [true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}

Просмотреть файл

@ -138,7 +138,6 @@ android {
}
dependencies {
implementation project(':@react-native-community_netinfo')
implementation project(':react-native-webview')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"

Просмотреть файл

@ -8,7 +8,6 @@ import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.reactnativecommunity.netinfo.NetInfoPackage;
import com.reactnativecommunity.webview.RNCWebViewPackage;
import java.util.Arrays;
@ -26,7 +25,6 @@ public class MainApplication extends Application implements ReactApplication {
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new NetInfoPackage(),
new RNCWebViewPackage()
);
}

Просмотреть файл

@ -1,6 +1,4 @@
rootProject.name = 'RXPTest'
include ':@react-native-community_netinfo'
project(':@react-native-community_netinfo').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/netinfo/android')
include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
include ':app'

Просмотреть файл

@ -5,7 +5,6 @@
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@ -21,7 +20,6 @@
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };
6D5B77E9E6F648EB8ADF799E /* libRNCNetInfo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D84626BC41A4406DAC31CDCF /* libRNCNetInfo.a */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
D2278308222FDC55009150CC /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2278307222FDC55009150CC /* JavaScriptCore.framework */; };
DC59425A11A24663A46F6493 /* libRNCWebView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6C292C692AED4DC2B496B1DB /* libRNCWebView.a */; };
@ -112,54 +110,12 @@
remoteGlobalIDString = 3D3CD9321DE5FBEE00167DC4;
remoteInfo = "cxxreact-tvOS";
};
0CFA0AE922987EC4007F740A /* PBXContainerItemProxy */ = {
07C03E3A1EC4EB8600E549B0 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = EDEBC6D6214B3E7000DD5AC8;
remoteInfo = jsi;
};
0CFA0AEB22987EC4007F740A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = EDEBC73B214B45A300DD5AC8;
remoteInfo = jsiexecutor;
};
0CFA0AED22987EC4007F740A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = ED296FB6214C9A0900B7C4FE;
remoteInfo = "jsi-tvOS";
};
0CFA0AEF22987EC4007F740A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = ED296FEE214C9CF800B7C4FE;
remoteInfo = "jsiexecutor-tvOS";
};
0CFA0AF722987EC4007F740A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 6ACD0BF3CAC840B79C2544A5 /* RNCNetInfo.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RNCNetInfo;
};
0CFA0AF922987EC4007F740A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 6ACD0BF3CAC840B79C2544A5 /* RNCNetInfo.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = B5027B1B2237B30F00F1AABA;
remoteInfo = "RNCNetInfo-tvOS";
};
0CFA0AFC22987EC4007F740A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 16D0CEE186654808941ED16F /* RNCWebView.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RNCWebView;
remoteGlobalIDString = 3D3CD9181DE5FBD800167DC4;
remoteInfo = "jschelpers-tvOS";
};
139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
@ -238,6 +194,13 @@
remoteGlobalIDString = 3D3CD9251DE5FBEC00167DC4;
remoteInfo = cxxreact;
};
3DAD3EAC1DF850E9000B6D8A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 3D3CD90B1DE5FBD600167DC4;
remoteInfo = jschelpers;
};
5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */;
@ -294,6 +257,20 @@
remoteGlobalIDString = 3DBE0D0D1F3B181C0099AA32;
remoteInfo = "fishhook-tvOS";
};
D4A8C3C220247A9D008BE855 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 9936F3131F5F2E4B0010BF04;
remoteInfo = privatedata;
};
D4A8C3C420247A9D008BE855 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 9936F32F1F5F2E5B0010BF04;
remoteInfo = "privatedata-tvOS";
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
@ -313,14 +290,12 @@
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = RXPTest/Info.plist; sourceTree = "<group>"; };
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = RXPTest/main.m; sourceTree = "<group>"; };
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
16D0CEE186654808941ED16F /* RNCWebView.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNCWebView.xcodeproj; path = "../node_modules/react-native-webview/ios/RNCWebView.xcodeproj"; sourceTree = "<group>"; };
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
6ACD0BF3CAC840B79C2544A5 /* RNCNetInfo.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNCNetInfo.xcodeproj; path = "../node_modules/@react-native-community/netinfo/ios/RNCNetInfo.xcodeproj"; sourceTree = "<group>"; };
6C292C692AED4DC2B496B1DB /* libRNCWebView.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNCWebView.a; sourceTree = "<group>"; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
D2278307222FDC55009150CC /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
D84626BC41A4406DAC31CDCF /* libRNCNetInfo.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNCNetInfo.a; sourceTree = "<group>"; };
16D0CEE186654808941ED16F /* RNCWebView.xcodeproj */ = {isa = PBXFileReference; name = "RNCWebView.xcodeproj"; path = "../node_modules/react-native-webview/ios/RNCWebView.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
6C292C692AED4DC2B496B1DB /* libRNCWebView.a */ = {isa = PBXFileReference; name = "libRNCWebView.a"; path = "libRNCWebView.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -340,7 +315,6 @@
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
6D5B77E9E6F648EB8ADF799E /* libRNCNetInfo.a in Frameworks */,
DC59425A11A24663A46F6493 /* libRNCWebView.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -390,32 +364,6 @@
name = Products;
sourceTree = "<group>";
};
0CFA0AC522987EC1007F740A /* Recovered References */ = {
isa = PBXGroup;
children = (
D84626BC41A4406DAC31CDCF /* libRNCNetInfo.a */,
6C292C692AED4DC2B496B1DB /* libRNCWebView.a */,
);
name = "Recovered References";
sourceTree = "<group>";
};
0CFA0AF122987EC4007F740A /* Products */ = {
isa = PBXGroup;
children = (
0CFA0AF822987EC4007F740A /* libRNCNetInfo.a */,
0CFA0AFA22987EC4007F740A /* libRNCNetInfo-tvOS.a */,
);
name = Products;
sourceTree = "<group>";
};
0CFA0AF322987EC4007F740A /* Products */ = {
isa = PBXGroup;
children = (
0CFA0AFD22987EC4007F740A /* libRNCWebView.a */,
);
name = Products;
sourceTree = "<group>";
};
139105B71AF99BAD00B5F7CC /* Products */ = {
isa = PBXGroup;
children = (
@ -459,16 +407,16 @@
07C03E371EC4EB8600E549B0 /* libyoga.a */,
3DAD3EA91DF850E9000B6D8A /* libcxxreact.a */,
07C03E391EC4EB8600E549B0 /* libcxxreact.a */,
3DAD3EAD1DF850E9000B6D8A /* libjschelpers.a */,
07C03E3B1EC4EB8600E549B0 /* libjschelpers.a */,
8CCE8B902182ACCF00855E24 /* libjsinspector.a */,
8CCE8B922182ACCF00855E24 /* libjsinspector-tvOS.a */,
07AE0CFB1F74268D0035D6C1 /* libthird-party.a */,
07AE0CFD1F74268D0035D6C1 /* libthird-party.a */,
07AE0CFF1F74268D0035D6C1 /* libdouble-conversion.a */,
07AE0D011F74268D0035D6C1 /* libdouble-conversion.a */,
0CFA0AEA22987EC4007F740A /* libjsi.a */,
0CFA0AEC22987EC4007F740A /* libjsiexecutor.a */,
0CFA0AEE22987EC4007F740A /* libjsi-tvOS.a */,
0CFA0AF022987EC4007F740A /* libjsiexecutor-tvOS.a */,
D4A8C3C320247A9D008BE855 /* libprivatedata.a */,
D4A8C3C520247A9D008BE855 /* libprivatedata-tvOS.a */,
);
name = Products;
sourceTree = "<group>";
@ -505,7 +453,6 @@
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */,
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
6ACD0BF3CAC840B79C2544A5 /* RNCNetInfo.xcodeproj */,
16D0CEE186654808941ED16F /* RNCWebView.xcodeproj */,
);
name = Libraries;
@ -527,7 +474,6 @@
832341AE1AAA6A7D00B99B32 /* Libraries */,
83CBBA001A601CBA00E9B192 /* Products */,
D22782DB222FDC54009150CC /* Frameworks */,
0CFA0AC522987EC1007F740A /* Recovered References */,
);
indentWidth = 2;
sourceTree = "<group>";
@ -589,7 +535,6 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
@ -641,14 +586,6 @@
ProductGroup = 146834001AC3E56700842450 /* Products */;
ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
},
{
ProductGroup = 0CFA0AF122987EC4007F740A /* Products */;
ProjectRef = 6ACD0BF3CAC840B79C2544A5 /* RNCNetInfo.xcodeproj */;
},
{
ProductGroup = 0CFA0AF322987EC4007F740A /* Products */;
ProjectRef = 16D0CEE186654808941ED16F /* RNCWebView.xcodeproj */;
},
);
projectRoot = "";
targets = (
@ -742,53 +679,11 @@
remoteRef = 07C03E381EC4EB8600E549B0 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
0CFA0AEA22987EC4007F740A /* libjsi.a */ = {
07C03E3B1EC4EB8600E549B0 /* libjschelpers.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libjsi.a;
remoteRef = 0CFA0AE922987EC4007F740A /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
0CFA0AEC22987EC4007F740A /* libjsiexecutor.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libjsiexecutor.a;
remoteRef = 0CFA0AEB22987EC4007F740A /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
0CFA0AEE22987EC4007F740A /* libjsi-tvOS.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = "libjsi-tvOS.a";
remoteRef = 0CFA0AED22987EC4007F740A /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
0CFA0AF022987EC4007F740A /* libjsiexecutor-tvOS.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = "libjsiexecutor-tvOS.a";
remoteRef = 0CFA0AEF22987EC4007F740A /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
0CFA0AF822987EC4007F740A /* libRNCNetInfo.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRNCNetInfo.a;
remoteRef = 0CFA0AF722987EC4007F740A /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
0CFA0AFA22987EC4007F740A /* libRNCNetInfo-tvOS.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = "libRNCNetInfo-tvOS.a";
remoteRef = 0CFA0AF922987EC4007F740A /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
0CFA0AFD22987EC4007F740A /* libRNCWebView.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRNCWebView.a;
remoteRef = 0CFA0AFC22987EC4007F740A /* PBXContainerItemProxy */;
path = libjschelpers.a;
remoteRef = 07C03E3A1EC4EB8600E549B0 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
139105C11AF99BAD00B5F7CC /* libRCTSettings.a */ = {
@ -868,6 +763,13 @@
remoteRef = 3DAD3EA81DF850E9000B6D8A /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
3DAD3EAD1DF850E9000B6D8A /* libjschelpers.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libjschelpers.a;
remoteRef = 3DAD3EAC1DF850E9000B6D8A /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
@ -924,6 +826,20 @@
remoteRef = D4A8C3B220247A9D008BE855 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
D4A8C3C320247A9D008BE855 /* libprivatedata.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libprivatedata.a;
remoteRef = D4A8C3C220247A9D008BE855 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
D4A8C3C520247A9D008BE855 /* libprivatedata-tvOS.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = "libprivatedata-tvOS.a";
remoteRef = D4A8C3C420247A9D008BE855 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
@ -989,15 +905,10 @@
DEVELOPMENT_TEAM = UBF8T346G9;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/@react-native-community/netinfo/ios",
"$(SRCROOT)/../node_modules/react-native-webview/ios",
);
INFOPLIST_FILE = RXPTest/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/RXPTest\"",
);
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
@ -1006,6 +917,10 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = RXPTest;
VERSIONING_SYSTEM = "apple-generic";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/RXPTest\"",
);
};
name = Debug;
};
@ -1017,15 +932,10 @@
DEVELOPMENT_TEAM = UBF8T346G9;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/@react-native-community/netinfo/ios",
"$(SRCROOT)/../node_modules/react-native-webview/ios",
);
INFOPLIST_FILE = RXPTest/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/RXPTest\"",
);
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
@ -1034,6 +944,10 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = RXPTest;
VERSIONING_SYSTEM = "apple-generic";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/RXPTest\"",
);
};
name = Release;
};

Просмотреть файл

@ -29,13 +29,11 @@
"webpack-dev-server": "^3.3.1"
},
"dependencies": {
"@react-native-community/netinfo": "^3.2.0",
"react": "16.8.3",
"react-dom": "16.8.3",
"react-native": "0.59.5",
"react-native-webview": "^5.7.2",
"react-native-windows": "^0.57.1",
"reactxp": "^1.6.1",
"reactxp-netinfo": "0.0.1-alpha.1"
"reactxp": "^1.6.1"
}
}

Просмотреть файл

@ -1,10 +1,9 @@
/*
* Tests the ~RX.Network~ reatxp-netinfo APIs in an interactive manner.
* Tests the RX.Network APIs in an interactive manner.
*/
import _ = require('lodash');
import RX = require('reactxp');
import RXNetInfo, { Types as RXNetInfoTypes } from 'reactxp-netinfo'
import * as CommonStyles from '../CommonStyles';
import { Test, TestResult, TestType } from '../Test';
@ -54,7 +53,7 @@ class NetworkView extends RX.Component<RX.CommonProps, NetworkState> {
componentDidMount() {
this._isMounted = true;
this._connectivityChangedEvent = RXNetInfo.connectivityChangedEvent.subscribe(isConnected => {
this._connectivityChangedEvent = RX.Network.connectivityChangedEvent.subscribe(isConnected => {
this.setState({
connectionState: isConnected ? 'Connected' : 'Disconnected'
});
@ -68,14 +67,10 @@ class NetworkView extends RX.Component<RX.CommonProps, NetworkState> {
componentWillUnmount() {
this._isMounted = false;
if (this._connectivityChangedEvent) {
this._connectivityChangedEvent.unsubscribe();
}
}
private _queryConnectivityState() {
RXNetInfo.isConnected().then(isConnected => {
RX.Network.isConnected().then(isConnected => {
if (this._isMounted) {
this.setState({
connectionState: isConnected ? 'Connected' : 'Disconnected'
@ -91,7 +86,7 @@ class NetworkView extends RX.Component<RX.CommonProps, NetworkState> {
}
private _queryNetworkState() {
RXNetInfo.getType().then(type => {
RX.Network.getType().then(type => {
if (this._isMounted) {
this.setState({
networkType: this._formatNetworkType(type)
@ -134,24 +129,24 @@ class NetworkView extends RX.Component<RX.CommonProps, NetworkState> {
);
}
private _formatNetworkType(type: RXNetInfoTypes.DeviceNetworkType): string {
private _formatNetworkType(type: RX.Types.DeviceNetworkType): string {
switch (type) {
case RXNetInfoTypes.DeviceNetworkType.Unknown:
case RX.Types.DeviceNetworkType.Unknown:
return 'Unknown';
case RXNetInfoTypes.DeviceNetworkType.None:
case RX.Types.DeviceNetworkType.None:
return 'None';
case RXNetInfoTypes.DeviceNetworkType.Wifi:
case RX.Types.DeviceNetworkType.Wifi:
return 'WiFi';
case RXNetInfoTypes.DeviceNetworkType.Mobile2G:
case RX.Types.DeviceNetworkType.Mobile2G:
return 'Mobile 2G';
case RXNetInfoTypes.DeviceNetworkType.Mobile3G:
case RX.Types.DeviceNetworkType.Mobile3G:
return 'Mobile 3G';
case RXNetInfoTypes.DeviceNetworkType.Mobile4G:
case RX.Types.DeviceNetworkType.Mobile4G:
return 'Mobile 4G';
default:

Просмотреть файл

@ -1,8 +1,9 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "rxptest", "rxptest\rxptest.csproj", "{CD08AF08-321A-4E52-A9A1-4B685D85154A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "rxptest", "rxptest\rxptest.csproj", "9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b"
ProjectSection(ProjectDependencies) = postProject
{2EACF721-73B5-46AE-9775-4A8674D05A9C} = {2EACF721-73B5-46AE-9775-4A8674D05A9C}
EndProjectSection
@ -19,14 +20,12 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Facebook.Yoga.Shared", "..\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yoga.uwp", "..\node_modules\react-native-windows\Yoga\csharp\Yoga\Yoga.Universal.vcxproj", "{2EACF721-73B5-46AE-9775-4A8674D05A9C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RNCNetInfo", "..\node_modules\@react-native-community\netinfo\windows\RNCNetInfo\RNCNetInfo.csproj", "{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\node_modules\react-native-windows\Yoga\csharp\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{91c42d32-291d-4b72-90b4-551663d60b8b}*SharedItemsImports = 13
..\node_modules\react-native-windows\ReactWindows\ReactNative.Shared\ReactNative.Shared.projitems*{c7673ad5-e3aa-468c-a5fd-fa38154e205c}*SharedItemsImports = 4
..\node_modules\react-native-windows\Yoga\csharp\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{c7673ad5-e3aa-468c-a5fd-fa38154e205c}*SharedItemsImports = 4
..\node_modules\react-native-windows\ReactWindows\ReactNative.Shared\ReactNative.Shared.projitems*{eea8b852-4d07-48e1-8294-a21ab5909fe5}*SharedItemsImports = 13
ReactNative.Shared\ReactNative.Shared.projitems*{c7673ad5-e3aa-468c-a5fd-fa38154e205c}*SharedItemsImports = 4
ReactNative.Shared\ReactNative.Shared.projitems*{eea8b852-4d07-48e1-8294-a21ab5909fe5}*SharedItemsImports = 13
..\Yoga\csharp\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{c7673ad5-e3aa-468c-a5fd-fa38154e205c}*SharedItemsImports = 4
..\Yoga\csharp\Facebook.Yoga\Facebook.Yoga.Shared.projitems*{91c42d32-291d-4b72-90b4-551663d60b8b}*SharedItemsImports = 13
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
@ -35,9 +34,6 @@ Global
DebugBundle|ARM = DebugBundle|ARM
DebugBundle|x64 = DebugBundle|x64
DebugBundle|x86 = DebugBundle|x86
Development|ARM = Development|ARM
Development|x64 = Development|x64
Development|x86 = Development|x86
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
@ -46,51 +42,42 @@ Global
ReleaseBundle|x86 = ReleaseBundle|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Debug|ARM.ActiveCfg = Debug|ARM
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Debug|ARM.Build.0 = Debug|ARM
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Debug|ARM.Deploy.0 = Debug|ARM
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Debug|x64.ActiveCfg = Debug|x64
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Debug|x64.Build.0 = Debug|x64
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Debug|x64.Deploy.0 = Debug|x64
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Debug|x86.ActiveCfg = Debug|x86
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Debug|x86.Build.0 = Debug|x86
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Debug|x86.Deploy.0 = Debug|x86
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.DebugBundle|ARM.ActiveCfg = DebugBundle|ARM
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.DebugBundle|ARM.Build.0 = DebugBundle|ARM
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.DebugBundle|ARM.Deploy.0 = DebugBundle|ARM
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.DebugBundle|x64.ActiveCfg = DebugBundle|x64
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.DebugBundle|x64.Build.0 = DebugBundle|x64
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.DebugBundle|x64.Deploy.0 = DebugBundle|x64
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.DebugBundle|x86.ActiveCfg = DebugBundle|x86
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.DebugBundle|x86.Build.0 = DebugBundle|x86
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.DebugBundle|x86.Deploy.0 = DebugBundle|x86
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Development|ARM.ActiveCfg = DebugBundle|ARM
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Development|ARM.Build.0 = DebugBundle|ARM
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Development|ARM.Deploy.0 = DebugBundle|ARM
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Development|x64.ActiveCfg = DebugBundle|x64
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Development|x64.Build.0 = DebugBundle|x64
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Development|x64.Deploy.0 = DebugBundle|x64
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Development|x86.ActiveCfg = DebugBundle|x86
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Development|x86.Build.0 = DebugBundle|x86
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Development|x86.Deploy.0 = DebugBundle|x86
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Release|ARM.ActiveCfg = Release|ARM
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Release|ARM.Build.0 = Release|ARM
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Release|ARM.Deploy.0 = Release|ARM
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Release|x64.ActiveCfg = Release|x64
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Release|x64.Build.0 = Release|x64
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Release|x64.Deploy.0 = Release|x64
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Release|x86.ActiveCfg = Release|x86
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Release|x86.Build.0 = Release|x86
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.Release|x86.Deploy.0 = Release|x86
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.ReleaseBundle|ARM.ActiveCfg = ReleaseBundle|ARM
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.ReleaseBundle|ARM.Build.0 = ReleaseBundle|ARM
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.ReleaseBundle|ARM.Deploy.0 = ReleaseBundle|ARM
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.ReleaseBundle|x64.ActiveCfg = ReleaseBundle|x64
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.ReleaseBundle|x64.Build.0 = ReleaseBundle|x64
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.ReleaseBundle|x64.Deploy.0 = ReleaseBundle|x64
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.ReleaseBundle|x86.ActiveCfg = ReleaseBundle|x86
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.ReleaseBundle|x86.Build.0 = ReleaseBundle|x86
{CD08AF08-321A-4E52-A9A1-4B685D85154A}.ReleaseBundle|x86.Deploy.0 = ReleaseBundle|x86
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Debug|ARM.ActiveCfg = Debug|ARM
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Debug|ARM.Build.0 = Debug|ARM
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Debug|ARM.Deploy.0 = Debug|ARM
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Debug|x64.ActiveCfg = Debug|x64
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Debug|x64.Build.0 = Debug|x64
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Debug|x64.Deploy.0 = Debug|x64
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Debug|x86.ActiveCfg = Debug|x86
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Debug|x86.Build.0 = Debug|x86
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Debug|x86.Deploy.0 = Debug|x86
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.DebugBundle|ARM.ActiveCfg = DebugBundle|ARM
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.DebugBundle|ARM.Build.0 = DebugBundle|ARM
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.DebugBundle|ARM.Deploy.0 = DebugBundle|ARM
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.DebugBundle|x64.ActiveCfg = DebugBundle|x64
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.DebugBundle|x64.Build.0 = DebugBundle|x64
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.DebugBundle|x64.Deploy.0 = DebugBundle|x64
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.DebugBundle|x86.ActiveCfg = DebugBundle|x86
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.DebugBundle|x86.Build.0 = DebugBundle|x86
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.DebugBundle|x86.Deploy.0 = DebugBundle|x86
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Release|ARM.ActiveCfg = Release|ARM
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Release|ARM.Build.0 = Release|ARM
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Release|ARM.Deploy.0 = Release|ARM
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Release|x64.ActiveCfg = Release|x64
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Release|x64.Build.0 = Release|x64
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Release|x64.Deploy.0 = Release|x64
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Release|x86.ActiveCfg = Release|x86
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Release|x86.Build.0 = Release|x86
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.Release|x86.Deploy.0 = Release|x86
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.ReleaseBundle|ARM.ActiveCfg = ReleaseBundle|ARM
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.ReleaseBundle|ARM.Build.0 = ReleaseBundle|ARM
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.ReleaseBundle|ARM.Deploy.0 = ReleaseBundle|ARM
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.ReleaseBundle|x64.ActiveCfg = ReleaseBundle|x64
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.ReleaseBundle|x64.Build.0 = ReleaseBundle|x64
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.ReleaseBundle|x64.Deploy.0 = ReleaseBundle|x64
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.ReleaseBundle|x86.ActiveCfg = ReleaseBundle|x86
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.ReleaseBundle|x86.Build.0 = ReleaseBundle|x86
9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b.ReleaseBundle|x86.Deploy.0 = ReleaseBundle|x86
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Debug|ARM.ActiveCfg = Debug|ARM
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Debug|ARM.Build.0 = Debug|ARM
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Debug|x64.ActiveCfg = Debug|x64
@ -103,12 +90,6 @@ Global
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.DebugBundle|x64.Build.0 = Debug|x64
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.DebugBundle|x86.ActiveCfg = Debug|x86
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.DebugBundle|x86.Build.0 = Debug|x86
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Development|ARM.ActiveCfg = Debug|ARM
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Development|ARM.Build.0 = Debug|ARM
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Development|x64.ActiveCfg = Debug|x64
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Development|x64.Build.0 = Debug|x64
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Development|x86.ActiveCfg = Debug|x86
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Development|x86.Build.0 = Debug|x86
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Release|ARM.ActiveCfg = Release|ARM
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Release|ARM.Build.0 = Release|ARM
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Release|x64.ActiveCfg = Release|x64
@ -133,12 +114,6 @@ Global
{4B72C796-16D5-4E3A-81C0-3E36F531E578}.DebugBundle|x64.Build.0 = Debug|x64
{4B72C796-16D5-4E3A-81C0-3E36F531E578}.DebugBundle|x86.ActiveCfg = Debug|Win32
{4B72C796-16D5-4E3A-81C0-3E36F531E578}.DebugBundle|x86.Build.0 = Debug|Win32
{4B72C796-16D5-4E3A-81C0-3E36F531E578}.Development|ARM.ActiveCfg = Debug|ARM
{4B72C796-16D5-4E3A-81C0-3E36F531E578}.Development|ARM.Build.0 = Debug|ARM
{4B72C796-16D5-4E3A-81C0-3E36F531E578}.Development|x64.ActiveCfg = Debug|x64
{4B72C796-16D5-4E3A-81C0-3E36F531E578}.Development|x64.Build.0 = Debug|x64
{4B72C796-16D5-4E3A-81C0-3E36F531E578}.Development|x86.ActiveCfg = Debug|Win32
{4B72C796-16D5-4E3A-81C0-3E36F531E578}.Development|x86.Build.0 = Debug|Win32
{4B72C796-16D5-4E3A-81C0-3E36F531E578}.Release|ARM.ActiveCfg = Release|ARM
{4B72C796-16D5-4E3A-81C0-3E36F531E578}.Release|ARM.Build.0 = Release|ARM
{4B72C796-16D5-4E3A-81C0-3E36F531E578}.Release|x64.ActiveCfg = Release|x64
@ -163,12 +138,6 @@ Global
{7596216B-669C-41F8-86DA-F3637F6545C0}.DebugBundle|x64.Build.0 = Debug|x64
{7596216B-669C-41F8-86DA-F3637F6545C0}.DebugBundle|x86.ActiveCfg = Debug|x86
{7596216B-669C-41F8-86DA-F3637F6545C0}.DebugBundle|x86.Build.0 = Debug|x86
{7596216B-669C-41F8-86DA-F3637F6545C0}.Development|ARM.ActiveCfg = Debug|ARM
{7596216B-669C-41F8-86DA-F3637F6545C0}.Development|ARM.Build.0 = Debug|ARM
{7596216B-669C-41F8-86DA-F3637F6545C0}.Development|x64.ActiveCfg = Debug|x64
{7596216B-669C-41F8-86DA-F3637F6545C0}.Development|x64.Build.0 = Debug|x64
{7596216B-669C-41F8-86DA-F3637F6545C0}.Development|x86.ActiveCfg = Debug|x86
{7596216B-669C-41F8-86DA-F3637F6545C0}.Development|x86.Build.0 = Debug|x86
{7596216B-669C-41F8-86DA-F3637F6545C0}.Release|ARM.ActiveCfg = Release|ARM
{7596216B-669C-41F8-86DA-F3637F6545C0}.Release|ARM.Build.0 = Release|ARM
{7596216B-669C-41F8-86DA-F3637F6545C0}.Release|x64.ActiveCfg = Release|x64
@ -193,12 +162,6 @@ Global
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.DebugBundle|x64.Build.0 = Debug|x64
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.DebugBundle|x86.ActiveCfg = Debug|Win32
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.DebugBundle|x86.Build.0 = Debug|Win32
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.Development|ARM.ActiveCfg = Debug|ARM
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.Development|ARM.Build.0 = Debug|ARM
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.Development|x64.ActiveCfg = Debug|x64
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.Development|x64.Build.0 = Debug|x64
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.Development|x86.ActiveCfg = Debug|Win32
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.Development|x86.Build.0 = Debug|Win32
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.Release|ARM.ActiveCfg = Release|ARM
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.Release|ARM.Build.0 = Release|ARM
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.Release|x64.ActiveCfg = Release|x64
@ -211,36 +174,6 @@ Global
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.ReleaseBundle|x64.Build.0 = Release|x64
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.ReleaseBundle|x86.ActiveCfg = Release|Win32
{2EACF721-73B5-46AE-9775-4A8674D05A9C}.ReleaseBundle|x86.Build.0 = Release|Win32
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Debug|ARM.ActiveCfg = Debug|ARM
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Debug|ARM.Build.0 = Debug|ARM
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Debug|x64.ActiveCfg = Debug|x64
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Debug|x64.Build.0 = Debug|x64
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Debug|x86.ActiveCfg = Debug|x86
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Debug|x86.Build.0 = Debug|x86
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.DebugBundle|ARM.ActiveCfg = Debug|ARM
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.DebugBundle|ARM.Build.0 = Debug|ARM
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.DebugBundle|x64.ActiveCfg = Debug|x64
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.DebugBundle|x64.Build.0 = Debug|x64
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.DebugBundle|x86.ActiveCfg = Debug|x86
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.DebugBundle|x86.Build.0 = Debug|x86
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Development|ARM.ActiveCfg = Development|ARM
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Development|ARM.Build.0 = Development|ARM
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Development|x64.ActiveCfg = Development|x64
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Development|x64.Build.0 = Development|x64
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Development|x86.ActiveCfg = Development|x86
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Development|x86.Build.0 = Development|x86
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Release|ARM.ActiveCfg = Release|ARM
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Release|ARM.Build.0 = Release|ARM
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Release|x64.ActiveCfg = Release|x64
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Release|x64.Build.0 = Release|x64
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Release|x86.ActiveCfg = Release|x86
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.Release|x86.Build.0 = Release|x86
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.ReleaseBundle|ARM.ActiveCfg = Release|ARM
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.ReleaseBundle|ARM.Build.0 = Release|ARM
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.ReleaseBundle|x64.ActiveCfg = Release|x64
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.ReleaseBundle|x64.Build.0 = Release|x64
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.ReleaseBundle|x86.ActiveCfg = Release|x86
{4ACDD44C-E556-423E-BD74-B4CEF3E67FF0}.ReleaseBundle|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Просмотреть файл

@ -1,7 +1,6 @@
using ReactNative;
using ReactNative.Modules.Core;
using ReactNative.Shell;
using ReactNativeCommunity.NetInfo;
using System.Collections.Generic;
namespace rxptest
@ -25,7 +24,6 @@ namespace rxptest
protected override List<IReactPackage> Packages => new List<IReactPackage>
{
new MainReactPackage(),
new RNCNetInfoPackage(),
};
}
}

Просмотреть файл

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{CD08AF08-321A-4E52-A9A1-4B685D85154A}</ProjectGuid>
<ProjectGuid>9bbd0d12-a1ee-4f9f-b2f8-e2f3bf63ab5b</ProjectGuid>
<OutputType>AppContainerExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>rxptest</RootNamespace>
@ -18,6 +18,7 @@
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<PackageCertificateKeyFile>rxptest_TemporaryKey.pfx</PackageCertificateKeyFile>
<PackageCertificateThumbprint>50F7227C472371D7441028F660BDFCDF35B7FA83</PackageCertificateThumbprint>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<DependencyConfiguration>Debug</DependencyConfiguration>
</PropertyGroup>
@ -207,10 +208,6 @@
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\node_modules\%40react-native-community\netinfo\windows\RNCNetInfo\RNCNetInfo.csproj">
<Project>{4acdd44c-e556-423e-bd74-b4cef3e67ff0}</Project>
<Name>RNCNetInfo</Name>
</ProjectReference>
<ProjectReference Include="..\..\node_modules\react-native-windows\ReactWindows\ReactNative\ReactNative.csproj">
<Project>{c7673ad5-e3aa-468c-a5fd-fa38154e205c}</Project>
<Name>ReactNative</Name>
@ -244,4 +241,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

Просмотреть файл

@ -26,6 +26,7 @@ import LinkingImpl from '../native-common/Linking';
import LocationImpl from '../common/Location';
import ModalImpl from '../native-common/Modal';
import RXModuleInterface = require('../common/ModuleInterface');
import NetworkImpl from '../native-common/Network';
import PickerImpl from '../native-common/Picker';
import PlatformImpl from '../native-common/Platform';
import PopupImpl from '../native-common/Popup';
@ -82,6 +83,8 @@ module ReactXP {
export let Location: RXInterfaces.Location = LocationImpl;
export type Modal = RXInterfaces.Modal;
export let Modal: RXInterfaces.Modal = ModalImpl;
export type Network = RXInterfaces.Network;
export let Network: RXInterfaces.Network = NetworkImpl;
export type Platform = RXInterfaces.Platform;
export let Platform: RXInterfaces.Platform = PlatformImpl;
export type Popup = RXInterfaces.Popup;

Просмотреть файл

@ -192,6 +192,12 @@ export interface LocationConfiguration {
skipPermissionRequests: boolean;
}
export abstract class Network {
abstract isConnected(): SyncTasks.Promise<boolean>;
abstract getType(): SyncTasks.Promise<Types.DeviceNetworkType>;
connectivityChangedEvent = new SubscribableEvent<(isConnected: boolean) => void>();
}
export abstract class Platform {
abstract getType(): Types.PlatformType;
abstract select<T>(specifics: { [ platform in Types.PlatformType | 'default' ]?: T }): T | undefined;

Просмотреть файл

@ -42,6 +42,8 @@ export declare module ReactXP {
export let Location: RX.Location;
export type Modal = RX.Modal;
export let Modal: RX.Modal;
export type Network = RX.Network;
export let Network: RX.Network;
export type Platform = RX.Platform;
export let Platform: RX.Platform;
export type Popup = RX.Popup;

Просмотреть файл

@ -1403,3 +1403,15 @@ export interface LayoutInfo {
// Platform
// ----------------------------------------------------------------------
export type PlatformType = 'web' | 'ios' | 'android' | 'windows' | 'macos';
//
// Network
// ----------------------------------------------------------------------
export enum DeviceNetworkType {
Unknown,
None,
Wifi,
Mobile2G,
Mobile3G,
Mobile4G
}

Просмотреть файл

@ -25,6 +25,7 @@ import LinkImpl from '../native-common/Link';
import LocationImpl from '../common/Location';
import ModalImpl from '../native-common/Modal';
import RXModuleInterface = require('../common/ModuleInterface');
import NetworkImpl from '../native-common/Network';
import PickerImpl from '../native-common/Picker';
import PlatformImpl from '../native-common/Platform';
import PopupImpl from '../native-common/Popup';
@ -81,6 +82,8 @@ module ReactXP {
export let Location: RXInterfaces.Location = LocationImpl;
export type Modal = RXInterfaces.Modal;
export let Modal: RXInterfaces.Modal = ModalImpl;
export type Network = RXInterfaces.Network;
export let Network: RXInterfaces.Network = NetworkImpl;
export type Platform = RXInterfaces.Platform;
export let Platform: RXInterfaces.Platform = PlatformImpl;
export type Popup = RXInterfaces.Popup;

Просмотреть файл

@ -25,6 +25,7 @@ import LinkImpl from '../native-common/Link';
import LocationImpl from '../common/Location';
import ModalImpl from '../native-common/Modal';
import RXModuleInterface = require('../common/ModuleInterface');
import NetworkImpl from '../native-common/Network';
import PickerImpl from '../native-common/Picker';
import PlatformImpl from '../native-common/Platform';
import PopupImpl from '../native-common/Popup';
@ -82,6 +83,8 @@ module ReactXP {
export let Location: RXInterfaces.Location = LocationImpl;
export type Modal = RXInterfaces.Modal;
export let Modal: RXInterfaces.Modal = ModalImpl;
export type Network = RXInterfaces.Network;
export let Network: RXInterfaces.Network = NetworkImpl;
export type Platform = RXInterfaces.Platform;
export let Platform: RXInterfaces.Platform = PlatformImpl;
export type Popup = RXInterfaces.Popup;

Просмотреть файл

@ -0,0 +1,96 @@
/**
* Network.ts
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*
* Native implementation of network information APIs.
*/
import * as RN from 'react-native';
import * as SyncTasks from 'synctasks';
import * as RX from '../common/Interfaces';
export class Network extends RX.Network {
constructor() {
super();
const onEventOccuredHandler = this._onEventOccured.bind(this);
// The "change" event is being deprecated. See if the newer "connectionchange"
// event is available instead. We can't determine this directly, but we can
// check whether the accompanying RN.NetInfo.getConnectionInfo is available.
RN.NetInfo.isConnected.addEventListener(
RN.NetInfo.getConnectionInfo ? 'connectionChange' : 'change',
onEventOccuredHandler);
}
isConnected(): SyncTasks.Promise<boolean> {
const deferred = SyncTasks.Defer<boolean>();
RN.NetInfo.isConnected.fetch().then(isConnected => {
deferred.resolve(isConnected);
}).catch(() => {
deferred.reject('RN.NetInfo.isConnected.fetch() failed');
});
return deferred.promise();
}
getType(): SyncTasks.Promise<RX.Types.DeviceNetworkType> {
// Is the newer call available? Use it instead of the soon-to-be-deprecated
// NetInfo.fetch call if possible.
if (RN.NetInfo.getConnectionInfo) {
return SyncTasks.fromThenable(RN.NetInfo.getConnectionInfo()).then(info => {
return Network._getNetworkTypeFromConnectionInfo(info);
});
} else {
// Use the older RN.NetInfo.fetch call if the newer call isn't available.
return SyncTasks.fromThenable(RN.NetInfo.fetch().then(networkType => {
return Network._getNetworkTypeFromNetInfo(networkType);
}));
}
}
private _onEventOccured(isConnected: boolean) {
this.connectivityChangedEvent.fire(isConnected);
}
private static _getNetworkTypeFromNetInfo(networkType: string): RX.Types.DeviceNetworkType {
switch (networkType) {
case 'UNKNOWN':
return RX.Types.DeviceNetworkType.Unknown;
case 'NONE':
return RX.Types.DeviceNetworkType.None;
case 'WIFI':
return RX.Types.DeviceNetworkType.Wifi;
case 'MOBILE_2G':
return RX.Types.DeviceNetworkType.Mobile2G;
case 'MOBILE_3G':
return RX.Types.DeviceNetworkType.Mobile3G;
case 'MOBILE_4G':
return RX.Types.DeviceNetworkType.Mobile4G;
}
return RX.Types.DeviceNetworkType.Unknown;
}
private static _getNetworkTypeFromConnectionInfo(info: RN.ConnectionInfo): RX.Types.DeviceNetworkType {
if (info.effectiveType === '2g') {
return RX.Types.DeviceNetworkType.Mobile2G;
} else if (info.effectiveType === '3g') {
return RX.Types.DeviceNetworkType.Mobile3G;
} else if (info.effectiveType === '4g') {
return RX.Types.DeviceNetworkType.Mobile4G;
} else if (info.type === 'wifi' || info.type === 'ETHERNET') {
return RX.Types.DeviceNetworkType.Wifi;
} else if (info.type === 'none') {
return RX.Types.DeviceNetworkType.None;
}
return RX.Types.DeviceNetworkType.Unknown;
}
}
export default new Network();

Просмотреть файл

@ -1,24 +1,21 @@
/**
* Video.tsx
* Network.ts
*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*
* Web-specific implementation of the cross-platform Video abstraction.
* Web-specific implementation of Network information APIs.
*/
import * as SyncTasks from 'synctasks';
import * as Types from '../common/Types';
import * as Interfaces from '../common/Interfaces';
import * as RX from '../common/Interfaces';
export class NetInfo extends Interfaces.NetInfo {
export class Network extends RX.Network {
constructor() {
super();
const onEventOccuredHandler = () => {
this.connectivityChangedEvent.fire(navigator.onLine);
};
const onEventOccuredHandler = this._onEventOccured.bind(this);
// Avoid accessing window if it's not defined (for test environment).
if (typeof(window) !== 'undefined') {
@ -31,9 +28,13 @@ export class NetInfo extends Interfaces.NetInfo {
return SyncTasks.Resolved(navigator.onLine);
}
getType(): SyncTasks.Promise<Types.DeviceNetworkType> {
return SyncTasks.Resolved(Types.DeviceNetworkType.Unknown);
getType(): SyncTasks.Promise<RX.Types.DeviceNetworkType> {
return SyncTasks.Resolved(RX.Types.DeviceNetworkType.Unknown);
}
private _onEventOccured() {
this.connectivityChangedEvent.fire(navigator.onLine);
}
}
export default new NetInfo();
export default new Network();

Просмотреть файл

@ -32,6 +32,7 @@ import InternationalImpl from './International';
import { Link as LinkImpl } from './Link';
import LinkingImpl from './Linking';
import ModalImpl from './Modal';
import NetworkImpl from './Network';
import { Picker as PickerImpl } from './Picker';
import PlatformImpl from './Platform';
import { ScrollView as ScrollViewImpl } from './ScrollView';
@ -84,6 +85,8 @@ module ReactXP {
export let Location: RXInterfaces.Location = LocationImpl;
export type Modal = RXInterfaces.Modal;
export let Modal: RXInterfaces.Modal = ModalImpl;
export type Network = RXInterfaces.Network;
export let Network: RXInterfaces.Network = NetworkImpl;
export type Platform = RXInterfaces.Platform;
export let Platform: RXInterfaces.Platform = PlatformImpl;
export type Popup = RXInterfaces.Popup;

Просмотреть файл

@ -24,6 +24,7 @@ import LinkingImpl from '../native-common/Linking';
import LocationImpl from '../common/Location';
import ModalImpl from '../native-common/Modal';
import RXModuleInterface = require('../common/ModuleInterface');
import NetworkImpl from '../native-common/Network';
import PickerImpl from '../native-common/Picker';
import PlatformImpl from '../native-common/Platform';
import PopupImpl from '../native-common/Popup';
@ -82,6 +83,8 @@ module ReactXP {
export let Location: RXInterfaces.Location = LocationImpl;
export type Modal = RXInterfaces.Modal;
export let Modal: RXInterfaces.Modal = ModalImpl;
export type Network = RXInterfaces.Network;
export let Network: RXInterfaces.Network = NetworkImpl;
export type Platform = RXInterfaces.Platform;
export let Platform: RXInterfaces.Platform = PlatformImpl;
export type Popup = RXInterfaces.Popup;