diff --git a/app/gui/src/main/resources/themes/dark-theme.css b/app/gui/src/main/resources/themes/dark-theme.css new file mode 100644 index 0000000000..8167cc87d5 --- /dev/null +++ b/app/gui/src/main/resources/themes/dark-theme.css @@ -0,0 +1,34 @@ +.root { + -fx-accent: #1e74c6; + -fx-focus-color: -fx-accent; + -fx-base: #373e43; + -fx-control-inner-background: derive(-fx-base, 35%); + -fx-control-inner-background-alt: -fx-control-inner-background ; +} + +.label{ + -fx-text-fill: lightgray; +} + +.text-field { + -fx-prompt-text-fill: gray; +} + +.titulo{ + -fx-font-weight: bold; + -fx-font-size: 18px; +} + +.button{ + -fx-focus-traversable: false; +} + +.button:hover{ + -fx-text-fill: white; +} + +.separator *.line { + -fx-background-color: #3C3C3C; + -fx-border-style: solid; + -fx-border-width: 1px; +} \ No newline at end of file diff --git a/app/gui/src/main/scala/org/bitcoins/gui/GlobalData.scala b/app/gui/src/main/scala/org/bitcoins/gui/GlobalData.scala index 23fc662980..92ec1fb236 100644 --- a/app/gui/src/main/scala/org/bitcoins/gui/GlobalData.scala +++ b/app/gui/src/main/scala/org/bitcoins/gui/GlobalData.scala @@ -6,4 +6,8 @@ object GlobalData { val currentBalance: DoubleProperty = DoubleProperty(0) val log: StringProperty = StringProperty("") + + val statusText: StringProperty = StringProperty("") + + val defaultDarkTheme: Boolean = true } diff --git a/app/gui/src/main/scala/org/bitcoins/gui/TaskRunner.scala b/app/gui/src/main/scala/org/bitcoins/gui/TaskRunner.scala index 0b9f3fadf1..4b68f82ed0 100644 --- a/app/gui/src/main/scala/org/bitcoins/gui/TaskRunner.scala +++ b/app/gui/src/main/scala/org/bitcoins/gui/TaskRunner.scala @@ -11,7 +11,7 @@ import scalafx.scene.control.{Alert, Label} * * Copied from [[https://github.com/scalafx/ScalaFX-Tutorials/blob/master/slick-table/src/main/scala/org/scalafx/slick_table/TaskRunner.scala]] */ -class TaskRunner(mainView: Node, glassPane: Node, statusLabel: Label) { +class TaskRunner(mainView: Node, glassPane: Node) { /** * Run an operation on a separate thread. Return and wait for its completion, @@ -35,7 +35,7 @@ class TaskRunner(mainView: Node, glassPane: Node, statusLabel: Label) { // Indicate task in progress Platform.runLater { showProgress(true) - statusLabel.text = caption + GlobalData.statusText.value = caption } val task = new javafx.concurrent.Task[R] { @@ -44,13 +44,13 @@ class TaskRunner(mainView: Node, glassPane: Node, statusLabel: Label) { } override def succeeded(): Unit = { showProgress(false) - statusLabel.text = caption + " - Done." + GlobalData.statusText.value = caption + " - Done." // Do callback, if defined } override def failed(): Unit = { showProgress(false) - statusLabel.text = caption + " - Failed." + GlobalData.statusText.value = caption + " - Failed." val t = Option(getException) t.foreach(_.printStackTrace()) // Show error message @@ -65,7 +65,7 @@ class TaskRunner(mainView: Node, glassPane: Node, statusLabel: Label) { } override def cancelled(): Unit = { showProgress(false) - statusLabel.text = caption + " - Cancelled." + GlobalData.statusText.value = caption + " - Cancelled." } } diff --git a/app/gui/src/main/scala/org/bitcoins/gui/WalletGUI.scala b/app/gui/src/main/scala/org/bitcoins/gui/WalletGUI.scala index 15187e7f9e..30daf387bb 100644 --- a/app/gui/src/main/scala/org/bitcoins/gui/WalletGUI.scala +++ b/app/gui/src/main/scala/org/bitcoins/gui/WalletGUI.scala @@ -1,11 +1,13 @@ package org.bitcoins.gui import javafx.event.{ActionEvent, EventHandler} +import org.bitcoins.gui.settings.SettingsPane import scalafx.application.{JFXApp, Platform} import scalafx.beans.property.StringProperty import scalafx.geometry.{Insets, Pos} import scalafx.scene.Scene import scalafx.scene.control.Alert.AlertType +import scalafx.scene.control.TabPane.TabClosingPolicy import scalafx.scene.control._ import scalafx.scene.layout.{BorderPane, HBox, StackPane, VBox} @@ -51,7 +53,7 @@ object WalletGUI extends JFXApp { private val model = new WalletGUIModel() private val getNewAddressButton = new Button { - text = "Get New Addreses" + text = "Get New Address" onAction = new EventHandler[ActionEvent] { override def handle(event: ActionEvent): Unit = model.onGetNewAddress() } @@ -76,9 +78,28 @@ object WalletGUI extends JFXApp { bottom = statusLabel } + private val settingsPane = new SettingsPane + + private val tabPane: TabPane = new TabPane { + + val walletTab: Tab = new Tab { + text = "Wallet" + content = borderPane + } + + val settingsTab: Tab = new Tab { + text = "Settings" + content = settingsPane.view + } + + tabs = Seq(walletTab, settingsTab) + + tabClosingPolicy = TabClosingPolicy.Unavailable + } + private val rootView = new StackPane { children = Seq( - borderPane, + tabPane, glassPane ) } @@ -88,7 +109,11 @@ object WalletGUI extends JFXApp { scene = new Scene(rootView) } - private val taskRunner = new TaskRunner(resultArea, glassPane, statusLabel) + if (GlobalData.defaultDarkTheme) { + stage.scene.value.getStylesheets.add("/themes/dark-theme.css") + } + + private val taskRunner = new TaskRunner(resultArea, glassPane) model.taskRunner = taskRunner Platform.runLater(sendButton.requestFocus()) diff --git a/app/gui/src/main/scala/org/bitcoins/gui/settings/SettingsPane.scala b/app/gui/src/main/scala/org/bitcoins/gui/settings/SettingsPane.scala new file mode 100644 index 0000000000..67ec1ad226 --- /dev/null +++ b/app/gui/src/main/scala/org/bitcoins/gui/settings/SettingsPane.scala @@ -0,0 +1,31 @@ +package org.bitcoins.gui.settings + +import javafx.event.{ActionEvent, EventHandler} +import org.bitcoins.gui.GlobalData +import org.bitcoins.gui.WalletGUI.stage +import scalafx.scene.control.CheckBox +import scalafx.scene.layout.StackPane + +class SettingsPane { + + private val themeCheckBox = new CheckBox { + text = "Dark Theme" + selected = GlobalData.defaultDarkTheme + onAction = new EventHandler[ActionEvent] { + override def handle(event: ActionEvent): Unit = { + if (!selected.value) { + stage.scene.value.getStylesheets.removeAll("/themes/dark-theme.css") + } else { + stage.scene.value.getStylesheets.add("/themes/dark-theme.css") + } + () + } + } + } + + val view: StackPane = new StackPane { + children = Seq( + themeCheckBox + ) + } +}