diff --git a/lib/app.dart b/lib/app.dart index d2a97ce..e1e9673 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -332,7 +332,7 @@ class _KapyNotesAppState extends State 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; diff --git a/lib/core/theme.dart b/lib/core/theme.dart index c356a25..4f81254 100644 --- a/lib/core/theme.dart +++ b/lib/core/theme.dart @@ -116,6 +116,18 @@ class CalcPalette extends ThemeExtension { 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. /// @@ -244,6 +256,8 @@ class CalcPalette extends ThemeExtension { required this.accentText, required this.pageBorder, required this.textDivider, + required this.switchThumb, + required this.shadow, this.translucency = 1, this.paperTranslucency = 1, }); @@ -310,6 +324,8 @@ class CalcPalette extends ThemeExtension { Color? accentText, Color? pageBorder, Color? textDivider, + Color? switchThumb, + Color? shadow, double? translucency, double? paperTranslucency, }) => CalcPalette( @@ -373,6 +389,8 @@ class CalcPalette extends ThemeExtension { 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, ); @@ -445,6 +463,8 @@ class CalcPalette extends ThemeExtension { 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, @@ -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. @@ -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. @@ -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 @@ -1161,7 +1188,7 @@ class KapyTheme { final scheme = ColorScheme.fromSeed( - seedColor: dark ? _darkAccent : brand, + seedColor: accent, brightness: brightness, ).copyWith( primary: accent, diff --git a/lib/data/engine_provider.dart b/lib/data/engine_provider.dart index bf886c3..21a973a 100644 --- a/lib/data/engine_provider.dart +++ b/lib/data/engine_provider.dart @@ -7,7 +7,8 @@ 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 @@ -15,6 +16,7 @@ import 'rates.dart'; class EngineProvider extends ChangeNotifier { final RatesRepository _rates; final LayoutPrefs _prefs; + final DateTime Function() _now; late CalcEngine _engine; late Highlighter _highlighter; @@ -22,7 +24,7 @@ class EngineProvider extends ChangeNotifier { late DigitGrouping _grouping; String? _timeZoneId; - EngineProvider(this._rates, this._prefs) { + EngineProvider(this._rates, this._prefs, this._now) { _grouping = _prefs.digitGrouping; _timeZoneId = _prefs.timeZoneId; _rebuild(); @@ -58,6 +60,7 @@ class EngineProvider extends ChangeNotifier { ratesPerUsd: _rates.rates, grouping: _grouping, timeZoneId: _timeZoneId, + now: _now, ); _highlighter = Highlighter(_engine.registry); } diff --git a/lib/ui/instant_capture.dart b/lib/ui/instant_capture.dart index 05e8e28..e50a7bb 100644 --- a/lib/ui/instant_capture.dart +++ b/lib/ui/instant_capture.dart @@ -83,7 +83,7 @@ class _InstantCaptureAppState extends State @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), diff --git a/lib/ui/notes_list.dart b/lib/ui/notes_list.dart index 5db8e56..8c5980a 100644 --- a/lib/ui/notes_list.dart +++ b/lib/ui/notes_list.dart @@ -145,10 +145,10 @@ const _cardRadius = BorderRadius.only( bottomRight: Radius.circular(14), ); -const _cardShadow = [ - BoxShadow(color: Color(0x33000000), offset: Offset(0, 1)), +List _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, @@ -302,7 +302,7 @@ class NoteCardFace extends StatelessWidget { : blank ? Border.all(color: palette.separator) : null, - boxShadow: _cardShadow, + boxShadow: _cardShadow(palette), ), child: Stack( children: [ @@ -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, ), @@ -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, diff --git a/lib/ui/page_card.dart b/lib/ui/page_card.dart index e51d518..d7ae379 100644 --- a/lib/ui/page_card.dart +++ b/lib/ui/page_card.dart @@ -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}); @@ -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), diff --git a/lib/ui/page_toolbar.dart b/lib/ui/page_toolbar.dart index d376936..0356d13 100644 --- a/lib/ui/page_toolbar.dart +++ b/lib/ui/page_toolbar.dart @@ -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( diff --git a/lib/ui/settings_dialog.dart b/lib/ui/settings_dialog.dart index e5404b3..8a238ef 100644 --- a/lib/ui/settings_dialog.dart +++ b/lib/ui/settings_dialog.dart @@ -1182,15 +1182,15 @@ class _SettingsDialogState extends State decoration: BoxDecoration( color: palette.surfaceBackground, borderRadius: corners, - boxShadow: const [ + boxShadow: [ BoxShadow( - color: Color(0x80000000), + color: palette.shadowAt(0x80), offset: Offset(0, 30), blurRadius: 60, spreadRadius: -24, ), BoxShadow( - color: Color(0x59000000), + color: palette.shadowAt(0x59), offset: Offset(0, 2), blurRadius: 8, ), diff --git a/lib/ui/settings_rows.dart b/lib/ui/settings_rows.dart index ea8a1fc..8179164 100644 --- a/lib/ui/settings_rows.dart +++ b/lib/ui/settings_rows.dart @@ -450,13 +450,13 @@ class SettingsSwitch extends StatelessWidget { child: DecoratedBox( decoration: BoxDecoration( color: value - ? (pointer ? palette.textPrimary : scheme.onPrimary) + ? (pointer ? palette.switchThumb : scheme.onPrimary) : palette.textTertiary, shape: BoxShape.circle, boxShadow: pointer && value - ? const [ + ? [ BoxShadow( - color: Color(0x40000000), + color: palette.shadowAt(0x40), offset: Offset(0, 1), blurRadius: 2, ), diff --git a/lib/ui/sidebar.dart b/lib/ui/sidebar.dart index 105791d..3d540ca 100644 --- a/lib/ui/sidebar.dart +++ b/lib/ui/sidebar.dart @@ -2466,9 +2466,9 @@ class _SearchFieldState extends State<_SearchField> { color: palette.surfaceBackground, border: Border.all(color: palette.controlBorder, width: 1.5), borderRadius: BorderRadius.circular(12), - boxShadow: const [ + boxShadow: [ BoxShadow( - color: Color(0x4D000000), + color: palette.shadowAt(0x4D), offset: Offset(0, 1), blurRadius: 2, ), diff --git a/test/billing/goldens/pro_sheet_phone_light.png b/test/billing/goldens/pro_sheet_phone_light.png index 3f50f73..9608dfc 100644 Binary files a/test/billing/goldens/pro_sheet_phone_light.png and b/test/billing/goldens/pro_sheet_phone_light.png differ diff --git a/test/billing/goldens/pro_sheet_phone_light_details.png b/test/billing/goldens/pro_sheet_phone_light_details.png index 3cb85d1..29bd835 100644 Binary files a/test/billing/goldens/pro_sheet_phone_light_details.png and b/test/billing/goldens/pro_sheet_phone_light_details.png differ diff --git a/test/goldens/desktop_dark_note_pinned.png b/test/goldens/desktop_dark_note_pinned.png index ed4333e..908ce0f 100644 Binary files a/test/goldens/desktop_dark_note_pinned.png and b/test/goldens/desktop_dark_note_pinned.png differ diff --git a/test/goldens/desktop_light.png b/test/goldens/desktop_light.png index 1ddd2ed..1c32061 100644 Binary files a/test/goldens/desktop_light.png and b/test/goldens/desktop_light.png differ diff --git a/test/goldens/desktop_light_settings_appearance.png b/test/goldens/desktop_light_settings_appearance.png index c65a980..7475787 100644 Binary files a/test/goldens/desktop_light_settings_appearance.png and b/test/goldens/desktop_light_settings_appearance.png differ diff --git a/test/goldens/sidebar_streak_light.png b/test/goldens/sidebar_streak_light.png index 1d552c2..88c97f5 100644 Binary files a/test/goldens/sidebar_streak_light.png and b/test/goldens/sidebar_streak_light.png differ diff --git a/test/goldens/toast_error_light.png b/test/goldens/toast_error_light.png index 1ff0472..c38a6d4 100644 Binary files a/test/goldens/toast_error_light.png and b/test/goldens/toast_error_light.png differ diff --git a/test/goldens/toolbar_shared_note_light.png b/test/goldens/toolbar_shared_note_light.png index d1b8a2d..3d93c29 100644 Binary files a/test/goldens/toolbar_shared_note_light.png and b/test/goldens/toolbar_shared_note_light.png differ diff --git a/test/goldens/welcome_phone_light.png b/test/goldens/welcome_phone_light.png index 6f136d0..8cc8a64 100644 Binary files a/test/goldens/welcome_phone_light.png and b/test/goldens/welcome_phone_light.png differ