From 2f63119c6cda7c9fcb08c781b0a5307a8e1f0740 Mon Sep 17 00:00:00 2001 From: Rohan Sircar Date: Mon, 21 Dec 2020 19:43:39 +0530 Subject: [PATCH] TodoListView is a borderpane now --- .../ui/components/todo/TodoListView.scala | 112 +++++++----------- 1 file changed, 45 insertions(+), 67 deletions(-) diff --git a/src/main/scala/nova/monadic_sfx/ui/components/todo/TodoListView.scala b/src/main/scala/nova/monadic_sfx/ui/components/todo/TodoListView.scala index 42eaf5d..d823b5a 100644 --- a/src/main/scala/nova/monadic_sfx/ui/components/todo/TodoListView.scala +++ b/src/main/scala/nova/monadic_sfx/ui/components/todo/TodoListView.scala @@ -22,6 +22,9 @@ import scalafx.scene.control.ListCell import scalafx.scene.control.SelectionMode import scalafx.scene.layout.HBox import scalafx.scene.text.Text +import scalafx.geometry.Pos +import scalafx.scene.layout.BorderPane +import scalafx.scene.layout.Priority object TodoListView { def apply( @@ -33,58 +36,18 @@ object TodoListView { val todos = store.map { case (_, state) => state.todos } val _selectedItems = ObjectProperty(Seq.empty[Todo]) - new HBox { + new BorderPane { padding = Insets(5) val _content = StringProperty("") - children = Seq( - new JFXTextField { - text ==> _content - }, - new JFXListView[Todo] { + center = new HBox { + padding = Insets(5) + children ++= Seq(new JFXListView[Todo] { + hgrow = Priority.Always def selectedItems = selectionModel().selectedItems.view - + styleClass ++= Seq("text-white") selectionModel().selectionMode = SelectionMode.Multiple selectionModel().selectedItems.observableSeqValue ==> _selectedItems - stylesheets ++= Seq( - (os.rel / "static" / "css" / "main.css").toString - ) - - style = """| - | .scroll-bar:horizontal .track, - | .scroll-bar:vertical .track{ - | -fx-background-color:transparent; - | -fx-border-color:transparent; - | -fx-background-radius: 0em; - | -fx-border-radius:2em; - | } - | - | .scroll-bar:horizontal .increment-button , - | .scroll-bar:horizontal .decrement-button { - | -fx-background-color:transparent; - | -fx-background-radius: 0em; - | -fx-padding:0 0 10 0; - | } - | - | .scroll-bar:vertical .increment-button , - | .scroll-bar:vertical .decrement-button { - | -fx-background-color:transparent; - | -fx-background-radius: 0em; - | -fx-padding:0 10 0 0; - | } - | .scroll-bar .increment-arrow, - | .scroll-bar .decrement-arrow{ - | -fx-shape:" "; - | -fx-padding:0; - | } - | - | .scroll-bar:horizontal .thumb, - | .scroll-bar:vertical .thumb { - | -fx-background-color:derive(black,90%); - | -fx-background-insets: 2, 0, 0; - | -fx-background-radius: 2em; - }""".stripMargin - cc += items <-- todos val emptyCell = ObjectProperty(new HBox) @@ -136,28 +99,43 @@ object TodoListView { } ) } - }, - new JFXButton { - text = "Add" - // disable <== _selectedItems.map(_.length > 0) - obsAction - .useLazyEval(me.Task(TodoListStore.Add(_content()))) --> store - }, - new JFXButton { - text = "Edit" - disable <== _selectedItems.map(_.length > 1) - obsAction.useLazyEval( - me.Task( - TodoListStore.Edit( - _selectedItems - .map(_.headOption.map(_.id).getOrElse(-1)) - .value, - _content() + }) + } + + bottom = new HBox { + spacing = 5 + padding = Insets(5) + children = Seq( + new JFXTextField { + text ==> _content + }, + new JFXButton { + text = "Add" + alignment = Pos.Center + // disable <== _selectedItems.map(_.length > 0) + styleClass = Seq("btn", "btn-primary") + obsAction + .useLazyEval(me.Task(TodoListStore.Add(_content()))) --> store + }, + new JFXButton { + text = "Edit" + alignment = Pos.Center + disable <== _selectedItems.map(_.length > 1) + styleClass = Seq("btn", "btn-info") + style = "" + obsAction.useLazyEval( + me.Task( + TodoListStore.Edit( + _selectedItems + .map(_.headOption.map(_.id).getOrElse(-1)) + .value, + _content() + ) ) - ) - ) --> store - } - ) + ) --> store + } + ) + } } } )