at main 3.5 kB view raw
1import 'dart:io'; 2 3import 'package:flutter/material.dart'; 4 5import '../screens/create_gallery_page.dart'; 6 7class UploadProgressOverlay extends StatelessWidget { 8 final List<GalleryImage> images; 9 final int currentIndex; 10 final double progress; // 0.0 - 1.0 11 final bool visible; 12 13 const UploadProgressOverlay({ 14 super.key, 15 required this.images, 16 required this.currentIndex, 17 required this.progress, 18 this.visible = false, 19 }); 20 21 @override 22 Widget build(BuildContext context) { 23 if (!visible) return const SizedBox.shrink(); 24 final theme = Theme.of(context); 25 26 // Get the current image being uploaded 27 final currentImage = currentIndex < images.length ? images[currentIndex] : null; 28 29 // Calculate overall progress: completed images + current image's progress 30 double overallProgress = 0.0; 31 if (images.isNotEmpty) { 32 overallProgress = (currentIndex + progress) / images.length; 33 } 34 35 return Material( 36 color: Colors.transparent, 37 child: Stack( 38 children: [ 39 Positioned.fill(child: Container(color: Colors.black.withOpacity(0.9))), 40 Center( 41 child: Padding( 42 padding: const EdgeInsets.all(32), 43 child: Column( 44 mainAxisSize: MainAxisSize.min, 45 mainAxisAlignment: MainAxisAlignment.center, 46 children: [ 47 Row( 48 mainAxisSize: MainAxisSize.min, 49 children: [ 50 SizedBox( 51 width: 24, 52 height: 24, 53 child: CircularProgressIndicator( 54 strokeWidth: 2.5, 55 valueColor: AlwaysStoppedAnimation<Color>(Colors.white), 56 ), 57 ), 58 const SizedBox(width: 12), 59 Text( 60 'Uploading photos...', 61 style: theme.textTheme.titleMedium?.copyWith(color: Colors.white), 62 ), 63 ], 64 ), 65 const SizedBox(height: 16), 66 67 // Show current image at true aspect ratio 68 if (currentImage != null) 69 Container( 70 constraints: const BoxConstraints(maxWidth: 300, maxHeight: 300), 71 child: Image.file( 72 File(currentImage.file.path), 73 fit: BoxFit.contain, // Maintain aspect ratio 74 ), 75 ), 76 77 const SizedBox(height: 16), 78 79 // Progress indicator (overall progress) 80 SizedBox( 81 width: 300, 82 child: LinearProgressIndicator( 83 value: overallProgress, 84 backgroundColor: theme.colorScheme.surfaceContainerHighest.withOpacity(0.5), 85 valueColor: AlwaysStoppedAnimation<Color>(theme.colorScheme.primary), 86 ), 87 ), 88 89 const SizedBox(height: 8), 90 91 // Position counter and progress percentage 92 Text( 93 '${currentIndex + 1} of ${images.length}${(overallProgress * 100).toInt()}%', 94 style: theme.textTheme.bodyMedium?.copyWith(color: Colors.white70), 95 ), 96 ], 97 ), 98 ), 99 ), 100 ], 101 ), 102 ); 103 } 104}