Note: This is a pre-release of BagaWork. Many things will likely change before the first stable release.

Glossaries

This example shows how to create an app where the user can practice on translating words from Swedish to English.

Open in Online Editor
class MyApp extends App{
	
	createStartPage(){
		return StartPage
	}
	
	createLayout(content){
		return Rows.padding(4).children(
			Text.text(`Glossary App!`),
			content.size(1),
		)
	}
	
}
class StartPage extends Page{
	
	createGui(){
		return a.createLayout(
			Rows.children(
				Space,
				Text.text(`In this app, you can practice on Swedish-English glossaries.`),
				Space,
				Text.text(`Select category.`),
				Space,
				Columns.children(
					Space,
					Rows.children(
						Button.text(`Colors`).page(Color1Page),
						Box.height(2),
						Button.text(`Numbers`).page(Number1Page),
					),
					Space,
				),
				Space,
			)
		)
	}
	
}
class Color1Page extends Page{
	
	createGui(){
		return a.createLayout(
			Rows.children(
				Space,
				Text.text(`1. Enter the English word for the Swedish word "grön".`),
				Space,
				EnterText.placeholder(`Hint: green`).pageIfEqual(`green`, Color2Page),
			)
		)
	}
	
}
class Color2Page extends Page{
	
	createGui(){
		return a.createLayout(
			Rows.children(
				Space,
				Text.text(`2. Enter the English word for the Swedish word "röd".`),
				Space,
				EnterText.placeholder(`Hint: red`).pageIfEqual(`red`, Color3Page),
			)
		)
	}
	
}
class Color3Page extends Page{
	
	createGui(){
		return a.createLayout(
			Rows.children(
				Space,
				Text.text(`3. Enter the English word for the Swedish word "blå".`),
				Space,
				EnterText.placeholder(`Hint: blue`).pageIfEqual(`blue`, DonePage),
			)
		)
	}
	
}
class DonePage extends Page{
	
	createGui(){
		return a.createLayout(
			Rows.children(
				Space,
				Text.text(`Good, and don't you forget them!`),
				Space,
				Button.text(`Back to start page`).page(StartPage),
			)
		)
	}
	
}
class Number1Page extends Page{
	
	createGui(){
		return a.createLayout(
			Rows.children(
				Space,
				Text.text(`1. Enter the English word for the Swedish word "två".`),
				Space,
				EnterText.placeholder(`Hint: two`).pageIfEqual(`two`, Number2Page),
			)
		)
	}
	
}
class Number2Page extends Page{
	
	createGui(){
		return a.createLayout(
			Rows.children(
				Space,
				Text.text(`2. Enter the English word for the Swedish word "fem".`),
				Space,
				EnterText.placeholder(`Hint: five`).pageIfEqual(`five`, Number3Page),
			)
		)
	}
	
}
class Number3Page extends Page{
	
	createGui(){
		return a.createLayout(
			Rows.children(
				Space,
				Text.text(`3. Enter the English word for the Swedish word "åtta".`),
				Space,
				EnterText.placeholder(`Hint: eight`).pageIfEqual(`eight`, DonePage),
			)
		)
	}
	
}