mirror of
				https://github.com/immich-app/immich.git
				synced 2025-10-30 10:12:33 -04:00 
			
		
		
		
	* dep(mobile): update flutter and deps * chore: dart analyzer * chore: update flutter workflow version * chore: dart format * fix: gallery_viewer PopScope --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
		
			
				
	
	
		
			58 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:flutter/material.dart';
 | |
| 
 | |
| /// A widget that animates implicitly between a play and a pause icon.
 | |
| class AnimatedPlayPause extends StatefulWidget {
 | |
|   const AnimatedPlayPause({
 | |
|     super.key,
 | |
|     required this.playing,
 | |
|     this.size,
 | |
|     this.color,
 | |
|   });
 | |
| 
 | |
|   final double? size;
 | |
|   final bool playing;
 | |
|   final Color? color;
 | |
| 
 | |
|   @override
 | |
|   State<StatefulWidget> createState() => AnimatedPlayPauseState();
 | |
| }
 | |
| 
 | |
| class AnimatedPlayPauseState extends State<AnimatedPlayPause>
 | |
|     with SingleTickerProviderStateMixin {
 | |
|   late final animationController = AnimationController(
 | |
|     vsync: this,
 | |
|     value: widget.playing ? 1 : 0,
 | |
|     duration: const Duration(milliseconds: 300),
 | |
|   );
 | |
| 
 | |
|   @override
 | |
|   void didUpdateWidget(AnimatedPlayPause oldWidget) {
 | |
|     super.didUpdateWidget(oldWidget);
 | |
|     if (widget.playing != oldWidget.playing) {
 | |
|       if (widget.playing) {
 | |
|         animationController.forward();
 | |
|       } else {
 | |
|         animationController.reverse();
 | |
|       }
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   void dispose() {
 | |
|     animationController.dispose();
 | |
|     super.dispose();
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   Widget build(BuildContext context) {
 | |
|     return Center(
 | |
|       child: AnimatedIcon(
 | |
|         color: widget.color,
 | |
|         size: widget.size,
 | |
|         icon: AnimatedIcons.play_pause,
 | |
|         progress: animationController,
 | |
|       ),
 | |
|     );
 | |
|   }
 | |
| }
 |