Skip to content

Commit 7c7f9fb

Browse files
ChenlingasMxhy
authored andcommitted
fix: example明暗主题色
1 parent 597fdb8 commit 7c7f9fb

File tree

10 files changed

+114
-413
lines changed

10 files changed

+114
-413
lines changed

example/examples/src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const styles = StyleSheet.create({
1717

1818
const App = () => {
1919
const colorScheme = useColorScheme();
20-
console.log('colorScheme', colorScheme);
2120
return (
2221
<RootSiblingParent>
2322
<SafeAreaView style={styles.block}>

example/examples/src/Layout/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React, {PureComponent} from 'react';
22
import {StyleSheet, View, ViewProps, ViewStyle, SafeAreaView, ScrollView, ScrollViewProps, Text, TextStyle, Image, StyleProp} from 'react-native';
33
import PropTypes from 'prop-types';
4+
import {Theme} from '@uiw/react-native';
5+
import {useTheme} from '@shopify/restyle';
46

57
export interface HeaderProps {
68
title?: string;
@@ -36,8 +38,9 @@ export interface BodyProps extends ScrollViewProps {
3638

3739
const Body = (props: BodyProps) => {
3840
const {children, style, isScroll, ...other} = props;
41+
const theme = useTheme<Theme>();
3942
return (
40-
<ScrollView style={[styles.body, style]} automaticallyAdjustContentInsets={false} {...other}>
43+
<ScrollView style={[style, {backgroundColor: theme.colors.background || '#fff'}]} automaticallyAdjustContentInsets={false} {...other}>
4144
{children}
4245
</ScrollView>
4346
);
@@ -150,9 +153,6 @@ const styles = StyleSheet.create({
150153
// shadowOpacity: 0.8,
151154
zIndex: 999,
152155
},
153-
body: {
154-
backgroundColor: '#ededed',
155-
},
156156
logo: {
157157
flex: 1,
158158
flexDirection: 'row',
Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,50 @@
11
import React from 'react';
22
import {Text, View} from 'react-native';
3-
import {Divider} from '@uiw/react-native';
3+
import {Divider, Theme} from '@uiw/react-native';
44
import {ComProps} from '../../routes';
55
import Layout, {Container} from '../../Layout';
6+
import {useTheme} from '@shopify/restyle';
67

78
const {Header, Body, Card, Footer} = Layout;
89

910
export interface DividerViewProps extends ComProps {}
1011

11-
export default class DividerView extends React.Component<DividerViewProps> {
12-
render() {
13-
const {route} = this.props;
14-
const description = route.params.description;
15-
const title = route.params.title;
16-
return (
17-
<Container>
18-
<Layout>
19-
<Header title={title} description={description} />
20-
<Body>
21-
<Card title="横向分割线" style={{backgroundColor: '#ffffff'}}>
22-
<Text>分割线</Text>
23-
<Divider label="OR" />
24-
<Text>分割线</Text>
25-
<Divider label="暂无数据" />
26-
<Text>分割线</Text>
27-
<Divider label="调整间隔" gutter={30} />
28-
<Text>分割线</Text>
29-
</Card>
12+
export default function DividerView(props: DividerViewProps) {
13+
const {route} = props;
14+
const description = route.params.description;
15+
const title = route.params.title;
16+
const theme = useTheme<Theme>();
17+
return (
18+
<Container>
19+
<Layout style={{backgroundColor: theme.colors.background}}>
20+
<Header title={title} description={description} />
21+
<Body>
22+
<Card title="横向分割线" style={{backgroundColor: theme.colors.background}}>
23+
<Divider label="OR" />
24+
<Text />
25+
<Divider label="暂无数据" />
26+
<Text />
27+
<Divider label="调整间隔" gutter={30} />
28+
<Text />
29+
</Card>
3030

31-
<Card title="分割线标题位置" style={{backgroundColor: '#ffffff'}}>
32-
<Text>分割线</Text>
33-
<Divider label="left" orientation="left" labelStyle={{fontWeight: 'bold'}} />
34-
<Text>分割线</Text>
35-
<Divider label="center" labelStyle={{fontWeight: 'bold'}} />
36-
<Text>分割线</Text>
37-
<Divider label="right" orientation="right" labelStyle={{fontWeight: 'bold'}} />
38-
</Card>
31+
<Card title="分割线标题位置" style={{backgroundColor: theme.colors.background}}>
32+
<Text />
33+
<Divider label="left" orientation="left" labelStyle={{fontWeight: 'bold'}} />
34+
<Text />
35+
<Divider label="center" labelStyle={{fontWeight: 'bold'}} />
36+
<Text />
37+
<Divider label="right" orientation="right" labelStyle={{fontWeight: 'bold'}} />
38+
</Card>
3939

40-
<Card title="纵向分割线" style={{backgroundColor: '#ffffff'}}>
41-
<View style={{height: 200}}>
42-
<Divider type="vertical" label="OR" />
43-
</View>
44-
</Card>
45-
</Body>
46-
<Footer />
47-
</Layout>
48-
</Container>
49-
);
50-
}
40+
<Card title="纵向分割线" style={{backgroundColor: theme.colors.background}}>
41+
<View style={{height: 200}}>
42+
<Divider type="vertical" label="OR" />
43+
</View>
44+
</Card>
45+
</Body>
46+
<Footer />
47+
</Layout>
48+
</Container>
49+
);
5150
}

packages/core/src/CheckBox/index.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,27 +74,20 @@ function CheckBox(props: CheckBoxProps) {
7474
let colorIcon = $color;
7575
let divStyl: ViewProps['style'] = {};
7676
if (disabled) {
77-
colorIcon = color(colorIcon).alpha(0.52).rgb().string();
77+
colorIcon = theme.colors.disabled || color(colorIcon).alpha(0.52).rgb().string();
7878
divStyl.opacity = 0.5;
7979
}
80+
const textColor = theme.colors.primary_text || 'black';
8081
return (
8182
<TouchableOpacity disabled={disabled} {...otherProps} style={[styles.default, style]} onPress={onPress}>
8283
<View style={[styIcon]}>
8384
{typeof iconName === 'string' ? <Icon size={size} fill={colorIcon} name={iconName} /> : iconName}
8485
</View>
85-
{children && <Div children={children} style={[divStyl, textStyle]} />}
86+
{children && <Div children={children} style={[divStyl, { color: textColor }, textStyle]} />}
8687
</TouchableOpacity>
8788
);
8889
}
8990

90-
// console.log('theme', theme);
91-
// CheckBox.defaultProps = {
92-
// checkedIcon: 'circle-check',
93-
// unCheckedIcon: 'circle-o',
94-
// color: '#3578e5', //theme.colors.primary_background,
95-
// size: 16,
96-
// };
97-
9891
export default CheckBox;
9992

10093
const styles = StyleSheet.create({

packages/core/src/Divider/index.tsx

Lines changed: 59 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React, { Component } from 'react';
22
import { View, Text, ViewProps, TextProps, StyleSheet } from 'react-native';
3+
import { Theme } from '../theme';
4+
import { useTheme } from '@shopify/restyle';
35

46
export interface DividerProps extends ViewProps {
57
label?: string;
@@ -24,6 +26,13 @@ export default function Divider(props: DividerProps) {
2426
orientation = 'center',
2527
...restProps
2628
} = props;
29+
30+
const theme = useTheme<Theme>();
31+
32+
const styles = createStyles({
33+
textColor: theme.colors.primary_text || 'rgba(0, 0, 0, 0.54)',
34+
});
35+
2736
if (typeof children === 'string') {
2837
label = children;
2938
children = null;
@@ -47,7 +56,7 @@ export default function Divider(props: DividerProps) {
4756
labelStyle = StyleSheet.flatten(labelStyle);
4857
}
4958
children = (
50-
<Text testID="RNE__Divider__label" style={[styles.label, labelStyle]}>
59+
<Text testID="RNE__Divider__label" style={[styles.label, labelStyle, {}]}>
5160
{' '}
5261
{label}{' '}
5362
</Text>
@@ -77,46 +86,52 @@ export default function Divider(props: DividerProps) {
7786
);
7887
}
7988

80-
const styles = StyleSheet.create({
81-
warpper: {
82-
alignItems: 'center',
83-
},
84-
horizontal: {
85-
justifyContent: 'center',
86-
flexDirection: 'row',
87-
flexGrow: 1,
88-
flexShrink: 1,
89-
},
90-
vertical: {
91-
justifyContent: 'center',
92-
flexDirection: 'column',
93-
flexGrow: 1,
94-
flexShrink: 1,
95-
},
96-
lineStart: {
97-
backgroundColor: 'rgb(229, 229, 229)',
98-
flexDirection: 'column',
99-
flexShrink: 100,
100-
flexGrow: 1,
101-
},
102-
lineEnd: {
103-
backgroundColor: 'rgb(229, 229, 229)',
104-
flexDirection: 'column',
105-
flexShrink: 100,
106-
flexGrow: 1,
107-
},
108-
lineHorizontal: {
109-
height: 1,
110-
minHeight: 1,
111-
minWidth: 16,
112-
},
113-
lineVertical: {
114-
width: 1,
115-
minHeight: 16,
116-
minWidth: 1,
117-
},
118-
label: {
119-
color: 'rgba(0, 0, 0, 0.54)',
120-
fontSize: 14,
121-
},
122-
});
89+
type CreStyle = {
90+
textColor: string;
91+
};
92+
93+
function createStyles({ textColor }: CreStyle) {
94+
return StyleSheet.create({
95+
warpper: {
96+
alignItems: 'center',
97+
},
98+
horizontal: {
99+
justifyContent: 'center',
100+
flexDirection: 'row',
101+
flexGrow: 1,
102+
flexShrink: 1,
103+
},
104+
vertical: {
105+
justifyContent: 'center',
106+
flexDirection: 'column',
107+
flexGrow: 1,
108+
flexShrink: 1,
109+
},
110+
lineStart: {
111+
backgroundColor: 'rgb(229, 229, 229)',
112+
flexDirection: 'column',
113+
flexShrink: 100,
114+
flexGrow: 1,
115+
},
116+
lineEnd: {
117+
backgroundColor: 'rgb(229, 229, 229)',
118+
flexDirection: 'column',
119+
flexShrink: 100,
120+
flexGrow: 1,
121+
},
122+
lineHorizontal: {
123+
height: 1,
124+
minHeight: 1,
125+
minWidth: 16,
126+
},
127+
lineVertical: {
128+
width: 1,
129+
minHeight: 16,
130+
minWidth: 1,
131+
},
132+
label: {
133+
color: textColor,
134+
fontSize: 14,
135+
},
136+
});
137+
}

packages/core/src/Empty/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import React, { Component } from 'react';
1+
import React from 'react';
22
import { StyleSheet, Text, TextProps } from 'react-native';
33
import Icon from '../Icon';
44
import Flex, { FlexProps } from '../Flex';
5+
import { Theme } from '../theme';
6+
import { useTheme } from '@shopify/restyle';
57

68
export const iconStr = `
79
<svg width="64" height="41" viewBox="0 0 64 41">
@@ -40,19 +42,17 @@ export interface EmptyProps extends FlexProps {
4042

4143
export default function Empty(props: EmptyProps) {
4244
const { size = 64, label = '暂无数据', xml = iconStr, labelStyle, children, ...otherProps } = props;
45+
const theme = useTheme<Theme>();
46+
const textColor = theme.colors.primary_text || 'rgba(0,0,0,0.25)';
4347
return (
4448
<Flex direction="column" justify="center" align="center" {...otherProps}>
4549
{xml && <Icon xml={xml} size={size} />}
4650
{!!children
4751
? children
4852
: label &&
49-
typeof label === 'string' && <Text style={StyleSheet.flatten([styles.label, labelStyle])}>{label}</Text>}
53+
typeof label === 'string' && (
54+
<Text style={StyleSheet.flatten([{ color: textColor }, labelStyle])}>{label}</Text>
55+
)}
5056
</Flex>
5157
);
5258
}
53-
54-
const styles = StyleSheet.create({
55-
label: {
56-
color: 'rgba(0,0,0,0.25)',
57-
},
58-
});

packages/core/src/Form/styles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { StyleSheet } from 'react-native';
22

33
const styles = StyleSheet.create({
44
warpper: {
5-
backgroundColor: '#fff5',
5+
backgroundColor: '#fff',
66
},
77
form_items_container: {
88
flex: 1,

packages/core/src/Grid/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,9 @@ export interface GridProps extends ViewProps {
8181

8282
export default function Grid(props: GridProps) {
8383
const theme = useTheme<Theme>();
84-
8584
const styles = createStyles({
86-
color: theme.colors.white || '#fff',
85+
color: theme.colors.background || '#fff',
8786
});
88-
8987
const {
9088
style,
9189
data = [],

0 commit comments

Comments
 (0)