Skip to content

Commit

Permalink
Implement DisableAcrylic (Fixes bdlukaa#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-hann committed Nov 11, 2021
1 parent 3c191d8 commit e8edae9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 24 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Date format: DD/MM/YYYY

## [3.4.1] - [08/11/2021]

* [next]
- `ContentDialog` constraints can now be customizable ([#86](https://github.com/bdlukaa/fluent_ui/issues/86))
- Add possibility to disable acrylic by wrapping it in a `DisableAcrylic` ([#89](https://github.com/bdlukaa/fluent_ui/issues/89))

## [3.4.0] - Flexibility - [22/10/2021]

Expand Down
66 changes: 43 additions & 23 deletions lib/src/styles/acrylic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ class _AcrylicGuts extends StatelessWidget {
AcrylicHelper.getTintOpacityModifier(properties.tint),
);

final disabled = DisableAcrylic.of(context) != null;

return ClipPath(
clipper: ShapeBorderClipper(shape: properties.shape),
child: CustomPaint(
Expand All @@ -379,32 +381,34 @@ class _AcrylicGuts extends StatelessWidget {
properties.luminosityAlpha,
),
),
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: properties.blurAmount,
sigmaY: properties.blurAmount,
),
child: Stack(children: [
const Opacity(
opacity: 0.02,
child: DecoratedBox(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/AcrylicNoise.png",
package: "fluent_ui",
child: disabled
? child
: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: properties.blurAmount,
sigmaY: properties.blurAmount,
),
child: Stack(children: [
const Opacity(
opacity: 0.02,
child: DecoratedBox(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/AcrylicNoise.png",
package: "fluent_ui",
),
alignment: Alignment.topLeft,
repeat: ImageRepeat.repeat,
),
backgroundBlendMode: BlendMode.srcOver,
color: Colors.transparent,
),
),
alignment: Alignment.topLeft,
repeat: ImageRepeat.repeat,
),
backgroundBlendMode: BlendMode.srcOver,
color: Colors.transparent,
),
child,
]),
),
),
child,
]),
),
),
);
}
Expand Down Expand Up @@ -560,3 +564,19 @@ class _NoiseTextureCacher {
);
}
}

class DisableAcrylic extends InheritedWidget {
const DisableAcrylic({
Key? key,
required Widget child,
}) : super(key: key, child: child);

static DisableAcrylic? of(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType<DisableAcrylic>();
}

@override
bool updateShouldNotify(DisableAcrylic oldWidget) {
return true;
}
}

0 comments on commit e8edae9

Please sign in to comment.