Skip to content

Commit 4ea63ec

Browse files
committed
karm-kira: Tweaked text inputs and print-dialog.
1 parent 13ac1b9 commit 4ea63ec

File tree

4 files changed

+63
-25
lines changed

4 files changed

+63
-25
lines changed

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
#include <karm-kira/input.h>
44
#include <karm-ui/layout.h>
5+
#include <mdi/account.h>
6+
#include <mdi/email.h>
57
#include <mdi/form-textbox.h>
8+
#include <mdi/lock.h>
69

710
#include "model.h"
811

@@ -16,9 +19,10 @@ static inline Page PAGE_INPUT{
1619
return Ui::vflow(
1720
16,
1821
Math::Align::CENTER,
19-
Kr::input(Mdi::FORM_TEXTBOX, "Username"s, ""s) | Ui::pinSize({240, Ui::UNCONSTRAINED}),
20-
Kr::input(Mdi::FORM_TEXTBOX, "Email"s, ""s) | Ui::pinSize({240, Ui::UNCONSTRAINED}),
21-
Kr::input(Mdi::FORM_TEXTBOX, "Password"s, ""s) | Ui::pinSize({240, Ui::UNCONSTRAINED})
22+
Kr::input(Mdi::ACCOUNT, "Username"s, ""s) | Ui::pinSize({240, Ui::UNCONSTRAINED}),
23+
Kr::input(Mdi::EMAIL, "Email"s, ""s) | Ui::pinSize({240, Ui::UNCONSTRAINED}),
24+
Kr::input(Mdi::LOCK, "Password"s, ""s) | Ui::pinSize({240, Ui::UNCONSTRAINED}),
25+
Kr::input("Text"s, ""s) | Ui::pinSize({240, Ui::UNCONSTRAINED})
2226
) |
2327
Ui::center();
2428
},

src/libs/karm-kira/input.cpp

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include <karm-ui/focus.h>
2+
#include <karm-ui/layout.h>
3+
#include <karm-ui/view.h>
4+
5+
#include "input.h"
6+
7+
namespace Karm::Kira {
8+
9+
Ui::Child input(Mdi::Icon icon, String placeholder, String text) {
10+
return Ui::hflow(
11+
8,
12+
Math::Align::VCENTER | Math::Align::START,
13+
Ui::icon(icon),
14+
Ui::stack(
15+
text ? Ui::empty() : Ui::labelMedium(Gfx::ZINC600, placeholder),
16+
Ui::input(Ui::TextStyles::labelMedium(), text, NONE)
17+
) | Ui::grow()
18+
) |
19+
Ui::box({
20+
.padding = {6, 12, 6, 12},
21+
.borderRadii = 4,
22+
.borderWidth = 1,
23+
.borderFill = Ui::GRAY800,
24+
}) |
25+
Ui::minSize({Ui::UNCONSTRAINED, 36}) |
26+
Ui::focusable();
27+
}
28+
29+
Ui::Child input(String placeholder, String text) {
30+
return Ui::hflow(
31+
8,
32+
Math::Align::VCENTER | Math::Align::START,
33+
Ui::stack(
34+
text ? Ui::empty() : Ui::labelMedium(Gfx::ZINC600, placeholder),
35+
Ui::input(Ui::TextStyles::labelMedium(), text, NONE)
36+
) | Ui::grow()
37+
) |
38+
Ui::box({
39+
.padding = {6, 12, 6, 12},
40+
.borderRadii = 4,
41+
.borderWidth = 1,
42+
.borderFill = Ui::GRAY800,
43+
}) |
44+
Ui::minSize({Ui::UNCONSTRAINED, 36}) |
45+
Ui::focusable();
46+
}
47+
48+
} // namespace Karm::Kira

src/libs/karm-kira/input.h

+3-22
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,13 @@
11
#pragma once
22

3-
#include <karm-ui/focus.h>
43
#include <karm-ui/input.h>
5-
#include <karm-ui/layout.h>
6-
#include <karm-ui/view.h>
74

85
#include "_prelude.h"
96

107
namespace Karm::Kira {
118

12-
static inline Ui::Child input(Mdi::Icon icon, String placeholder, String text) {
13-
return Ui::hflow(
14-
8,
15-
Math::Align::CENTER,
16-
Ui::icon(icon),
17-
Ui::stack(
18-
text ? Ui::empty() : Ui::labelMedium(Gfx::ZINC600, placeholder),
19-
Ui::input(Ui::TextStyles::labelMedium(), text, NONE)
20-
) | Ui::grow()
21-
) |
22-
Ui::box({
23-
.padding = {6, 12, 6, 12},
24-
.borderRadii = 4,
25-
.borderWidth = 1,
26-
.borderFill = Ui::GRAY800,
27-
}) |
28-
Ui::minSize({Ui::UNCONSTRAINED, 36}) |
29-
Ui::focusable();
30-
}
9+
Ui::Child input(Mdi::Icon icon, String placeholder, String text);
10+
11+
Ui::Child input(String placeholder, String text);
3112

3213
} // namespace Karm::Kira

src/libs/karm-kira/print-dialog.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,19 @@ Ui::Child _paperSelect() {
134134
return select(selectValue("A4"s), [] -> Ui::Children {
135135
Vec<Ui::Child> groups;
136136

137+
bool first = false;
137138
for (auto &serie : Print::SERIES) {
138139
Vec<Ui::Child> items;
139140
items.pushBack(selectLabel(serie.name));
140141
for (auto const &stock : serie.stocks) {
141142
items.pushBack(selectItem(Ui::NOP, stock.name));
142143
}
143144

145+
if (not first)
146+
groups.pushBack(Ui::separator());
144147
groups.pushBack(selectGroup(std::move(items)));
148+
149+
first = false;
145150
}
146151

147152
return groups;

0 commit comments

Comments
 (0)