diff --git a/zh-cn/react-native-community-netinfo.md b/zh-cn/react-native-community-netinfo.md index 2ae2054effcf4e81eaf8f70d65317a683c8fd362..ca0f6fcfd1bc882dc180d5e35c59045425f6a91a 100644 --- a/zh-cn/react-native-community-netinfo.md +++ b/zh-cn/react-native-community-netinfo.md @@ -1,4 +1,3 @@ - > 模板版本:v0.2.2

@@ -97,7 +96,7 @@ export default App; "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", - "rnoh-netinfo": "file:../../node_modules/@react-native-oh-tpl/netinfo/harmony/netinfo.har" + "@react-native-oh-tpl/netinfo": "file:../../node_modules/@react-native-oh-tpl/netinfo/harmony/netinfo.har" } ``` @@ -122,15 +121,15 @@ ohpm install project(rnapp) cmake_minimum_required(VERSION 3.4.1) set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") -set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") ++ set(OH_MODULE "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp") add_subdirectory("${RNOH_CPP_DIR}" ./rn) -# RNOH_BEGIN: add_package_subdirectories +# RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) -+ add_subdirectory("${OH_MODULE_DIR}/rnoh-netinfo/src/main/cpp" ./netinfo) -# RNOH_END: add_package_subdirectories ++ add_subdirectory("${OH_MODULE}/@react-native-oh-tpl/netinfo/src/main/cpp" ./netinfo) +# RNOH_END: manual_package_linking_1 add_library(rnoh_app SHARED "./PackageProvider.cpp" @@ -139,10 +138,10 @@ add_library(rnoh_app SHARED target_link_libraries(rnoh_app PUBLIC rnoh) -# RNOH_BEGIN: link_packages +# RNOH_BEGIN: manual_package_linking_2 target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) + target_link_libraries(rnoh_app PUBLIC rnoh_netinfo) -# RNOH_END: link_packages +# RNOH_END: manual_package_linking_2 ``` 打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: @@ -169,7 +168,7 @@ std::vector> PackageProvider::getPackages(Package::Cont ```diff import type {RNPackageContext, RNPackage} from 'rnoh/ts'; import {SamplePackage} from 'rnoh-sample-package/ts'; -+ import {NetInfoPackage} from 'rnoh-netinfo/ts'; ++ import {NetInfoPackage} from '@react-native-oh-tpl/netinfo/ts'; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ @@ -207,82 +206,78 @@ RNOH:0.72.27; SDK:HarmonyOS-Next-DB1 5.0.0.29(SP1) ; IDE:DevEco Studio 5.0 #### NetInfoStateType -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ----------- | ---------------------------------------------------------- | ------ | -------- | ------------ | ----------------- | -| `none` | No network connection is active | String | no | All | yes | -| `unknown` | The network state could not or has yet to be be determined | String | no | All | yes | -| `cellular` | Active network over cellular | String | no | All | no | -| `wifi` | Active network over Wifi | String | no | All | yes | -| `bluetooth` | Active network over Bluetooth | String | no | Android, Web | no | -| `ethernet` | Active network over wired ethernet | String | no | All | no | -| `wimax` | Active network over WiMax | String | no | Android, Web | no | -| `vpn` | Active network over VPN | String | no | Android | no | -| `other` | Active network over another type of network | String | no | All | no | +| Name | Description | Type | Required | Platform | HarmonyOS Support | +|-------------|------------------------------------------------------------|--------|----------|-------------|-------------------| +| `none` | No network connection is active | String | no | iOS Android | yes | +| `unknown` | The network state could not or has yet to be be determined | String | no | iOS Android | yes | +| `cellular` | Active network over cellular | String | no | iOS Android | no | +| `wifi` | Active network over Wifi | String | no | iOS Android | yes | +| `bluetooth` | Active network over Bluetooth | String | no | Android | no | +| `ethernet` | Active network over wired ethernet | String | no | iOS Android | no | +| `wimax` | Active network over WiMax | String | no | Android | no | +| `vpn` | Active network over VPN | String | no | Android | no | +| `other` | Active network over another type of network | String | no | iOS Android | no | #### NetInfoCellularGeneration -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ------ | ----------------------------------------------------------------------------------------------------------------- | ------ | -------- | --------------------- | ----------------- | -| `null` | Either we are not currently connected to a cellular network or type could not be determined | String | no | Android, iOS, Windows | no | -| `2g` | Currently connected to a 2G cellular network. Includes CDMA, EDGE, GPRS, and IDEN type connections | String | no | Android, iOS, Windows | no | -| `3g` | Currently connected to a 3G cellular network. Includes EHRPD, EVDO, HSPA, HSUPA, HSDPA, and UTMS type connections | String | no | Android, iOS, Windows | no | -| `4g` | Currently connected to a 4G cellular network. Includes HSPAP and LTE type connections | String | no | Android, iOS, Windows | no | -| `5g` | Currently connected to a 5G cellular network. Includes NRNSA (iOS only) and NR type connections | String | no | Android, iOS, Windows | no | +| Name | Description | Type | Required | Platform | HarmonyOS Support | +|--------|-------------------------------------------------------------------------------------------------------------------|--------|----------|-------------|-------------------| +| `null` | Either we are not currently connected to a cellular network or type could not be determined | String | no | iOS Android | no | +| `2g` | Currently connected to a 2G cellular network. Includes CDMA, EDGE, GPRS, and IDEN type connections | String | no | iOS Android | no | +| `3g` | Currently connected to a 3G cellular network. Includes EHRPD, EVDO, HSPA, HSUPA, HSDPA, and UTMS type connections | String | no | iOS Android | no | +| `4g` | Currently connected to a 4G cellular network. Includes HSPAP and LTE type connections | String | no | iOS Android | no | +| `5g` | Currently connected to a 5G cellular network. Includes NRNSA (iOS only) and NR type connections | String | no | iOS Android | no | #### NetInfoState -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | -------- | -------- | ----------------- | -| `type` | The type of the current connection. | NetInfoStateType | yes | All | yes | -| `isConnected` | If there is an active network connection. Defaults to null on most platforms for unknown networks. Note: Web browsers report network type unknown for many otherwise valid networks (https://caniuse.com/netinfo), so isConnected may be true or false and represent a real connection status even for unknown network types in certain cases. | boolean, null | yes | All | yes | -| `isInternetReachable` | If the internet is reachable with the currently active network connection. If unknown defaults to null | boolean, null | yes | All | yes | -| `isWifiEnabled` | (Android only) Whether the device's WiFi is ON or OFF. | boolean | yes | All | yes | -| `details` | The value depends on the type value. See below. | | yes | All | yes | +| Name | Description | Type | Required | Platform | HarmonyOS Support | +|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------|----------|-------------|-------------------| +| `type` | The type of the current connection. | NetInfoStateType | yes | iOS Android | yes | +| `isConnected` | If there is an active network connection.
Defaults to null on most platforms for unknown networks.
Note: Web browsers report network type unknown for many otherwise valid networks (https://caniuse.com/netinfo),
so isConnected may be true or false and represent a real connection status even for unknown network types in certain cases. | boolean, null | yes | iOS Android | yes | +| `isInternetReachable` | If the internet is reachable with the currently active network connection.
If unknown defaults to null | boolean, null | yes | iOS Android | yes | +| `isWifiEnabled` | (Android only) Whether the device's WiFi is ON or OFF. | boolean | yes | iOS Android | yes | +| `details` | The value depends on the type value. See below. | | yes | iOS Android | yes | ### Details -#### Type is none or unknown - -`details` is `null`. - #### Type is wifi -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -------- | ---------------------------------- | ----------------- | -| `isConnectionExpensive` | If the network connection is considered "expensive". This could be in either energy or monetary terms. | boolean | yes | All | yes | -| `ssid` | The SSID of the network. May not be present, null, or an empty string if it cannot be determined. On iOS, your app must meet at least one of the following requirements and you must set the shouldFetchWiFiSSID configuration option or no attempt will be made to fetch the SSID. On Android, you need to have the ACCESS_FINE_LOCATION permission in your AndroidManifest.xml and accepted by the user. | string | yes | Android, iOS (not tvOS), Windows | yes | -| `bssid` | The BSSID of the network. May not be present, null, or an empty string if it cannot be determined. On iOS, make sure your app meets at least one of the following requirements. On Android, you need to have the ACCESS_FINE_LOCATION permission in your AndroidManifest.xml and accepted by the user. | string | yes | Android, iOS (not tvOS), Windows\* | yes | -| `strength` | An integer number from 0 to 100 for the signal strength. May not be present if the signal strength cannot be determined. | number | yes | Android, Windows | yes | -| `ipAddress` | The external IP address. Can be in IPv4 or IPv6 format. May not be present if it cannot be determined. | string | yes | Android, iOS, macOS, Windows | yes | -| `subnet` | The subnet mask in IPv4 format. May not be present if it cannot be determined. | string | yes | Android, iOS, macOS | yes | -| `frequency` | Network frequency. Example: For 2.4 GHz networks, the method will return 2457. May not be present if it cannot be determined. | number | yes | Android, Windows\* | yes | -| `linkSpeed` | The link speed in Mbps. | number | yes | Android | yes | -| `rxLinkSpeed` | The current receive link speed in Mbps. | number | yes | Android | yes | -| `txLinkSpeed` | The current transmit link speed in Mbps. | number | yes | Android | yes | +| Name | Description | Type | Required | Platform | HarmonyOS Support | +|-------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|----------|-------------|-------------------| +| `isConnectionExpensive` | If the network connection is considered "expensive".
This could be in either energy or monetary terms. | boolean | yes | iOS Android | yes | +| `ssid` | The SSID of the network.
May not be present, null, or an empty string if it cannot be determined.
On iOS, your app must meet at least one of the following requirements and you must set the shouldFetchWiFiSSID configuration option or no attempt will be made to fetch the SSID.
On Android, you need to have the ACCESS_FINE_LOCATION permission in your AndroidManifest.
xml and accepted by the user. | string | yes | iOS Android | yes | +| `bssid` | The BSSID of the network.
May not be present, null, or an empty string if it cannot be determined.
On iOS, make sure your app meets at least one of the following requirements.
On Android, you need to have the ACCESS_FINE_LOCATION permission in your AndroidManifest.
xml and accepted by the user. | string | yes | iOS Android | yes | +| `strength` | An integer number from 0 to 100 for the signal strength.
May not be present if the signal strength cannot be determined. | number | yes | Android | yes | +| `ipAddress` | The external IP address. Can be in IPv4 or IPv6 format.
May not be present if it cannot be determined. | string | yes | iOS Android | yes | +| `subnet` | The subnet mask in IPv4 format.
May not be present if it cannot be determined. | string | yes | iOS Android | yes | +| `frequency` | Network frequency. Example: For 2.4 GHz networks, the method will return 2457.
May not be present if it cannot be determined. | number | yes | Android | yes | +| `linkSpeed` | The link speed in Mbps. | number | yes | Android | yes | +| `rxLinkSpeed` | The current receive link speed in Mbps. | number | yes | Android | yes | +| `txLinkSpeed` | The current transmit link speed in Mbps. | number | yes | Android | yes | #### Type is cellular -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ----------------------- | --------------------------------------------------------------------------------------------------------------------- | :-----------------------: | :------: | :-------------------: | :---------------: | -| `isConnectionExpensive` | If the network connection is considered "expensive". This could be in either energy or monetary terms. | boolean | yes | All | no | -| `cellularGeneration` | The generation of the cell network the user is connected to. This can give an indication of speed, but no guarantees. | NetInfoCellularGeneration | yes | Android, iOS, Windows | no | -| `carrier` | The network carrier name. May not be present or may be empty if none can be determined. | +string | yes | Android, iOS | no | +| Name | Description | Type | Required | Platform | HarmonyOS Support | +|-------------------------|-----------------------------------------------------------------------------------------------------------------------|:-------------------------:|:--------:|:-----------:|:-----------------:| +| `isConnectionExpensive` | If the network connection is considered "expensive". This could be in either energy or monetary terms. | boolean | yes | iOS Android | no | +| `cellularGeneration` | The generation of the cell network the user is connected to. This can give an indication of speed, but no guarantees. | NetInfoCellularGeneration | yes | iOS Android | no | +| `carrier` | The network carrier name. May not be present or may be empty if none can be determined. | +string | yes | iOS Android | no | #### Type is bluetooth, ethernet, wimax, vpn, or other -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ----------------------- | ------------------------------------------------------------------------------------------------------ | :-----: | :------: | :------: | :---------------: | -| `isConnectionExpensive` | If the network connection is considered "expensive". This could be in either energy or monetary terms. | boolean | yes | All | no | +| Name | Description | Type | Required | Platform | HarmonyOS Support | +|-------------------------|-------------------------------------------------------------------------------------------------------------|:-------:|:--------:|:-----------:|:-----------------:| +| `isConnectionExpensive` | If the network connection is considered "expensive".
This could be in either energy or monetary terms. | boolean | yes | iOS Android | no | ## 静态方法 -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------: | :------: | :------: | :---------------: | -| `fetch()` | Returns a Promise that resolves to a NetInfoState object. | function | yes | All | yes | -| `refresh()` | Updates NetInfo's internal state, then returns a Promise that resolves to a NetInfoState object. This is similar to fetch(), but really only useful on platforms that do not supply internet reachability natively. For example, you can use it to immediately re-run an internet reachability test if a network request fails unexpectedly. | function | yes | All | yes | -| `addEventListener()` | Subscribe to connection information. The callback is called with a parameter of type NetInfoState whenever the connection state changes. Your listener will be called with the latest information soon after you subscribe and then with any subsequent changes afterwards. You should not assume that the listener is called in the same way across devices or platforms. | function | yes | All | yes | -| `useNetInfo()` | A React Hook which can be used to get access to the latest state from the global instance. It returns a hook with the NetInfoState type. | function | yes | All | yes | -| `useNetInfoInstance()` | A React Hook which can be used to create and manage an isolated instance of a network manager class. It returns a refresh function and the current NetInfoState. | function | yes | All | yes | +| Name | Description | Type | Required | Platform | HarmonyOS Support | +|------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------:|:--------:|:-----------:|:-----------------:| +| `fetch()` | Returns a Promise that resolves to a NetInfoState object. | function | yes | iOS Android | yes | +| `refresh()` | Updates NetInfo's internal state, then returns a Promise that resolves to a NetInfoState object.
This is similar to fetch(), but really only useful on platforms that do not supply internet reachability natively.
For example, you can use it to immediately re-run an internet reachability test if a network request fails unexpectedly. | function | yes | iOS Android | yes | +| `addEventListener()` | Subscribe to connection information.
The callback is called with a parameter of type NetInfoState whenever the connection state changes.
Your listener will be called with the latest information soon after you subscribe and then with any subsequent changes afterwards.
You should not assume that the listener is called in the same way across devices or platforms. | function | yes | iOS Android | yes | +| `useNetInfo()` | A React Hook which can be used to get access to the latest state from the global instance.
It returns a hook with the NetInfoState type. | function | yes | iOS Android | yes | +| `useNetInfoInstance()` | A React Hook which can be used to create and manage an isolated instance of a network manager class.
It returns a refresh function and the current NetInfoState. | function | yes | iOS Android | yes | ## 遗留问题 @@ -293,5 +288,3 @@ RNOH:0.72.27; SDK:HarmonyOS-Next-DB1 5.0.0.29(SP1) ; IDE:DevEco Studio 5.0 ## 开源协议 本项目基于 [The MIT License (MIT)](https://github.com/react-native-netinfo/react-native-netinfo/blob/master/LICENSE) ,请自由地享受和参与开源。 - - \ No newline at end of file diff --git a/zh-cn/react-native-screens.md b/zh-cn/react-native-screens.md index fc118f1bbb05a00f66fd4895c136d18b70f7db0b..a7a317e0e2bb1f317974700367088251043138f2 100644 --- a/zh-cn/react-native-screens.md +++ b/zh-cn/react-native-screens.md @@ -1,5 +1,4 @@ - -> 模板版本:v0.1.3 +> 模板版本:v0.2.2

react-native-screens

@@ -8,11 +7,13 @@ Supported platforms - + License

+> [!tip] [Github 地址](https://github.com/software-mansion/react-native-screens) + ## 安装与使用 进入到工程目录并输入以下命令: @@ -22,12 +23,8 @@ #### **npm** ```bash -npm install @react-navigation/bottom-tabs npm install @react-navigation/native -npm install @react-navigation/native-stack npm install @react-navigation/stack -npm install @react-native-oh-tpl/react-native-gesture-handler -npm install react-native-reanimated npm install @react-native-oh-tpl/react-native-safe-area-context npm install react-native-screens ``` @@ -35,75 +32,71 @@ npm install react-native-screens #### **yarn** ```bash -yarn add @react-navigation/bottom-tabs yarn add @react-navigation/native -yarn add @react-navigation/native-stack yarn add @react-navigation/stack -yarn add @react-native-oh-tpl/react-native-gesture-handler -yarn add react-native-reanimated yarn add @react-native-oh-tpl/react-native-safe-area-context yarn add react-native-screens ``` -声明:[@react-native-oh-tpl/react-native-safe-area-context](/zh-cn/react-native-safe-area-context.md)和[@react-native-oh-tpl/react-native-gesture-handler](/zh-cn/react-native-gesture-handler.md)需要进行额外的配置,详情请去对应的文档查看。 - 下面的代码展示了这个库的基本使用场景: +> [!WARNING] 使用时 import 的库名不变。 + ```js -import React from "react"; -import { NavigationContainer, ParamListBase } from "@react-navigation/native"; -import { ScrollView, Button, Tesxt } from "react-native"; -import { NativeStackNavigationProp } from "react-native-screens"; -import { createBottomTabNavigator } from "@react-navigation/bottom-tabs"; -import { createStackNavigator } from "@react-navigation/stack"; -import { enableScreens } from "react-native-screens"; +import React from 'react'; +import {ScrollView, Button, View, Text} from 'react-native'; +import {NavigationContainer} from '@react-navigation/native'; +import {createStackNavigator} from '@react-navigation/stack'; + +function Home({navigation}) { + return ( + + + Home Screen + +