forked from GNUsocial/gnu-social
[PLUGINS][Oomox] Reset theme colors added
This commit is contained in:
parent
863cfbdedc
commit
12557a1e16
|
@ -70,22 +70,26 @@ class Oomox
|
||||||
|
|
||||||
$form_light->handleRequest($request);
|
$form_light->handleRequest($request);
|
||||||
if ($form_light->isSubmitted() && $form_light->isValid()) {
|
if ($form_light->isSubmitted() && $form_light->isValid()) {
|
||||||
$data = $form_light->getData();
|
$reset_button = $form_light->get('colour_reset_light');
|
||||||
$current_oomox_settings = Entity\Oomox::create(
|
if ($reset_button->isClicked()) {
|
||||||
[
|
$current_oomox_settings->resetTheme(true);
|
||||||
'actor_id' => $actor_id,
|
} else {
|
||||||
'colour_foreground_light' => $data['colour_foreground_light'],
|
$data = $form_light->getData();
|
||||||
'colour_background_hard_light' => $data['colour_background_hard_light'],
|
$current_oomox_settings = Entity\Oomox::create(
|
||||||
'colour_background_card_light' => $data['colour_background_card_light'],
|
[
|
||||||
'colour_border_light' => $data['colour_border_light'],
|
'actor_id' => $actor_id,
|
||||||
'colour_accent_light' => $data['colour_accent_light'],
|
'colour_foreground_light' => $data['colour_foreground_light'],
|
||||||
],
|
'colour_background_hard_light' => $data['colour_background_hard_light'],
|
||||||
);
|
'colour_background_card_light' => $data['colour_background_card_light'],
|
||||||
|
'colour_border_light' => $data['colour_border_light'],
|
||||||
|
'colour_accent_light' => $data['colour_accent_light'],
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
DB::merge($current_oomox_settings);
|
DB::merge($current_oomox_settings);
|
||||||
DB::flush();
|
DB::flush();
|
||||||
|
|
||||||
Cache::delete(\Plugin\Oomox\Oomox::cacheKey($user));
|
Cache::delete(\Plugin\Oomox\Oomox::cacheKey($user));
|
||||||
|
|
||||||
throw new RedirectException();
|
throw new RedirectException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,22 +113,27 @@ class Oomox
|
||||||
|
|
||||||
$form_dark->handleRequest($request);
|
$form_dark->handleRequest($request);
|
||||||
if ($form_dark->isSubmitted() && $form_dark->isValid()) {
|
if ($form_dark->isSubmitted() && $form_dark->isValid()) {
|
||||||
$data = $form_dark->getData();
|
$reset_button = $form_dark->get('colour_reset_dark');
|
||||||
$current_oomox_settings = Entity\Oomox::create(
|
if ($reset_button->isClicked()) {
|
||||||
[
|
$current_oomox_settings->resetTheme(false);
|
||||||
'actor_id' => $actor_id,
|
|
||||||
'colour_foreground_dark' => $data['colour_foreground_dark'],
|
} else {
|
||||||
'colour_background_hard_dark' => $data['colour_background_hard_dark'],
|
$data = $form_dark->getData();
|
||||||
'colour_background_card_dark' => $data['colour_background_card_dark'],
|
$current_oomox_settings = Entity\Oomox::create(
|
||||||
'colour_border_dark' => $data['colour_border_dark'],
|
[
|
||||||
'colour_accent_dark' => $data['colour_accent_dark'],
|
'actor_id' => $actor_id,
|
||||||
],
|
'colour_foreground_dark' => $data['colour_foreground_dark'],
|
||||||
);
|
'colour_background_hard_dark' => $data['colour_background_hard_dark'],
|
||||||
|
'colour_background_card_dark' => $data['colour_background_card_dark'],
|
||||||
|
'colour_border_dark' => $data['colour_border_dark'],
|
||||||
|
'colour_accent_dark' => $data['colour_accent_dark'],
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
DB::merge($current_oomox_settings);
|
DB::merge($current_oomox_settings);
|
||||||
DB::flush();
|
DB::flush();
|
||||||
|
|
||||||
Cache::delete(\Plugin\Oomox\Oomox::cacheKey($user));
|
Cache::delete(\Plugin\Oomox\Oomox::cacheKey($user));
|
||||||
|
|
||||||
throw new RedirectException();
|
throw new RedirectException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +153,7 @@ class Oomox
|
||||||
$background_card = 'colour_background_card_' . ($is_light ? 'light' : 'dark');
|
$background_card = 'colour_background_card_' . ($is_light ? 'light' : 'dark');
|
||||||
$border = 'colour_border_' . ($is_light ? 'light' : 'dark');
|
$border = 'colour_border_' . ($is_light ? 'light' : 'dark');
|
||||||
$accent = 'colour_accent_' . ($is_light ? 'light' : 'dark');
|
$accent = 'colour_accent_' . ($is_light ? 'light' : 'dark');
|
||||||
$shadow = 'colour_shadow_' . ($is_light ? 'light' : 'dark');
|
$reset = 'colour_reset_' . ($is_light ? 'light' : 'dark');
|
||||||
$save = 'save_oomox_colours_' . ($is_light ? 'light' : 'dark');
|
$save = 'save_oomox_colours_' . ($is_light ? 'light' : 'dark');
|
||||||
|
|
||||||
if (isset($current_oomox_settings)) {
|
if (isset($current_oomox_settings)) {
|
||||||
|
@ -201,6 +210,7 @@ class Oomox
|
||||||
'help' => _m('Choose the accent colour'), ],
|
'help' => _m('Choose the accent colour'), ],
|
||||||
],
|
],
|
||||||
['hidden', HiddenType::class, []],
|
['hidden', HiddenType::class, []],
|
||||||
|
[$reset, SubmitType::class, ['label' => _m('Reset colors to default')]],
|
||||||
[$save, SubmitType::class, ['label' => _m('Submit')]],
|
[$save, SubmitType::class, ['label' => _m('Submit')]],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,6 +197,23 @@ class Oomox extends Entity
|
||||||
return $this->modified;
|
return $this->modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function resetTheme(bool $is_light) {
|
||||||
|
if ($is_light) {
|
||||||
|
$this->colour_background_hard_light = '#09090d';
|
||||||
|
$this->colour_background_card_light = '#ebebeb';
|
||||||
|
$this->colour_foreground_light = '#f0f0f0';
|
||||||
|
$this->colour_border_light = '#d5d5d5';
|
||||||
|
$this->colour_accent_light = '#a22430';
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$this->colour_background_hard_dark = '#141216';
|
||||||
|
$this->colour_background_card_dark = '#131217';
|
||||||
|
$this->colour_foreground_dark = '#f0f6f6';
|
||||||
|
$this->colour_border_dark = '#201f25';
|
||||||
|
$this->colour_accent_dark = '#5ddbcf';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
// }}} Autocode
|
// }}} Autocode
|
||||||
public static function schemaDef(): array
|
public static function schemaDef(): array
|
||||||
|
|
Loading…
Reference in New Issue