Skip to content

Commit 5769e93

Browse files
Merge pull request #1609 from SimonRothUCF/react/dark-mode
Dark Mode
2 parents 1f269bf + e9dff02 commit 5769e93

File tree

66 files changed

+3638
-322
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+3638
-322
lines changed

fuel/app/classes/controller/api/user.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function post_settings()
2626
$set_meta = [
2727
'useGravatar' => Input::json('useGravatar', null),
2828
'notify' => Input::json('notify', null),
29+
'darkMode' => Input::json('darkMode', null)
2930
];
3031

3132
$success = Materia\Api::user_update_meta($set_meta);

fuel/app/classes/controller/qsets.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
class Controller_Qsets extends Controller
88
{
9+
use Trait_CommonControllerTemplate;
910

1011
public function action_import()
1112
{

fuel/app/classes/controller/questions.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
class Controller_Questions extends Controller
88
{
9+
use Trait_CommonControllerTemplate;
10+
911
public function get_import()
1012
{
1113
// Validate Logged in

fuel/app/classes/model/user.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ class Model_User extends Orm\Model
55

66
protected static $_default_profile_fields = [
77
'useGravatar' => true,
8-
'notify' => true
8+
'notify' => true,
9+
'darkMode' => false
910
];
1011

1112
protected static $_properties = [

fuel/app/classes/trait/commoncontrollertemplate.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
trait Trait_CommonControllerTemplate
88
{
99
use Trait_Analytics;
10+
use Trait_DarkMode;
1011

1112
protected $_disable_browser_cache = false;
1213

@@ -32,6 +33,11 @@ public function after($response)
3233

3334
$this->inject_common_js_constants();
3435

36+
if ($this->is_using_darkmode())
37+
{
38+
$this->theme->get_template()->set('darkmode', true);
39+
}
40+
3541
return parent::after($response);
3642
}
3743

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Materia
4+
* License outlined in licenses folder
5+
*/
6+
7+
trait Trait_DarkMode
8+
{
9+
protected function is_using_darkmode()
10+
{
11+
if (\Service_User::verify_session() == true)
12+
{
13+
$meta = \Model_User::find_current()->profile_fields;
14+
$darkmode = ! empty($meta['darkMode']) && $meta['darkMode'];
15+
return $darkmode;
16+
}
17+
else return false;
18+
}
19+
}

fuel/app/themes/default/layouts/react.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<?= Css::render() ?>
1515
<?= $partials['google_analytics'] ?? '' ?>
1616
</head>
17-
<body class="<?= (isset($page_type) ? $page_type : '') ?>">
17+
<body class="<?= (isset($page_type) ? $page_type : '') ?> <?= (isset($darkmode) ? 'darkMode' : '') ?>">
1818
<div id="app"></div>
1919
<div id="modal"></div>
2020
<?= Js::render() ?>
407 KB
Loading

public/img/404_insand_dark.png

30.4 KB
Loading

public/img/404_logo_balls_dark.png

36.7 KB
Loading

0 commit comments

Comments
 (0)