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.
 
 
 

57 lines
1.4 KiB

package nova.monadic_sfx.pages
import nova.monadic_sfx.AppTypes
import scalafx.scene.control.TextField
import scalafx.scene.control._
import scalafx.scene.layout.VBox
import scalafx.scene.Node
import scalafx.Includes._
import scalafx.scene.Parent
import scalafx.application.JFXApp.PrimaryStage
// import io.odin.syntax._
// import _root_.monix.eval.Task
// import io.odin.monix._
// import javafx.beans.property.ObjectProperty
// import javafx.event.{ActionEvent, EventHandler}
class LoginPage(
appStage: PrimaryStage,
backend: AppTypes.HttpBackend,
system: akka.actor.ActorSystem
) {
//pure function callbacks, but with side effects still
private def onLogout(stage: PrimaryStage) = {
println("logging out")
stage.scene().setRoot(render)
}
private def onLogin(stage: PrimaryStage) = {
println("logging in")
stage
.scene()
.setRoot(HomePage(backend, system, () => onLogout(appStage)))
}
private lazy val root = new VBox {
children = Seq(
new TextField {
text = "username"
editable = true
},
new TextField {
text = "password"
},
new Button {
text = "Login"
onAction = () => onLogin(appStage)
}
)
}
def render: Parent = root
}
object LoginPage {
def apply(
appStage: PrimaryStage,
backend: AppTypes.HttpBackend,
system: akka.actor.ActorSystem
) = new LoginPage(appStage, backend, system).render
}