How do you create Pages and Views? #18
-
I'm planning on creating a larger "Todo" app example, since that seems to be the go-to in framework examples today. Unfortunately, I'm not able to figure out how to get views and pages working, mind sharing a simple example? My intuition is telling me to implement the View / Page function such that you can build out something like:
But I'm not able to figure out what is needed to happen in Page/View. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
PagesIn Qlovaseed, pages are global views with special integration with the browser's navigation and paths. type Page interface {
Page(page.Router) seed.Seed
} Here is an example, you should always return page.New from the Page method if possible. //Create a type for the page, the type is used to globally identify the page.
type DemoPage struct {
//Pages can take client-type arguments, defined as members of the page's struct type.
Message client.String
}
func (demo DemoPage) Page(r page.Router) seed.Seed {
return page.New(
//The text is set to the value of the Message argument.
text.New(text.SetStringTo(demo.Message)),
)
}
//If you have access to a page.Router, you can 'Goto' a page and provide arguments.
router.Goto(DemoPage{
Message: client.NewString("Hello World"),
}) In app.New, you will need to register the pages and set the main page: app.New("Demo",
page.AddPages(DemoPage{}),
page.Set(DemoPage{}),
) ViewsViews in Qlovaseed allow for views in the app that can be swapped within a given page. type View interface {
View(view.Controller) seed.Seed
} To add the view to a parent call: //Example of a parent to add the view to.
column.New(
view.Set(DemoView{}),
)
//If you have access to the view.Controller of the parent seed, you can 'Goto' a view and provide arguments.
controller.Goto(DemoView{}) |
Beta Was this translation helpful? Give feedback.
Pages
In Qlovaseed, pages are global views with special integration with the browser's navigation and paths.
To create a page, you need to implement the page interface:
Here is an example, you should always return page.New from the Page method if possible.