Skip to content

Commit 6b7c4a2

Browse files
committed
fix(MaskLayer&NoticeBar&Pagination):调整 MaskLayer & NoticeBar & Pagination主题色配置
1 parent 1d97fef commit 6b7c4a2

File tree

5 files changed

+169
-102
lines changed

5 files changed

+169
-102
lines changed

packages/core/src/MaskLayer/index.tsx

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
11
import React, { useState, useMemo } from 'react';
22
import { Modal, ModalProps as RNModalProps, Animated, TouchableOpacity, StyleSheet } from 'react-native';
33
import { usePrevious } from '../utils';
4+
import { Theme } from '../theme';
5+
import { useTheme } from '@shopify/restyle';
46

5-
const styles = StyleSheet.create({
6-
position: {
7-
position: 'absolute',
8-
backgroundColor: 'transparent',
9-
top: 0,
10-
bottom: 0,
11-
left: 0,
12-
right: 0,
13-
zIndex: 9998,
14-
},
15-
backdrop: {
16-
backgroundColor: '#000',
17-
},
18-
content: {
19-
backgroundColor: '#fff',
20-
position: 'absolute',
21-
},
22-
});
7+
type CreStyle = {
8+
whiteColor: string;
9+
blackBackground: string;
10+
};
11+
12+
function createStyles({ whiteColor, blackBackground }: CreStyle) {
13+
return StyleSheet.create({
14+
position: {
15+
position: 'absolute',
16+
backgroundColor: 'transparent',
17+
top: 0,
18+
bottom: 0,
19+
left: 0,
20+
right: 0,
21+
zIndex: 9998,
22+
},
23+
backdrop: {
24+
backgroundColor: blackBackground,
25+
},
26+
content: {
27+
backgroundColor: whiteColor,
28+
position: 'absolute',
29+
},
30+
});
31+
}
2332

2433
export interface MaskLayerProps extends RNModalProps {
2534
/**
@@ -46,6 +55,12 @@ export interface MaskLayerProps extends RNModalProps {
4655
}
4756

4857
const MaskLayer = (props: MaskLayerProps = {}) => {
58+
const theme = useTheme<Theme>();
59+
const styles = createStyles({
60+
whiteColor: theme.colors.white,
61+
blackBackground: theme.colors.black,
62+
});
63+
4964
const {
5065
maskClosable = true,
5166
children,
@@ -115,4 +130,4 @@ const MaskLayer = (props: MaskLayerProps = {}) => {
115130
);
116131
};
117132

118-
export default MaskLayer;
133+
export default MaskLayer;

packages/core/src/NoticeBar/index.tsx

Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React, { useState } from 'react';
22
import { StyleProp, Text, TouchableWithoutFeedback, View, ViewStyle, TextStyle, StyleSheet } from 'react-native';
33
import Icon from '../Icon';
44
import Marquee, { MarqueeProps } from './Marquee';
5+
import { Theme } from '../theme';
6+
import { useTheme } from '@shopify/restyle';
57

68
export type NoticeBarProps = {
79
children?: any;
@@ -15,6 +17,11 @@ export type NoticeBarProps = {
1517
};
1618

1719
const NoticeBar = (props: NoticeBarProps) => {
20+
const theme = useTheme<Theme>();
21+
const styles = createStyles({
22+
bgColor: theme.colors.func100,
23+
smalCol: theme.colors.func600,
24+
});
1825
const [show, setShow] = useState(true);
1926

2027
const onPress = () => {
@@ -29,7 +36,7 @@ const NoticeBar = (props: NoticeBarProps) => {
2936
let { children, mode, icon, style, action, marqueeProps, textStyle } = props;
3037

3138
let operationDom: any = null;
32-
icon = typeof icon === 'undefined' ? <Icon name="notification" color="#f4333c" size={15} /> : icon;
39+
icon = typeof icon === 'undefined' ? <Icon name="notification" color={theme.colors.func600} size={15} /> : icon;
3340
if (mode === 'closable') {
3441
operationDom = (
3542
<TouchableWithoutFeedback onPress={onPress}>
@@ -54,54 +61,63 @@ const NoticeBar = (props: NoticeBarProps) => {
5461
mode === 'closable' ? (
5562
main
5663
) : (
57-
<TouchableWithoutFeedback onPress={onPress} testID="RNE__NoticeBar__link" >{main}</TouchableWithoutFeedback>
64+
<TouchableWithoutFeedback onPress={onPress} testID="RNE__NoticeBar__link">
65+
{main}
66+
</TouchableWithoutFeedback>
5867
)
5968
) : null}
6069
</View>
6170
);
6271
};
6372

64-
const styles = StyleSheet.create({
65-
notice: {
66-
backgroundColor: '#fffada',
67-
height: 36,
68-
overflow: 'hidden',
69-
flexDirection: 'row',
70-
alignItems: 'center',
71-
color: '#f4333c',
72-
},
73-
container: {
74-
flex: 1,
75-
marginRight: 15,
76-
overflow: 'hidden',
77-
width: 0, // ios bug: width size is wrong (usecase: with react-navigation).
78-
},
79-
content: {
80-
fontSize: 15,
81-
color: '#f4333c',
82-
},
83-
left6: {
84-
marginLeft: 5,
85-
},
86-
left15: {
87-
marginLeft: 15,
88-
},
89-
actionWrap: {
90-
marginRight: 15,
91-
},
92-
close: {
93-
color: '#f4333c',
94-
fontSize: 18,
95-
fontWeight: '200',
96-
textAlign: 'left',
97-
},
98-
link: {
99-
transform: [{ rotate: '225deg' }],
100-
color: '#f4333c',
101-
fontSize: 10,
102-
fontWeight: '500',
103-
textAlign: 'left',
104-
},
105-
});
73+
type CreStyle = {
74+
bgColor: string;
75+
smalCol: string;
76+
};
77+
78+
function createStyles({ bgColor, smalCol }: CreStyle) {
79+
return StyleSheet.create({
80+
notice: {
81+
backgroundColor: bgColor,
82+
height: 36,
83+
overflow: 'hidden',
84+
flexDirection: 'row',
85+
alignItems: 'center',
86+
color: smalCol,
87+
},
88+
container: {
89+
flex: 1,
90+
marginRight: 15,
91+
overflow: 'hidden',
92+
width: 0, // ios bug: width size is wrong (usecase: with react-navigation).
93+
},
94+
content: {
95+
fontSize: 15,
96+
color: smalCol,
97+
},
98+
left6: {
99+
marginLeft: 5,
100+
},
101+
left15: {
102+
marginLeft: 15,
103+
},
104+
actionWrap: {
105+
marginRight: 15,
106+
},
107+
close: {
108+
color: smalCol,
109+
fontSize: 18,
110+
fontWeight: '200',
111+
textAlign: 'left',
112+
},
113+
link: {
114+
transform: [{ rotate: '225deg' }],
115+
color: smalCol,
116+
fontSize: 10,
117+
fontWeight: '500',
118+
textAlign: 'left',
119+
},
120+
});
121+
}
106122

107123
export default NoticeBar;

packages/core/src/Pagination/DirText.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { View, ViewStyle, StyleSheet, Text } from 'react-native';
33
import Icon from '../Icon';
44
import Button from '../Button';
55
import { size } from './index';
6+
import { Theme } from '../theme';
7+
import { useTheme } from '@shopify/restyle';
68

79
export enum containerSize {
810
small = 30,
@@ -25,7 +27,9 @@ export interface DirTextProps {
2527
}
2628

2729
const DirText = (props: DirTextProps) => {
28-
const { size, direction, disabled, icon, onPageChange, borderColor = '#8d8d8d', color } = props;
30+
const theme = useTheme<Theme>();
31+
32+
const { size, direction, disabled, icon, onPageChange, borderColor = theme.colors.gray300, color } = props;
2933
const dirText: '上一页' | '下一页' = useRef<'上一页' | '下一页'>(direction === 'left' ? '上一页' : '下一页').current;
3034
const [disabledStyle, setDisabledStyle] = useState(1);
3135
useEffect(() => {
@@ -38,7 +42,7 @@ const DirText = (props: DirTextProps) => {
3842
{
3943
minWidth: containerSize[size],
4044
borderColor: borderColor,
41-
backgroundColor: '#fff',
45+
backgroundColor: theme.colors.white,
4246
paddingHorizontal: icon ? 0 : 5,
4347
opacity: disabled ? disabledStyle : disabledStyle - 0.2,
4448
},
@@ -53,9 +57,9 @@ const DirText = (props: DirTextProps) => {
5357
}}
5458
>
5559
{icon ? (
56-
<Icon name={direction} size={contentSize[size]} color={color || '#3d3d3d'} />
60+
<Icon name={direction} size={contentSize[size]} color={color || theme.colors.gray500} />
5761
) : (
58-
<Text style={{ color: color || '#3d3d3d' }}>{dirText}</Text>
62+
<Text style={{ color: color || theme.colors.gray500 }}>{dirText}</Text>
5963
)}
6064
</Button>
6165
</View>

packages/core/src/Pagination/MoreDir.tsx

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React, { useState } from 'react';
22
import { View, ViewStyle, TextStyle, StyleSheet, Text, TextInput } from 'react-native';
33
import { size } from './index';
4+
import { Theme } from '../theme';
5+
import { useTheme } from '@shopify/restyle';
46

57
export enum containerSize {
68
small = 30,
@@ -21,6 +23,11 @@ export interface MoreDirProps {
2123
}
2224

2325
const MoreDir = (props: MoreDirProps) => {
26+
const theme = useTheme<Theme>();
27+
const styles = createStyles({
28+
boxColor: theme.colors.primary_background,
29+
});
30+
2431
const { setCurrent, current } = props;
2532
const [jumpCurrent, setJumpCurrent] = useState(1);
2633

@@ -51,23 +58,27 @@ const MoreDir = (props: MoreDirProps) => {
5158
);
5259
};
5360

54-
export const containerStyle: ViewStyle = {
55-
flexDirection: 'row',
56-
justifyContent: 'center',
57-
alignItems: 'center',
58-
marginLeft: 5,
59-
};
60-
export const inputStyle: ViewStyle | TextStyle = {
61-
height: 27,
62-
width: 33,
63-
borderColor: 'gray',
64-
borderWidth: 0.5,
65-
textAlign: 'center',
66-
padding: 2,
67-
marginHorizontal: 3,
61+
type CreStyle = {
62+
boxColor: string;
6863
};
69-
const styles = StyleSheet.create({
70-
containerStyle,
71-
inputStyle,
72-
});
64+
65+
function createStyles({ boxColor }: CreStyle) {
66+
return StyleSheet.create({
67+
containerStyle: {
68+
flexDirection: 'row',
69+
justifyContent: 'center',
70+
alignItems: 'center',
71+
marginLeft: 5,
72+
},
73+
inputStyle: {
74+
height: 27,
75+
width: 33,
76+
borderColor: boxColor,
77+
borderWidth: 0.5,
78+
textAlign: 'center',
79+
padding: 2,
80+
marginHorizontal: 3,
81+
},
82+
});
83+
}
7384
export default MoreDir;

0 commit comments

Comments
 (0)