|
| 1 | +#include <karm-kira/scaffold.h> |
| 2 | + |
| 3 | +#include "app.h" |
| 4 | +#include "model.h" |
| 5 | + |
| 6 | +// Pages |
| 7 | +#include "page-alert.h" |
| 8 | +#include "page-avatar.h" |
| 9 | +#include "page-badge.h" |
| 10 | +#include "page-card.h" |
| 11 | +#include "page-checkbox.h" |
| 12 | +#include "page-clock.h" |
| 13 | +#include "page-color-input.h" |
| 14 | +#include "page-context-menu.h" |
| 15 | +#include "page-dialog.h" |
| 16 | +#include "page-focusable.h" |
| 17 | +#include "page-hsv-square.h" |
| 18 | +#include "page-input.h" |
| 19 | +#include "page-navbar.h" |
| 20 | +#include "page-number.h" |
| 21 | +#include "page-print-dialog.h" |
| 22 | +#include "page-progress.h" |
| 23 | +#include "page-radio.h" |
| 24 | +#include "page-resizable.h" |
| 25 | +#include "page-rich-text.h" |
| 26 | +#include "page-rows.h" |
| 27 | +#include "page-select.h" |
| 28 | +#include "page-side-nav.h" |
| 29 | +#include "page-side-panel.h" |
| 30 | +#include "page-slider.h" |
| 31 | +#include "page-titlebar.h" |
| 32 | +#include "page-toggle.h" |
| 33 | + |
| 34 | +namespace Hideo::Zoo { |
| 35 | + |
| 36 | +static Array PAGES = { |
| 37 | + &PAGE_ALERT, |
| 38 | + &PAGE_AVATAR, |
| 39 | + &PAGE_BADGE, |
| 40 | + &PAGE_CARD, |
| 41 | + &PAGE_CHECKBOX, |
| 42 | + &PAGE_CLOCK, |
| 43 | + &PAGE_COLOR_INPUT, |
| 44 | + &PAGE_CONTEXT_MENU, |
| 45 | + &PAGE_DIALOG, |
| 46 | + &PAGE_FOCUS, |
| 47 | + &PAGE_HSV_SQUARE, |
| 48 | + &PAGE_INPUT, |
| 49 | + &PAGE_NAVBAR, |
| 50 | + &PAGE_NUMBER, |
| 51 | + &PAGE_PRINT_DIALOG, |
| 52 | + &PAGE_PROGRESS, |
| 53 | + &PAGE_RADIO, |
| 54 | + &PAGE_RESIZABLE, |
| 55 | + &PAGE_RICHTEXT, |
| 56 | + &PAGE_ROWS, |
| 57 | + &PAGE_SELECT, |
| 58 | + &PAGE_SIDE_PANEL, |
| 59 | + &PAGE_SIDENAV, |
| 60 | + &PAGE_SLIDER, |
| 61 | + &PAGE_TITLEBAR, |
| 62 | + &PAGE_TOGGLE, |
| 63 | +}; |
| 64 | + |
| 65 | +Ui::Child app() { |
| 66 | + return Ui::reducer<Model>([](State const& s) { |
| 67 | + return Kr::scaffold({ |
| 68 | + .icon = Mdi::DUCK, |
| 69 | + .title = "Zoo"s, |
| 70 | + .sidebar = [&] { |
| 71 | + return Kr::sidenav( |
| 72 | + iter(PAGES) |
| 73 | + .mapi([&](Page const* page, usize index) { |
| 74 | + return Kr::sidenavItem( |
| 75 | + index == s.page, |
| 76 | + Model::bind<Switch>(index), |
| 77 | + page->icon, |
| 78 | + page->name |
| 79 | + ); |
| 80 | + }) |
| 81 | + .collect<Ui::Children>() |
| 82 | + ); |
| 83 | + }, |
| 84 | + .body = [&] { |
| 85 | + auto& page = PAGES[s.page]; |
| 86 | + return Ui::vflow( |
| 87 | + Ui::vflow( |
| 88 | + Ui::titleMedium(page->name), |
| 89 | + Ui::empty(4), |
| 90 | + Ui::bodySmall(page->description) |
| 91 | + ) | Ui::insets(16), |
| 92 | + Ui::separator(), |
| 93 | + page->build() | Ui::grow() |
| 94 | + ); |
| 95 | + }, |
| 96 | + }); |
| 97 | + }); |
| 98 | +} |
| 99 | + |
| 100 | +} // namespace Hideo::Zoo |
0 commit comments