Skip to content

Instantly share code, notes, and snippets.

View ahinchman1's full-sized avatar

Amanda Hinchman-Dominguez ahinchman1

View GitHub Profile
@ahinchman1
ahinchman1 / MyApp.kt
Last active May 23, 2018 04:00
Kotlin example of GridView
// TornadoFX has View, Controller, and Model components, allowing you to separate your code cleanly.
class MyApp: View() {
// global variables
val numCol: Int = 8
// every view has a root component
override val root = gridpane {
vgap = 15.0
padding = insets(15)
for (var i in 1..numCol) {
@ahinchman1
ahinchman1 / NeighborhoodVCStyles.kt
Created May 23, 2018 04:11
A Basic Neighborhood with View, Controller, and Styles classes
class NeighborhoodView: View() {
// dependency injection
private val controller: NeighborhoodController by inject()
// set up neighborhood
override val root = gridpane {
vgap = 15.0
padding = insets(15)
row {
add(controller.grassPane())
@ahinchman1
ahinchman1 / CatScheduleModelVC.kt
Created May 23, 2018 04:38
Kotlin Cat Scheduler
class MainView : View("Neighborhood Cat Scheduler") {
override val root = stackpane {
borderpane {
prefHeight = 700.0
prefWidth = 800.0
top(NeighborhoodView::class)
left(BottomView::class)
}
addClass(Styles.main)
class BottomView: View() {
private val controller: BottomViewController by inject()
private val model: CatScheduleModel by inject()
private var cat: String = "/kitty/kitty1.png"
override val root = hbox {
tabpane {
tab("Monday") {
tableview(controller.mondays) {
class BottomView: View() {
private val controller: BottomViewController by inject()
private val model: CatScheduleModel by inject()
private var cat: String = "/kitty/kitty1.png"
private var weekdays = listOf(
Pair("Monday", controller.mondays),
Pair("Tuesday", controller.tuesdays),
Pair("Wednesday", controller.wednesdays),
Pair("Thursday", controller.thursdays),
class BottomView: View() {
private val controller: BottomViewController by inject()
private val model: CatScheduleModel by inject()
lateinit var avi: StackPane
private var weekdays = listOf(
Pair("Monday", controller.mondays),
Pair("Tuesday", controller.tuesdays),
Pair("Wednesday", controller.wednesdays),
// Creates a new Scope and injects a CatSchedule configured with the selected user into that scope.
fun editCatSchedule(catSchedule: CatSchedule) {
val catScheduleScope = CatScheduleScope()
catScheduleScope.model.item = catSchedule
find(Editor::class, scope = catScheduleScope).openModal()
}
class Editor: Fragment() {
// cast scope
override val scope = super.scope as CatScheduleScope
// extract our view model from the scope
private val model = scope.model
var ownerNameField : TextField by singleAssign()
var catNameField : TextField by singleAssign()
var timeField: TextField by singleAssign()
class NeighborhoodView: View() {
private val controller: NeighborhoodController by inject()
// set up neighborhood
override val root = stackpane {
gridpane {
...
}
pane {
class CatSchedule(ownerName: String, catName: String, address: String,
time: String, catImage: String) {
val ownerNameProperty = SimpleStringProperty(this, "", ownerName)
var ownerName by ownerNameProperty
val catNameProperty = SimpleStringProperty(this, "", catName)
var catName by catNameProperty
val addressProperty = SimpleStringProperty(this, "", address)
var address by addressProperty