diff --git a/app/lib/features/changes/widgets/change_style.dart b/app/lib/features/changes/widgets/change_style.dart index cd318b88..370c13c5 100644 --- a/app/lib/features/changes/widgets/change_style.dart +++ b/app/lib/features/changes/widgets/change_style.dart @@ -16,34 +16,47 @@ ThemeData hostTextTheme(BuildContext context) => ThemeData( platform: Theme.of(context).platform, ); -/// Native semantic roles, never a bespoke palette or added row tint. The exact -/// recorded +/- markers also distinguish changes without relying on colour. -({Color text, Color? background}) diffLineColors( +/// GitHub's diff palette (Primer): each changed line on a green or red tint, +/// its +/- marker and the +N/-N counts in the strong green or red. The code +/// itself keeps the label colour, as on GitHub, and the exact recorded +/// markers also distinguish changes without relying on colour. +({Color text, Color marker, Color? background}) diffLineColors( BuildContext context, ChangeLineKind kind, -) => switch (kind) { - ChangeLineKind.add => ( - text: addedColor(context), - background: addedColor(context).withValues(alpha: 0.12), - ), - ChangeLineKind.remove => ( - text: removedColor(context), - background: removedColor(context).withValues(alpha: 0.12), - ), - ChangeLineKind.context => (text: labelColor(context), background: null), -}; +) { + final dark = _isDark(context); + return switch (kind) { + ChangeLineKind.add => ( + text: labelColor(context), + marker: addedColor(context), + background: dark ? const Color(0x262EA043) : const Color(0xFFDAFBE1), + ), + ChangeLineKind.remove => ( + text: labelColor(context), + marker: removedColor(context), + background: dark ? const Color(0x1AF85149) : const Color(0xFFFFEBE9), + ), + ChangeLineKind.context => ( + text: labelColor(context), + marker: labelColor(context), + background: null, + ), + }; +} -/// Added lines and counts: the platform's green, readable in both themes. -Color addedColor(BuildContext context) => usesCupertino(context) - ? CupertinoColors.systemGreen.resolveFrom(context) - : (Theme.of(context).brightness == Brightness.dark - ? const Color(0xFF81C995) - : const Color(0xFF1E8E3E)); +bool _isDark(BuildContext context) => + (usesCupertino(context) + ? CupertinoTheme.brightnessOf(context) + : Theme.of(context).brightness) == + Brightness.dark; -/// Removed lines and counts: the platform's red. -Color removedColor(BuildContext context) => usesCupertino(context) - ? CupertinoColors.systemRed.resolveFrom(context) - : Theme.of(context).colorScheme.error; +/// Added lines and counts: GitHub's addition green. +Color addedColor(BuildContext context) => + _isDark(context) ? const Color(0xFF3FB950) : const Color(0xFF1A7F37); + +/// Removed lines and counts: GitHub's deletion red. +Color removedColor(BuildContext context) => + _isDark(context) ? const Color(0xFFF85149) : const Color(0xFFD1242F); final _statToken = RegExp(r'(?