@@ -272,28 +272,15 @@ class Activity {
272272 //Flag to check if any other input box is active or not
273273 this . isInputON = false ;
274274
275- // Flag to check if dark mode is on or not
276- this . isDarkModeON = false ;
275+ // If the theme is set to "darkMode", enable dark mode else diable
277276 try {
278- if ( this . storage . darkMode === undefined ) {
279- this . isDarkModeON = false ;
280- } else if ( this . storage . darkMode !== null ) {
281- this . isDarkModeON = this . storage . darkMode ;
282-
283- if ( typeof this . isDarkModeON === "string" ) {
284- if ( this . isDarkModeON === "true" ) {
285- this . isDarkModeON = true ;
286- body . classList . add ( 'dark-mode' ) ;
287- //navbar.classList.add('dark-mode');
288- } else if ( this . isDarkModeON === "false" ) {
289- this . isDarkModeON = false ;
290- body . classList . remove ( 'dark-mode' ) ;
291- }
292- }
277+ if ( this . storage . myThemeName === "darkMode" ) {
278+ body . classList . add ( "dark-mode" ) ;
279+ } else {
280+ body . classList . remove ( "dark-mode" ) ;
293281 }
294282 } catch ( e ) {
295- console . error ( "Error accessing darkMode storage:" , e ) ;
296- this . isDarkModeON = false ;
283+ console . error ( "Error accessing myThemeName storage:" , e ) ;
297284 }
298285
299286 this . beginnerMode = true ;
@@ -1082,7 +1069,7 @@ class Activity {
10821069 modal . style . textAlign = "left" ;
10831070 const title = document . createElement ( "h2" ) ;
10841071 title . textContent = "Clear Workspace" ;
1085- title . style . color = "#0066FF" ;
1072+ title . style . color = platformColor . blueButton ;
10861073 title . style . fontSize = "24px" ;
10871074 title . style . margin = "0 0 16px 0" ;
10881075 modal . appendChild ( title ) ;
@@ -6488,15 +6475,18 @@ class Activity {
64886475
64896476 this . _createErrorContainers ( ) ;
64906477
6491- // Function to toggle dark mode
6492- this . toggleDarkMode = ( ) => {
6493- this . isDarkModeON = ! this . isDarkModeON ; // Toggle the boolean value
6494- console . log ( `Dark Mode is now ${ this . isDarkModeON ? "ON" : "OFF" } ` ) ;
6478+ // Function to toggle theme mode
6479+ this . toggleThemeMode = ( ) => {
6480+ if ( this . storage . myThemeName === "darkMode" ) {
6481+ // If currently in dark mode, remove the theme
6482+ delete this . storage . myThemeName ;
6483+ } else {
6484+ this . storage . myThemeName = "darkMode" ;
6485+ }
64956486 try {
6496- this . storage . darkMode = this . isDarkModeON . toString ( ) ; // Save the state as a string
64976487 window . location . reload ( ) ;
64986488 } catch ( e ) {
6499- console . error ( "Error saving darkMode state to storage :" , e ) ;
6489+ console . error ( "Error reloading the window :" , e ) ;
65006490 }
65016491 } ;
65026492
@@ -6566,7 +6556,7 @@ class Activity {
65666556 this . toolbar . renderModeSelectIcon ( doSwitchMode , doRecordButton , doAnalytics , doOpenPlugin , deletePlugin , setScroller ) ;
65676557 this . toolbar . renderRunSlowlyIcon ( doSlowButton ) ;
65686558 this . toolbar . renderRunStepIcon ( doStepButton ) ;
6569- this . toolbar . renderDarkModeIcon ( this . toggleDarkMode ) ;
6559+ this . toolbar . renderDarkModeIcon ( this . toggleThemeMode ) ;
65706560 this . toolbar . renderMergeIcon ( _doMergeLoad ) ;
65716561 this . toolbar . renderRestoreIcon ( restoreTrash ) ;
65726562 if ( _THIS_IS_MUSIC_BLOCKS_ ) {
0 commit comments