Skip to content

Offline gym log for Android. No account, no ads, no internet.

Fix the cut edge on the blur behind sheets

InlitX186ebefc9212
diff --git a/lib/app/app_shell.dart b/lib/app/app_shell.dart
index 99b4452..073e62f 100644
--- a/lib/app/app_shell.dart
+++ b/lib/app/app_shell.dart
@@ -296,11 +296,23 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Single
_blurQueued = true;
WidgetsBinding.instance.addPostFrameCallback((_) {
_blurQueued = false;
- if (!mounted || sheetRecede.value <= 0.001 || !blurEffects) return;
final box = _appKey.currentContext?.findRenderObject();
- if (box is! RenderRepaintBoundary || !box.hasSize) return;
+ if (!mounted || sheetRecede.value <= 0.001 || !blurEffects || box is! RenderRepaintBoundary || !box.hasSize) {
+ edgeBlurRaster.value = null;
+ return;
+ }
final scale = fineEffects ? 0.5 : 0.3;
final ratio = MediaQuery.devicePixelRatioOf(context) * scale;
+ if (edgeBlurRaster.value != ratio) {
+ edgeBlurRaster.value = ratio;
+ _blurQueued = true;
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ _blurQueued = false;
+ _queueBlur();
+ });
+ WidgetsBinding.instance.scheduleFrame();
+ return;
+ }
try {
final small = box.toImageSync(pixelRatio: ratio);
final sigma = 2 * ratio;
@@ -312,7 +324,10 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Single
final old = _blurred;
setState(() => _blurred = soft);
old?.dispose();
- } catch (_) {}
+ } catch (_) {
+ } finally {
+ edgeBlurRaster.value = null;
+ }
});
}
diff --git a/lib/widgets/glass.dart b/lib/widgets/glass.dart
index b2ae721..6ba4c95 100644
--- a/lib/widgets/glass.dart
+++ b/lib/widgets/glass.dart
@@ -222,6 +222,8 @@ class _GlassDialogRoute<T> extends DialogRoute<T> with _GlassCount<T> {
}
+final ValueNotifier<double?> edgeBlurRaster = ValueNotifier(null);
+
class EdgeBlur extends StatefulWidget {
const EdgeBlur({super.key, required this.height, this.top = true, this.sigma = 16, this.shade = 1});
@@ -245,6 +247,7 @@ class _EdgeBlurState extends State<EdgeBlur> {
@override
void initState() {
super.initState();
+ edgeBlurRaster.addListener(_rerender);
if (_program != null || !ui.ImageFilter.isShaderFilterSupported) return;
(_loading ??= ui.FragmentProgram.fromAsset('assets/shaders/edge_fade.frag')).then((p) {
_program = p;
@@ -252,8 +255,13 @@ class _EdgeBlurState extends State<EdgeBlur> {
}, onError: (_) {});
}
+ void _rerender() {
+ if (mounted) setState(() {});
+ }
+
@override
void dispose() {
+ edgeBlurRaster.removeListener(_rerender);
_dropShaders();
super.dispose();
}
@@ -300,7 +308,7 @@ class _EdgeBlurState extends State<EdgeBlur> {
if (!blurEffects)
const SizedBox.shrink()
else if (program != null)
- for (final f in _layers(program, MediaQuery.devicePixelRatioOf(context)))
+ for (final f in _layers(program, edgeBlurRaster.value ?? MediaQuery.devicePixelRatioOf(context)))
Positioned.fill(
child: ClipRect(child: BackdropFilter(filter: f, child: const SizedBox.expand())),
)