Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class _KapyNotesAppState extends State<KapyNotesApp>
widget.notes.create();
}
widget.rates.loadCache();
_engines = EngineProvider(widget.rates, widget.prefs);
_engines = EngineProvider(widget.rates, widget.prefs, widget.notes.now);
_ready = true;
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted) return;
Expand Down
147 changes: 87 additions & 60 deletions lib/core/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ class CalcPalette extends ThemeExtension<CalcPalette> {
final Color pageBorder;
final Color textDivider;

/// A switch's thumb while it is on, standing on the sage track.
final Color switchThumb;

/// What casts every shadow, with its alpha as the strength: black in dark,
/// the ink at a fraction of that in light, where a black shadow reads as
/// dirt on the paper.
final Color shadow;

/// The shadow a black at [alpha] casts in dark, scaled by [shadow]'s own
/// strength so the dark values stay exact and light ones soften with it.
Color shadowAt(int alpha) => shadow.withAlpha((shadow.a * alpha).round());

/// How much of the desktop the window's chrome lets through: a multiplier on
/// the alpha of every [GlassSurface]. 1 is fully opaque.
///
Expand Down Expand Up @@ -244,6 +256,8 @@ class CalcPalette extends ThemeExtension<CalcPalette> {
required this.accentText,
required this.pageBorder,
required this.textDivider,
required this.switchThumb,
required this.shadow,
this.translucency = 1,
this.paperTranslucency = 1,
});
Expand Down Expand Up @@ -310,6 +324,8 @@ class CalcPalette extends ThemeExtension<CalcPalette> {
Color? accentText,
Color? pageBorder,
Color? textDivider,
Color? switchThumb,
Color? shadow,
double? translucency,
double? paperTranslucency,
}) => CalcPalette(
Expand Down Expand Up @@ -373,6 +389,8 @@ class CalcPalette extends ThemeExtension<CalcPalette> {
accentText: accentText ?? this.accentText,
pageBorder: pageBorder ?? this.pageBorder,
textDivider: textDivider ?? this.textDivider,
switchThumb: switchThumb ?? this.switchThumb,
shadow: shadow ?? this.shadow,
translucency: translucency ?? this.translucency,
paperTranslucency: paperTranslucency ?? this.paperTranslucency,
);
Expand Down Expand Up @@ -445,6 +463,8 @@ class CalcPalette extends ThemeExtension<CalcPalette> {
accentText: mix(accentText, other.accentText),
pageBorder: mix(pageBorder, other.pageBorder),
textDivider: mix(textDivider, other.textDivider),
switchThumb: mix(switchThumb, other.switchThumb),
shadow: mix(shadow, other.shadow),
translucency: translucency + (other.translucency - translucency) * t,
paperTranslucency:
paperTranslucency + (other.paperTranslucency - paperTranslucency) * t,
Expand Down Expand Up @@ -908,14 +928,11 @@ class AppFonts {
class KapyTheme {
const KapyTheme._();

/// A restrained copper accent, used sparingly for focus and active state.
/// It echoes the warm caret in the visual reference without tinting every
/// calculator token or control. The dark theme's accent is Riverbank's
/// sage, which marks what is on, done or open: checkboxes, switches,
/// progress and the open note.
static const brand = Color(0xFFC97849);
/// Riverbank's sage, which marks what is on, done or open: checkboxes,
/// switches, progress and the open note. Deeper in light, where it carries
/// light ink.
static const _darkAccent = Color(0xFF7D9468);
static const _lightAccent = Color(0xFFA85F38);
static const _lightAccent = Color(0xFF56703C);

/// The accent the theme for [brightness] marks focus, the caret and what is
/// on with.
Expand Down Expand Up @@ -1025,72 +1042,82 @@ class KapyTheme {
accentText: Color(0xFF9DB384),
pageBorder: Color(0xFF2E2A25),
textDivider: Color(0xFF554F47),
switchThumb: Color(0xFFE2DCCF),
shadow: Color(0xFF000000),
);

/// A cool, clean paper palette rather than the previous warm stationery.
/// Riverbank light: warm paper, ink-brown text and a deeper sage.
///
/// The dark palette turned over, from the light page in Paper: the page is
/// the lightest layer, the window a step behind it and the rail a step
/// behind that. Edges are warm tints rather than grey lines, shadows come
/// from the ink at low alpha, and sage and clay deepen so that what sits on
/// them keeps its contrast.
static const CalcPalette lightPalette = CalcPalette(
number: Color(0xFF3F4248),
keyword: Color(0xFFA85F38),
unit: Color(0xFF5E6B62),
currency: Color(0xFF5E6B62),
function: Color(0xFFA85F38),
variable: Color(0xFFA85F38),
operator: Color(0xFF73757A),
comment: Color(0xFF919399),
chipNumber: Color(0xFF667254),
chipCurrency: Color(0xFF667254),
chipUnit: Color(0xFF667254),
chipBoolean: Color(0xFF667254),
chipOther: Color(0xFF667254),
textPrimary: Color(0xFF292B30),
textSecondary: Color(0xFF65686E),
textTertiary: Color(0xFF92949A),
separator: Color(0x16000000),
sidebarBackground: Color(0xFFF0EFEC),
editorBackground: Color(0xFFF8F7F4),
gutterBackground: Color(0xFFF4F3EF),
surfaceBackground: Color(0xFFF2F1ED),
controlBackground: Color(0xFFEAE9E5),
controlBorder: Color(0xFFD8D7D2),
selectedBackground: Color(0xFFE2E0DA),
selectedBorder: Color(0xFFA85F38),
selection: Color(0x30C97849),
hover: Color(0xFFE8E7E3),
number: Color(0xFF2A2620),
keyword: Color(0xFF2A2620),
unit: Color(0xFF8A8476),
currency: Color(0xFF8A8476),
function: Color(0xFF2A2620),
variable: Color(0xFF2A2620),
operator: Color(0xFF8A8476),
comment: Color(0xFF8A8476),
chipNumber: Color(0xFF445A2F),
chipCurrency: Color(0xFF445A2F),
chipUnit: Color(0xFF445A2F),
chipBoolean: Color(0xFF445A2F),
chipOther: Color(0xFF445A2F),
textPrimary: Color(0xFF2A2620),
textSecondary: Color(0xFF6F695C),
textTertiary: Color(0xFF8A8476),
separator: Color(0xFFD9D2C1),
sidebarBackground: Color(0xFFF3EFE4),
editorBackground: Color(0xFFFCFAF4),
gutterBackground: Color(0xFFFCFAF4),
surfaceBackground: Color(0xFFFCFAF4),
controlBackground: Color(0xFFEFEADD),
controlBorder: Color(0xFFE2DCCB),
selectedBackground: Color(0xFFE2DCCB),
selectedBorder: Color(0xFF56703C),
selection: Color(0x3356703C),
hover: Color(0xFFEBE5D6),
// The optional notepad style keeps a barely visible fibre. Plain remains
// the default, and dark paper stays completely clean.
paperFiber: Color(0x085B5148),
paperRuling: Color(0x12000000),
railBackground: Color(0xFFEFEADD),
paperRuling: Color(0xFFE6E0D0),
railBackground: Color(0xFFECE6D8),
railBorder: Color(0x0F2A2620),
tonalBackground: Color(0xFF56703C),
tonalForeground: Color(0xFFFCFAF4),
tonalKeyBackground: Color(0xFF445A2F),
tonalKeyText: Color(0xFFE6ECDB),
tonalBackground: Color(0xFFE6ECDB),
tonalForeground: Color(0xFF445A2F),
tonalKeyBackground: Color(0xFFD3DEC2),
tonalKeyText: Color(0xFF56703C),
keycapBackground: Color(0xFFEFEADD),
keycapBorder: Color(0xFFE2DCCB),
keycapBorder: Color(0xFFD9D2C1),
keycapText: Color(0xFF6F695C),
stickyMustard: Color(0xFFF6E7A6),
stickyTeal: Color(0xFFD5E5E6),
stickyOlive: Color(0xFFDCE6C8),
stickyRust: Color(0xFFF5D9C7),
stickySage: Color(0xFFE6ECDB),
scrim: Color(0x33000000),
resultPillBackground: Color(0xFFE6ECDB),
stickyMustard: Color(0xFFF4EBC8),
stickyTeal: Color(0xFFDCE8E6),
stickyOlive: Color(0xFFE6EBD5),
stickyRust: Color(0xFFF2E0D4),
stickySage: Color(0xFFE3EBD8),
scrim: Color(0x332A2620),
resultPillBackground: Color(0xFFE3EBD8),
resultPillText: Color(0xFF445A2F),
totalPillBackground: Color(0xFF56703C),
totalPillText: Color(0xFFFCFAF4),
clay: Color(0xFFD0663B),
textHeading: Color(0xFF292B30),
textSubheading: Color(0xFF3F4248),
textMuted: Color(0xFF55585E),
textDescription: Color(0xFF6B6D73),
cardBackground: Color(0xFFF2F1ED),
paneEdge: Color(0xFFE2E0DA),
switchTrackOff: Color(0xFFDAD8D2),
textHeading: Color(0xFF2A2620),
textSubheading: Color(0xFF3A352D),
textMuted: Color(0xFF4A453B),
textDescription: Color(0xFF6F695C),
cardBackground: Color(0xFFF6F2E8),
paneEdge: Color(0xFFE2DCCB),
switchTrackOff: Color(0xFFDCD5C4),
cardTitle: Color(0xFF2A2620),
accentText: Color(0xFF56703C),
pageBorder: Color(0xFFE3E1DC),
textDivider: Color(0xFFB9BBC0),
pageBorder: Color(0xFFE6E0D0),
textDivider: Color(0xFFBDB6A6),
switchThumb: Color(0xFFFCFAF4),
shadow: Color(0x662A2620),
);

/// Transparency mode.
Expand Down Expand Up @@ -1152,7 +1179,7 @@ class KapyTheme {
final dark = brightness == Brightness.dark;
final compactControls = AppPlatform.isDesktop;
final accent = accentFor(brightness);
final onAccent = dark ? const Color(0xFF1C1A17) : Colors.white;
final onAccent = dark ? const Color(0xFF1C1A17) : const Color(0xFFFCFAF4);
final buttonHeight = AppControlMetrics.buttonHeight;
final iconButtonExtent = AppControlMetrics.iconButtonExtent;
final tapTarget = compactControls
Expand All @@ -1161,7 +1188,7 @@ class KapyTheme {

final scheme =
ColorScheme.fromSeed(
seedColor: dark ? _darkAccent : brand,
seedColor: accent,
brightness: brightness,
).copyWith(
primary: accent,
Expand Down
7 changes: 5 additions & 2 deletions lib/data/engine_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ import 'layout_prefs.dart';
import 'rates.dart';

/// Keeps a [CalcEngine] in step with the current exchange rates and the
/// number system the user has chosen.
/// number system the user has chosen, dating it by [_now]: the clock the
/// notes are dated by, so "today" in a line and "Today" on its card agree.
///
/// The engine is immutable in both, so either change means building a new
/// one rather than patching it — which also guarantees no line is ever
/// evaluated against a half-updated currency table.
class EngineProvider extends ChangeNotifier {
final RatesRepository _rates;
final LayoutPrefs _prefs;
final DateTime Function() _now;

late CalcEngine _engine;
late Highlighter _highlighter;
int _ratesRevision = -1;
late DigitGrouping _grouping;
String? _timeZoneId;

EngineProvider(this._rates, this._prefs) {
EngineProvider(this._rates, this._prefs, this._now) {
_grouping = _prefs.digitGrouping;
_timeZoneId = _prefs.timeZoneId;
_rebuild();
Expand Down Expand Up @@ -58,6 +60,7 @@ class EngineProvider extends ChangeNotifier {
ratesPerUsd: _rates.rates,
grouping: _grouping,
timeZoneId: _timeZoneId,
now: _now,
);
_highlighter = Highlighter(_engine.registry);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/instant_capture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class _InstantCaptureAppState extends State<InstantCaptureApp>
@override
Widget build(BuildContext context) {
return WidgetsApp(
color: const Color(0xFFFAF9F7),
color: KapyTheme.lightPalette.editorBackground,
debugShowCheckedModeBanner: false,
builder: (context, _) =>
_CaptureSurface(controller: widget.controller, focusNode: _focusNode),
Expand Down
16 changes: 8 additions & 8 deletions lib/ui/notes_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ const _cardRadius = BorderRadius.only(
bottomRight: Radius.circular(14),
);

const _cardShadow = [
BoxShadow(color: Color(0x33000000), offset: Offset(0, 1)),
List<BoxShadow> _cardShadow(CalcPalette palette) => [
BoxShadow(color: palette.shadowAt(0x33), offset: const Offset(0, 1)),
BoxShadow(
color: Color(0x73000000),
color: palette.shadowAt(0x73),
offset: Offset(0, 8),
blurRadius: 14,
spreadRadius: -10,
Expand Down Expand Up @@ -302,7 +302,7 @@ class NoteCardFace extends StatelessWidget {
: blank
? Border.all(color: palette.separator)
: null,
boxShadow: _cardShadow,
boxShadow: _cardShadow(palette),
),
child: Stack(
children: [
Expand Down Expand Up @@ -744,9 +744,9 @@ class NotesListControls extends StatelessWidget {
? BoxDecoration(
color: palette.selectedBackground,
borderRadius: BorderRadius.circular(7),
boxShadow: const [
boxShadow: [
BoxShadow(
color: Color(0x4D000000),
color: palette.shadowAt(0x4D),
offset: Offset(0, 1),
blurRadius: 2,
),
Expand Down Expand Up @@ -988,9 +988,9 @@ class _MediaMenu extends StatelessWidget {
color: palette.controlBackground,
border: Border.all(color: palette.separator),
borderRadius: BorderRadius.circular(12),
boxShadow: const [
boxShadow: [
BoxShadow(
color: Color(0x80000000),
color: palette.shadowAt(0x80),
offset: Offset(0, 12),
blurRadius: 28,
spreadRadius: -14,
Expand Down
36 changes: 22 additions & 14 deletions lib/ui/page_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import '../core/theme.dart';

/// The page the open note is written on: a rounded sheet a step lighter than
/// the window, which clips whatever is on it to its corners.
///
/// In glass mode the sheet is only its edge. Everything on it paints its own
/// translucent paper, the page toolbar included, so a fill here would thicken
/// the glass under all of it, and a shadow would show through the page as a
/// dark slab.
class PageCard extends StatelessWidget {
const PageCard({super.key, required this.child});

Expand All @@ -15,25 +20,28 @@ class PageCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final palette = context.palette;
final glass = palette.isGlass;
return DecoratedBox(
key: const ValueKey('page-card'),
decoration: BoxDecoration(
color: palette.paperColor,
color: glass ? null : palette.paperColor,
borderRadius: const BorderRadius.all(Radius.circular(radius)),
border: Border.all(color: palette.pageBorder, width: borderWidth),
boxShadow: const [
BoxShadow(
color: Color(0x40000000),
offset: Offset(0, 1),
blurRadius: 2,
),
BoxShadow(
color: Color(0x66000000),
offset: Offset(0, 16),
blurRadius: 32,
spreadRadius: -20,
),
],
boxShadow: glass
? null
: [
BoxShadow(
color: palette.shadowAt(0x40),
offset: Offset(0, 1),
blurRadius: 2,
),
BoxShadow(
color: palette.shadowAt(0x66),
offset: Offset(0, 16),
blurRadius: 32,
spreadRadius: -20,
),
],
),
child: Padding(
padding: const EdgeInsets.all(borderWidth),
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/page_toolbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ class PageToolbar extends StatelessWidget {
final newNoteShortcut = this.newNoteShortcut;
final updates = this.updates;

return SizedBox(
return Container(
key: const ValueKey('page-toolbar'),
height: AppControlMetrics.scaleBar(context, height),
color: palette.isGlass ? palette.paperColor : null,
child: Stack(
children: [
const Positioned.fill(
Expand Down
Loading
Loading