Skip to content

Commit

Permalink
feat: Support new FoF/Default-User-Preferences (#61)
Browse files Browse the repository at this point in the history
* Support new FoF/Default-User-Preferences

* Apply fixes from StyleCI

Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
imorland and StyleCIBot authored Jun 12, 2022
1 parent 9aaa098 commit d352aa0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
},
"flagrow": {
"discuss": "https://discuss.flarum.org/d/21492"
}
},
"optional-dependencies": [
"fof/default-user-preferences"
]
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 6 additions & 0 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
namespace FoF\NightMode;

use Flarum\Extend;
use Flarum\Extension\ExtensionManager;
use Flarum\Settings\SettingsRepositoryInterface;
use FoF\DefaultUserPreferences\Extend\RegisterUserPreferenceDefault;

return [
(new Extend\Frontend('forum'))
Expand Down Expand Up @@ -54,4 +56,8 @@
}, false)
->serializeToForum('fofNightMode.showThemeToggleOnHeaderAlways', 'fofNightMode.show_theme_toggle_on_header_always', 'boolval', false)
->serializeToForum('fof-nightmode.default_theme', 'fof-nightmode.default_theme', 'intval', 0),

class_exists(RegisterUserPreferenceDefault::class) && resolve(ExtensionManager::class)->isEnabled('fof-default-user-preferences') ? (new RegisterUserPreferenceDefault())
->default('fofNightMode', 0, 'number')
->default('fofNightMode_perDevice', false, 'bool') : [],
];
8 changes: 8 additions & 0 deletions resources/locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ fof-nightmode:
auto: Your theme will be automatically selected based on your browser or device settings. For example, if you have dark mode enabled in iOS, the forums will be dark too.
day: The classic experience which you're used to. Loved and tested.
night: You're a bit of a night owl. You watch over the forum at night, while the birds are sleeping and the foxes are hunting. Or you just prefer the darker colours!

fof-default-user-preferences:
admin:
settings:
fofNightMode: "FoF Nightmode: Color theme to use by default"
fofNightMode-help: "0 - automatic, 1 - light mode, 2 - dark mode"
fofNightMode_perDevice: "FoF Nightmode: Use per device settings"
fofNightMode_perDevice-help: Use per device preferences for nightmode settings

0 comments on commit d352aa0

Please sign in to comment.