diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 7f2beca..84e3c5b 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -220,21 +220,109 @@ class _HomePageState extends State children: [ const Spacer(flex: 9), if (_fileNotifier.loading) - Padding( - padding: const EdgeInsets.only(bottom: 24.0), - child: ClipRRect( - borderRadius: BorderRadius.circular(500), - child: SizedBox( - width: MediaQuery.of(context).size.width * 0.25, - child: LinearProgressIndicator( - backgroundColor: - Colors.white.withOpacity(0.1), - color: Colors.white, - minHeight: 2, + if (_fileNotifier.zipfileName == '') + Padding( + padding: const EdgeInsets.only(bottom: 24.0), + child: ClipRRect( + borderRadius: BorderRadius.circular(500), + child: SizedBox( + width: + MediaQuery.of(context).size.width * 0.25, + child: LinearProgressIndicator( + backgroundColor: + Colors.white.withOpacity(0.1), + color: Colors.white, + minHeight: 2, + ), + ), + ), + ) + else + Container( + padding: const EdgeInsets.fromLTRB(12, 4, 12, 4), + margin: const EdgeInsets.only(bottom: 24.0), + width: MediaQuery.of(context).size.width * 0.25, + height: 48, + decoration: BoxDecoration( + color: Colors.white12, + borderRadius: BorderRadius.circular(6), + border: Border.all( + color: Colors.white.withOpacity(0.05), + width: 0.5, ), ), + child: Row( + children: [ + Container( + width: 24, + height: 24, + decoration: BoxDecoration( + color: Colors.white12, + borderRadius: BorderRadius.circular(4), + border: Border.all( + color: Colors.white.withOpacity(0.05), + width: 0.5, + ), + ), + child: Center( + child: Text( + _fileNotifier.zipfileName[0], + style: GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + ), + ), + const SizedBox(width: 12), + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + SizedBox( + width: (MediaQuery.of(context) + .size + .width * + 0.25) - + 24 - + 38, + child: Text( + _fileNotifier.zipfileName, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: GoogleFonts.poppins( + fontSize: 10, + fontWeight: FontWeight.normal, + color: Colors.white, + ), + ), + ), + const SizedBox(height: 8), + ClipRRect( + borderRadius: + BorderRadius.circular(500), + child: SizedBox( + width: (MediaQuery.of(context) + .size + .width * + 0.25) - + 24 - + 38, + child: LinearProgressIndicator( + backgroundColor: + Colors.white.withOpacity(0.1), + color: Colors.white, + minHeight: 3, + ), + ), + ), + ]) + ], + ), ), - ), if (_fileNotifier.fileLink != null) Row( mainAxisSize: MainAxisSize.min, diff --git a/lib/providers/file_notifier.dart b/lib/providers/file_notifier.dart index 778d14c..8b14f35 100644 --- a/lib/providers/file_notifier.dart +++ b/lib/providers/file_notifier.dart @@ -7,6 +7,7 @@ class FileNotifier with ChangeNotifier { bool get loading => _fileService.loading; bool get processing => _fileService.processing; String? get fileLink => _fileService.fileLink; + String get zipfileName => _fileService.zipfileName; Future getLinkFromFilePicker() async { await _fileService.getLinkFromFilePicker(); diff --git a/lib/services/file_service.dart b/lib/services/file_service.dart index 873abba..4ea5c1a 100644 --- a/lib/services/file_service.dart +++ b/lib/services/file_service.dart @@ -4,6 +4,7 @@ import 'package:file_picker/file_picker.dart'; import 'package:odin/services/github_service.dart'; import 'package:odin/services/locator.dart'; import 'package:odin/services/zip_service.dart'; +import 'package:path/path.dart'; class FileService { final _githubService = locator(); @@ -11,6 +12,7 @@ class FileService { bool loading = false; bool processing = false; String? fileLink; + String zipfileName = ''; Future getLinkFromFilePicker() async { fileLink = null; @@ -18,10 +20,12 @@ class FileService { await FilePicker.platform.pickFiles(allowMultiple: true); final String? _path; if (result != null) { + zipfileName = ''; loading = true; processing = true; List files = result.paths.map((path) => File(path!)).toList(); final zippedFile = await _zipService.zipFile(fileToZips: files); + zipfileName = basename(zippedFile.path); processing = false; _path = await _githubService.uploadFileAnonymous(zippedFile); loading = false; @@ -36,11 +40,13 @@ class FileService { fileLink = null; final String? _path; if (urls.isNotEmpty) { + zipfileName = ''; loading = true; processing = true; final List fileToZips = urls.map((e) => File(e.toFilePath())).toList(); final zippedFile = await _zipService.zipFile(fileToZips: fileToZips); + zipfileName = basename(zippedFile.path); processing = false; _path = await _githubService.uploadFileAnonymous(zippedFile); loading = false;