You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

95 lines
2.3 KiB

package nova.monadic_sfx.ui.controller
import animatefx.animation.AnimationFX
import animatefx.animation.Bounce
import animatefx.animation.FadeIn
import animatefx.util.{SequentialAnimationFX => SeqFX}
import cats.effect.Sync
import monix.eval.Task
import nova.monadic_sfx.implicits.FontIcon
import nova.monadic_sfx.implicits.IconLiteral
import nova.monadic_sfx.implicits.JFXButton
import nova.monadic_sfx.implicits.JFXListView
import nova.monadic_sfx.implicits.JFXTextArea
import nova.monadic_sfx.implicits.JFXTextField
import nova.monadic_sfx.ui.components.todo.TodoListComponentOld
import scalafx.collections.ObservableBuffer
import scalafx.scene.control.Label
import scalafx.scene.layout.HBox
import scalafx.scene.paint.Color
class TodoController(todoListComponent: TodoListComponentOld) {
import AnimFX._
def root =
new HBox {
children = Seq(
new Label {
text = "Todo"
},
new JFXButton {
text = " Click me"
onAction = _ => {
new FadeIn(new Label("hello")).play()
val anim = new SeqFX(
new Bounce(new Label("hello")),
new FadeIn(new Label("hello"))
).toAnimFX[Task]
for {
_ <- Task.unit
_ <- anim.playL
} yield ()
}
},
new JFXTextField {
text = "hello"
labelFloat = true
},
new JFXListView[String] {
items = ObservableBuffer("hello")
},
new JFXTextArea {
prefWidth = 400
text = "blah"
labelFloat = true
},
new FontIcon {
iconSize = 50
iconColor = Color.Black
iconLiteral = IconLiteral.Gmi10k
}
)
}
// def test() = {
// new TextField("hello").lookup()
// }
// def test2() = {
// new Label().lookup()
// }
}
abstract class AnimFX[F[_]: Sync] {
def playL: F[Unit]
}
object AnimFX {
implicit class AnimationFXExt(anim: AnimationFX) {
def toAnimFX[F[_]](implicit
F: Sync[F]
) =
new AnimFX[F] {
override def playL: F[Unit] =
F.delay(anim.play())
}
}
implicit class SeqAnimationFXExt(anim: SeqFX) {
def toAnimFX[F[_]](implicit
F: Sync[F]
) =
new AnimFX[F] {
override def playL: F[Unit] =
F.delay(anim.play())
}
}
}