Nostro/interfaces/Nostro.Ui-Theme.cppm
Jorijn van der Graaf 5b4037955b 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>
2026-11-19 12:27:14 +01:00

66 lines
3.2 KiB
C++

// SPDX-License-Identifier: GPL-3.0-only
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
export module Nostro.Ui:Theme;
import std;
import :Geometry;
// The colours and sizes every widget draws with. The colours follow the system: light or dark, and its accent
// colour. The sizes are the design's (dp), turned into pixels where they are used.
export namespace Nostro::Ui {
struct Theme {
Color background{0.96f, 0.96f, 0.97f}; // behind everything
Color surface{1.0f, 1.0f, 1.0f}; // bars, cards, sheets, fields
Color surfaceAlt{0.93f, 0.93f, 0.94f}; // what stands out from a surface: a chip, a selected tab
Color text{0.11f, 0.11f, 0.12f};
Color muted{0.43f, 0.43f, 0.45f}; // secondary text
Color accent{0.18f, 0.44f, 0.93f};
Color onAccent{1.0f, 1.0f, 1.0f}; // text on the accent colour
Color divider{0.88f, 0.88f, 0.89f};
Color positive{0.10f, 0.53f, 0.25f}; // money coming in
Color warning{1.0f, 0.95f, 0.80f}; // a notice's ground
Color onWarning{0.40f, 0.30f, 0.01f};
Color danger{0.80f, 0.16f, 0.16f}; // an error, a step that cannot be undone
Color onDanger{1.0f, 1.0f, 1.0f};
Color scrim{0.0f, 0.0f, 0.0f, 0.35f}; // over what a sheet covers
bool dark = false;
static Theme Light();
static Theme Dark();
// The system's accent colour, with text on it dark or light as its brightness asks.
void Accent(Color color);
// A control's colour while the pointer is over it, and while it is pressed: tinted towards the text colour, so
// the change shows on a light theme and on a dark one.
Color Hovered(Color color) const;
Color Pressed(Color color) const;
// The one taken of a few choices that stand on the quiet ground: lighter than that ground, as what is raised
// from it would be, on a light theme and on a dark one.
Color Taken() const;
};
// Text sizes, in dp.
namespace TextSize {
inline constexpr float display = 32; // a balance
inline constexpr float title = 22; // a screen's title
inline constexpr float heading = 18;
inline constexpr float body = 16;
inline constexpr float label = 14;
inline constexpr float caption = 12;
}
// Distances, in dp.
namespace Size {
inline constexpr float unit = 4; // every gap is a multiple of it
inline constexpr float gutter = 16; // between content and the window's edge
inline constexpr float touch = 48; // the least a finger can hit
inline constexpr float control = 48; // a button's and a field's height
inline constexpr float row = 64; // a list row with two lines
inline constexpr float bar = 56; // the top and bottom bars
inline constexpr float radius = 12; // cards and sheets
inline constexpr float controlRadius = 8;
inline constexpr float contentMax = 640; // a form or a list does not grow wider than this
inline constexpr float pull = 64; // how far down a list is pulled before letting go reads it again
}
}