-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bac6305
commit 2fafbbc
Showing
4 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma once | ||
|
||
#include <karm-kira/select.h> | ||
#include <karm-ui/layout.h> | ||
#include <mdi/form-select.h> | ||
|
||
#include "model.h" | ||
|
||
namespace Hideo::Zoo { | ||
|
||
static inline Page PAGE_SELECT{ | ||
Mdi::FORM_SELECT, | ||
"Select", | ||
"A control that allows the user to toggle between checked and not checked.", | ||
[] { | ||
return Kr::select( | ||
Kr::selectValue("Pick something to eat"s), | ||
[] -> Ui::Children { | ||
return { | ||
Kr::selectGroup({ | ||
Kr::selectLabel("Fruits"s), | ||
Kr::selectItem(Ui::NOP, "Apple"s), | ||
Kr::selectItem(Ui::NOP, "Banana"s), | ||
Kr::selectItem(Ui::NOP, "Cherry"s), | ||
}), | ||
Ui::separator(), | ||
Kr::selectGroup({ | ||
Kr::selectLabel("Vegetables"s), | ||
Kr::selectItem(Ui::NOP, "Carrot"s), | ||
Kr::selectItem(Ui::NOP, "Cucumber"s), | ||
Kr::selectItem(Ui::NOP, "Tomato"s), | ||
}), | ||
Ui::separator(), | ||
Kr::selectGroup({ | ||
Kr::selectLabel("Meat"s), | ||
Kr::selectItem(Ui::NOP, "Beef"s), | ||
Kr::selectItem(Ui::NOP, "Chicken"s), | ||
Kr::selectItem(Ui::NOP, "Pork"s), | ||
}), | ||
}; | ||
} | ||
) | | ||
Ui::center(); | ||
}, | ||
}; | ||
|
||
} // namespace Hideo::Zoo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include <karm-ui/anim.h> | ||
#include <karm-ui/layout.h> | ||
#include <karm-ui/popover.h> | ||
#include <karm-ui/scroll.h> | ||
#include <mdi/chevron-down.h> | ||
|
||
#include "select.h" | ||
|
||
namespace Karm::Kira { | ||
|
||
Ui::Child select(Ui::Child value, Ui::Slots slots) { | ||
return Ui::button( | ||
[slots = std::move(slots)](auto &n) { | ||
Ui::showPopover( | ||
n, | ||
n.bound().bottomStart(), | ||
Ui::vflow( | ||
slots() | ||
) | | ||
Ui::vscroll() | | ||
Ui::sizing({n.bound().width, Ui::UNCONSTRAINED}, {Ui::UNCONSTRAINED, 160}) | | ||
Ui::box({ | ||
.borderRadii = 6, | ||
.borderWidth = 1, | ||
.borderFill = Ui::GRAY800, | ||
.backgroundFill = Ui::GRAY900, | ||
.shadowStyle = Gfx::BoxShadow::elevated(4), | ||
}) | | ||
Ui::scaleIn() | ||
); | ||
}, | ||
Ui::ButtonStyle::outline(), | ||
Ui::hflow( | ||
8, | ||
Math::Align::CENTER, | ||
value, | ||
Ui::icon(Mdi::CHEVRON_DOWN) | ||
) | Ui::insets({6, 12, 6, 16}) | | ||
Ui::minSize({Ui::UNCONSTRAINED, 36}) | ||
); | ||
} | ||
|
||
Ui::Child selectValue(String text) { | ||
return Ui::labelMedium(text); | ||
} | ||
|
||
Ui::Child selectLabel(String text) { | ||
return Ui::labelMedium(Ui::GRAY400, text) | | ||
Ui::insets({12, 6, 3, 14}); | ||
} | ||
|
||
Ui::Child selectItem(Ui::OnPress onPress, String t) { | ||
return Ui::hflow( | ||
12, | ||
Math::Align::CENTER, | ||
Ui::text(t) | ||
) | | ||
Ui::insets({6, 6, 6, 10}) | | ||
Ui::minSize({Ui::UNCONSTRAINED, 28}) | | ||
Ui::button( | ||
[onPress = std::move(onPress)](auto &n) { | ||
onPress(n); | ||
Ui::closePopover(n); | ||
}, | ||
Ui::ButtonStyle::subtle() | ||
) | | ||
Ui::insets(4); | ||
} | ||
|
||
Ui::Child selectGroup(Ui::Children children) { | ||
return Ui::vflow(children); | ||
} | ||
|
||
} // namespace Karm::Kira |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include <karm-ui/input.h> | ||
|
||
#include "_prelude.h" | ||
|
||
namespace Karm::Kira { | ||
|
||
Ui::Child select(Ui::Child value, Ui::Slots options); | ||
|
||
Ui::Child selectValue(String text); | ||
|
||
Ui::Child selectLabel(String text); | ||
|
||
Ui::Child selectItem(Ui::OnPress onPress, String t); | ||
|
||
Ui::Child selectGroup(Ui::Children children); | ||
|
||
} // namespace Karm::Kira |