Skip to content

Commit 293a1ab

Browse files
committed
fix(Radio):增加borderColor和checkedColor api & 更新文档
1 parent 7393ba1 commit 293a1ab

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

example/examples/src/routes/Radio/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ export default class RadioView extends React.Component<
3939
<Header title={title} description={description} />
4040
<Body>
4141
<Card title="基础实例">
42-
<Radio>所有人可见</Radio>
42+
<Radio checkedColor="#fd8a00" borderColor="#fd8a00">
43+
所有人可见
44+
</Radio>
4345
<Spacing />
4446
<Radio>超级管理员</Radio>
4547
</Card>

packages/core/src/Radio/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,6 @@ function Demo() {
8484
| `circleSize` | Radio 大小 | Number | `20` |
8585
| `thumbSize` | Radio 选中部分大小 | Number | `12` |
8686
| `onPress` | 点击 Radio 的点击回调函数 | (event) => void | - |
87-
| `color` | Radio 颜色 | string | `#008EF0` |
87+
| `color` | Radio 禁用后颜色 | string | `#c3c5c7` |
88+
| `checkedColor` | Radio 颜色 | string | `#008EF0` |
89+
| `borderColor` | Radio 边框颜色 | string | `#bdc1cc` |

packages/core/src/Radio/index.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export interface RadioProps extends ViewProps {
4848
disabled?: boolean;
4949
circleSize?: number;
5050
color?: string;
51+
checkedColor?: string;
52+
borderColor?: string;
5153
thumbSize?: number;
5254
onPress?: (event: GestureResponderEvent) => void;
5355
}
@@ -62,6 +64,8 @@ export default class Radio extends Component<RadioProps, RadioState> {
6264
static defaultProps: RadioProps = {
6365
checked: false,
6466
circleSize: 20,
67+
checkedColor: '#008EF0',
68+
borderColor: '#bdc1cc',
6569
color: '#c3c5c7',
6670
thumbSize: 12,
6771
};
@@ -110,14 +114,23 @@ export default class Radio extends Component<RadioProps, RadioState> {
110114
});
111115
};
112116
render() {
113-
const { style, color, circleSize, thumbSize, disabled, ...otherProps } = this.props;
117+
const {
118+
style,
119+
color,
120+
circleSize,
121+
thumbSize,
122+
disabled,
123+
checkedColor,
124+
borderColor: bdColor,
125+
...otherProps
126+
} = this.props;
114127
const sizeValue = this.state.sizeValue.interpolate({
115128
inputRange: [0, thumbSize!],
116129
outputRange: [0, thumbSize!],
117130
// extrapolate: 'clamp',
118131
});
119-
const backgroundColor = disabled ? color : '#008EF0';
120-
const borderColor = disabled ? color : '#bdc1cc';
132+
const backgroundColor = disabled ? color : checkedColor;
133+
const borderColor = disabled ? color : bdColor;
121134
return (
122135
<View style={[styles.defalut, style]} {...otherProps}>
123136
<TouchableOpacity disabled={disabled} style={[styles.touch]} onPress={this.handlePress}>

0 commit comments

Comments
 (0)