Skip to content

Commit ad852a3

Browse files
authored
Merge pull request #303 from openmultiplayer/appearance_uses_radiobutton
The appearances tab in settings now has a radiobutton
2 parents e4182f0 + 3a14098 commit ad852a3

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

src/components/RadioButton.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { ColorValue, Pressable, View, ViewProps } from "react-native";
2+
import { useTheme } from "../states/theme";
3+
4+
interface IProps extends ViewProps {
5+
color?: ColorValue;
6+
onChange?: (value: boolean) => void;
7+
value?: boolean;
8+
}
9+
10+
const RadioButton = (props: IProps) => {
11+
const { theme } = useTheme();
12+
const Wrapper = props.onChange ? Pressable : View;
13+
14+
return (
15+
<Wrapper
16+
style={[
17+
{
18+
height: 17,
19+
width: 17,
20+
borderRadius: 17 / 2,
21+
borderWidth: 2,
22+
padding: 2,
23+
},
24+
props.style,
25+
{ borderColor: props.color ? props.color : theme.primary },
26+
]}
27+
onPress={() => {
28+
if (props.onChange) {
29+
props.onChange(!props.value);
30+
}
31+
}}
32+
>
33+
{props.value && (
34+
<View
35+
style={{
36+
height: "100%",
37+
width: "100%",
38+
borderRadius: 17 / 2,
39+
backgroundColor: props.color ? props.color : theme.primary,
40+
}}
41+
/>
42+
)}
43+
</Wrapper>
44+
);
45+
};
46+
47+
export default RadioButton;

src/containers/Settings/Tab/Languages.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Pressable, ScrollView, StyleSheet, View } from "react-native";
2-
import CheckBox from "../../../components/CheckBox";
32
import Text from "../../../components/Text";
43
import { getLanguages } from "../../../locales";
54
import { useGenericPersistentState } from "../../../states/genericStates";
65
import { useSettingsModal } from "../../../states/settingsModal";
76
import { useTheme } from "../../../states/theme";
87
import { sc } from "../../../utils/sizeScaler";
8+
import RadioButton from "../../../components/RadioButton";
99

1010
const Appearance = () => {
1111
const { language, setLanguage } = useGenericPersistentState();
@@ -49,7 +49,7 @@ const Appearance = () => {
4949
hideSettings();
5050
}}
5151
>
52-
<CheckBox
52+
<RadioButton
5353
value={language === lang.type}
5454
style={{ marginRight: sc(10) }}
5555
/>

0 commit comments

Comments
 (0)