diff --git a/src/screens/settings/container/settingsContainer.js b/src/screens/settings/container/settingsContainer.js index bb6f73976..b8d5c7971 100644 --- a/src/screens/settings/container/settingsContainer.js +++ b/src/screens/settings/container/settingsContainer.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { Platform, Alert } from 'react-native'; +import { Platform, Alert, Appearance } from 'react-native'; import { connect } from 'react-redux'; import { Client } from '@hiveio/dhive'; import VersionNumber from 'react-native-version-number'; @@ -7,6 +7,8 @@ import Config from 'react-native-config'; import { injectIntl } from 'react-intl'; import messaging from '@react-native-firebase/messaging'; import { languageRestart } from '../../../utils/I18nUtils'; +import THEME_OPTIONS from '../../../constants/options/theme'; + // Realm import { getExistUser, @@ -22,6 +24,7 @@ import { setAuthStatus, setExistUser, removeAllUserData, + getTheme, } from '../../../realm/realm'; // Services and Actions @@ -119,6 +122,21 @@ class SettingsContainer extends Component { setNsfw2DB(action); break; + case 'theme': + let setting = THEME_OPTIONS[action].value; + const systemTheme = Appearance.getColorScheme(); + + dispatch(isDarkTheme(setting === null + ? systemTheme === 'dark' + : setting + )); + + setTheme(setting); + this.setState({ + themeSetting:setting + }) + break; + default: break; } @@ -208,11 +226,6 @@ class SettingsContainer extends Component { this._handleNotification(action, actionType); break; - case 'theme': - dispatch(isDarkTheme(action)); - setTheme(action); - break; - case 'default_footer': dispatch(isDefaultFooter(action)); // setDefaultFooter(action);