Respond to review

This commit is contained in:
Ben Carman 2020-04-07 17:16:14 -05:00
parent 70d29050f8
commit 09399f1349
4 changed files with 42 additions and 9 deletions

View file

@ -1,3 +1,4 @@
/* Taken from https://stackoverflow.com/a/58441758/6947285 */
.root {
-fx-accent: #1e74c6;
-fx-focus-color: -fx-accent;

View file

@ -1,7 +1,7 @@
package org.bitcoins.gui
import javafx.event.{ActionEvent, EventHandler}
import org.bitcoins.gui.settings.SettingsPane
import org.bitcoins.gui.settings.{SettingsPane, Themes}
import scalafx.application.{JFXApp, Platform}
import scalafx.beans.property.StringProperty
import scalafx.geometry.{Insets, Pos}
@ -104,13 +104,20 @@ object WalletGUI extends JFXApp {
)
}
stage = new JFXApp.PrimaryStage {
title = "Bitcoin-S Wallet"
scene = new Scene(rootView)
private val styleSheets = if (GlobalData.defaultDarkTheme) {
Seq(Themes.DarkTheme.fileLocation)
} else {
Seq.empty
}
if (GlobalData.defaultDarkTheme) {
stage.scene.value.getStylesheets.add("/themes/dark-theme.css")
private val walletScene = new Scene {
root = rootView
stylesheets = styleSheets
}
stage = new JFXApp.PrimaryStage {
title = "Bitcoin-S Wallet"
scene = walletScene
}
private val taskRunner = new TaskRunner(resultArea, glassPane)

View file

@ -2,7 +2,6 @@ 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
@ -14,9 +13,9 @@ class SettingsPane {
onAction = new EventHandler[ActionEvent] {
override def handle(event: ActionEvent): Unit = {
if (!selected.value) {
stage.scene.value.getStylesheets.removeAll("/themes/dark-theme.css")
Themes.DarkTheme.undoTheme
} else {
stage.scene.value.getStylesheets.add("/themes/dark-theme.css")
Themes.DarkTheme.applyTheme
}
()
}

View file

@ -0,0 +1,26 @@
package org.bitcoins.gui.settings
import org.bitcoins.gui.WalletGUI.stage
sealed abstract class Theme {
def fileLocation: String
def applyTheme: Boolean =
stage.scene.value.getStylesheets.add(fileLocation)
def undoTheme: Boolean =
stage.scene.value.getStylesheets.removeAll(fileLocation)
}
object Themes {
final case object DarkTheme extends Theme {
override def fileLocation: String = "/themes/dark-theme.css"
}
val all: Vector[Theme] = Vector(DarkTheme)
def fromString(str: String): Option[Theme] = {
all.find(theme => str.toLowerCase() == theme.toString.toLowerCase)
}
}