diff --git a/lib/screens/my_files/files_detail_screen.dart b/lib/screens/my_files/files_detail_screen.dart index 220d2558..9147f9d3 100644 --- a/lib/screens/my_files/files_detail_screen.dart +++ b/lib/screens/my_files/files_detail_screen.dart @@ -16,7 +16,6 @@ import 'package:atsign_atmosphere_pro/utils/file_utils.dart'; import 'package:atsign_atmosphere_pro/utils/images.dart'; import 'package:atsign_atmosphere_pro/utils/vectors.dart'; import 'package:atsign_atmosphere_pro/view_models/my_files_provider.dart'; -import 'package:file_selector/file_selector.dart'; import 'package:flutter/material.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -314,12 +313,12 @@ class _FilesDetailScreenState extends State { // : SizedBox(); // }, // ), - Padding( - padding: const EdgeInsets.only(left: 6.0), - child: SvgPicture.asset( - AppVectors.icDownloadFile, - ), - ), + // Padding( + // padding: const EdgeInsets.only(left: 6.0), + // child: SvgPicture.asset( + // AppVectors.icDownloadFile, + // ), + // ), Padding( padding: const EdgeInsets.only(left: 6.0), child: GestureDetector( @@ -458,7 +457,7 @@ class _FilesDetailScreenState extends State { ), SizedBox(height: 7), Text( - "${(files[index].contactName ?? '').split("@")[1]}", + "${(files[index].contactName)?.split("@")[1] ?? ''}", style: TextStyle( color: Colors.black, fontWeight: FontWeight.w600, @@ -470,7 +469,7 @@ class _FilesDetailScreenState extends State { children: [ Expanded( child: Text( - "${files[index].contactName}", + "${files[index].contactName ?? ''}", style: TextStyle( color: Colors.black, fontSize: 10, diff --git a/lib/screens/my_files/widgets/downloads_folders.dart b/lib/screens/my_files/widgets/downloads_folders.dart index 291558cd..9edac1eb 100644 --- a/lib/screens/my_files/widgets/downloads_folders.dart +++ b/lib/screens/my_files/widgets/downloads_folders.dart @@ -42,3 +42,4 @@ Future openFilePath(String path) async { CommonUtilityFunctions().showNoFileDialog(); } } + diff --git a/lib/services/common_utility_functions.dart b/lib/services/common_utility_functions.dart index d66ae82c..ee45cb14 100644 --- a/lib/services/common_utility_functions.dart +++ b/lib/services/common_utility_functions.dart @@ -691,215 +691,223 @@ class CommonUtilityFunctions { borderRadius: BorderRadius.circular(10.toHeight), child: GestureDetector( onTap: () async { - await showDialog( - context: NavService.navKey.currentContext!, - builder: (_) => Material( - type: MaterialType.transparency, - child: Column( - children: [ - SizedBox( - height: 10, - ), - Align( - alignment: Alignment.centerLeft, - child: Padding( - padding: const EdgeInsets.only(left: 32), - child: InkWell( - onTap: () { - Navigator.pop( - NavService.navKey.currentContext!); - }, - child: Icon( - Icons.clear, - color: Colors.white, - size: 24, - ), - ), + File test = File(path); + bool fileExists = await test.exists(); + if (fileExists) { + await showDialog( + context: NavService.navKey.currentContext!, + builder: (_) => Material( + type: MaterialType.transparency, + child: Column( + children: [ + SizedBox( + height: 10, ), - ), - SizedBox( - height: 10, - ), - Expanded( - child: Container( - // height: double.infinity, - width: double.infinity, - margin: EdgeInsets.symmetric(horizontal: 33), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - image: DecorationImage( - image: FileImage( - File(path), + Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.only(left: 32), + child: InkWell( + onTap: () { + Navigator.pop( + NavService.navKey.currentContext!); + }, + child: Icon( + Icons.clear, + color: Colors.white, + size: 24, ), - fit: BoxFit.cover, ), ), ), - ), - SizedBox( - height: 40, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(left: 6.0), - child: SvgPicture.asset( - AppVectors.icDownloadFile, - height: 50, - width: 50, + SizedBox( + height: 10, + ), + Expanded( + child: Container( + // height: double.infinity, + width: double.infinity, + margin: EdgeInsets.symmetric(horizontal: 33), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + image: DecorationImage( + image: FileImage( + File(path), + ), + fit: BoxFit.cover, + ), ), ), - SizedBox( - width: 10, - ), - Padding( - padding: const EdgeInsets.only(left: 6.0), - child: GestureDetector( - onTap: () async { - Navigator.pop( - NavService.navKey.currentContext!); - Navigator.pop( - NavService.navKey.currentContext!); - await FileUtils.moveToSendFile(path); - }, - child: SvgPicture.asset( - AppVectors.icSendFile, - height: 50, - width: 50, + ), + SizedBox( + height: 40, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // Padding( + // padding: const EdgeInsets.only(left: 6.0), + // child: SvgPicture.asset( + // AppVectors.icDownloadFile, + // height: 50, + // width: 50, + // ), + // ), + // SizedBox( + // width: 10, + // ), + Padding( + padding: const EdgeInsets.only(left: 6.0), + child: GestureDetector( + onTap: () async { + Navigator.pop( + NavService.navKey.currentContext!); + Navigator.pop( + NavService.navKey.currentContext!); + await FileUtils.moveToSendFile(path); + }, + child: SvgPicture.asset( + AppVectors.icSendFile, + height: 50, + width: 50, + ), ), ), - ), - SizedBox( - width: 10, - ), - Padding( - padding: const EdgeInsets.only(left: 6.0), - child: GestureDetector( - onTap: () async { - await onDelete(); - }, - child: SvgPicture.asset( - AppVectors.icDeleteFile, - height: 50, - width: 50, + SizedBox( + width: 10, + ), + Padding( + padding: const EdgeInsets.only(left: 6.0), + child: GestureDetector( + onTap: () async { + await onDelete(); + }, + child: SvgPicture.asset( + AppVectors.icDeleteFile, + height: 50, + width: 50, + ), ), ), - ), - ], - ), - SizedBox( - height: 40, - ), - Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(5), + ], ), - padding: EdgeInsets.all(20), - margin: EdgeInsets.symmetric(horizontal: 25), - width: double.infinity, - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Text( - fileDetail.fileName ?? "", - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - ), - ), - ), - SizedBox(width: 12), - Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - "$shortDate", + SizedBox( + height: 40, + ), + Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(5), + ), + padding: EdgeInsets.all(20), + margin: EdgeInsets.symmetric(horizontal: 25), + width: double.infinity, + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + fileDetail.fileName ?? "", style: TextStyle( - fontSize: 12, - color: ColorConstants.oldSliver, + fontSize: 18, + fontWeight: FontWeight.bold, ), ), - Container( - width: 1, - height: 8, - color: Color(0xFFD7D7D7), - margin: EdgeInsets.symmetric( - horizontal: 3, + ), + SizedBox(width: 12), + Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "$shortDate", + style: TextStyle( + fontSize: 12, + color: ColorConstants.oldSliver, + ), ), - ), - Text( - "$time", - style: TextStyle( - fontSize: 12, - color: ColorConstants.oldSliver, + Container( + width: 1, + height: 8, + color: Color(0xFFD7D7D7), + margin: EdgeInsets.symmetric( + horizontal: 3, + ), ), - ), - ], + Text( + "$time", + style: TextStyle( + fontSize: 12, + color: ColorConstants.oldSliver, + ), + ), + ], + ), + ], + ), + SizedBox(height: 5), + Text( + double.parse(fileDetail.size.toString()) <= + 1024 + ? '${fileDetail.size} ' + + TextStrings().kb + : '${(fileDetail.size! / (1024 * 1024)).toStringAsFixed(2)} ' + + TextStrings().mb, + style: TextStyle( + color: ColorConstants.grey, + fontSize: 12, ), - ], - ), - SizedBox(height: 5), - Text( - double.parse(fileDetail.size.toString()) <= - 1024 - ? '${fileDetail.size} ' + TextStrings().kb - : '${(fileDetail.size! / (1024 * 1024)).toStringAsFixed(2)} ' + - TextStrings().mb, - style: TextStyle( - color: ColorConstants.grey, - fontSize: 12, + textAlign: TextAlign.left, ), - textAlign: TextAlign.left, - ), - SizedBox(height: 10), - nickname.isNotEmpty - ? Text( - nickname, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ) - : SizedBox(), - SizedBox(height: 5), - Text( - fileDetail.contactName ?? "", - style: TextStyle( - fontSize: 14, + SizedBox(height: 10), + nickname.isNotEmpty + ? Text( + nickname, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), + ) + : SizedBox(), + SizedBox(height: 5), + Text( + fileDetail.contactName ?? "", + style: TextStyle( + fontSize: 14, + ), ), - ), - SizedBox(height: 10), - // fileDetail.message.isNotNull - // ? - Text( - "Message", - style: TextStyle( - fontSize: 12, - color: Colors.grey, + SizedBox(height: 10), + // fileDetail.message.isNotNull + // ? + Text( + "Message", + style: TextStyle( + fontSize: 12, + color: Colors.grey, + ), ), - ), - // : SizedBox(), - SizedBox(height: 5), - Text( - fileDetail.message ?? "", - style: TextStyle( - fontSize: 14, + // : SizedBox(), + SizedBox(height: 5), + Text( + fileDetail.message ?? "", + style: TextStyle( + fontSize: 14, + ), ), - ), - ], + ], + ), ), ), - ), - ], + ], + ), ), - ), - ); + ); + } else { + CommonUtilityFunctions().showNoFileDialog(); + } }, child: Container( height: 50.toHeight,