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

Modal

This example shows how to create an app showing/hiding a Modal/Dialog.

Open in Online Editor
class MyApp extends App{
	
	shownModal = ``
	
	createStartPage(){
		return StartPage
	}
	
	showHelpModal(){
		a.shownModal = `help`
	}
	
	closeModal(){
		a.shownModal = ``
	}
	
	createLayout(pageContent){
		
		const helpModal = Box.keepIf(a.shownModal == `help`).padding(7).backgroundColor(`#77777777`).child(
			Rows.backgroundColor(`white`).cornerRadius(5).children(
				Text.text(`Help`),
				Space,
				Text.text(`Here comes a long descriptive text helping you...`).left(),
				Space,
				Columns.children(
					Space,
					Button.text(`Close`).handler(a.closeModal),
					Space,
				),
			),
		)
		
		return Layers.backgroundColor(`aliceblue`).children(
			pageContent,
			helpModal,
		)
		
	}
	
}
class StartPage extends Page{
	createGui(){
		return a.createLayout(
			Rows.children(
				Text.text(`Need help?`),
				Button.text(`Yes`).handler(a.showHelpModal),
			)
		)
	}
}