Skip to content

Commit 4b3651e

Browse files
author
hy
committed
fix(Bottn) 变更Button按钮边框的颜色以解决其他使用Button按钮的组件颜色展示不对的问题
1 parent 47f5173 commit 4b3651e

File tree

4 files changed

+37
-26
lines changed

4 files changed

+37
-26
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import React from 'react';
2-
import { View, Text } from 'react-native';
3-
import { Button, Spacing, Icon, Flex } from '@uiw/react-native';
4-
import { ComProps } from '../../routes';
5-
import Layout, { Container } from '../../Layout';
6-
const { Header, Body, Card, Footer } = Layout;
2+
import {View, Text} from 'react-native';
3+
import {Button, Spacing, Icon, Flex} from '@uiw/react-native';
4+
import {ComProps} from '../../routes';
5+
import Layout, {Container} from '../../Layout';
6+
const {Header, Body, Card, Footer} = Layout;
77

8-
export interface ButtonViewProps extends ComProps { }
8+
export interface ButtonViewProps extends ComProps {}
99

1010
export default class ButtonView extends React.Component<ButtonViewProps> {
1111
render() {
12-
const { route } = this.props;
12+
const {route} = this.props;
1313
const description = route.params.description;
1414
const title = route.params.title;
1515
return (
1616
<Container>
1717
<Layout>
1818
<Header title={title} description={description} />
19-
<Body style={{ paddingLeft: 16, paddingRight: 16 }}>
19+
<Body style={{paddingLeft: 16, paddingRight: 16}}>
2020
<Card title="基础实例">
2121
<Flex>
2222
<Button type="primary">蓝色按钮</Button>
@@ -104,23 +104,23 @@ export default class ButtonView extends React.Component<ButtonViewProps> {
104104
<Button color="#a63d2c">自定义颜色{'color="#a63d2c"'}</Button>
105105
</Card>
106106
<Card title="文本样式">
107-
<Button textStyle={{ fontSize: 20 }} color="yellow">
107+
<Button textStyle={{fontSize: 20}} color="yellow">
108108
字号调整{'textStyle = {{fontSize:20}}'}
109109
</Button>
110110
<Spacing />
111-
<Button textStyle={{ color: 'blue' }}>文本颜色{'textStyle={{color:"blue"}}'}</Button>
111+
<Button textStyle={{color: 'blue'}}>文本颜色{'textStyle={{color:"blue"}}'}</Button>
112112
<Spacing />
113-
<Button color="#a63d2c" textStyle={{ letterSpacing: 2 }}>
113+
<Button color="#a63d2c" textStyle={{letterSpacing: 2}}>
114114
文本间距{'textStyle={{letterSpacing:3}}'}
115115
</Button>
116116
</Card>
117117
<Card title="设置边框">
118-
<Button bordered={false} color="#dc3545">
119-
不显示边框{'bordered={false}'}
118+
<Button bordered={true} color="#ffc107">
119+
显示边框{'bordered={false}'}
120120
</Button>
121121
<Spacing />
122-
<Button bordered={true} color="#28a745">
123-
不显示边框{'bordered={false}'}
122+
<Button bordered={true} color="#1EABCD">
123+
显示边框{'bordered={false}'}
124124
</Button>
125125
</Card>
126126
<Card title="显示图标">

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default class ButtonGroupView extends Component<ButtonGroupViewProps> {
6666
<Button>边框</Button>
6767
</ButtonGroup>
6868
<Spacing />
69-
<ButtonGroup bordered={false} color="#ffc107">
69+
<ButtonGroup bordered={true} color="#ffc107">
7070
<Button>警告</Button>
7171
<Button>警告</Button>
7272
<Button>警告</Button>

packages/core/src/Button/index.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,13 @@ export default function ButtonView<T>(props: ButtonProps) {
8484
// borderWidth = 1;
8585
// }
8686
if (disabled) {
87-
textColor = color(theme.colors.disabled || '#CCCCCC').alpha(0.1).rgb().string();
88-
backgroundColor = color(theme.colors.disabled || '#CCCCCC').rgb().string();
87+
textColor = color(theme.colors.disabled || '#CCCCCC')
88+
.alpha(0.1)
89+
.rgb()
90+
.string();
91+
backgroundColor = color(theme.colors.disabled || '#CCCCCC')
92+
.rgb()
93+
.string();
8994
}
9095
if (buttonColor) {
9196
backgroundColor = color(buttonColor).rgb().string();
@@ -94,22 +99,29 @@ export default function ButtonView<T>(props: ButtonProps) {
9499
borderRadius = rounded;
95100
}
96101
if (bordered) {
97-
borderColor = color(theme.colors.black || '#000000').alpha(0.1).rgb().string();
102+
borderColor = color(theme.colors.gray200 || backgroundColor)
103+
.alpha(1)
104+
.rgb()
105+
.string();
98106
borderWidth = 1;
99107
}
100108
// if (!bordered || buttonColor) {
101109
// borderWidth = 0;
102110
// }
103111
const buttonStyle = {
104-
backgroundColor: backgroundColor || "#3578e5",
112+
backgroundColor: backgroundColor || '#3578e5',
105113
borderColor,
106114
borderWidth,
107115
borderRadius,
108116
};
109-
if ((type || backgroundColor || buttonColor || buttonStyle.backgroundColor) && type !== "light") {
110-
textColor = color(theme.colors.white || '#FFFFFF').rgb().string()
117+
if ((type || backgroundColor || buttonColor || buttonStyle.backgroundColor) && type !== 'light') {
118+
textColor = color(theme.colors.white || '#FFFFFF')
119+
.rgb()
120+
.string();
111121
} else {
112-
textColor = color(theme.colors.black || '#000000').rgb().string();
122+
textColor = color(theme.colors.black || '#000000')
123+
.rgb()
124+
.string();
113125
}
114126
const textStyle = { color: textColor };
115127
let sizeStyle = {};

packages/core/src/Progress/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ Progress 进度条
1414
import React from 'react';
1515
import { SafeAreaView } from 'react-native';
1616
import { Progress } from '@uiw/react-native';
17-
import { motorcycle } from './svg';
1817

1918
function Demo() {
2019
return (
2120
<SafeAreaView style={{ flex: 1 }}>
22-
<Progress type='circle' />
21+
<Progress type='circle' value={50}/>
2322
</SafeAreaView>
2423
)
2524
}
@@ -37,7 +36,7 @@ import { Progress } from '@uiw/react-native';
3736
function Demo() {
3837
return (
3938
<SafeAreaView style={{ flex: 1 }}>
40-
<Progress type='circle' color={['#FFD080', 'red']} />
39+
<Progress type='circle' color={['#FFD080', 'red']} value={50} />
4140
</SafeAreaView>
4241
)
4342
}

0 commit comments

Comments
 (0)