MCPcopy Create free account
hub / github.com/AshampooSystems/boden / MainViewController

Method MainViewController

examples/reddit/src/reddit.cpp:248–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246{
247 public:
248 MainViewController() : _listViewController(std::make_shared<PostListViewController>())
249 {
250 _window = std::make_shared<ui::Window>();
251 _window->title = "UI Demo";
252 _window->geometry = Rect{0, 0, 1024, 768};
253 _window->setLayout(std::make_shared<ui::yoga::Layout>());
254
255 auto navigationView = std::make_shared<ui::NavigationView>();
256 navigationView->stylesheet = FlexJsonStringify({
257 "direction" : "Column",
258 "flexGrow" : 1.0,
259 "flexShrink" : 1.0,
260 "alignItems" : "Stretch",
261 "padding" : {"all" : 20}
262 });
263
264 _listViewController->view()->visible.onChange() += [&](auto &p) {
265 if (p.get()) {
266 _listViewController->deselect();
267 }
268 };
269
270 navigationView->pushView(_listViewController->view(), "Reddit");
271
272 _listViewController->onClicked() += [navigationView](auto title, auto url, auto imageUrl) {
273 auto post = std::make_shared<PostDetailController>(title, url, imageUrl);
274 navigationView->pushView(post->view(), "Details");
275 };
276
277 _window->contentView = navigationView;
278 _window->visible = true;
279 }
280
281 protected:
282 std::shared_ptr<ui::Window> _window;

Callers

nothing calls this directly

Calls 5

deselectMethod · 0.80
setLayoutMethod · 0.45
viewMethod · 0.45
getMethod · 0.45
pushViewMethod · 0.45

Tested by

no test coverage detected