Skip to content

Commit

Permalink
backdrop filter grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
deckerst committed Feb 14, 2025
1 parent ae9e297 commit 9853733
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 34 deletions.
9 changes: 5 additions & 4 deletions lib/widgets/aves_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,11 @@ class _AvesAppState extends State<AvesApp> with WidgetsBindingObserver {
final EventChannel _errorChannel = const OptionalEventChannel('deckers.thibault/aves/error');

// Flutter has various page transition implementations for Android:
// - `FadeUpwardsPageTransitionsBuilder` on Oreo / API 27 and below
// - `OpenUpwardsPageTransitionsBuilder` on Pie / API 28
// - `ZoomPageTransitionsBuilder` on Android 10 / API 29 and above (default in Flutter v3.22.0)
// - `PredictiveBackPageTransitionsBuilder` for Android 15 / API 35 intra-app predictive back
// - `FadeUpwardsPageTransitionsBuilder` on Oreo / Android 8 / API 27 and below
// - `OpenUpwardsPageTransitionsBuilder` on Pie / Android 9 / API 28
// - `ZoomPageTransitionsBuilder` on Q / Android 10 / API 29 (default in Flutter v3.22.0)
// - `FadeForwardsPageTransitionsBuilder` on U / Android 14 / API 34
// - `PredictiveBackPageTransitionsBuilder` for Android 15 / API 35 intra-app predictive back (default to `ZoomPageTransitionsBuilder`)
static const _defaultPageTransitionsBuilder = FadeUpwardsPageTransitionsBuilder();
static final GlobalKey<NavigatorState> _navigatorKey = GlobalKey(debugLabel: 'app-navigator');
static ScreenBrightness? _screenBrightness;
Expand Down
8 changes: 3 additions & 5 deletions lib/widgets/common/fx/blurred.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ final _filter = ImageFilter.blur(sigmaX: 4, sigmaY: 4);
// as it yields performance issues when there are other layers on top
final _identity = ImageFilter.matrix(Matrix4.identity().storage);

// TODO TLAD [impeller] use `BackdropKey`

class BlurredRect extends StatelessWidget {
final bool enabled;
final Widget child;
Expand All @@ -22,7 +20,7 @@ class BlurredRect extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ClipRect(
child: BackdropFilter(
child: BackdropFilter.grouped(
// do not modify tree when disabling filter
filter: enabled ? _filter : _identity,
child: child,
Expand Down Expand Up @@ -61,7 +59,7 @@ class BlurredRRect extends StatelessWidget {
Widget build(BuildContext context) {
return ClipRRect(
borderRadius: borderRadius ?? BorderRadius.zero,
child: BackdropFilter(
child: BackdropFilter.grouped(
// do not modify tree when disabling filter
filter: enabled ? _filter : _identity,
child: child,
Expand All @@ -83,7 +81,7 @@ class BlurredOval extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ClipOval(
child: BackdropFilter(
child: BackdropFilter.grouped(
// do not modify tree when disabling filter
filter: enabled ? _filter : _identity,
child: child,
Expand Down
14 changes: 8 additions & 6 deletions lib/widgets/common/map/geo_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,14 @@ class _GeoMapState extends State<GeoMap> {
child = Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
mapHeight != null
? SizedBox(
height: mapHeight,
child: child,
)
: Expanded(child: child),
BackdropGroup(
child: mapHeight != null
? SizedBox(
height: mapHeight,
child: child,
)
: Expanded(child: child),
),
SafeArea(
top: false,
bottom: false,
Expand Down
40 changes: 21 additions & 19 deletions lib/widgets/viewer/entry_viewer_stack.dart
Original file line number Diff line number Diff line change
Expand Up @@ -261,27 +261,29 @@ class _EntryViewerStackState extends State<EntryViewerStack> with EntryViewContr
return ValueListenableBuilder<bool>(
valueListenable: _viewLocked,
builder: (context, locked, child) {
return Stack(
children: [
child!,
if (!pipEnabled) ...[
if (locked) ...[
const Positioned.fill(
child: AbsorbPointer(),
),
Positioned.fill(
child: GestureDetector(
onTap: () => _overlayVisible.value = !_overlayVisible.value,
return BackdropGroup(
child: Stack(
children: [
child!,
if (!pipEnabled) ...[
if (locked) ...[
const Positioned.fill(
child: AbsorbPointer(),
),
),
_buildViewerLockedBottomOverlay(),
] else
..._buildOverlays(availableSize).map(_decorateOverlay),
const TopGestureAreaProtector(),
const SideGestureAreaProtector(),
const BottomGestureAreaProtector(),
Positioned.fill(
child: GestureDetector(
onTap: () => _overlayVisible.value = !_overlayVisible.value,
),
),
_buildViewerLockedBottomOverlay(),
] else
..._buildOverlays(availableSize).map(_decorateOverlay),
const TopGestureAreaProtector(),
const SideGestureAreaProtector(),
const BottomGestureAreaProtector(),
],
],
],
),
);
},
child: viewer,
Expand Down

0 comments on commit 9853733

Please sign in to comment.