fixed AnimatedDialog scaling

This commit is contained in:
Vadim 2024-01-13 17:07:32 +01:00
parent 8cf5d38c37
commit d09542cede

View file

@ -191,7 +191,6 @@ class AnimatedDialogState extends State<AnimatedDialog> with SingleTickerProvide
onDismiss: close, onDismiss: close,
builder: widget.closedChild != null && widget.openedChild != null builder: widget.closedChild != null && widget.openedChild != null
? (_) => _AnimatedSwitcher( ? (_) => _AnimatedSwitcher(
sizeAnimation: _sizeAnimation,
closedOpacityAnimation: _closedOpacityAnimation, closedOpacityAnimation: _closedOpacityAnimation,
openedOpacityAnimation: _openedOpacityAnimation, openedOpacityAnimation: _openedOpacityAnimation,
closedSize: _sizeTween.begin!, closedSize: _sizeTween.begin!,
@ -291,7 +290,6 @@ class _AnimatedOverlay extends StatelessWidget {
} }
class _AnimatedSwitcher extends StatelessWidget { class _AnimatedSwitcher extends StatelessWidget {
final Animation<Size?> sizeAnimation;
final Animation<double> closedOpacityAnimation; final Animation<double> closedOpacityAnimation;
final Animation<double> openedOpacityAnimation; final Animation<double> openedOpacityAnimation;
final Size closedSize; final Size closedSize;
@ -300,7 +298,6 @@ class _AnimatedSwitcher extends StatelessWidget {
final Widget openedChild; final Widget openedChild;
const _AnimatedSwitcher({ const _AnimatedSwitcher({
required this.sizeAnimation,
required this.closedOpacityAnimation, required this.closedOpacityAnimation,
required this.openedOpacityAnimation, required this.openedOpacityAnimation,
required this.closedSize, required this.closedSize,
@ -316,17 +313,21 @@ class _AnimatedSwitcher extends StatelessWidget {
children: [ children: [
Opacity( Opacity(
opacity: closedOpacityAnimation.value, opacity: closedOpacityAnimation.value,
child: Transform.scale( child: FittedBox(
scale: sizeAnimation.value!.width / closedSize.width, child: SizedBox.fromSize(
child: SizedBox( size: closedSize,
width: closedSize.width,
child: closedChild, child: closedChild,
), ),
), ),
), ),
Opacity( Opacity(
opacity: openedOpacityAnimation.value, opacity: openedOpacityAnimation.value,
child: openedChild, child: FittedBox(
child: SizedBox.fromSize(
size: openedSize,
child: openedChild,
),
),
), ),
], ],
); );