Skip to content

Commit 512fd44

Browse files
author
Nur Fikri
committed
implement dark mode for all components
1 parent 7664cbc commit 512fd44

File tree

41 files changed

+7720
-22654
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+7720
-22654
lines changed

components/Button/Button.tsx

Lines changed: 231 additions & 227 deletions
Large diffs are not rendered by default.

components/CheckBox/CheckBox.tsx

Lines changed: 73 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,84 @@
1-
import React from 'react';
1+
import React from "react";
22
import {
3-
ColorValue,
4-
TextInput,
5-
TextInputProps,
6-
TouchableOpacity,
7-
View,
8-
ViewStyle,
9-
} from 'react-native';
10-
import { component, theme } from '../../constants/colors';
11-
import { Ionicons } from '@expo/vector-icons';
3+
ColorValue,
4+
TextInput,
5+
TextInputProps,
6+
TouchableOpacity,
7+
View,
8+
ViewStyle,
9+
} from "react-native";
10+
import { component, themeColor } from "../../constants/colors";
11+
import { Ionicons } from "@expo/vector-icons";
12+
import { useTheme } from "../../provider/ThemeProvider";
1213

1314
interface Props {
14-
value: boolean;
15-
onValueChange?: (newValue: boolean) => void;
16-
checkedColor?: ColorValue;
17-
uncheckedColor?: ColorValue;
18-
inverseColor?: ColorValue;
19-
disabled?: boolean;
20-
style?: ViewStyle;
21-
size?: number;
15+
value: boolean;
16+
onValueChange?: (newValue: boolean) => void;
17+
checkedColor?: ColorValue;
18+
uncheckedColor?: ColorValue;
19+
inverseColor?: ColorValue;
20+
disabled?: boolean;
21+
style?: ViewStyle;
22+
size?: number;
2223
}
2324

2425
const Checkbox: React.FC<Props> = ({
25-
value = false,
26-
onValueChange,
27-
checkedColor = component.checkBox.checkedColor,
28-
uncheckedColor = component.checkBox.uncheckedColor,
29-
inverseColor = theme.white,
30-
disabled = false,
31-
size = 24,
32-
style,
26+
value = false,
27+
onValueChange,
28+
checkedColor,
29+
uncheckedColor,
30+
inverseColor = themeColor.white,
31+
disabled = false,
32+
size = 24,
33+
style,
3334
}) => {
34-
const handleChange = () => {
35-
if (onValueChange) {
36-
onValueChange(!value);
37-
}
38-
};
35+
const { theme } = useTheme();
36+
const selectedCheckedColor = checkedColor
37+
? checkedColor
38+
: component[theme].checkBox.checkedColor;
39+
const selectedUncheckedColor = uncheckedColor
40+
? uncheckedColor
41+
: component[theme].checkBox.uncheckedColor;
3942

40-
return (
41-
<TouchableOpacity
42-
onPress={handleChange}
43-
style={{
44-
...style,
45-
width: size,
46-
height: size,
47-
alignItems: 'center',
48-
justifyContent: 'center',
49-
borderRadius: style?.borderRadius || 4,
50-
borderColor: value ? checkedColor : uncheckedColor,
51-
backgroundColor: disabled
52-
? component.checkBox.disabledColor
53-
: value
54-
? checkedColor
55-
: 'transparent',
56-
borderWidth: 1,
57-
}}
58-
disabled={disabled}
59-
>
60-
<Ionicons
61-
name="md-checkmark"
62-
size={size - 2}
63-
color={disabled ? inverseColor : value ? inverseColor : uncheckedColor}
64-
/>
65-
</TouchableOpacity>
66-
);
43+
const handleChange = () => {
44+
if (onValueChange) {
45+
onValueChange(!value);
46+
}
47+
};
48+
49+
return (
50+
<TouchableOpacity
51+
onPress={handleChange}
52+
style={{
53+
...style,
54+
width: size,
55+
height: size,
56+
alignItems: "center",
57+
justifyContent: "center",
58+
borderRadius: style?.borderRadius || 4,
59+
borderColor: value ? selectedCheckedColor : selectedUncheckedColor,
60+
backgroundColor: disabled
61+
? component[theme].checkBox.disabledColor
62+
: value
63+
? selectedCheckedColor
64+
: "transparent",
65+
borderWidth: 1,
66+
}}
67+
disabled={disabled}
68+
>
69+
<Ionicons
70+
name="md-checkmark"
71+
size={size - 2}
72+
color={
73+
disabled
74+
? inverseColor
75+
: value
76+
? inverseColor
77+
: selectedUncheckedColor
78+
}
79+
/>
80+
</TouchableOpacity>
81+
);
6782
};
6883

6984
export default Checkbox;

components/Layout/Layout.tsx

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
1-
import React from 'react';
2-
import { component } from '../../constants/colors';
1+
import React from "react";
2+
import { component } from "../../constants/colors";
33
import {
4-
SafeAreaView,
5-
SafeAreaViewProps,
6-
} from 'react-native-safe-area-context';
4+
SafeAreaView,
5+
SafeAreaViewProps,
6+
} from "react-native-safe-area-context";
7+
import { useTheme } from "../../provider/ThemeProvider";
78

89
interface Props extends SafeAreaViewProps {
9-
backgroundColor?: string;
10+
backgroundColor?: string;
1011
}
1112

1213
const Layout: React.FC<Props> = (props: Props) => {
13-
return (
14-
<SafeAreaView
15-
{...props}
16-
style={[
17-
props.style,
18-
{
19-
flex: 1,
20-
backgroundColor:
21-
props.backgroundColor || component.layout.backgroundColor,
22-
},
23-
]}
24-
>
25-
{props.children}
26-
</SafeAreaView>
27-
);
14+
const { theme } = useTheme();
15+
return (
16+
<SafeAreaView
17+
{...props}
18+
style={[
19+
props.style,
20+
{
21+
flex: 1,
22+
backgroundColor:
23+
props.backgroundColor || component[theme].layout.backgroundColor,
24+
},
25+
]}
26+
>
27+
{props.children}
28+
</SafeAreaView>
29+
);
2830
};
2931

3032
export default Layout;

0 commit comments

Comments
 (0)