#pragma once // Spec: SPEC.md UX-VIEWS-02. Form-style controls: Toggle, menu Picker, compact DatePicker, Form sections, // TabView, character counter helpers. Metrics in spec/Layout.hpp. #include #include #include #include "ui/Overlays.hpp" #include "ui/Views.hpp" namespace dp::ui { // Wrap a view so a tap reports its on-screen rect (anchors for menus and popovers). ViewPtr OnTapRect(ViewPtr content, std::function handler); ViewPtr Switch(BoolBinding value, Color tint); ViewPtr Toggle(ViewPtr label, BoolBinding value, Color tint); struct PickerOption { std::string title; int tag = 0; }; // SwiftUI Picker with the default (menu) style inside a form row. ViewPtr MenuPicker(ViewPtr label, std::vector options, int selectedTag, std::function onSelect); struct CivilDate { int year = 2000; unsigned month = 1; unsigned day = 1; bool operator==(const CivilDate&) const = default; static CivilDate today(); bool after(const CivilDate& o) const; }; // Compact date picker; selection limited to dates up to `maxDate`. ViewPtr DatePicker(ViewPtr label, std::function get, std::function set, CivilDate maxDate); struct FormSection { std::string header; std::string footer; std::vector rows; }; // Inset grouped form (rounded cards on BG_2, rows on BG_1) inside a vertical ScrollView. ViewPtr Form(std::vector sections, ScrollOptions scroll = {}); // A card of stacked rows (separators between), used by Form and by custom screens. ViewPtr GroupedCard(std::vector rows, Color background); ViewPtr FormRow(ViewPtr content); // horizontal padding 16, min height 44 struct TabItem { std::string title; std::string icon; int badge = 0; std::function content; }; // Bottom tab bar plus selected content. `onReselect` fires when the selected tab is tapped again. ViewPtr TabView(std::vector tabs, int selected, std::function onSelect, std::function onReselect); // "12/500" character counter (monospaced 12, FG_2, red when out of range). ViewPtr CharacterCounter(int count, int maxCount, int minCount = -1); } // namespace dp::ui