TodoListView is a borderpane now

This commit is contained in:
Rohan Sircar 2020-12-21 19:43:39 +05:30
parent 08fe33b5d8
commit 2f63119c6c

View File

@ -22,6 +22,9 @@ import scalafx.scene.control.ListCell
import scalafx.scene.control.SelectionMode import scalafx.scene.control.SelectionMode
import scalafx.scene.layout.HBox import scalafx.scene.layout.HBox
import scalafx.scene.text.Text import scalafx.scene.text.Text
import scalafx.geometry.Pos
import scalafx.scene.layout.BorderPane
import scalafx.scene.layout.Priority
object TodoListView { object TodoListView {
def apply( def apply(
@ -33,58 +36,18 @@ object TodoListView {
val todos = store.map { case (_, state) => state.todos } val todos = store.map { case (_, state) => state.todos }
val _selectedItems = ObjectProperty(Seq.empty[Todo]) val _selectedItems = ObjectProperty(Seq.empty[Todo])
new HBox { new BorderPane {
padding = Insets(5) padding = Insets(5)
val _content = StringProperty("") val _content = StringProperty("")
children = Seq( center = new HBox {
new JFXTextField { padding = Insets(5)
text ==> _content children ++= Seq(new JFXListView[Todo] {
}, hgrow = Priority.Always
new JFXListView[Todo] {
def selectedItems = selectionModel().selectedItems.view def selectedItems = selectionModel().selectedItems.view
styleClass ++= Seq("text-white")
selectionModel().selectionMode = SelectionMode.Multiple selectionModel().selectionMode = SelectionMode.Multiple
selectionModel().selectedItems.observableSeqValue ==> _selectedItems 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 cc += items <-- todos
val emptyCell = ObjectProperty(new HBox) val emptyCell = ObjectProperty(new HBox)
@ -136,16 +99,30 @@ object TodoListView {
} }
) )
} }
})
}
bottom = new HBox {
spacing = 5
padding = Insets(5)
children = Seq(
new JFXTextField {
text ==> _content
}, },
new JFXButton { new JFXButton {
text = "Add" text = "Add"
alignment = Pos.Center
// disable <== _selectedItems.map(_.length > 0) // disable <== _selectedItems.map(_.length > 0)
styleClass = Seq("btn", "btn-primary")
obsAction obsAction
.useLazyEval(me.Task(TodoListStore.Add(_content()))) --> store .useLazyEval(me.Task(TodoListStore.Add(_content()))) --> store
}, },
new JFXButton { new JFXButton {
text = "Edit" text = "Edit"
alignment = Pos.Center
disable <== _selectedItems.map(_.length > 1) disable <== _selectedItems.map(_.length > 1)
styleClass = Seq("btn", "btn-info")
style = ""
obsAction.useLazyEval( obsAction.useLazyEval(
me.Task( me.Task(
TodoListStore.Edit( TodoListStore.Edit(
@ -160,5 +137,6 @@ object TodoListView {
) )
} }
} }
}
) )
} }