Skip to content

Commit ae52f13

Browse files
committed
refactor!: rename StretchGlass to LiquidStretch
1 parent 3f445df commit ae52f13

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

packages/liquid_glass_renderer/example/lib/basic_app.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class BasicApp extends HookWidget {
6464
mainAxisSize: MainAxisSize.min,
6565
spacing: 16,
6666
children: [
67-
StretchGlass(
67+
LiquidStretch(
6868
child: LiquidGlass(
6969
settings: settings,
7070
shape: LiquidRoundedSuperellipse(
@@ -78,7 +78,7 @@ class BasicApp extends HookWidget {
7878
),
7979
),
8080
),
81-
StretchGlass(
81+
LiquidStretch(
8282
child: FakeGlass(
8383
settings: settings,
8484
shape: LiquidRoundedSuperellipse(

packages/liquid_glass_renderer/example/lib/widgets/bottom_bar.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class _LiquidGlassBottomBarState extends State<LiquidGlassBottomBar> {
120120
spacing: widget.spacing,
121121
children: [
122122
Expanded(
123-
child: StretchGlass(
123+
child: LiquidStretch(
124124
stretch: .2,
125125
child: LiquidGlass.inLayer(
126126
clipBehavior: Clip.none,
@@ -310,7 +310,7 @@ class _ExtraButtonState extends State<_ExtraButton> {
310310
final theme = CupertinoTheme.of(context);
311311
return GestureDetector(
312312
onTap: widget.config.onTap,
313-
child: StretchGlass(
313+
child: LiquidStretch(
314314
child: Semantics(
315315
button: true,
316316
label: widget.config.label,

packages/liquid_glass_renderer/lib/liquid_glass_renderer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
library liquid_glass_renderer;
33

44
export 'src/fake_glass.dart' show FakeGlass;
5-
export 'src/glass_distortion.dart' show StretchGlass;
5+
export 'src/stretch.dart' show LiquidStretch;
66
export 'src/glass_glow.dart' show GlassGlow, GlassGlowLayer;
77
export 'src/glass_link.dart' show GlassLink;
88
export 'src/glassify.dart' show Glassify;

packages/liquid_glass_renderer/lib/src/glass_distortion.dart renamed to packages/liquid_glass_renderer/lib/src/stretch.dart

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import 'package:motor/motor.dart';
1010
///
1111
/// Will listen to drag gestures from the user without interfering with other
1212
/// gestures.
13-
class StretchGlass extends StatelessWidget {
14-
/// Creates a new [StretchGlass] widget with the given [child],
13+
class LiquidStretch extends StatelessWidget {
14+
/// Creates a new [LiquidStretch] widget with the given [child],
1515
/// [interactionScale], and [stretch].
16-
const StretchGlass({
16+
const LiquidStretch({
1717
required this.child,
1818
this.interactionScale = 1.05,
1919
this.stretch = .5,
@@ -42,6 +42,10 @@ class StretchGlass extends StatelessWidget {
4242

4343
@override
4444
Widget build(BuildContext context) {
45+
if (stretch == 0 && interactionScale == 1.0) {
46+
return child;
47+
}
48+
4549
return GlassDragBuilder(
4650
builder: (context, value, child) {
4751
final scale = value == null ? 1.0 : interactionScale;
@@ -83,6 +87,11 @@ class _RawGlassStretch extends StatelessWidget {
8387

8488
@override
8589
Widget build(BuildContext context) {
90+
if (stretch == Offset.zero) {
91+
// Skip any transformations if there's no stretch
92+
return child;
93+
}
94+
8695
final scale = getScale(stretch: stretch);
8796
final matrix = Matrix4.identity()
8897
..scaleByDouble(scale.dx, scale.dy, 1, 1)

0 commit comments

Comments
 (0)