-
-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy patherror.h
38 lines (32 loc) · 907 Bytes
/
error.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <karm-ui/box.h>
#include <karm-ui/layout.h>
#include <karm-ui/view.h>
#include <mdi/alert-octagon-outline.h>
namespace Karm::Ui {
static inline Child errorScope(Str what, auto callback) {
Res<Child> child = callback();
if (child) {
return child.unwrap();
}
return box(
{
.padding = 12,
.borderRadii = 6,
.borderWidth = 1,
.borderFill = Gfx::RED700,
.backgroundFill = Gfx::RED900,
.foregroundFill = Gfx::RED100,
},
hflow(
6,
icon(Mdi::ALERT_OCTAGON_OUTLINE, 26) | center(),
vflow(
4,
text(TextStyles::titleMedium().withColor(Gfx::WHITE), "Can't display {}", what),
text(Io::toSentenceCase(child.none().msg()).unwrap())
)
)
);
}
} // namespace Karm::Ui