Skip to content

Commit

Permalink
feat: Added auto setting to dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
artalat committed Dec 28, 2023
1 parent 7062352 commit dcd098f
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/settings/DarkModeSetting/DarkModeSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Configs } from '@bluebase/core/dist/Configs';
import React, { useState } from 'react';

const ModeName: { [key: string]: string } = {
auto: 'Light',
auto: 'Auto',
dark: 'Dark',
light: 'Light',
};
Expand All @@ -19,17 +19,35 @@ export const DarkModeSetting = () => {

const changeModeSetting = (mode: Configs['theme.mode']) => () => changeMode(mode);

let title = 'User Preferences';
let description = 'Appearance is detected automatically based on your device settings.';

if (themeMode === 'dark') {
title = 'Dark Mode';
description = 'Dark mode is always on.';
}

if (themeMode === 'light') {
title = 'Light Mode';
description = 'Light mode is always on.';
}

return (
<React.Fragment>
<List.Item
left={<List.Icon name="brightness-3" />}
title={ModeName[themeMode] === 'Dark' ? __('Dark Mode') : __('Light Mode')}
description={__(ModeName[themeMode])}
title={__(title)}
description={__(description)}
onPress={toggle}

Check warning on line 41 in src/settings/DarkModeSetting/DarkModeSetting.tsx

View workflow job for this annotation

GitHub Actions / Test, Build & Release (16)

JSX props should not use arrow functions
/>
<Dialog dismissable visible={visible} onDismiss={toggle}>

Check warning on line 43 in src/settings/DarkModeSetting/DarkModeSetting.tsx

View workflow job for this annotation

GitHub Actions / Test, Build & Release (16)

JSX props should not use arrow functions
<List.Subheader>{__('Mode')}</List.Subheader>
<Divider />
<List.Item
title={__(ModeName.auto)}
onPress={changeModeSetting('auto')}
selected={themeMode === 'auto'}
/>
<List.Item
title={__(ModeName.light)}
onPress={changeModeSetting('light')}
Expand Down

0 comments on commit dcd098f

Please sign in to comment.