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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ The format is based on [Keep a Changelog][1], and this project adheres to

- Refined piano key rendering with a top-edge shadow gradient for stronger
depth/anchoring and improved contrast for top marker caps.
- Updated pressed piano key highlights to use a unified accent color with
layered shading/gradient treatment for better contrast across white and black
keys.

### Fixed

Expand Down
26 changes: 4 additions & 22 deletions lib/features/piano/models/piano_palette.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import 'package:flutter/material.dart';
class PianoPalette {
final Color background;
final Color whiteKey;
final Color whiteKeyHighlight;
final Color pressedKeyHighlight;
final Color blackKey;
final Color blackKeyHighlight;
final Color border;

const PianoPalette({
required this.background,
required this.whiteKey,
required this.whiteKeyHighlight,
required this.pressedKeyHighlight,
required this.blackKey,
required this.blackKeyHighlight,
required this.border,
});
}
Expand All @@ -24,28 +22,13 @@ PianoPalette buildPianoPalette(ColorScheme cs) {

final background = cs.surfaceContainerLow;

Color overlayOn(Color base, Color overlay, double opacity) =>
Color.alphaBlend(overlay.withValues(alpha: opacity), base);

final whiteKey = isDark
? Color.alphaBlend(cs.surface.withValues(alpha: 0.18), Colors.white)
: Colors.white;

final primaryTooClose =
(whiteKey.computeLuminance() - cs.primary.computeLuminance()).abs() <
0.10;

final pressedOverlay = (isDark && primaryTooClose)
? cs.primaryContainer
: cs.primary;

final whiteKeyHighlight = isDark
? overlayOn(whiteKey, pressedOverlay, 0.18)
: cs.primaryContainer;

final blackKey = const Color(0xFF111111);

final blackKeyHighlight = isDark
final pressedKeyHighlight = isDark
? Color.alphaBlend(whiteKey.withValues(alpha: 0.18), cs.primaryContainer)
: Color.alphaBlend(whiteKey.withValues(alpha: 0.18), cs.primary);

Expand All @@ -57,9 +40,8 @@ PianoPalette buildPianoPalette(ColorScheme cs) {
return PianoPalette(
background: background,
whiteKey: whiteKey,
whiteKeyHighlight: whiteKeyHighlight,
pressedKeyHighlight: pressedKeyHighlight,
blackKey: blackKey,
blackKeyHighlight: blackKeyHighlight,
border: border,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ class PianoKeyboard extends StatelessWidget {
highlightedNoteNumbers: highlightedNoteNumbers,

whiteKeyColor: palette.whiteKey,
whiteKeyHighlightColor: palette.whiteKeyHighlight,
pressedKeyHighlightColor: palette.pressedKeyHighlight,
whiteKeyBorderColor: palette.border,
blackKeyColor: palette.blackKey,
blackKeyHighlightColor: palette.blackKeyHighlight,
backgroundColor: palette.background,

decorations: decorations,
Expand Down
Loading
Loading