Skip to content

Commit cc7160c

Browse files
committed
0.78
1 parent a5e5ffd commit cc7160c

File tree

344 files changed

+49140
-44
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

344 files changed

+49140
-44
lines changed

cndocs/keyboard.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ title: Keyboard
1212

1313
```SnackPlayer name=Keyboard%20Example&supportedPlatforms=ios,android
1414
import React, {useState, useEffect} from 'react';
15-
import {Keyboard, Text, TextInput, StyleSheet, View} from 'react-native';
15+
import {Keyboard, Text, TextInput, StyleSheet} from 'react-native';
16+
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';
1617
1718
const Example = () => {
18-
const [keyboardStatus, setKeyboardStatus] = useState('');
19+
const [keyboardStatus, setKeyboardStatus] = useState('Keyboard Hidden');
1920
2021
useEffect(() => {
2122
const showSubscription = Keyboard.addListener('keyboardDidShow', () => {
@@ -32,14 +33,16 @@ const Example = () => {
3233
}, []);
3334
3435
return (
35-
<View style={style.container}>
36-
<TextInput
37-
style={style.input}
38-
placeholder="Click here…"
39-
onSubmitEditing={Keyboard.dismiss}
40-
/>
41-
<Text style={style.status}>{keyboardStatus}</Text>
42-
</View>
36+
<SafeAreaProvider>
37+
<SafeAreaView style={style.container}>
38+
<TextInput
39+
style={style.input}
40+
placeholder="Click here…"
41+
onSubmitEditing={Keyboard.dismiss}
42+
/>
43+
<Text style={style.status}>{keyboardStatus}</Text>
44+
</SafeAreaView>
45+
</SafeAreaProvider>
4346
);
4447
};
4548
@@ -54,7 +57,7 @@ const style = StyleSheet.create({
5457
borderRadius: 4,
5558
},
5659
status: {
57-
padding: 10,
60+
padding: 16,
5861
textAlign: 'center',
5962
},
6063
});
@@ -119,7 +122,7 @@ static dismiss()
119122
static scheduleLayoutAnimation(event: KeyboardEvent);
120123
```
121124

122-
用于将TextInput(或其他键盘附属视图)的大小或位置变化与键盘移动同步。
125+
用于将 TextInput(或其他键盘附属视图)的大小或位置变化与键盘移动同步。
123126

124127
---
125128

cndocs/keyboardavoidingview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Specify how to react to the presence of the keyboard.
8484

8585
### `contentContainerStyle`
8686

87-
如果设定 behavior 值为'position',则会生成一个 View 作为内容容器。此属性用于指定此内容容器的样式。
87+
如果设定 behavior 值为`'position'`,则会生成一个 View 作为内容容器。此属性用于指定此内容容器的样式。
8888

8989
| 类型 |
9090
| --------------------------------- |

cndocs/layout-props.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,16 @@ borderBottomWidth 与 CSS 中的 border-bottom-width 属性作用相同。详情
495495

496496
---
497497

498+
### `boxSizing`
499+
500+
`boxSizing` 定义了元素的尺寸相关的属性 (如`width`, `height`, `minWidth`, `minHeight`等)的计算方式。如果 `boxSizing``border-box`,这些尺寸会应用到元素的边框盒。如果它是 `content-box`,这些尺寸会应用到元素的内容盒。默认值是 `border-box`。有关更多信息,请参阅 [web 文档](https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing)
501+
502+
| Type | Required |
503+
| --------------------------------- | -------- |
504+
| enum('border-box', 'content-box') | No |
505+
506+
---
507+
498508
### `columnGap`
499509

500510
`columnGap` 的作用类似于 CSS 中的 `column-gap`。在 React Native 中仅支持像素单位。有关更多详细信息,请查看 https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap。
@@ -905,17 +915,21 @@ flexGrow 接受任意大于等于 0 的浮点数,默认值为 0。容器中剩
905915

906916
### `position`
907917

908-
在 React Native 中,`position`与常规 CSS 类似,但默认情况下所有元素都设置为`relative`,因此`absolute`定位始终是相对于父元素的。
918+
在 React Native 中,`position`[常规 CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/position) 类似,但默认情况下所有元素都设置为`relative`,因此`absolute`定位始终是相对于父元素的。
909919

910-
如果您想要使用特定数量的逻辑像素相对于其父元素来定位子元素,请将子元素设置为具有`absolute`位置
920+
`relative` 会根据布局的正常流来定位元素。内边距(`top`, `bottom`, `left`, `right`)会相对于这个布局进行偏移
911921

912-
如果您想要将子元素相对于不是其父元素的对象进行定位,请不要为此使用样式。请使用组件树
922+
`absolute` 会从布局的正常流中移除元素。内边距(`top`, `bottom`, `left`, `right`)会相对于它的[包含块](./flexbox.md#the-containing-block)进行偏移
913923

914-
有关 React Native 和 CSS 之间`position`差异的更多详细信息,请参见 https://github.com/facebook/yoga
924+
`static` 会根据布局的正常流来定位元素。内边距(`top`, `bottom`, `left`, `right`)不会产生任何效果。
915925

916-
| 类型 | 必需 |
917-
| ---------------------------- | ---- |
918-
| enum('absolute', 'relative') ||
926+
`static` 元素不会形成包含块来容纳绝对定位的子元素。
927+
928+
有关更多信息,请参阅 [Flexbox 布局文档](./flexbox.md#position)。此外,有关 React Native 和 CSS 之间`position`差异的更多详细信息,请参见 [Yoga 布局引擎的文档](https://www.yogalayout.dev/docs/styling/position)
929+
930+
| 类型 | 必需 |
931+
| -------------------------------------- | ---- |
932+
| enum('absolute', 'relative', 'static') ||
919933

920934
---
921935

cndocs/libraries.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ React Native 提供了一系列内置的[核心组件和 API](components-and-api
1212

1313
## 选择一个包管理器
1414

15-
React Native libraries are typically installed from the [npm registry](https://www.npmjs.com/) using a Node.js package manager such as [npm CLI](https://docs.npmjs.com/cli/npm) or [Yarn 经典版(v1)](https://classic.yarnpkg.com/en/).
16-
1715
通常,React Native 库是从 [npm 源](https://www.npmjs.com/) 安装的,使用诸如 [npm CLI](https://docs.npmjs.com/cli/npm)[Yarn 经典版(v1)](https://classic.yarnpkg.com/en/) 的 Node.js 包管理器。
1816

1917
如果你的电脑上安装了 Node.js,那么你已经有了 npm CLI。一些开发者更喜欢使用 Yarn v1,因为它具有略快的安装时间和额外的高级功能,如 workspace。这两种工具都可以很好地支持 React Native。为了简化解释,在本指南的其余部分我们将假设使用 npm。

cndocs/linking-libraries-ios.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ _我们随着 React Native 发布的所有库都在仓库中的`Libraries`文件
1919

2020
```bash
2121
$ npm install 某个带有原生依赖的库
22+
$ npx pod-install
2223
```
2324

2425
:::info 提示
25-
React Native will link your libs based on `dependencies` and `devDependencies` in your `package.json` file.
26+
React Native 只会读取`package.json`中列出的`dependencies` `devDependencies`来进行自动链接。
2627
:::
2728

28-
That's it! Next time you build your app the native code will be linked thanks to the [autolinking](https://github.com/react-native-community/cli/blob/main/docs/autolinking.md) mechanism.
29+
这样就可以了!由于集成了 [autolinking](https://github.com/react-native-community/cli/blob/main/docs/autolinking.md) 机制,下次你构建你的应用时原生代码就会自动链接了。
2930

3031
### 手动链接
3132

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Measuring the Layout
1+
# 测量布局
22

3-
Sometimes, you need to measure the current layout to apply some changes to the overall layout or to make decisions and call some specific logic.
3+
有时,您需要测量当前布局以应用某些更改或做出决策并调用某些特定逻辑。
44

5-
React Native provides some native methods to know what are the measurements of the views.
5+
React Native 提供了一些原生方法来了解视图的测量值。
66

7-
The best way to invoke those methods is in a `useLayoutEffect` hook: this will give you the most recent values for those measurements and it will let you apply changes in the same frame when the measurements are computed.
7+
最推荐的方法是在 `useLayoutEffect` 钩子中调用这些方法:这将为您提供最新的测量值,并且当测量值计算完成后,您可以在同一帧中应用更改。
88

9-
Typical code will look like this:
9+
典型的代码如下所示:
1010

1111
```tsx
1212
function AComponent(children) {
@@ -26,28 +26,28 @@ function AComponent(children) {
2626
}
2727
```
2828

29-
:::note
30-
The methods described here are available on most of the default components provided by React Native. However, they are _not_ available on composite components that aren't directly backed by a native view. This will generally include most components that you define in your own app.
29+
:::note 注意
30+
这里描述的方法在大多数默认组件中都可用。然而,它们在不是直接由原生视图支持的复合组件中是不可用的。这通常包括您在应用中自定义的大多数组件。
3131
:::
3232

3333
## measure(callback)
3434

35-
Determines the location on screen (`x` and `y`), `width`, and `height` in the viewport of the given view. Returns the values via an async callback. If successful, the callback will be called with the following arguments:
35+
确定视图在屏幕上的位置 (`x` `y`)`width` `height`。通过异步回调返回这些值。如果成功,回调将使用以下参数调用:
3636

37-
- `x`: the `x` coordinate of the origin (top-left corner) of the measured view in the viewport.
38-
- `y`: the `y` coordinate of the origin (top-left corner) of the measured view in the viewport.
39-
- `width`: the `width` of the view.
40-
- `height`: the `height` of the view.
41-
- `pageX`: the `x` coordinate of the view in the viewport (typically the whole screen).
42-
- `pageY`: the `y` coordinate of the view in the viewport (typically the whole screen).
37+
- `x`: 视图在视口中的 `x` 坐标(左上角)。
38+
- `y`: 视图在视口中的 `y` 坐标(左上角)。
39+
- `width`: 视图的 `width`
40+
- `height`: 视图的 `height`
41+
- `pageX`: 视图在视口中的 `x` 坐标(通常是整个屏幕)。
42+
- `pageY`: 视图在视口中的 `y` 坐标(通常是整个屏幕)。
4343

44-
Also the `width` and `height` returned by `measure()` are the `width` and `height` of the component in the viewport.
44+
`measure()` 返回的 `width` `height` 是视图在视口中的 `width` `height`
4545

4646
## measureInWindow(callback)
4747

48-
Determines the location (`x` and `y`) of the given view in the window and returns the values via an async callback. If the React root view is embedded in another native view, this will give you the absolute coordinates. If successful, the callback will be called with the following arguments:
48+
确定视图在窗口中的位置 (`x` `y`) 并返回这些值通过异步回调。如果 React 根视图嵌套在另一个原生视图中,这将为您提供绝对坐标。如果成功,回调将使用以下参数调用:
4949

50-
- `x`: the `x` coordinate of the view in the current window.
51-
- `y`: the `y` coordinate of the view in the current window.
52-
- `width`: the `width` of the view.
53-
- `height`: the `height` of the view.
50+
- `x`: 视图在当前窗口中的 `x` 坐标。
51+
- `y`: 视图在当前窗口中的 `y` 坐标。
52+
- `width`: 视图的 `width`
53+
- `height`: 视图的 `height`
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from "react";
2+
import IOSContent from "./fabric-native-components-ios.md";
3+
import AndroidContent from "./fabric-native-components-android.md";
4+
5+
export function FabricNativeComponentsIOS() {
6+
return <IOSContent />;
7+
}
8+
9+
export function FabricNativeComponentsAndroid() {
10+
return <AndroidContent />;
11+
}

0 commit comments

Comments
 (0)