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,120 @@
// SPDX-License-Identifier: GPL-3.0-only
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
export module Nostro.Ui:Draw;
import std;
import :Geometry;
import :Text;
// What a frame draws, as a list the window turns into its own items and the tests read: rounded boxes, circles and
// lines of text, in layers. The window library draws a batch in one pass in which every shape comes before every
// text, so a shape meant to cover text drawn earlier needs a pass of its own; and a pass is cut to one box. The list
// keeps the order things were drawn in by starting a new batch where one pass could not show it: where the clip
// changes, and where a shape would land on text already in the batch. Each batch is a pass over the whole window, so
// a screen is drawn with few of them: its layers, and a clip per scrolling area.
export namespace Nostro::Ui {
enum class TextAlign : std::uint8_t {
Left, // x is where the text starts
Center, // x is its middle
Right // x is where it ends
};
// Drawn in this order, whatever order a screen draws them in.
enum class Layer : std::uint8_t {
Background,
Content, // what scrolls
Chrome, // the bars around it
Overlay, // a sheet or a dialog, and the scrim under it
Popup // a menu or a notice, above everything
};
inline constexpr std::size_t layerCount = 5;
// A box's corner radii, clockwise from the top left.
struct Corners {
float topLeft = 0;
float topRight = 0;
float bottomRight = 0;
float bottomLeft = 0;
static constexpr Corners All(float radius) noexcept {
return {radius, radius, radius, radius};
}
static constexpr Corners Top(float radius) noexcept {
return {radius, radius, 0, 0};
}
friend bool operator==(const Corners&, const Corners&) = default;
};
struct RectItem {
Box box;
Color color;
Corners corners;
float outline = 0; // the width of a line along its edge, inside the box
Color outlineColor;
};
struct CircleItem {
Point center;
float radius = 0;
Color color;
float outline = 0;
Color outlineColor;
};
struct TextItem {
std::string text;
float x = 0;
float baseline = 0;
FontFace face = FontFace::Regular;
float px = 0;
Color color;
TextAlign align = TextAlign::Left;
Box bounds; // the line's box: its width, from its ascent to a line's height below that
};
// One pass: the shapes, then the text over them, all cut to `clip`.
struct Batch {
std::optional<Box> clip; // nothing: the whole window
std::vector<RectItem> rects;
std::vector<CircleItem> circles;
std::vector<TextItem> texts;
};
class DrawList {
public:
// `bounds` is the window: what lies outside it, or outside the clip, is not kept.
DrawList(const TextMeasure& measure, Box bounds);
// What is drawn from here on goes to this layer.
void SetLayer(Layer layer) noexcept;
Layer CurrentLayer() const noexcept;
// Cuts what is drawn from here on, in any layer, to `box` within the clip there was, until the matching PopClip.
void PushClip(Box box);
void PopClip();
void Rect(const RectItem& item);
void Rect(Box box, Color color, float radius = 0);
void Circle(const CircleItem& item);
void Circle(Point center, float radius, Color color);
// One line; returns its width.
float Text(std::string_view text, float x, float baseline, FontFace face, float px, Color color, TextAlign align = TextAlign::Left);
std::span<const Batch> Batches(Layer layer) const noexcept;
std::size_t BatchCount() const noexcept;
// Every line of text in the list, in the order it is drawn: what a screen says.
std::vector<std::string> Texts() const;
private:
// The batch a shape that covers `box`, or a text, goes into.
Batch& BatchFor(std::optional<Box> shape);
bool Visible(Box box) const noexcept;
const TextMeasure* measure;
Box bounds;
Layer layer = Layer::Background;
std::vector<Box> clips;
std::array<std::vector<Batch>, layerCount> layers;
};
}