mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-11-21 20:00:49 +01:00
fix(mornye): blur the cover under the controls into one tone
The blur below the full-screen cover kept the cover's larger shapes and was see-through near the screen edges, so it read as a second, faint cover laid over the sharp one. It is now blurred far past its shapes and stays opaque up to its edges: the area under the controls is one tone taken from the cover that shifts slowly down the screen.
This commit is contained in:
1 parent
ec948c3bdd
commit
4554a12392
2 files changed
+26
-6
No files matched your search
@@ -279,11 +279,16 @@ class PlayerCoverBlur extends StatefulWidget {
|
||||
required this.artUri,
|
||||
required this.colorScheme,
|
||||
this.reveal,
|
||||
this.sigma = 48,
|
||||
});
|
||||
|
||||
final String? artUri;
|
||||
final ColorScheme colorScheme;
|
||||
|
||||
/// The blur radius in logical pixels. The default keeps the cover's
|
||||
/// larger shapes; a few times that leaves only its colours.
|
||||
final double sigma;
|
||||
|
||||
/// Without it the blur sits between two layers of the surface colour and
|
||||
/// is blurred live while the cover decodes. With it, only the blur is
|
||||
/// drawn, transparent down to `top` and opaque from `bottom` (logical
|
||||
@@ -297,7 +302,6 @@ class PlayerCoverBlur extends StatefulWidget {
|
||||
|
||||
class _PlayerCoverBlurState extends State<PlayerCoverBlur>
|
||||
with SingleTickerProviderStateMixin {
|
||||
static const _sigma = 48.0;
|
||||
static const _artWidth = PlayerArtwork.miniCacheWidth;
|
||||
|
||||
late final _listener = ImageStreamListener(
|
||||
@@ -392,18 +396,26 @@ class _PlayerCoverBlurState extends State<PlayerCoverBlur>
|
||||
Size size,
|
||||
double dpr,
|
||||
({double top, double bottom})? reveal,
|
||||
double logicalSigma,
|
||||
) {
|
||||
final scale = dpr / 4;
|
||||
final width = math.max(1, (size.width * scale).ceil());
|
||||
final height = math.max(1, (size.height * scale).ceil());
|
||||
final rect = Rect.fromLTWH(0, 0, width.toDouble(), height.toDouble());
|
||||
final sigma = _sigma * scale;
|
||||
final sigma = logicalSigma * scale;
|
||||
final recorder = ui.PictureRecorder();
|
||||
final canvas = Canvas(recorder);
|
||||
if (reveal != null) canvas.saveLayer(rect, Paint());
|
||||
canvas.saveLayer(
|
||||
rect,
|
||||
Paint()..imageFilter = ui.ImageFilter.blur(sigmaX: sigma, sigmaY: sigma),
|
||||
Paint()
|
||||
..imageFilter = ui.ImageFilter.blur(
|
||||
sigmaX: sigma,
|
||||
sigmaY: sigma,
|
||||
// Alone over a sharp cover the blur has to stay opaque up to its
|
||||
// edges; between the surface layers it fades into them instead.
|
||||
tileMode: reveal == null ? null : TileMode.clamp,
|
||||
),
|
||||
);
|
||||
paintImage(
|
||||
canvas: canvas,
|
||||
@@ -453,7 +465,10 @@ class _PlayerCoverBlurState extends State<PlayerCoverBlur>
|
||||
if (reveal != null) return const SizedBox.shrink();
|
||||
// Blur live while the cover decodes and for the placeholder.
|
||||
blurred = ImageFiltered(
|
||||
imageFilter: ui.ImageFilter.blur(sigmaX: _sigma, sigmaY: _sigma),
|
||||
imageFilter: ui.ImageFilter.blur(
|
||||
sigmaX: widget.sigma,
|
||||
sigmaY: widget.sigma,
|
||||
),
|
||||
child: PlayerArtwork(
|
||||
artUri: widget.artUri,
|
||||
colorScheme: widget.colorScheme,
|
||||
@@ -464,10 +479,11 @@ class _PlayerCoverBlurState extends State<PlayerCoverBlur>
|
||||
final dpr = MediaQuery.devicePixelRatioOf(context);
|
||||
blurred = LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final inputs = (art, constraints.biggest, dpr, reveal);
|
||||
final sigma = widget.sigma;
|
||||
final inputs = (art, constraints.biggest, dpr, reveal, sigma);
|
||||
if (inputs != _blurInputs) {
|
||||
_blur?.dispose();
|
||||
_blur = _render(art, constraints.biggest, dpr, reveal);
|
||||
_blur = _render(art, constraints.biggest, dpr, reveal, sigma);
|
||||
_blurInputs = inputs;
|
||||
}
|
||||
final outgoing = _outgoing;
|
||||
|
||||
@@ -273,6 +273,10 @@ class _CoverBlur extends StatelessWidget {
|
||||
// Opaque by the middle of the artwork's own fade, before the
|
||||
// flat gradient under it shows as a dull band between the two.
|
||||
reveal: (top: top, bottom: (top + bottom) / 2),
|
||||
// Far past the cover's shapes: they would read as a second,
|
||||
// see-through cover under the sharp one. Only its colours stay,
|
||||
// as one tone that shifts slowly down the screen.
|
||||
sigma: 120,
|
||||
),
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
|
||||
Reference in new issue
Block a user