2023-11-09 21:19:08 +02:00
|
|
|
import * as React from 'react';
|
|
|
|
import { FunctionComponent, ReactNode } from 'react';
|
|
|
|
|
|
|
|
import { View, Text, Switch } from 'react-native';
|
|
|
|
import { UpdateSettingValueCallback } from './types';
|
|
|
|
import { themeStyle } from '@joplin/lib/theme';
|
|
|
|
import { ConfigScreenStyles } from './configScreenStyles';
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
settingId: string;
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2023-11-09 21:19:08 +02:00
|
|
|
value: any;
|
|
|
|
|
|
|
|
themeId: number;
|
|
|
|
styles: ConfigScreenStyles;
|
|
|
|
|
|
|
|
label: string;
|
|
|
|
updateSettingValue: UpdateSettingValueCallback;
|
|
|
|
|
|
|
|
description?: ReactNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SettingsToggle: FunctionComponent<Props> = props => {
|
|
|
|
const theme = themeStyle(props.themeId);
|
|
|
|
const styleSheet = props.styles.styleSheet;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View>
|
|
|
|
<View style={props.styles.getContainerStyle(false)}>
|
|
|
|
<Text key="label" style={styleSheet.switchSettingText}>
|
|
|
|
{props.label}
|
|
|
|
</Text>
|
|
|
|
<Switch
|
|
|
|
key="control"
|
|
|
|
style={styleSheet.switchSettingControl}
|
|
|
|
trackColor={{ false: theme.dividerColor }}
|
|
|
|
value={props.value}
|
|
|
|
onValueChange={(value: boolean) => void props.updateSettingValue(props.settingId, value)}
|
2024-11-09 14:46:16 +02:00
|
|
|
accessibilityHint={props.label}
|
2023-11-09 21:19:08 +02:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
{props.description}
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SettingsToggle;
|