Skip to content

Commit

Permalink
The appearances tab in settings now has a radiobutton
Browse files Browse the repository at this point in the history
Previously, checkboxes were uesd, which indicates more than one value
can be active at the same time. However, chosing more than one language
at once makes little sense :D
  • Loading branch information
Bios-Marcel committed Feb 5, 2025
1 parent e4182f0 commit 3a14098
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
47 changes: 47 additions & 0 deletions src/components/RadioButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { ColorValue, Pressable, View, ViewProps } from "react-native";
import { useTheme } from "../states/theme";

interface IProps extends ViewProps {
color?: ColorValue;
onChange?: (value: boolean) => void;
value?: boolean;
}

const RadioButton = (props: IProps) => {
const { theme } = useTheme();
const Wrapper = props.onChange ? Pressable : View;

return (
<Wrapper
style={[
{
height: 17,
width: 17,
borderRadius: 17 / 2,
borderWidth: 2,
padding: 2,
},
props.style,
{ borderColor: props.color ? props.color : theme.primary },
]}
onPress={() => {
if (props.onChange) {
props.onChange(!props.value);
}
}}
>
{props.value && (
<View
style={{
height: "100%",
width: "100%",
borderRadius: 17 / 2,
backgroundColor: props.color ? props.color : theme.primary,
}}
/>
)}
</Wrapper>
);
};

export default RadioButton;
4 changes: 2 additions & 2 deletions src/containers/Settings/Tab/Languages.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Pressable, ScrollView, StyleSheet, View } from "react-native";
import CheckBox from "../../../components/CheckBox";
import Text from "../../../components/Text";
import { getLanguages } from "../../../locales";
import { useGenericPersistentState } from "../../../states/genericStates";
import { useSettingsModal } from "../../../states/settingsModal";
import { useTheme } from "../../../states/theme";
import { sc } from "../../../utils/sizeScaler";
import RadioButton from "../../../components/RadioButton";

const Appearance = () => {
const { language, setLanguage } = useGenericPersistentState();
Expand Down Expand Up @@ -49,7 +49,7 @@ const Appearance = () => {
hideSettings();
}}
>
<CheckBox
<RadioButton
value={language === lang.type}
style={{ marginRight: sc(10) }}
/>
Expand Down

0 comments on commit 3a14098

Please sign in to comment.