TodoListView is a borderpane now
This commit is contained in:
parent
08fe33b5d8
commit
2f63119c6c
@ -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,28 +99,43 @@ object TodoListView {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
new JFXButton {
|
}
|
||||||
text = "Add"
|
|
||||||
// disable <== _selectedItems.map(_.length > 0)
|
bottom = new HBox {
|
||||||
obsAction
|
spacing = 5
|
||||||
.useLazyEval(me.Task(TodoListStore.Add(_content()))) --> store
|
padding = Insets(5)
|
||||||
},
|
children = Seq(
|
||||||
new JFXButton {
|
new JFXTextField {
|
||||||
text = "Edit"
|
text ==> _content
|
||||||
disable <== _selectedItems.map(_.length > 1)
|
},
|
||||||
obsAction.useLazyEval(
|
new JFXButton {
|
||||||
me.Task(
|
text = "Add"
|
||||||
TodoListStore.Edit(
|
alignment = Pos.Center
|
||||||
_selectedItems
|
// disable <== _selectedItems.map(_.length > 0)
|
||||||
.map(_.headOption.map(_.id).getOrElse(-1))
|
styleClass = Seq("btn", "btn-primary")
|
||||||
.value,
|
obsAction
|
||||||
_content()
|
.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
|
}
|
||||||
}
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user