Skip to content

Commit eab3d52

Browse files
authored
docs(cndocs): 同步翻译更新(高质量) (#998)
1 parent 522035d commit eab3d52

10 files changed

Lines changed: 424 additions & 541 deletions

cndocs/actionsheetios.md

Lines changed: 64 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,58 @@ id: actionsheetios
33
title: ActionSheetIOS
44
---
55

6-
显示一个 iOS 原生的[Action Sheet](https://developer.apple.com/design/human-interface-guidelines/ios/views/action-sheets/)组件。
6+
显示 iOS 原生的 [Action Sheet](https://developer.apple.com/design/human-interface-guidelines/action-sheets) 组件。
77

88
## 示例
99

10-
```SnackPlayer name=ActionSheetIOS&supportedPlatforms=ios
11-
import React, { useState } from "react";
12-
import { ActionSheetIOS, Button, StyleSheet, Text, View } from "react-native";
10+
```SnackPlayer name=ActionSheetIOS%20Example&supportedPlatforms=ios
11+
import React, {useState} from 'react';
12+
import {ActionSheetIOS, Button, StyleSheet, Text} from 'react-native';
13+
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';
14+
1315
const App = () => {
14-
const [result, setResult] = useState("🔮");
16+
const [result, setResult] = useState('🔮');
17+
1518
const onPress = () =>
1619
ActionSheetIOS.showActionSheetWithOptions(
1720
{
18-
options: ["Cancel", "Generate number", "Reset"],
21+
options: ['Cancel', 'Generate number', 'Reset'],
1922
destructiveButtonIndex: 2,
2023
cancelButtonIndex: 0,
21-
userInterfaceStyle: 'dark'
24+
userInterfaceStyle: 'dark',
2225
},
2326
buttonIndex => {
2427
if (buttonIndex === 0) {
2528
// cancel action
2629
} else if (buttonIndex === 1) {
27-
setResult(Math.floor(Math.random() * 100) + 1);
30+
setResult(String(Math.floor(Math.random() * 100) + 1));
2831
} else if (buttonIndex === 2) {
29-
setResult("🔮");
32+
setResult('🔮');
3033
}
31-
}
34+
},
3235
);
36+
3337
return (
34-
<View style={styles.container}>
35-
<Text style={styles.result}>{result}</Text>
36-
<Button onPress={onPress} title="Show Action Sheet" />
37-
</View>
38+
<SafeAreaProvider>
39+
<SafeAreaView style={styles.container}>
40+
<Text style={styles.result}>{result}</Text>
41+
<Button onPress={onPress} title="Show Action Sheet" />
42+
</SafeAreaView>
43+
</SafeAreaProvider>
3844
);
3945
};
46+
4047
const styles = StyleSheet.create({
4148
container: {
4249
flex: 1,
43-
justifyContent: "center"
50+
justifyContent: 'center',
4451
},
4552
result: {
4653
fontSize: 64,
47-
textAlign: "center"
48-
}
54+
textAlign: 'center',
55+
},
4956
});
57+
5058
export default App;
5159
```
5260

@@ -63,32 +71,36 @@ static showActionSheetWithOptions: (
6371
);
6472
```
6573

66-
在 iOS 设备上显示一个 ActionSheet 弹出框,其中`options`参数为一个对象,其属性必须包含以下一项或多项:
74+
在 iOS 设备上显示一个 ActionSheet 弹出框,其中 `options` 参数为一个对象,其属性必须包含以下一项或多项:
6775

68-
- `options`(字符串数组) - 按钮标题列表(必需)
69-
- `cancelButtonIndex`(整数) - `options` 中取消按钮的索引
70-
- `cancelButtonTintColor`(字符串) - 用于改变取消按钮文本颜色的颜色([颜色](colors)
71-
- `destructiveButtonIndex`(整数或整数数组) - `options` 中破坏性按钮的索引
72-
- `title`(字符串) - 显示在操作表上方的标题
73-
- `message`(字符串) - 显示在标题下方的消息
74-
- `anchor`(数字) - 操作表应锚定的节点(用于 iPad)
75-
- `tintColor`(字符串) - 用于非破坏性按钮标题的颜色([颜色](colors)
76-
- `disabledButtonIndices`(数字数组) - 应禁用的按钮索引列表
77-
- `userInterfaceStyle`(字符串) - 用于操作表的界面样式,可以设置为 `light``dark`,否则将使用默认的系统样式
78-
79-
`callback`函数则仅接受一个参数,即所点击按钮的索引。
76+
- `options`(字符串数组)- 按钮标题列表(必需)
77+
- `cancelButtonIndex`(整数)- `options` 中取消按钮的索引
78+
- `cancelButtonTintColor`(字符串)- 用于改变取消按钮文本颜色的[颜色](colors)
79+
- `destructiveButtonIndex`(整数或整数数组)- `options` 中破坏性按钮的索引
80+
- `title`(字符串)- 显示在操作表上方的标题
81+
- `message`(字符串)- 显示在标题下方的消息
82+
- `anchor`(数字)- 操作表应锚定的节点(用于 iPad)
83+
- `tintColor`(字符串)- 用于非破坏性按钮标题的[颜色](colors)
84+
- `disabledButtonIndices`(数字数组)- 应禁用的按钮索引列表
85+
- `userInterfaceStyle`(字符串)- 用于操作表的界面样式,可以设置为 `light``dark`,否则将使用默认的系统样式
8086

81-
一个例子:
87+
`callback` 函数仅接受一个参数,即所点击按钮的从零开始的索引。
8288

83-
```
84-
ActionSheetIOS.showActionSheetWithOptions({
85-
options: ['取消', '删除'],
86-
destructiveButtonIndex: 1,
87-
cancelButtonIndex: 0,
88-
},
89-
(buttonIndex) => {
90-
if (buttonIndex === 1) { /* 当接收到的索引为1,即点击了删除按钮时,执行对应操作 */ }
91-
});
89+
一个简单的例子:
90+
91+
```tsx
92+
ActionSheetIOS.showActionSheetWithOptions(
93+
{
94+
options: ['Cancel', 'Remove'],
95+
destructiveButtonIndex: 1,
96+
cancelButtonIndex: 0,
97+
},
98+
buttonIndex => {
99+
if (buttonIndex === 1) {
100+
/* destructive action */
101+
}
102+
},
103+
);
92104
```
93105

94106
---
@@ -113,18 +125,20 @@ static showShareActionSheetWithOptions: (
113125
);
114126
```
115127

116-
在 iOS 设备上显示一个分享弹出框,其中`options`参数为一个对象,其属性包含以下几项(必须至少有 message 或 url):
128+
在 iOS 设备上显示一个分享弹出框,其中 `options` 参数为一个对象,必须包含 `message``url` 中的至少一项,还可以额外指定 `subject``excludedActivityTypes`
117129

118-
- `url` (字符串) - 要分享的 URL 地址
119-
- `message` (字符串) - 要分享的信息
120-
- `subject` (字符串) - 要分享的信息主题
121-
- `excludedActivityTypes` (数组) - 指定在 actionsheet 中不显示的活动
130+
- `url`(字符串)- 要分享的 URL 地址
131+
- `message`(字符串)- 要分享的信息
132+
- `subject`(字符串)- 要分享的信息主题
133+
- `excludedActivityTypes`(数组)- 指定在 ActionSheet 中不显示的活动
122134

123-
注:如果`url`指向本地文件,或者是一个 base64 编码的 url,则会直接读取并分享相应的文件。你可以用这样的方式来分享图片、视频以及 PDF 文件等。If `url` points to a remote file or address it must conform to URL format as described in [RFC 2396](https://www.ietf.org/rfc/rfc2396.txt). For example, a web URL without a proper protocol (HTTP/HTTPS) will not be shared.
135+
:::note
136+
如果 `url` 指向本地文件,或者是一个 base64 编码的 URI,则会直接读取并分享相应的文件。你可以用这种方式来分享图片、视频以及 PDF 文件等。如果 `url` 指向远程文件或地址,则必须符合 [RFC 2396](https://www.ietf.org/rfc/rfc2396.txt) 中描述的 URL 格式。例如,不带正确协议(HTTP/HTTPS)的网址将无法被分享。
137+
:::
124138

125-
`failureCallback`函数仅接受一个错误对象参数。此对象中仅包含一个可选的`stack`属性,类型为字符串。
139+
`failureCallback` 函数仅接受一个错误对象参数。此对象中仅包含一个可选的 `stack` 属性,类型为字符串。
126140

127-
`successCallback`函数接受两个参数:
141+
`successCallback` 函数接受两个参数:
128142

129-
- 表示成功与否的布尔值
130-
- 成功的话返回一个表示分享方式的字符串
143+
- 一个表示成功与否的布尔值
144+
- 成功时返回一个表示分享方式的字符串

cndocs/activityindicator.md

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,36 @@ id: activityindicator
33
title: ActivityIndicator
44
---
55

6-
显示一个圆形的 loading 提示符号
6+
显示一个圆形的加载指示器
77

88
## 示例
99

1010
```SnackPlayer name=ActivityIndicator%20Example
11-
import React from "react";
12-
import { ActivityIndicator, StyleSheet, Text, View } from "react-native";
11+
import React from 'react';
12+
import {ActivityIndicator, StyleSheet} from 'react-native';
13+
import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';
1314
1415
const App = () => (
15-
<View style={[styles.container, styles.horizontal]}>
16-
<ActivityIndicator />
17-
<ActivityIndicator size="large" />
18-
<ActivityIndicator size="small" color="#0000ff" />
19-
<ActivityIndicator size="large" color="#00ff00" />
20-
</View>
16+
<SafeAreaProvider>
17+
<SafeAreaView style={[styles.container, styles.horizontal]}>
18+
<ActivityIndicator />
19+
<ActivityIndicator size="large" />
20+
<ActivityIndicator size="small" color="#0000ff" />
21+
<ActivityIndicator size="large" color="#00ff00" />
22+
</SafeAreaView>
23+
</SafeAreaProvider>
2124
);
2225
2326
const styles = StyleSheet.create({
2427
container: {
2528
flex: 1,
26-
justifyContent: "center"
29+
justifyContent: 'center',
2730
},
2831
horizontal: {
29-
flexDirection: "row",
30-
justifyContent: "space-around",
31-
padding: 10
32-
}
32+
flexDirection: 'row',
33+
justifyContent: 'space-around',
34+
padding: 10,
35+
},
3336
});
3437
3538
export default App;
@@ -39,15 +42,15 @@ export default App;
3942

4043
## Props
4144

42-
### [View Props](view.md#props)
45+
### [View Props](view#props)
4346

44-
继承了所有的[View Props](view.md#props).
47+
继承了所有 [View Props](view#props)
4548

4649
---
4750

4851
### `animating`
4952

50-
是否要显示指示器动画,默认为 true 表示显示,false 则隐藏
53+
是否显示指示器动画。`true` 表示显示,`false` 表示隐藏
5154

5255
| 类型 | 默认值 |
5356
| ---- | ------ |
@@ -59,26 +62,32 @@ export default App;
5962

6063
滚轮的前景颜色。
6164

62-
| 类型 | 默认值 |
63-
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
64-
| [color](colors) | `null` (系统默认的强调色)<div class="label android">Android</div><hr/><ins style={{background: '#999'}} className="color-box" />`'#999999'` <div className="label ios">iOS</div> |
65+
| 类型 | 默认值 |
66+
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
67+
| [color](colors) | `null`(系统默认强调色)<div className="label android">Android</div><hr/><ins style={{background: '#999'}} className="color-box" />`'#999999'` <div className="label ios">iOS</div> |
6568

6669
---
6770

68-
### `hidesWhenStopped` <div class="label ios">iOS</div>
71+
### `hidesWhenStopped` <div className="label ios">iOS</div>
6972

70-
`animating`为 false 的时候,是否要隐藏指示器(默认为 true)。如果`animating``hidesWhenStopped`都为 false,则显示一个静止的指示器
73+
`animating` 为 false 的时候,是否隐藏指示器(默认为 true)。
7174

7275
| 类型 | 默认值 |
7376
| ---- | ------ |
7477
| bool | `true` |
7578

7679
---
7780

81+
### `ref`
82+
83+
一个 ref 设置函数,在挂载时会被赋值为一个[元素节点](element-nodes)
84+
85+
---
86+
7887
### `size`
7988

80-
指示器的大小,默认为'small'。目前只能在 Android 上设定具体的数值。
89+
指示器的大小,默认为 `'small'`。目前只能在 Android 上设定具体的数值。
8190

82-
| 类型 | 默认值 |
83-
| ------------------------------------------------------------------------------ | --------- |
84-
| enum(`'small'`, `'large'`)<hr/>number <div class="label android">Android</div> | `'small'` |
91+
| 类型 | 默认值 |
92+
| ---------------------------------------------------------------------------------- | --------- |
93+
| enum(`'small'`, `'large'`)<hr/>number <div className="label android">Android</div> | `'small'` |

0 commit comments

Comments
 (0)