Skip to content
Snippets Groups Projects
Commit e7f1b110 authored by Guransh Khurana's avatar Guransh Khurana
Browse files

created a toggleDarkMode function and implemented action for menu bar items dark and light

parent de1a2954
No related branches found
No related tags found
3 merge requests!34All additional functionalities added,!33Added theme and image support functionality to the note app,!32Draft: Dark theme main serverless
Pipeline #90028 passed
......@@ -44,6 +44,7 @@ class TextWindow(): Application() {
private var newname = true
private var curfile = Note()
var isDarkMode = false
private fun notesname() : MutableList<String> {
val retlist = mutableListOf<String>()
......@@ -256,6 +257,8 @@ class TextWindow(): Application() {
}
}
filemenu.items.addAll(open, save, delete)
modechange.items.addAll(dark, light)
menubar.menus.addAll(filemenu, modechange)
......@@ -265,6 +268,18 @@ class TextWindow(): Application() {
stage.scene = Scene(box, 300.0, 300.0)
dark.setOnAction {
if (!isDarkMode) {
toggleDarkMode(stage.scene, isDarkMode)
}
}
light.setOnAction {
if (isDarkMode) {
toggleDarkMode(stage.scene, isDarkMode)
}
}
/**
* Logic for key presses:
* - Save: Ctrl + S
......
package notes.multi.utilities
import javafx.application.Application
import javafx.scene.Scene
import javafx.stage.Stage
import javafx.geometry.Pos
import javafx.scene.control.Button
import javafx.scene.control.Label
import javafx.scene.layout.StackPane
import javafx.scene.layout.VBox
import javafx.scene.paint.Color
import javafx.scene.text.Font
import javax.swing.text.html.StyleSheet
fun toggleDarkMode(scene: Scene, isDarkMode: Boolean) {
//val darktheme: StyleSheet = StyleSheet(false, "notes/multi/utilities/darktheme.css")
if (isDarkMode) {
//note.text.toString(). = Color.WHITE
scene.root.style = "-fx-background-color: ${Color.BLACK.toString().replace("0x", "#")}; -fx-text-fill: ${Color.WHITE.toString().replace("0x", "#")}"
} else {
//note.text = Color.BLACK
scene.root.style = "-fx-background-color: ${Color.WHITE.toString().replace("0x", "#")}; -fx-text-fill: ${Color.BLACK.toString().replace("0x", "#")}"
}
//isDarkMode = !isDarkMode
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment