Skip to content

Commit 729335d

Browse files
panbibihy
authored andcommitted
fix(Switch&Timeline&TreeSelect):调整Switch & Timeline & TreeSelect主题色配置
1 parent c9f8f6e commit 729335d

File tree

5 files changed

+52
-37
lines changed

5 files changed

+52
-37
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default class TreeSelectDemo extends React.Component<TreeSelectViewProps>
5454
<React.Fragment>
5555
<TreeSelect
5656
defaultValue={['01', '01-1', '01-1-1']}
57-
activeColor="red"
57+
// activeColor="red"
5858
options={option}
5959
onChange={(value: any, nodes: any) => {
6060
console.log(value, nodes);

packages/core/src/Switch/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
LayoutChangeEvent,
1010
StyleSheet,
1111
} from 'react-native';
12+
import { Theme } from '../theme';
13+
import { useTheme } from '@shopify/restyle';
1214

1315
export interface SwitchProps extends SwitchPropsDefault {
1416
trackStyle?: ViewStyle;
@@ -35,14 +37,15 @@ export interface SwitchState {
3537
}
3638

3739
function Switch(props: SwitchProps) {
40+
const theme = useTheme<Theme>();
3841
const {
3942
style,
4043
size,
4144
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4245
checked = false,
43-
color,
46+
color = theme.colors.primary_background || '#3578e5',
4447
disabled,
45-
thumbColor,
48+
thumbColor = theme.colors.text_active || '#fff',
4649
trackStyle,
4750
thumbStyle,
4851
...otherProps
@@ -196,8 +199,6 @@ function Switch(props: SwitchProps) {
196199
Switch.defaultProps = {
197200
checked: false,
198201
size: 'default',
199-
thumbColor: '#fff',
200-
color: '#4DD964',
201202
onValueChange: () => {},
202203
};
203204

packages/core/src/Timeline/index.tsx

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { View, Text, StyleSheet, ViewProps } from 'react-native';
33
import { TabsItemIconTypes } from '../Tabs/TabsItem';
44
import Icon, { IconsName } from '../Icon';
55
import { number } from 'prop-types';
6+
import { useTheme } from '@shopify/restyle';
7+
import { Theme } from '../theme';
68

79
export interface TimelineItemsProps {
810
/** 标题 */
@@ -46,23 +48,31 @@ const Desc = (desc?: string | string[]) => {
4648
}
4749
};
4850

49-
const IconCustom = (icon?: IconsName | React.ReactElement | React.ReactNode, size?: number, color?: string) => {
50-
if (icon) {
51-
return (
52-
<>
53-
{typeof icon === 'string' ? (
54-
<Icon name={icon as IconsName} size={size ? size : 15} color={color ? color : 'red'} />
55-
) : (
56-
icon
57-
)}
58-
</>
59-
);
60-
} else {
61-
return <Icon name="circle-o" size={size ? size : 15} color={color ? color : '#e4e7ed'} />;
62-
}
63-
};
64-
6551
const TimeLine = (props: TimelineProps) => {
52+
const theme = useTheme<Theme>();
53+
54+
const IconCustom = (icon?: IconsName | React.ReactElement | React.ReactNode, size?: number, color?: string) => {
55+
if (icon) {
56+
return (
57+
<>
58+
{typeof icon === 'string' ? (
59+
<Icon name={icon as IconsName} size={size ? size : 15} color={color ? color : 'red'} />
60+
) : (
61+
icon
62+
)}
63+
</>
64+
);
65+
} else {
66+
return (
67+
<Icon
68+
name="circle-o"
69+
size={size ? size : 15}
70+
color={color ? color : theme.colors.primary_background || '#3578e5'}
71+
/>
72+
);
73+
}
74+
};
75+
6676
const { items = [], isReverse, style, mode } = props;
6777

6878
const [lineItem, setLineItem] = useState<TimelineItemsProps[]>([]);

packages/core/src/TreeSelect/styles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const style = StyleSheet.create({
1414
backgroundColor: '#f6f7f9',
1515
},
1616
active_nth_item: {
17-
backgroundColor: '#fef4f3',
17+
backgroundColor: '#EEF4FF',
1818
borderWidth: 1,
1919
borderRadius: 5,
2020
marginLeft: 10,

packages/core/src/TreeSelect/tree-select.tsx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import Icon from '../Icon';
66
import Ellipsis from '../Ellipsis';
77
import Modal, { ModalProps } from '../Modal';
88
import { style } from './styles';
9+
import { Theme } from '../theme';
10+
import { useTheme } from '@shopify/restyle';
911

1012
export interface TreeSelectOption {
1113
[key: string]: any;
@@ -28,22 +30,24 @@ export type TreeSelectProps = {
2830
modalProps?: ModalProps;
2931
};
3032

31-
const defaultProps = {
32-
options: [],
33-
fieldNames: {},
34-
defaultValue: [],
35-
activeColor: '#5847FF',
36-
placeholder: '请选择',
37-
extra: undefined,
38-
showClear: true,
39-
contentStyle: {},
40-
placeholderColor: '',
41-
disabled: false,
42-
height: 300,
43-
modalProps: {},
44-
};
45-
4633
export const TreeSelect: FC<TreeSelectProps> = (p) => {
34+
const theme = useTheme<Theme>();
35+
36+
const defaultProps = {
37+
options: [],
38+
fieldNames: {},
39+
defaultValue: [],
40+
activeColor: theme.colors.primary_background || '#3578e5',
41+
placeholder: '请选择',
42+
extra: undefined,
43+
showClear: true,
44+
contentStyle: {},
45+
placeholderColor: '',
46+
disabled: false,
47+
height: 300,
48+
modalProps: {},
49+
};
50+
4751
const props = { ...defaultProps, ...p };
4852
const labelName = props.fieldNames.label || 'label';
4953
const valueName = props.fieldNames.value || 'value';

0 commit comments

Comments
 (0)