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.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,16 +99,30 @@ object TodoListView {
}
)
}
})
}
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(
@ -160,5 +137,6 @@ object TodoListView {
)
}
}
}
)
}