Skip to content

Commit 29b29e2

Browse files
committed
vaev-browser: Added spinner when reloading the page.
1 parent 38bb772 commit 29b29e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1296
-5
lines changed

src/apps/hideo-zoo/app.cpp

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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

src/apps/hideo-zoo/app.h

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
#include <karm-ui/node.h>
4+
5+
namespace Hideo::Zoo {
6+
7+
Ui::Child app();
8+
9+
} // namespace Hideo::Zoo

src/apps/hideo-zoo/main/main.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <karm-sys/entry.h>
2+
#include <karm-ui/app.h>
3+
4+
#include "../app.h"
5+
6+
Async::Task<> entryPointAsync(Sys::Context& ctx) {
7+
co_return co_await Ui::runAsync(ctx, Hideo::Zoo::app());
8+
}

src/apps/hideo-zoo/main/manifest.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://schemas.cute.engineering/stable/cutekit.manifest.component.v1",
3+
"id": "hideo-zoo.main",
4+
"props": {
5+
"cpp-excluded": true
6+
},
7+
"type": "exe",
8+
"requires": [
9+
"hideo-zoo"
10+
]
11+
}

src/apps/hideo-zoo/manifest.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "https://schemas.cute.engineering/stable/cutekit.manifest.component.v1",
3+
"id": "hideo-zoo",
4+
"type": "lib",
5+
"description": "Showcase the beautiful Kira components library",
6+
"requires": [
7+
"karm-kira"
8+
]
9+
}

src/apps/hideo-zoo/model.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "model.h"
2+
3+
namespace Hideo::Zoo {
4+
5+
Ui::Task<Action> reduce(State& s, Action action) {
6+
action.visit(
7+
[&](Switch action) {
8+
s.page = action.page;
9+
}
10+
);
11+
12+
return NONE;
13+
}
14+
15+
} // namespace Hideo::Zoo

src/apps/hideo-zoo/model.h

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#pragma once
2+
3+
#include <karm-ui/reducer.h>
4+
#include <mdi/_prelude.h>
5+
6+
namespace Hideo::Zoo {
7+
8+
struct Page {
9+
Mdi::Icon icon;
10+
Str name;
11+
Str description;
12+
Func<Ui::Child()> build;
13+
};
14+
15+
struct State {
16+
usize page;
17+
};
18+
19+
struct Switch {
20+
usize page;
21+
};
22+
23+
using Action = Union<Switch>;
24+
25+
Ui::Task<Action> reduce(State& s, Action action);
26+
27+
using Model = Ui::Model<State, Action, reduce>;
28+
29+
} // namespace Hideo::Zoo

src/apps/hideo-zoo/page-alert.h

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#pragma once
2+
3+
#include <karm-kira/dialog.h>
4+
#include <karm-ui/dialog.h>
5+
#include <karm-ui/input.h>
6+
#include <karm-ui/layout.h>
7+
#include <mdi/alert.h>
8+
9+
#include "model.h"
10+
11+
namespace Hideo::Zoo {
12+
13+
static inline Page PAGE_ALERT{
14+
Mdi::ALERT,
15+
"Alert",
16+
"A modal dialog that interrupts the user with important content and expects a response.",
17+
[] {
18+
return Ui::button(
19+
[](auto& n) {
20+
Ui::showDialog(
21+
n,
22+
Kr::dialogContent({
23+
Kr::dialogHeader({
24+
Kr::dialogTitle("Are you absolutely sure?"s),
25+
Kr::dialogDescription("This action cannot be undone. This will permanently delete your account and remove your data from our servers."s),
26+
}),
27+
Kr::dialogFooter({
28+
Kr::dialogCancel(),
29+
Kr::dialogAction(Ui::NOP, "Continue"s),
30+
}),
31+
})
32+
);
33+
},
34+
"Show alert"
35+
) |
36+
Ui::center();
37+
},
38+
};
39+
40+
} // namespace Hideo::Zoo

src/apps/hideo-zoo/page-avatar.h

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#pragma once
2+
3+
#include <karm-kira/avatar.h>
4+
#include <karm-ui/layout.h>
5+
#include <mdi/account-circle.h>
6+
#include <mdi/cat.h>
7+
8+
#include "model.h"
9+
10+
namespace Hideo::Zoo {
11+
12+
static inline Page PAGE_AVATAR{
13+
Mdi::ACCOUNT_CIRCLE,
14+
"Avatar",
15+
"An image element with a fallback for representing the user.",
16+
[] {
17+
return Ui::hflow(
18+
16,
19+
Kr::avatar(),
20+
Kr::avatar("CV"s),
21+
Kr::avatar(Mdi::CAT)
22+
) |
23+
Ui::center();
24+
},
25+
};
26+
27+
} // namespace Hideo::Zoo

src/apps/hideo-zoo/page-badge.h

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#pragma once
2+
3+
#include <karm-kira/badge.h>
4+
#include <karm-ui/layout.h>
5+
#include <mdi/card.h>
6+
7+
#include "model.h"
8+
9+
namespace Hideo::Zoo {
10+
11+
static inline Page PAGE_BADGE{
12+
Mdi::CARD,
13+
"Badge",
14+
"Displays a badge or a component that looks like a badge.",
15+
[] {
16+
return Ui::vflow(
17+
16,
18+
Math::Align::CENTER,
19+
Kr::badge(Kr::BadgeStyle::INFO, "Info"s),
20+
Kr::badge(Kr::BadgeStyle::SUCCESS, "Success"s),
21+
Kr::badge(Kr::BadgeStyle::WARNING, "Warning"s),
22+
Kr::badge(Kr::BadgeStyle::ERROR, "Error"s),
23+
Kr::badge(Gfx::GREEN, "New"s)
24+
) |
25+
Ui::center();
26+
},
27+
};
28+
29+
} // namespace Hideo::Zoo

src/apps/hideo-zoo/page-card.h

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#pragma once
2+
3+
#include <karm-kira/card.h>
4+
#include <karm-ui/layout.h>
5+
#include <mdi/rectangle.h>
6+
7+
#include "model.h"
8+
9+
namespace Hideo::Zoo {
10+
11+
static inline Page PAGE_CARD{
12+
Mdi::RECTANGLE,
13+
"Card",
14+
"A container that groups and styles its children.",
15+
[] {
16+
return Ui::labelMedium(
17+
Ui::GRAY700,
18+
"This is a card"
19+
) |
20+
Ui::center() |
21+
Ui::pinSize({400, 300}) |
22+
Kr::card() | Ui::center();
23+
},
24+
};
25+
26+
} // namespace Hideo::Zoo

src/apps/hideo-zoo/page-checkbox.h

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#pragma once
2+
3+
#include <karm-kira/checkbox.h>
4+
#include <karm-ui/layout.h>
5+
#include <mdi/checkbox-marked.h>
6+
7+
#include "model.h"
8+
9+
namespace Hideo::Zoo {
10+
11+
static inline Page PAGE_CHECKBOX{
12+
Mdi::CHECKBOX_MARKED,
13+
"Checkbox",
14+
"A control that allows the user to toggle between checked and not checked.",
15+
[] {
16+
return Kr::checkbox(
17+
true,
18+
NONE
19+
) |
20+
Ui::center();
21+
},
22+
};
23+
24+
} // namespace Hideo::Zoo

src/apps/hideo-zoo/page-clock.h

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#pragma once
2+
3+
#include <karm-ui/layout.h>
4+
#include <mdi/clock.h>
5+
6+
#include "model.h"
7+
8+
import Karm.Kira;
9+
10+
namespace Hideo::Zoo {
11+
12+
static inline Page PAGE_CLOCK{
13+
Mdi::CLOCK,
14+
"Clock",
15+
"An analogue clock that display the time",
16+
[] {
17+
return Kr::clock({}) |
18+
Ui::pinSize({400, 300}) |
19+
Ui::center();
20+
},
21+
};
22+
23+
} // namespace Hideo::Zoo

src/apps/hideo-zoo/page-color-input.h

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#pragma once
2+
3+
#include <karm-kira/color-input.h>
4+
#include <karm-ui/layout.h>
5+
#include <mdi/palette.h>
6+
7+
#include "model.h"
8+
9+
namespace Hideo::Zoo {
10+
11+
static inline Page PAGE_COLOR_INPUT{
12+
Mdi::PALETTE,
13+
"Color Input",
14+
"A control that allows the user to pick a color.",
15+
[] {
16+
return Kr::colorInput(
17+
Gfx::RED,
18+
NONE
19+
) |
20+
Ui::center();
21+
},
22+
};
23+
24+
} // namespace Hideo::Zoo

0 commit comments

Comments
 (0)