mirror of
				https://github.com/immich-app/immich.git
				synced 2025-10-31 02:27:08 -04:00 
			
		
		
		
	* chore: bump dart sdk to 3.8 * chore: make build * make pigeon * chore: format files --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
		
			
				
	
	
		
			33 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:flutter/material.dart';
 | |
| import 'package:immich_mobile/widgets/common/immich_loading_indicator.dart';
 | |
| 
 | |
| class DelayedLoadingIndicator extends StatelessWidget {
 | |
|   /// The delay to avoid showing the loading indicator
 | |
|   final Duration delay;
 | |
| 
 | |
|   /// Defaults to using the [ImmichLoadingIndicator]
 | |
|   final Widget? child;
 | |
| 
 | |
|   /// An optional fade in duration to animate the loading
 | |
|   final Duration? fadeInDuration;
 | |
| 
 | |
|   const DelayedLoadingIndicator({super.key, this.delay = const Duration(seconds: 3), this.child, this.fadeInDuration});
 | |
| 
 | |
|   @override
 | |
|   Widget build(BuildContext context) {
 | |
|     return FutureBuilder(
 | |
|       future: Future.delayed(delay),
 | |
|       builder: (context, snapshot) {
 | |
|         late Widget c;
 | |
|         if (snapshot.connectionState == ConnectionState.done) {
 | |
|           c = child ?? const ImmichLoadingIndicator(key: ValueKey('loading'));
 | |
|         } else {
 | |
|           c = Container(key: const ValueKey('hiding'));
 | |
|         }
 | |
| 
 | |
|         return AnimatedSwitcher(duration: fadeInDuration ?? Duration.zero, child: c);
 | |
|       },
 | |
|     );
 | |
|   }
 | |
| }
 |