diff --git a/frontend/mgramseva/lib/repository/core_repo.dart b/frontend/mgramseva/lib/repository/core_repo.dart index cdfc971fc..1b83ffcdd 100644 --- a/frontend/mgramseva/lib/repository/core_repo.dart +++ b/frontend/mgramseva/lib/repository/core_repo.dart @@ -27,7 +27,9 @@ import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; import 'package:universal_html/html.dart' as html; - +enum FileUploadStatus { + NOT_ACTIVE,STARTED,COMPLETED +} class CoreRepository extends BaseService { Future> getLocilisation( Map query) async { diff --git a/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart b/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart index 358c641b3..292cc5e96 100644 --- a/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart +++ b/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart @@ -468,7 +468,7 @@ class _ExpenseDetailsState extends State { key: expensesDetailsProvider.filePickerKey, callBack: expensesDetailsProvider.fileStoreIdCallBack, - extensions: ['jpg', 'pdf', 'png'], + extensions: ['jpg', 'pdf', 'png', 'jpeg'], contextKey: expenseProvider .expenseWalkthrougList[5].key, ), diff --git a/frontend/mgramseva/lib/widgets/file_picker.dart b/frontend/mgramseva/lib/widgets/file_picker.dart index 011a80295..f40a07146 100644 --- a/frontend/mgramseva/lib/widgets/file_picker.dart +++ b/frontend/mgramseva/lib/widgets/file_picker.dart @@ -36,6 +36,7 @@ class FilePickerDemoState extends State { FileType _pickingType = FileType.custom; TextEditingController _controller = TextEditingController(); final ImagePicker _picker = ImagePicker(); + FileUploadStatus fileUploading = FileUploadStatus.NOT_ACTIVE; @override void initState() { @@ -92,11 +93,20 @@ class FilePickerDemoState extends State { uploadFiles(List files) async { try{ + setState(() { + fileUploading = FileUploadStatus.STARTED; + }); var response = await CoreRepository().uploadFiles(files, widget.moduleName ?? APIConstants.API_MODULE_NAME); + setState(() { + fileUploading = FileUploadStatus.COMPLETED; + }); _fileStoreList.addAll(response); if(_selectedFiles.isNotEmpty) widget.callBack(_fileStoreList); }catch(e){ + setState(() { + fileUploading = FileUploadStatus.NOT_ACTIVE; + }); Notifiers.getToastMessage(context, e.toString(), 'ERROR'); } } @@ -190,6 +200,19 @@ class FilePickerDemoState extends State { : Text( "${ApplicationLocalizations.of(context).translate(i18.common.NO_FILE_UPLOADED)}", style: TextStyle(color: Colors.black, fontSize: 16), + ), + Row( + children: [ + fileUploading==FileUploadStatus.STARTED?Text("Uploading File",style: TextStyle( + color: Colors.black + ),):SizedBox(), + fileUploading==FileUploadStatus.STARTED?Transform.scale( + scale: 0.5, + child: CircularProgressIndicator(), + ) + :fileUploading==FileUploadStatus.COMPLETED?Icon(Icons.check_circle,color: Theme.of(context).primaryColor,) + :SizedBox(), + ], ) ], )) @@ -199,12 +222,16 @@ class FilePickerDemoState extends State { void onClickOfClear(int index){ setState(() { _selectedFiles.removeAt(index); + fileUploading = FileUploadStatus.NOT_ACTIVE; if(index < _fileStoreList.length) _fileStoreList.removeAt(index); }); widget.callBack(_fileStoreList); } void reset(){ + setState(() { + fileUploading = FileUploadStatus.NOT_ACTIVE; + }); _selectedFiles.clear(); _fileStoreList.clear(); }