feat(app): add the Nostro app, a window for phones and desktops

Linux phones have no banking apps, and a command line is no answer on a
phone. The app does everything the nostro command does and, like it, only
talks to nostrod: it holds no key and no token.

- Nostro.Ui, a toolkit whose screens are functions that fill a frame, ported
  from imsd-messages ca5cd72d; Nostro.App, the app's state, forms and screens;
  Nostro.Ui.Shell, which puts them on a Wayland window with Crafter.Graphics;
  nostro-app; and Nostro.DebugCommands for the --debug-api build.
- Client: every method also in an asynchronous form for an sd-event loop,
  with DaemonMissing and OutcomeUnknown.
- nostrod's Flatpak is net.catcrafts.Nostrod now and the app takes
  net.catcrafts.Nostro; install.sh moves the state. The app's Flatpak, both
  Flatpaks cross-built for aarch64, and the licence texts they carry.
- nostro-fake-system, a made-up bus and bank with a real nostrod on them, to
  look at the app against. The README's screenshots are taken on it.
- The nostro command: an API key's environment is the key's own to say, so
  --sandbox is for bunq-oauth alone, and a virtual card is listed as VIRTUAL.

The published contract changes in three places, before any release (design
rule 10):
- Transactions' query takes `stored`: answered from what nostrod has stored,
  without asking the bank. The app searches with it; before, every search was
  a call to bunq.
- AddBunq's `environment` no longer chooses over what the key says of itself:
  a key of the other environment is refused.
- SetCardStatus refuses to freeze or unfreeze a virtual card. bunq reports one
  as DEACTIVATED however well it pays, and leaves it as it is when asked,
  without an error.

The app is GPL-3.0-only, the library stays LGPL-3.0-only, and no code moved
from one to the other (design rule 13). Transaction's schema is unchanged.

Verified: the 17 tests pass with every line, function and region of what they
link run, and the five lint runs are clean. Every screen was looked at on the
made-up system, at a phone's and a desktop's sizes in the light and the dark
look, on Plasma under Wayland. What is said of bunq's cards comes from its
sandbox, with throwaway users, and from one real virtual card. Known to have
been used against production: connecting, and reading accounts, payments and
cards. Not known to have been tried: a payment from the app against bunq,
OAuth against bunq, and anything on a phone.

Building the app takes --graphics=, a Crafter.Graphics checkout on its branch
claude/nostro-app, until that branch is merged and pinned here.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-11-19 12:27:14 +01:00
commit 5b4037955b
106 changed files with 17804 additions and 289 deletions

View file

@ -0,0 +1,188 @@
// SPDX-License-Identifier: GPL-3.0-only
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
export module Nostro.Ui:Widgets;
import std;
import :Geometry;
import :Text;
import :Edit;
import :Draw;
import :Theme;
import :Input;
import :Context;
// What a screen is built from. Each widget is a function: given a frame and a box, it draws itself there and names
// the regions that can be pressed. It keeps nothing; what must outlive the frame (a field's text, the focus, a
// list's position) is the caller's or the Context's. Sizes are the design's, turned into pixels by the frame.
export namespace Nostro::Ui {
struct TextStyle {
FontFace face = FontFace::Regular;
float sizeDp = TextSize::body;
Color color;
TextAlign align = TextAlign::Left;
};
// The styles most text is set in, in the frame's colours.
TextStyle Body(const Frame& frame);
TextStyle Strong(const Frame& frame); // the body's size, heavier
TextStyle Muted(const Frame& frame); // secondary text, a size down
TextStyle Caption(const Frame& frame);
TextStyle Heading(const Frame& frame);
// One line in the middle of the box's height, cut with an ellipsis where it does not fit. A Center or Right
// alignment sets it against the box's middle or its right edge.
void Label(Frame& frame, Box box, std::string_view text, const TextStyle& style);
// Text wrapped to the box's width from its top; returns how tall it came out, whatever the box's height.
float Paragraph(Frame& frame, Box box, std::string_view text, const TextStyle& style);
float ParagraphHeight(Frame& frame, float width, std::string_view text, const TextStyle& style);
enum class ButtonKind : std::uint8_t {
Filled, // the one thing to do here
Tonal, // another thing to do
Plain, // text alone: an action in a bar or beside a button
Danger // a step that cannot be undone
};
struct ButtonOptions {
std::string key;
std::string label;
ButtonKind kind = ButtonKind::Filled;
bool enabled = true;
std::function<void()> onTap;
};
// Drawn in the box. The area that takes a press is the box and, for one lower than a finger needs, as much above
// and below it as makes up for that: leave that room between two of them.
void Button(Frame& frame, Box box, const ButtonOptions& options);
// How wide a button is at least, for its label.
float ButtonWidth(const Frame& frame, std::string_view label);
struct RowOptions {
std::string key;
std::string title;
std::string subtitle; // a second line, muted
std::string trailing; // at the right: an amount
std::string trailingSub; // under it: a date
std::optional<Color> trailingColor;
std::string badge; // a small mark after the title: "Sandbox"
std::optional<bool> selected; // a choice among rows, drawn as a radio button
bool chevron = false; // leads somewhere
bool enabled = true;
bool divider = true;
std::function<void()> onTap;
std::function<void()> onLongPress;
};
void ListRow(Frame& frame, Box box, const RowOptions& options);
struct ValueOptions {
std::string key;
std::string label;
std::string value;
float labelWidth = 112; // the room the label has before the value, in dp
std::function<void()> onTap; // nothing: it is only read
std::function<void()> onLongPress;
};
// A label and beside it what it stands for, wrapped to the room there is: a line of a sheet that says what
// something is. With an action it is a row that can be pressed, a finger tall in a window as narrow as a phone and
// closer to the next under a pointer. The text keeps clear of the box's sides, which a press is drawn up to. Drawn
// at the box's top and as wide as it; returns how tall it came out, which ValueRowHeight says beforehand.
float ValueRow(Frame& frame, Box box, const ValueOptions& options);
float ValueRowHeight(Frame& frame, float width, const ValueOptions& options);
struct FieldOptions {
std::string key;
std::string label;
std::string placeholder;
std::string prefix; // before the text, inside the field: a currency's symbol
std::string error; // under the field, in place of the helper
std::string helper;
std::optional<TextPurpose> purpose; // by default what the field's kind asks for
std::optional<std::uint32_t> hints;
bool enabled = true;
std::function<void()> onChange;
std::function<void()> onSubmit;
};
// A text field with its label above and its error or helper below, at the box's top and as wide as it; returns how
// tall it came out.
float TextField(Frame& frame, Box box, EditState& edit, const FieldOptions& options);
// How tall a field with these options comes out in a box that wide, for what must know before it is drawn.
float FieldHeight(Frame& frame, float width, const FieldOptions& options);
struct ChoiceOptions {
std::string key;
std::vector<std::string> labels;
std::size_t selected = 0;
bool enabled = true;
std::function<void(std::size_t)> onSelect;
};
// A few choices side by side, one of them taken: a box of segments.
void Segmented(Frame& frame, Box box, const ChoiceOptions& options);
// The sections of a screen, one of them shown: a strip with a line under the one that is.
void Tabs(Frame& frame, Box box, const ChoiceOptions& options);
enum class BannerKind : std::uint8_t {
Info,
Warning,
Error
};
struct BannerOptions {
std::string key;
BannerKind kind = BannerKind::Info;
std::string text;
std::string action; // a thing to do about it
std::function<void()> onAction;
std::function<void()> onDismiss; // nothing: it cannot be closed
};
// A notice across the box's width at its top; returns how tall it came out.
float Banner(Frame& frame, Box box, const BannerOptions& options);
// A small rounded mark: a status. ChipWidth is how wide it comes out.
void Chip(Frame& frame, Box box, std::string_view text, Color ground, Color color);
float ChipWidth(const Frame& frame, std::string_view text);
// A line along the box's bottom edge.
void Divider(Frame& frame, Box box);
// The ground where something is still being fetched: a bar of the box's width, less for a `fraction` under 1.
void Skeleton(Frame& frame, Box box, float fraction = 1.0f);
struct BarAction {
std::string key;
std::string label;
bool enabled = true;
std::function<void()> onTap;
};
struct TopBarOptions {
std::string title;
std::function<void()> onBack; // nothing: no way back from here
std::vector<BarAction> actions;
};
// The bar along an area's top; returns the area under it.
Box TopBar(Frame& frame, Box area, const TopBarOptions& options);
struct NavItem {
std::string key;
std::string label;
std::string detail; // beside the label, where there is room: a balance
bool selected = false;
bool header = false; // names a group, and cannot be pressed
std::function<void()> onTap;
};
// The app's places along an area's bottom, for a window as narrow as a phone; returns the area above it.
Box NavBar(Frame& frame, Box area, std::span<const NavItem> items);
// The same down an area's left side, `widthDp` wide, for a wider window; returns the area beside it.
Box Sidebar(Frame& frame, Box area, float widthDp, std::span<const NavItem> items);
struct SheetOptions {
std::string key;
std::string title;
float contentHeight = 0; // how tall the body wants to be, in pixels
std::function<void()> onDismiss; // a tap beside it, or Escape
};
// What is asked or shown over a screen: a sheet from the bottom edge in a narrow window, a dialog in the middle of a
// wider one, with what it covers dimmed and out of reach. `body` draws into the box it is given.
void Sheet(Frame& frame, const SheetOptions& options, const std::function<void(Box)>& body);
// How wide the box is that a sheet gives its body in this frame, for working out how tall the body wants to be.
float SheetBodyWidth(const Frame& frame);
}