diff --git a/lib/app.dart b/lib/app.dart index a8963946..06c18da4 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -60,7 +60,7 @@ class _MyAppState extends State { ChangeNotifierProvider(create: (context) => TrustedContactProvider()), ChangeNotifierProvider(create: (context) => AddContactProvider()), ChangeNotifierProvider(create: (context) => NestedRouteProvider()), - ChangeNotifierProvider(create: (context) => SwitchAtsignProvider()), + ChangeNotifierProvider(create: (context) => SwitchAtSignProvider()), ChangeNotifierProvider(create: (context) => FileDownloadChecker()), ChangeNotifierProvider(create: (context) => FileProgressProvider()), ChangeNotifierProvider( @@ -77,10 +77,6 @@ class _MyAppState extends State { builder: (BuildContext context, Widget? child) { final MediaQueryData data = MediaQuery.of(context); return GestureDetector( - onVerticalDragDown: (__) { - // When running in iOS, dismiss the keyboard when when user scrolls - // if (Platform.isIOS) hideKeyboard(context); - }, child: MediaQuery( data: data.copyWith( textScaleFactor: @@ -103,18 +99,6 @@ class _MyAppState extends State { foregroundColor: ColorConstants.iconHeaderColor, ), ), - // theme: ThemeData( - // fontFamily: 'Poppins', - // scaffoldBackgroundColor: Colors.white, - // primaryColor: Color.fromARGB(255, 240, 94, 62), - // appBarTheme: AppBarTheme( - // color: Colors.white, - // elevation: 0, - // iconTheme: IconThemeData(color: Colors.black), - // ), - // buttonBarTheme: ButtonBarThemeData( - // alignment: MainAxisAlignment.center, - // )), routes: routes, ), ); diff --git a/lib/data_models/enums/contact_filter_type.dart b/lib/data_models/enums/contact_filter_type.dart deleted file mode 100644 index d3f1d100..00000000 --- a/lib/data_models/enums/contact_filter_type.dart +++ /dev/null @@ -1,14 +0,0 @@ -enum ContactFilter { all, contacts, groups } - -extension ContactFilterExtension on ContactFilter { - String get display { - switch (this) { - case ContactFilter.all: - return "All Contacts"; - case ContactFilter.contacts: - return "Contacts"; - case ContactFilter.groups: - return "Groups"; - } - } -} diff --git a/lib/data_models/enums/file_types.dart b/lib/data_models/enums/file_types.dart deleted file mode 100644 index 4e73bd89..00000000 --- a/lib/data_models/enums/file_types.dart +++ /dev/null @@ -1,24 +0,0 @@ -// enum FileType { all, photo, video, audio, apk, document, unknown } -// -// extension GenderTypeExtension on FileType { -// String get text { -// switch (this) { -// case FileType.all: -// return 'All'; -// case FileType.photo: -// return 'Photo'; -// case FileType.video: -// return 'Video'; -// case FileType.audio: -// return 'Audio'; -// case FileType.apk: -// return 'APK'; -// case FileType.document: -// return 'Document'; -// case FileType.unknown: -// return 'Unknown'; -// default: -// return ''; -// } -// } -// } diff --git a/lib/dekstop_services/desktop_image_picker.dart b/lib/dekstop_services/desktop_image_picker.dart index a2ca7255..2236bff7 100644 --- a/lib/dekstop_services/desktop_image_picker.dart +++ b/lib/dekstop_services/desktop_image_picker.dart @@ -8,10 +8,6 @@ Future?> desktopImagePicker() async { final XTypeGroup typeGroup = XTypeGroup(); final List files = await openFiles(acceptedTypeGroups: [typeGroup]); - if (files == null) { - return null; - } - await Future.forEach(files, (XFile f) async { selectedFiles.add( PlatformFile( diff --git a/lib/desktop_routes/desktop_routes.dart b/lib/desktop_routes/desktop_routes.dart index c7327718..9b463115 100644 --- a/lib/desktop_routes/desktop_routes.dart +++ b/lib/desktop_routes/desktop_routes.dart @@ -3,7 +3,7 @@ import 'package:atsign_atmosphere_pro/data_models/file_modal.dart'; import 'package:atsign_atmosphere_pro/desktop_routes/desktop_route_names.dart'; import 'package:atsign_atmosphere_pro/desktop_screens/desktop_download_all_files/desktop_download_all_file.dart'; import 'package:atsign_atmosphere_pro/desktop_screens/desktop_home/desktop_home.dart'; -import 'package:atsign_atmosphere_pro/desktop_screens/trusted_sender/desktop_empty_trusted_sender.dart'; +import 'package:atsign_atmosphere_pro/desktop_screens/trusted_sender/widgets/desktop_empty_trusted_sender.dart'; import 'package:atsign_atmosphere_pro/desktop_screens_new/contacts_screen/desktop_contact_screen.dart'; import 'package:atsign_atmosphere_pro/desktop_screens_new/groups_screen/desktop_groups_screen.dart'; import 'package:atsign_atmosphere_pro/desktop_screens_new/settings_screen/blocked_contacts.dart'; diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_contacts_custom_list_tile.dart b/lib/desktop_screens/desktop_common_widgets/desktop_contacts_custom_list_tile.dart deleted file mode 100644 index d7d3c06c..00000000 --- a/lib/desktop_screens/desktop_common_widgets/desktop_contacts_custom_list_tile.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'package:atsign_atmosphere_pro/screens/common_widgets/contact_initial.dart'; -import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; -import 'package:flutter/material.dart'; - -class DesktopContactsCustomListTile extends StatelessWidget { - const DesktopContactsCustomListTile({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return ListTile( - onTap: () {}, - title: Padding( - padding: const EdgeInsets.symmetric(vertical: 6.0), - child: Text( - '@levina', - style: CustomTextStyles.desktopPrimaryRegular18, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - ), - subtitle: Text( - '@levina', - style: CustomTextStyles.secondaryRegular16, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - leading: Container( - height: 50, - width: 50, - decoration: BoxDecoration( - color: Colors.black, - shape: BoxShape.circle, - ), - child: ContactInitial( - initials: 'Levina', - size: 30, - maxSize: (80.0 - 30.0), - minSize: 50, - )), - trailing: IconButton( - onPressed: () {}, - icon: (false) ? Icon(Icons.close) : Icon(Icons.add), - ), - ); - } -} diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_custom_input_field.dart b/lib/desktop_screens/desktop_common_widgets/desktop_custom_input_field.dart index 39ffa1ab..e114f6e4 100644 --- a/lib/desktop_screens/desktop_common_widgets/desktop_custom_input_field.dart +++ b/lib/desktop_screens/desktop_common_widgets/desktop_custom_input_field.dart @@ -30,10 +30,12 @@ class DesktopCustomInputField extends StatelessWidget { @override Widget build(BuildContext context) { - textController = TextEditingController.fromValue(TextEditingValue( - text: initialValue != null ? initialValue : '', - selection: TextSelection.collapsed( - offset: initialValue != null ? initialValue.length : -1))); + textController = TextEditingController.fromValue( + TextEditingValue( + text: initialValue, + selection: TextSelection.collapsed(offset: initialValue.length), + ), + ); return Container( width: width.toWidth, height: height, diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_custom_vertical_tile.dart b/lib/desktop_screens/desktop_common_widgets/desktop_custom_vertical_tile.dart index fe23d663..ed2eaa24 100644 --- a/lib/desktop_screens/desktop_common_widgets/desktop_custom_vertical_tile.dart +++ b/lib/desktop_screens/desktop_common_widgets/desktop_custom_vertical_tile.dart @@ -6,68 +6,76 @@ import 'package:flutter/material.dart'; import 'package:at_common_flutter/services/size_config.dart'; import 'package:provider/provider.dart'; -Widget customPersonVerticalTile( - String title, String? subTitle, Function onCancel) { - // if file is being uploaded. - bool isCancelIcon = !Provider.of( - NavService.navKey.currentContext!, - listen: false) - .isFileSending; +class CustomPersonVerticalTile extends StatelessWidget { + final String title; + final String? subTitle; + final Function onCancel; - return Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - InkWell( - onTap: () {}, - child: Stack( - children: [ - ContactInitial( - initials: title, - size: 50, - maxSize: (80.0 - 30.0), - minSize: 50, - ), - Positioned( - top: 0, - right: 0, - child: InkWell( - onTap: () { - if (onCancel != null) { - onCancel(); - } - }, - child: isCancelIcon ? Icon(Icons.cancel) : SizedBox(), + const CustomPersonVerticalTile({ + required this.title, + this.subTitle, + required this.onCancel, + }); + + @override + Widget build(BuildContext context) { + bool isCancelIcon = !Provider.of( + NavService.navKey.currentContext!, + listen: false) + .isFileSending; + return Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + InkWell( + onTap: () {}, + child: Stack( + children: [ + ContactInitial( + initials: title, + size: 50, + maxSize: (80.0 - 30.0), + minSize: 50, ), - ), - ], - ), - ), - SizedBox(width: 10.toHeight), - Container( - padding: EdgeInsets.symmetric(vertical: 10), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - title, - style: CustomTextStyles.desktopPrimaryRegular14, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - SizedBox(height: 5.toHeight), - subTitle != null - ? Text( - subTitle, - style: CustomTextStyles.secondaryRegular12, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ) - : SizedBox(), - ], + Positioned( + top: 0, + right: 0, + child: InkWell( + onTap: () { + onCancel.call(); + }, + child: isCancelIcon ? Icon(Icons.cancel) : SizedBox(), + ), + ), + ], + ), ), - ) - ], - ); + SizedBox(width: 10.toHeight), + Container( + padding: EdgeInsets.symmetric(vertical: 10), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + title, + style: CustomTextStyles.desktopPrimaryRegular14, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + SizedBox(height: 5.toHeight), + subTitle != null + ? Text( + subTitle!, + style: CustomTextStyles.secondaryRegular12, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ) + : SizedBox(), + ], + ), + ) + ], + ); + } } diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_header.dart b/lib/desktop_screens/desktop_common_widgets/desktop_header.dart index d26b9a35..4882f6b1 100644 --- a/lib/desktop_screens/desktop_common_widgets/desktop_header.dart +++ b/lib/desktop_screens/desktop_common_widgets/desktop_header.dart @@ -6,21 +6,24 @@ import 'package:flutter/material.dart'; class DesktopHeader extends StatelessWidget { final String? title; final ValueChanged? onFilter; - List? actions; - List options = [ + final List? actions; + final List options = [ 'By type', 'By name', 'By size', 'By date', 'add-btn' ]; - bool showBackIcon, isTitleCentered; - DesktopHeader( - {this.title, - this.showBackIcon = true, - this.onFilter, - this.actions, - this.isTitleCentered = false}); + final bool showBackIcon, isTitleCentered; + + DesktopHeader({ + this.title, + this.showBackIcon = true, + this.onFilter, + this.actions, + this.isTitleCentered = false, + }); + @override Widget build(BuildContext context) { return Container( diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_person_horizontal_tile.dart b/lib/desktop_screens/desktop_common_widgets/desktop_person_horizontal_tile.dart deleted file mode 100644 index 975902b4..00000000 --- a/lib/desktop_screens/desktop_common_widgets/desktop_person_horizontal_tile.dart +++ /dev/null @@ -1,102 +0,0 @@ -import 'dart:typed_data'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/contact_initial.dart'; -import 'package:at_common_flutter/services/size_config.dart'; -import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; -import 'package:flutter/material.dart'; -// ignore: import_of_legacy_library_into_null_safe - -// ignore: must_be_immutable -class DesktopCustomPersonHorizontalTile extends StatelessWidget { - final String? title, subTitle; - final bool isTopRight; - final IconData? icon; - List? image; - - DesktopCustomPersonHorizontalTile({ - this.image, - this.title, - this.subTitle, - this.isTopRight = false, - this.icon, - }) { - if (image != null) { - var intList = image!.cast(); - image = Uint8List.fromList(intList); - } - } - - @override - Widget build(BuildContext context) { - return Container( - child: Row( - children: [ - Stack( - children: [ - image != null - ? ClipRRect( - borderRadius: - BorderRadius.all(Radius.circular(30.toWidth)), - child: Image.memory( - image as Uint8List, - width: 50.toWidth, - height: 50.toWidth, - fit: BoxFit.fill, - errorBuilder: (BuildContext _context, _, __) { - return Container( - child: Icon( - Icons.image, - size: 30.toFont, - ), - ); - }, - ), - ) - : ContactInitial( - initials: title ?? ' ', - size: 30, - maxSize: (80.0 - 30.0), - minSize: 50, - ), - icon != null - ? Positioned( - top: isTopRight ? 0 : null, - right: 0, - bottom: !isTopRight ? 0 : null, - child: Icon(icon)) - : SizedBox(), - ], - ), - SizedBox(width: 10.toHeight), - Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: 100, - child: title != null - ? Text( - title!, - style: CustomTextStyles.blackBold(), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ) - : SizedBox(), - ), - SizedBox(height: 5.toHeight), - subTitle != null - ? Text( - subTitle!, - style: CustomTextStyles.greyText16, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ) - : SizedBox(), - ], - ), - ) - ], - ), - ); - } -} diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_person_vertical_tile.dart b/lib/desktop_screens/desktop_common_widgets/desktop_person_vertical_tile.dart index 3f39dd7c..be90d240 100644 --- a/lib/desktop_screens/desktop_common_widgets/desktop_person_vertical_tile.dart +++ b/lib/desktop_screens/desktop_common_widgets/desktop_person_vertical_tile.dart @@ -3,11 +3,12 @@ import 'package:at_contacts_group_flutter/widgets/custom_circle_avatar.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/contact_initial.dart'; import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; import 'package:flutter/material.dart'; + // ignore: import_of_legacy_library_into_null_safe import 'package:at_common_flutter/services/size_config.dart'; class DesktopCustomPersonVerticalTile extends StatefulWidget { - final String? imageLocation, title, subTitle, atsign; + final String? imageLocation, title, subTitle, atSign; final bool isTopRight, isAssetImage; final IconData? icon; final Function? onCrossPressed; @@ -22,7 +23,7 @@ class DesktopCustomPersonVerticalTile extends StatefulWidget { this.onCrossPressed, this.isAssetImage = true, this.imageIntList, - this.atsign}); + this.atSign}); @override _DesktopCustomPersonVerticalTileState createState() => @@ -33,6 +34,7 @@ class _DesktopCustomPersonVerticalTileState extends State { Uint8List? image; String? contactName; + @override void initState() { super.initState(); diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_selected_contacts.dart b/lib/desktop_screens/desktop_common_widgets/desktop_selected_contacts.dart index 4ecac0e1..0add7422 100644 --- a/lib/desktop_screens/desktop_common_widgets/desktop_selected_contacts.dart +++ b/lib/desktop_screens/desktop_common_widgets/desktop_selected_contacts.dart @@ -7,8 +7,9 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class DesktopSelectedContacts extends StatefulWidget { - ValueChanged onChange; - bool showCancelIcon; + final ValueChanged onChange; + final bool showCancelIcon; + DesktopSelectedContacts(this.onChange, {this.showCancelIcon = false}); @override @@ -58,10 +59,10 @@ class _DesktopSelectedContactsState extends State { runSpacing: 10.0, spacing: 30.0, children: List.generate(selectedContacts.length, (index) { - return customPersonVerticalTile( - selectedContacts[index]!.contact!.atSign!, - selectedContacts[index]!.contact!.atSign, - () { + return CustomPersonVerticalTile( + title: selectedContacts[index]!.contact!.atSign!, + subTitle: selectedContacts[index]!.contact!.atSign, + onCancel: () { welcomeScreenProvider.removeContacts(selectedContacts[index]); welcomeScreenProvider.isSelectionItemChanged = true; widget.onChange(true); diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_selected_files.dart b/lib/desktop_screens/desktop_common_widgets/desktop_selected_files.dart index e37aeec5..52979a28 100644 --- a/lib/desktop_screens/desktop_common_widgets/desktop_selected_files.dart +++ b/lib/desktop_screens/desktop_common_widgets/desktop_selected_files.dart @@ -10,23 +10,26 @@ import 'package:provider/provider.dart'; import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; class DesktopSelectedFiles extends StatefulWidget { - ValueChanged onChange; + final ValueChanged onChange; final bool showCancelIcon; - DesktopSelectedFiles(this.onChange, {this.showCancelIcon = true}); + + DesktopSelectedFiles( + this.onChange, { + this.showCancelIcon = true, + }); + @override _DesktopSelectedFilesState createState() => _DesktopSelectedFilesState(); } class _DesktopSelectedFilesState extends State { - FileTransferProvider? _filePickerProvider; late WelcomeScreenProvider welcomeScreenProvider; + @override void initState() { welcomeScreenProvider = Provider.of( NavService.navKey.currentContext!, listen: false); - _filePickerProvider = - Provider.of(context, listen: false); super.initState(); } diff --git a/lib/desktop_screens/desktop_common_widgets/desktop_switch_atsign.dart b/lib/desktop_screens/desktop_common_widgets/desktop_switch_atsign.dart index f1a59c66..50ccf36b 100644 --- a/lib/desktop_screens/desktop_common_widgets/desktop_switch_atsign.dart +++ b/lib/desktop_screens/desktop_common_widgets/desktop_switch_atsign.dart @@ -11,51 +11,55 @@ import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; import 'package:flutter/material.dart'; -class DesktopSwitchAtsign extends StatefulWidget { - String atsign; - DesktopSwitchAtsign({Key? key, required this.atsign}) : super(key: key); +class DesktopSwitchAtSign extends StatefulWidget { + final String atSign; + + DesktopSwitchAtSign({ + Key? key, + required this.atSign, + }) : super(key: key); @override - State createState() => _DesktopSwitchAtsignState(); + State createState() => _DesktopSwitchAtSignState(); } -class _DesktopSwitchAtsignState extends State { +class _DesktopSwitchAtSignState extends State { BackendService backendService = BackendService.getInstance(); - bool isCurrentAtsign = false; - var atClientPrefernce; + bool isCurrentAtSign = false; + var atClientPreference; AtClient atClient = AtClientManager.getInstance().atClient; - String? atsignName = ''; + String? atSignName = ''; @override void initState() { - if (widget.atsign == atClient.getCurrentAtSign()) { - isCurrentAtsign = true; + if (widget.atSign == atClient.getCurrentAtSign()) { + isCurrentAtSign = true; } - getAtsignDetails(); + getAtSignDetails(); super.initState(); } - getAtsignDetails() { - atsignName = CommonUtilityFunctions().getCachedContactName(widget.atsign); + getAtSignDetails() { + atSignName = CommonUtilityFunctions().getCachedContactName(widget.atSign); setState(() {}); } @override Widget build(BuildContext context) { - if (widget.atsign == TextStrings().addNewAtsign) { + if (widget.atSign == TextStrings().addNewAtSign) { return addNewContactRow(); - } else if (widget.atsign == TextStrings().saveBackupKey) { + } else if (widget.atSign == TextStrings().saveBackupKey) { return saveBackupKeyRow(); } else { - return _contactRow(widget.atsign, atsignName ?? '', - isCurrentAtsign: isCurrentAtsign); + return _contactRow(widget.atSign, atSignName ?? '', + isCurrentAtSign: isCurrentAtSign); } } - Widget _contactRow(String _atsign, String _name, - {bool isCurrentAtsign = false}) { + Widget _contactRow(String _atSign, String _name, + {bool isCurrentAtSign = false}) { Uint8List? image = - CommonUtilityFunctions().getCachedContactImage(widget.atsign); + CommonUtilityFunctions().getCachedContactImage(widget.atSign); return Row( children: [ @@ -63,18 +67,18 @@ class _DesktopSwitchAtsignState extends State { ? CustomCircleAvatar( byteImage: image, nonAsset: true, - size: isCurrentAtsign ? 40 : 40, + size: isCurrentAtSign ? 40 : 40, ) : ContactInitial( - initials: _atsign, - size: isCurrentAtsign ? 40 : 40, - maxSize: isCurrentAtsign ? 50 : 40, - minSize: isCurrentAtsign ? 40 : 30, + initials: _atSign, + size: isCurrentAtSign ? 40 : 40, + maxSize: isCurrentAtSign ? 50 : 40, + minSize: isCurrentAtSign ? 40 : 30, ), SizedBox(width: 10), Container( child: Tooltip( - message: _atsign, + message: _atSign, child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, @@ -82,8 +86,8 @@ class _DesktopSwitchAtsignState extends State { SizedBox( width: 180, child: Text( - _atsign, - style: isCurrentAtsign + _atSign, + style: isCurrentAtSign ? CustomTextStyles.blackBold() : CustomTextStyles.desktopSecondaryRegular14, maxLines: 1, @@ -91,12 +95,12 @@ class _DesktopSwitchAtsignState extends State { ), ), SizedBox(height: 5), - (_name != null && _name != '') + _name.isNotEmpty ? SizedBox( width: 180, child: Text( _name, - style: isCurrentAtsign + style: isCurrentAtSign ? CustomTextStyles.greyText16 : CustomTextStyles.desktopSecondaryRegular14, maxLines: 1, @@ -115,7 +119,7 @@ class _DesktopSwitchAtsignState extends State { onTap: () { Navigator.of(NavService.navKey.currentContext!) .pop(); // this is to close the popup menu button - CommonUtilityFunctions().deleteAtSign(widget.atsign); + CommonUtilityFunctions().deleteAtSign(widget.atSign); }, child: Icon(Icons.delete))), ) diff --git a/lib/desktop_screens/desktop_common_widgets/person_vertical_tile.dart b/lib/desktop_screens/desktop_common_widgets/person_vertical_tile.dart index a5ba3751..5c91dfde 100644 --- a/lib/desktop_screens/desktop_common_widgets/person_vertical_tile.dart +++ b/lib/desktop_screens/desktop_common_widgets/person_vertical_tile.dart @@ -5,6 +5,7 @@ import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/contact_initial.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/triple_dot_loading.dart'; import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; + // import 'package:atsign_atmosphere_pro/services/size_config.dart' ; import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; import 'package:atsign_atmosphere_pro/view_models/file_transfer_provider.dart'; @@ -13,7 +14,7 @@ import 'package:provider/provider.dart'; class CustomPersonVerticalTile extends StatefulWidget { final ShareStatus shareStatus; - final bool isFailedAtsignList; + final bool isFailedAtSignList; final FileHistory? fileHistory; @override final Key? key; @@ -22,7 +23,7 @@ class CustomPersonVerticalTile extends StatefulWidget { {this.key, required this.shareStatus, required this.fileHistory, - this.isFailedAtsignList = false}); + this.isFailedAtSignList = false}); @override _CustomPersonVerticalTileState createState() => @@ -32,14 +33,15 @@ class CustomPersonVerticalTile extends StatefulWidget { class _CustomPersonVerticalTileState extends State { Uint8List? image; String? contactName; + @override void initState() { super.initState(); - getAtsignImage(); + getAtSignImage(); } // ignore: always_declare_return_types - getAtsignImage() async { + getAtSignImage() async { if (widget.shareStatus.atsign == null) return; var contact = await getAtSignDetails(widget.shareStatus.atsign!); @@ -98,7 +100,7 @@ class _CustomPersonVerticalTileState extends State { initials: widget.shareStatus.atsign ?? ' ', ), ), - widget.isFailedAtsignList + widget.isFailedAtSignList ? Positioned( child: Container( height: 50.toHeight, @@ -110,7 +112,7 @@ class _CustomPersonVerticalTileState extends State { child: InkWell( onTap: () async { print( - 'selectedFileHistory : ${widget.fileHistory!.fileTransferObject!.transferId}, atsign: ${widget.shareStatus.atsign}'); + 'selectedFileHistory : ${widget.fileHistory!.fileTransferObject!.transferId}, atSign: ${widget.shareStatus.atsign}'); await Provider.of(context, listen: false) diff --git a/lib/desktop_screens/desktop_download_all_files/desktop_download_all_file.dart b/lib/desktop_screens/desktop_download_all_files/desktop_download_all_file.dart index 0fcd1fc1..da952c9f 100644 --- a/lib/desktop_screens/desktop_download_all_files/desktop_download_all_file.dart +++ b/lib/desktop_screens/desktop_download_all_files/desktop_download_all_file.dart @@ -35,7 +35,7 @@ class _DesktopDownloadAllFilesState extends State { child: Column( children: [ Text( - TextStrings().recievedFileDownloadMsg, + TextStrings().receivedFileDownloadMsg, style: TextStyle( fontSize: 20.toFont, fontWeight: FontWeight.bold, diff --git a/lib/desktop_screens/desktop_history/desktop_history.dart b/lib/desktop_screens/desktop_history/desktop_history.dart index 62a369a2..f2585aa1 100644 --- a/lib/desktop_screens/desktop_history/desktop_history.dart +++ b/lib/desktop_screens/desktop_history/desktop_history.dart @@ -16,8 +16,12 @@ import 'package:provider/provider.dart'; class DesktopHistoryScreen extends StatefulWidget { final int tabIndex; - Key? key; - DesktopHistoryScreen({this.tabIndex = 0, this.key}); + + DesktopHistoryScreen({ + Key? key, + this.tabIndex = 0, + }); + @override _DesktopHistoryScreenState createState() => _DesktopHistoryScreenState(); } @@ -102,9 +106,7 @@ class _DesktopHistoryScreenState extends State @override Widget build(BuildContext context) { - if (historyProvider == null) { - historyProvider = Provider.of(context); - } + historyProvider = Provider.of(context); SizeConfig().init(context); return Scaffold( backgroundColor: ColorConstants.scaffoldColor, @@ -214,7 +216,7 @@ class _DesktopHistoryScreenState extends State } }, errorBuilder: (provider) => Center( - child: Text(TextStrings().errorOccured), + child: Text(TextStrings().errorOccurred), ), load: (provider) async { provider.getSentHistory(); @@ -263,7 +265,7 @@ class _DesktopHistoryScreenState extends State } }, errorBuilder: (provider) => Center( - child: Text(TextStrings().errorOccured), + child: Text(TextStrings().errorOccurred), ), ), ], diff --git a/lib/desktop_screens/desktop_history/widgets/desktop_received_file_details.dart b/lib/desktop_screens/desktop_history/widgets/desktop_received_file_details.dart index 088cbc36..362debdf 100644 --- a/lib/desktop_screens/desktop_history/widgets/desktop_received_file_details.dart +++ b/lib/desktop_screens/desktop_history/widgets/desktop_received_file_details.dart @@ -34,7 +34,7 @@ class _DesktopReceivedFileDetailsState int fileCount = 0, fileSize = 0; bool isDownloadAvailable = false, isDownloaded = false, - isFilesAvailableOfline = true, + isFilesAvailableOffline = true, isOverwrite = false; List existingFileNamesToOverwrite = []; Map _futureBuilder = {}; @@ -85,7 +85,7 @@ class _DesktopReceivedFileDetailsState if (fileExists == false) { if (mounted) { setState(() { - isFilesAvailableOfline = false; + isFilesAvailableOffline = false; }); } } else { @@ -166,7 +166,7 @@ class _DesktopReceivedFileDetailsState padding: const EdgeInsets.only(right: 10.0), child: IconButton( icon: ((isDownloaded || - isFilesAvailableOfline) && + isFilesAvailableOffline) && !isOverwrite) ? Icon( Icons.done, @@ -477,13 +477,13 @@ class _DesktopReceivedFileDetailsState setState(() { isDownloaded = true; isOverwrite = false; - isFilesAvailableOfline = true; + isFilesAvailableOffline = true; }); } - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, - TextStrings().fileDownloadd, + TextStrings().fileDownload, bgColor: ColorConstants.successGreen, ); @@ -495,7 +495,7 @@ class _DesktopReceivedFileDetailsState listen: false) .sendFileDownloadAcknowledgement(widget.fileTransfer!); } else { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings().downloadFailed, bgColor: ColorConstants.redAlert, diff --git a/lib/desktop_screens/desktop_history/widgets/desktop_received_file_list_tile.dart b/lib/desktop_screens/desktop_history/widgets/desktop_received_file_list_tile.dart index ae98b179..1cca30a0 100644 --- a/lib/desktop_screens/desktop_history/widgets/desktop_received_file_list_tile.dart +++ b/lib/desktop_screens/desktop_history/widgets/desktop_received_file_list_tile.dart @@ -33,9 +33,12 @@ class DesktopReceivedFilesListTile extends StatefulWidget { final FileTransfer? receivedHistory; final bool isSelected; - const DesktopReceivedFilesListTile( - {Key? key, this.receivedHistory, this.isSelected = false}) - : super(key: key); + const DesktopReceivedFilesListTile({ + Key? key, + this.receivedHistory, + this.isSelected = false, + }) : super(key: key); + @override _DesktopReceivedFilesListTileState createState() => _DesktopReceivedFilesListTileState(); @@ -91,8 +94,8 @@ class _DesktopReceivedFilesListTileState videoThumbnail = await VideoThumbnail.thumbnailData( video: path, imageFormat: ImageFormat.JPEG, - maxWidth: - 50, // specify the width of the thumbnail, let the height auto-scaled to keep the source aspect ratio + maxWidth: 50, + // specify the width of the thumbnail, let the height auto-scaled to keep the source aspect ratio quality: 100, ); return videoThumbnail; @@ -702,13 +705,13 @@ class _DesktopReceivedFilesListTileState .deleteReceivedItem(widget.receivedHistory!); if (res) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, 'Removed from received items list', bgColor: ColorConstants.successGreen); await deleteFileWhenRecevedItemRemoved(); } else { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, 'Failed', bgColor: ColorConstants.redAlert); } @@ -745,7 +748,7 @@ class _DesktopReceivedFilesListTileState await Provider.of( NavService.navKey.currentContext!, listen: false) - .deletMyFileRecord(widget.receivedHistory!.key); + .deleteMyFileRecord(widget.receivedHistory!.key); })); }); } diff --git a/lib/desktop_screens/desktop_history/widgets/desktop_sent_file_details.dart b/lib/desktop_screens/desktop_history/widgets/desktop_sent_file_details.dart index d2d09953..a2448bb4 100644 --- a/lib/desktop_screens/desktop_history/widgets/desktop_sent_file_details.dart +++ b/lib/desktop_screens/desktop_history/widgets/desktop_sent_file_details.dart @@ -17,8 +17,11 @@ import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; class DesktopSentFileDetails extends StatefulWidget { final FileHistory? selectedFileData; - Key? key; - DesktopSentFileDetails({this.key, this.selectedFileData}); + + DesktopSentFileDetails({ + Key? key, + this.selectedFileData, + }); @override _DesktopSentFileDetailsState createState() => _DesktopSentFileDetailsState(); @@ -183,7 +186,7 @@ class _DesktopSentFileDetailsState extends State { onPressed: () async { await Provider.of(context, listen: false) - .reuploadFiles( + .reUploadFiles( widget.selectedFileData!.fileDetails! .files!, index, @@ -241,7 +244,7 @@ class _DesktopSentFileDetailsState extends State { : SizedBox(), SizedBox(height: 15.toHeight), widget.selectedFileData != null - ? DesktopTranferOverlappingContacts( + ? DesktopTransferOverlappingContacts( key: Key(widget .selectedFileData!.fileTransferObject!.transferId), selectedList: widget.selectedFileData!.sharedWith, diff --git a/lib/desktop_screens/desktop_history/widgets/desktop_sent_file_list_tile.dart b/lib/desktop_screens/desktop_history/widgets/desktop_sent_file_list_tile.dart index 312d6578..d1ee3f94 100644 --- a/lib/desktop_screens/desktop_history/widgets/desktop_sent_file_list_tile.dart +++ b/lib/desktop_screens/desktop_history/widgets/desktop_sent_file_list_tile.dart @@ -379,7 +379,7 @@ class _DesktopSentFilesListTileState extends State { FileTransferProvider>( context, listen: false) - .reuploadFiles( + .reUploadFiles( filesList!, index, widget diff --git a/lib/desktop_screens/desktop_history/widgets/desktop_transfer_overlapping.dart b/lib/desktop_screens/desktop_history/widgets/desktop_transfer_overlapping.dart index ca0de228..3b51a83a 100644 --- a/lib/desktop_screens/desktop_history/widgets/desktop_transfer_overlapping.dart +++ b/lib/desktop_screens/desktop_history/widgets/desktop_transfer_overlapping.dart @@ -8,38 +8,38 @@ import 'package:at_common_flutter/services/size_config.dart'; import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; import 'package:provider/provider.dart'; -class DesktopTranferOverlappingContacts extends StatefulWidget { +class DesktopTransferOverlappingContacts extends StatefulWidget { final List? selectedList; final FileHistory? fileHistory; - const DesktopTranferOverlappingContacts( + const DesktopTransferOverlappingContacts( {Key? key, this.selectedList, this.fileHistory}) : super(key: key); @override - _DesktopTranferOverlappingContactsState createState() => - _DesktopTranferOverlappingContactsState(); + _DesktopTransferOverlappingContactsState createState() => + _DesktopTransferOverlappingContactsState(); } -class _DesktopTranferOverlappingContactsState - extends State { +class _DesktopTransferOverlappingContactsState + extends State { bool isExpanded = false; int noOfContactsRow = 0; - List atsignResharing = []; + List atSignReSharing = []; List deliveredToList = []; List downloadedByList = []; List filedInDeliveringList = []; @override void initState() { - atsignResharing = + atSignReSharing = List.generate(widget.selectedList!.length, (i) => false); noOfContactsRow = (widget.selectedList!.length / 5).ceil(); - sortAtsigns(); + sortAtSigns(); super.initState(); } - sortAtsigns() { + sortAtSigns() { deliveredToList = []; downloadedByList = []; filedInDeliveringList = []; @@ -64,7 +64,7 @@ class _DesktopTranferOverlappingContactsState EdgeInsets.symmetric(horizontal: 20.toHeight, vertical: 5.toHeight), child: Consumer( builder: (context, provider, _) { - sortAtsigns(); + sortAtSigns(); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -184,7 +184,7 @@ class _DesktopTranferOverlappingContactsState key: Key(filedInDeliveringList[index].atsign!), shareStatus: filedInDeliveringList[index], fileHistory: widget.fileHistory, - isFailedAtsignList: true), + isFailedAtSignList: true), ); }), ), diff --git a/lib/desktop_screens/desktop_home/desktop_home.dart b/lib/desktop_screens/desktop_home/desktop_home.dart index 1b665145..37d0f7c6 100644 --- a/lib/desktop_screens/desktop_home/desktop_home.dart +++ b/lib/desktop_screens/desktop_home/desktop_home.dart @@ -23,9 +23,9 @@ class DesktopHome extends StatefulWidget { class _DesktopHomeState extends State { BackendService backendService = BackendService.getInstance(); - late var atClientPrefernce; + late var atClientPreference; bool authenticating = false, onboardError = false; - String? currentatSign; + String? currentAtSign; @override void initState() { @@ -48,32 +48,29 @@ class _DesktopHomeState extends State { } void _checkToOnboard() async { - currentatSign = await backendService.getAtSign(); + currentAtSign = await backendService.getAtSign(); - if (currentatSign == '') { - currentatSign = null; + if (currentAtSign == '') { + currentAtSign = null; } if (mounted) { setState(() {}); } - print('currentatSign $currentatSign, ${(currentatSign != null)}'); + print('currentAtSign $currentAtSign, ${(currentAtSign != null)}'); await backendService .getAtClientPreference() - .then((value) => atClientPrefernce = value) - .catchError((e) { - print(e); - }); + .then((value) => atClientPreference = value); - if (currentatSign != null) { - await _onBoard(currentatSign); + if (currentAtSign != null) { + await _onBoard(currentAtSign); } } - Future _onBoard(String? _atsign) async { + Future _onBoard(String? _atSign) async { await CustomOnboarding.onboard( - atSign: _atsign, - atClientPrefernce: atClientPrefernce, + atSign: _atSign, + atClientPreference: atClientPreference, isInit: true, onError: onOnboardError); } @@ -110,16 +107,16 @@ class _DesktopHomeState extends State { Center( child: CommonButton( authenticating - ? '${TextStrings().initialisingFor} $currentatSign...' - : (currentatSign != null && !onboardError + ? '${TextStrings().initialisingFor} $currentAtSign...' + : (currentAtSign != null && !onboardError ? TextStrings().authenticating : 'Upload atSign'), - (currentatSign != null && !onboardError) + (currentAtSign != null && !onboardError) ? null : () { _onBoard(''); }, - color: (currentatSign != null && !onboardError) + color: (currentAtSign != null && !onboardError) ? ColorConstants.dullText : ColorConstants.raisinBlack, border: 252, @@ -133,7 +130,7 @@ class _DesktopHomeState extends State { Center( child: InkWell( onTap: () async { - await CommonUtilityFunctions().showResetAtsignDialog(); + await CommonUtilityFunctions().showResetAtSignDialog(); }, child: Container( width: 200, diff --git a/lib/desktop_screens/desktop_my_files/desktop_my_files.dart b/lib/desktop_screens/desktop_my_files/desktop_my_files.dart deleted file mode 100644 index 4a4cfff9..00000000 --- a/lib/desktop_screens/desktop_my_files/desktop_my_files.dart +++ /dev/null @@ -1,220 +0,0 @@ -import 'package:atsign_atmosphere_pro/desktop_screens/desktop_common_widgets/desktop_custom_input_field.dart'; -import 'package:atsign_atmosphere_pro/desktop_screens/desktop_common_widgets/desktop_header.dart'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; -import 'package:atsign_atmosphere_pro/view_models/history_provider.dart'; -import 'package:at_common_flutter/at_common_flutter.dart'; -import 'package:atsign_atmosphere_pro/view_models/my_files_provider.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -class DesktopMyFiles extends StatefulWidget { - @override - _DesktopMyFilesState createState() => _DesktopMyFilesState(); -} - -class _DesktopMyFilesState extends State - with TickerProviderStateMixin { - TabController? _controller; - late MyFilesProvider myFilesProvider; - bool _isFilterOption = false; - List tabs = []; - List tabNames = []; - - bool isLoading = false; - @override - void initState() { - myFilesProvider = Provider.of(context, listen: false); - ini(); - setState(() {}); - super.initState(); - } - - ini() async { - tabs = []; - tabNames = []; - tabs = Provider.of(context, listen: false).tabs; - tabNames = Provider.of(context, listen: false).tabNames; - _controller = - TabController(length: tabs.length, vsync: this, initialIndex: 0); - } - - @override - Widget build(BuildContext context) { - SizeConfig().init(context); - return Scaffold( - backgroundColor: ColorConstants.fadedBlue, - body: Stack( - children: [ - SingleChildScrollView( - child: (isLoading) - ? Center( - child: CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation( - ColorConstants.orange, - ), - )) - : Container( - // reducing size by 75 , so that last list item will be shown - height: SizeConfig().screenHeight, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox(height: 20), - DesktopHeader( - showBackIcon: false, - title: "My Files", - onFilter: (val) { - setState(() { - _isFilterOption = !_isFilterOption; - }); - }, - actions: [ - DesktopCustomInputField( - backgroundColor: Colors.white, - hintText: 'Search...', - icon: Icons.search, - height: 45, - iconColor: ColorConstants.greyText, - value: (val) { - myFilesProvider - .setFileSearchText(val.toLowerCase()); - }), - SizedBox(width: 15), - //TODO: filter option is removed from ui for now. - // InkWell( - // onTap: () { - // setState(() { - // _isFilterOption = !_isFilterOption; - // }); - // }, - // child: Container( - // child: Icon(Icons.filter_list_sharp), - // ), - // ), - // SizedBox(width: 10), - ]), - Container( - height: 40, - padding: EdgeInsets.only(left: 50), - child: TabBar( - onTap: (index) async {}, - isScrollable: true, - labelColor: ColorConstants.fontPrimary, - indicatorWeight: 5.toHeight, - indicatorColor: Colors.black, - indicatorSize: TabBarIndicatorSize.tab, - labelStyle: CustomTextStyles.primaryBold14, - unselectedLabelStyle: - CustomTextStyles.secondaryRegular14, - controller: _controller, - tabs: List.generate(tabNames.length, - (index) => Text(tabNames[index])), - ), - ), - SizedBox(height: 15), - Expanded( - child: TabBarView( - controller: _controller, - physics: ClampingScrollPhysics(), - children: tabs, - ), - ) - ], - ), - ), - ), - _isFilterOption - ? Positioned( - right: 15, - top: 20, - child: Container( - width: 150, - padding: EdgeInsets.only( - right: 10, left: 10, top: 10, bottom: 10), - decoration: BoxDecoration( - color: Colors.white, - border: Border.all( - color: ColorConstants.light_grey, width: 1), - borderRadius: BorderRadius.circular(10)), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Filters', - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold), - ), - InkWell( - onTap: () { - setState(() { - _isFilterOption = !_isFilterOption; - }); - }, - child: Icon(Icons.close, size: 18), - ), - ], - ), - Divider( - height: 10, - color: ColorConstants.greyText, - ), - getFilterOptionWidget('By type', true), - getFilterOptionWidget('By name', false), - getFilterOptionWidget('By size', false), - getFilterOptionWidget('By date', false), - SizedBox(height: 15), - TextButton( - onPressed: () {}, - style: ButtonStyle(backgroundColor: - MaterialStateProperty.resolveWith( - (Set states) { - return ColorConstants.orangeColor; - }, - ), fixedSize: MaterialStateProperty.resolveWith( - (Set states) { - return Size(120, 40); - }, - )), - child: Text( - 'Apply', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.normal, - ), - ), - ), - ], - ), - ), - ) - : SizedBox() - ], - ), - ); - } - - Widget getFilterOptionWidget(String title, bool isSelected) { - return Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - title, - style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold), - ), - Checkbox( - value: isSelected, - onChanged: (value) {}, - activeColor: Colors.black, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all( - Radius.circular(15), - ), - ), - ), - ], - ); - } -} diff --git a/lib/desktop_screens/desktop_my_files/widgets/desktop_file_card.dart b/lib/desktop_screens/desktop_my_files/widgets/desktop_file_card.dart index 2d2d594f..63f27d3e 100644 --- a/lib/desktop_screens/desktop_my_files/widgets/desktop_file_card.dart +++ b/lib/desktop_screens/desktop_my_files/widgets/desktop_file_card.dart @@ -17,13 +17,14 @@ class DesktopFileCard extends StatefulWidget { final String? filePath; final bool showDelete; final String transferId; - Key? key; - DesktopFileCard( - {this.title, - this.filePath, - this.showDelete = false, - required this.transferId, - this.key}); + + DesktopFileCard({ + Key? key, + this.title, + this.filePath, + this.showDelete = false, + required this.transferId, + }); @override State createState() => _DesktopFileCardState(); @@ -31,6 +32,7 @@ class DesktopFileCard extends StatefulWidget { class _DesktopFileCardState extends State { late Future _futureBuilder; + @override void initState() { super.initState(); diff --git a/lib/desktop_screens/desktop_my_files/widgets/desktop_recent.dart b/lib/desktop_screens/desktop_my_files/widgets/desktop_recent.dart index 44cadefc..ac7b20ba 100644 --- a/lib/desktop_screens/desktop_my_files/widgets/desktop_recent.dart +++ b/lib/desktop_screens/desktop_my_files/widgets/desktop_recent.dart @@ -10,12 +10,12 @@ import 'package:at_common_flutter/services/size_config.dart'; import 'package:open_file/open_file.dart'; import 'package:provider/provider.dart'; -class DesktopRecents extends StatefulWidget { +class DesktopRecent extends StatefulWidget { @override - _DesktopRecentsState createState() => _DesktopRecentsState(); + _DesktopRecentState createState() => _DesktopRecentState(); } -class _DesktopRecentsState extends State { +class _DesktopRecentState extends State { String? onHoverFileName; @override diff --git a/lib/desktop_screens/desktop_settings/desktop_settings.dart b/lib/desktop_screens/desktop_settings/desktop_settings.dart deleted file mode 100644 index ff7a5421..00000000 --- a/lib/desktop_screens/desktop_settings/desktop_settings.dart +++ /dev/null @@ -1,169 +0,0 @@ -import 'package:at_backupkey_flutter/widgets/backup_key_widget.dart'; -import 'package:at_client_mobile/at_client_mobile.dart'; -import 'package:at_common_flutter/services/size_config.dart'; -import 'package:atsign_atmosphere_pro/desktop_screens/desktop_common_widgets/desktop_header.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/switch_at_sign.dart'; -import 'package:atsign_atmosphere_pro/screens/settings/widgets/settings_buttons.dart'; -import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; -import 'package:atsign_atmosphere_pro/services/navigation_service.dart'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:atsign_atmosphere_pro/utils/images.dart'; -import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; -import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; -import 'package:flutter/material.dart'; -import 'package:package_info_plus/package_info_plus.dart'; -import 'package:url_launcher/url_launcher.dart'; - -class DesktopSettings extends StatefulWidget { - const DesktopSettings({Key? key}) : super(key: key); - - @override - State createState() => _DesktopSettingsState(); -} - -class _DesktopSettingsState extends State { - final List optionTitle = [ - TextStrings().switchatSign, - TextStrings().backUpKeys, - TextStrings().faqs, - TextStrings().contactUs, - TextStrings().termsAppBar, - TextStrings().deleteAtsigns, - ]; - - final List optionIcons = [ - ImageConstants.switchAtSign, - ImageConstants.backupKeys, - ImageConstants.faqs, - ImageConstants.contactUsLogo, - ImageConstants.termsAndConditions, - ImageConstants.deleteAtsigns, - ]; - - void switchAtsign() async { - var atSignList = await KeychainUtil.getAtsignList(); - await showModalBottomSheet( - context: NavService.navKey.currentContext!, - backgroundColor: Colors.transparent, - builder: (context) => AtSignBottomSheet( - atSignList: atSignList, - ), - ); - } - - @override - void initState() { - super.initState(); - - _initPackageInfo(); - } - - PackageInfo _packageInfo = PackageInfo( - appName: 'Unknown', - packageName: 'Unknown', - version: 'Unknown', - buildNumber: 'Unknown', - ); - - Future _initPackageInfo() async { - final PackageInfo info = await PackageInfo.fromPlatform(); - if (mounted) { - setState(() { - _packageInfo = info; - }); - } - } - - @override - Widget build(BuildContext context) { - SizeConfig().init(context); - return Scaffold( - body: Stack( - children: [ - Container( - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage( - ImageConstants.backgroundDesktop, - ), - fit: BoxFit.fill, - ), - ), - ), - SafeArea( - child: Column( - children: [ - SizedBox(height: 20), - DesktopHeader( - title: TextStrings().sidebarSettings, - showBackIcon: false, - ), - Padding( - padding: - const EdgeInsets.symmetric(horizontal: 36, vertical: 18), - child: ListView( - shrinkWrap: true, - children: [ - Text( - 'App Version ${_packageInfo.version} (${_packageInfo.buildNumber})', - style: CustomTextStyles.black12, - ), - SizedBox( - height: 28, - ), - SettingsButton( - buttonText: optionTitle[0], - onPressed: switchAtsign, - image: optionIcons[0], - ), - SizedBox( - height: 12, - ), - SettingsButton( - buttonText: optionTitle[1], - onPressed: () async { - BackupKeyWidget( - atsign: AtClientManager.getInstance() - .atClient - .getCurrentAtSign()!, - ).showBackupDialog(context); - }, - image: optionIcons[1], - ), - Divider( - height: 58, - color: ColorConstants.dividerGrey, - ), - SettingsButton( - buttonText: optionTitle[3], - onPressed: () async { - await launchUrl(Uri( - scheme: 'mailto', - path: 'atmospherepro@atsign.com')); - }, - image: optionIcons[3], - ), - SizedBox( - height: 24, - ), - SettingsButton( - buttonText: optionTitle[5], - onPressed: () async { - CommonUtilityFunctions().showResetAtsignDialog(); - }, - image: optionIcons[5], - ), - SizedBox( - height: 12, - ), - ], - ), - ), - ], - ), - ) - ], - ), - ); - } -} \ No newline at end of file diff --git a/lib/desktop_screens/desktop_welcome_screen/desktop_welcome_screen.dart b/lib/desktop_screens/desktop_welcome_screen/desktop_welcome_screen.dart deleted file mode 100644 index 92f8725f..00000000 --- a/lib/desktop_screens/desktop_welcome_screen/desktop_welcome_screen.dart +++ /dev/null @@ -1,769 +0,0 @@ -import 'package:at_backupkey_flutter/widgets/backup_key_widget.dart'; -import 'package:at_client_mobile/at_client_mobile.dart'; -import 'package:atsign_atmosphere_pro/desktop_routes/desktop_route_names.dart'; -import 'package:atsign_atmosphere_pro/desktop_routes/desktop_routes.dart'; -import 'package:atsign_atmosphere_pro/desktop_screens/desktop_common_widgets/desktop_switch_atsign.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/contact_initial.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_circle_avatar.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_onboarding.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/gradient_button.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/loading_widget.dart'; -import 'package:atsign_atmosphere_pro/services/backend_service.dart'; -import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:atsign_atmosphere_pro/utils/images.dart'; -import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; -import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; -import 'package:atsign_atmosphere_pro/view_models/file_download_checker.dart'; -import 'package:atsign_atmosphere_pro/view_models/side_bar_provider.dart'; -import 'package:atsign_atmosphere_pro/view_models/switch_atsign_provider.dart'; -import 'package:flutter/material.dart'; -import 'package:at_common_flutter/services/size_config.dart'; -import 'package:atsign_atmosphere_pro/services/navigation_service.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/provider_handler.dart'; -import 'package:provider/provider.dart'; -import 'package:atsign_atmosphere_pro/utils/constants.dart'; -import 'package:url_launcher/url_launcher.dart'; - -class DesktopWelcomeScreenStart extends StatefulWidget { - const DesktopWelcomeScreenStart({Key? key}) : super(key: key); - @override - _DesktopWelcomeScreenStartState createState() => - _DesktopWelcomeScreenStartState(); -} - -class _DesktopWelcomeScreenStartState extends State { - bool authenticating = false; - String? currentatSign; - AtClient atClient = AtClientManager.getInstance().atClient; - - @override - Widget build(BuildContext context) { - SizeConfig().init(context); - return ProviderHandler( - functionName: 'switchAtsign', - showError: true, - load: (provider) { - provider.update(); - }, - errorBuilder: (provider) { - return Text(TextStrings().error); - }, - successBuilder: (provider) { - atClient = AtClientManager.getInstance().atClient; - - print( - 'ProviderHandler SwitchAtsignProvider build called ${AtClientManager.getInstance().atClient.getCurrentAtSign()}'); - return Scaffold( - body: Stack(clipBehavior: Clip.none, children: [ - DesktopWelcomeScreen(atClient: atClient), - authenticating - ? LoadingDialog().showTextLoader( - '${TextStrings().initialisingFor} $currentatSign') - : SizedBox() - ]), - ); - }); - } -} - -class DesktopWelcomeScreen extends StatefulWidget { - const DesktopWelcomeScreen({ - Key? key, - required this.atClient, - }) : super(key: key); - - final AtClient atClient; - - @override - _DesktopWelcomeScreenState createState() => _DesktopWelcomeScreenState(); -} - -class _DesktopWelcomeScreenState extends State { - final List menuItemsIcons = [ - // general - ImageConstants.homeIcon, - ImageConstants.contactsIcon, - ImageConstants.transferHistoryIcon, - ImageConstants.blockedIcon, - ImageConstants.myFiles, - ImageConstants.groups, - // ImageConstants.transferHistoryIcon, - ImageConstants.trustedSender, - // helpcenter - ImageConstants.faqsIcon, - ImageConstants.termsAndConditionsIcon, - ImageConstants.sidebarSettings, - // ImageConstants.trustedSendersIcon, - // ImageConstants.contactUs, - ]; - - final List menuItemsTitle = [ - // general - TextStrings().sidebarHome, - TextStrings().sidebarContact, - TextStrings().sidebarTransferHistory, - TextStrings().sidebarBlockedUser, - TextStrings().myFiles, - TextStrings().groups, - // TextStrings().downloadAllFiles, - TextStrings().sidebarTrustedSenders, - // helpcenter - TextStrings().sidebarFaqs, - TextStrings().sidebarTermsAndConditions, - TextStrings().sidebarSettings, - // TextStrings().sidebarContactUs, - ]; - - final List routes = [ - DesktopRoutes.DESKTOP_HOME, - DesktopRoutes.DEKSTOP_CONTACTS_SCREEN, - DesktopRoutes.DESKTOP_HISTORY, - DesktopRoutes.DEKSTOP_BLOCKED_CONTACTS_SCREEN, - DesktopRoutes.DEKSTOP_MYFILES, - DesktopRoutes.DESKTOP_GROUP, - // DesktopRoutes.DESKTOP_DOWNLOAD_ALL, - DesktopRoutes.DESKTOP_EMPTY_TRUSTED_SENDER, - DesktopRoutes.DESKTOP_SETTINGS, - '', - '', - '', - '', - ]; - - bool showContent = false; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Stack(children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Consumer(builder: (_context, _sideBarProvider, _) { - return SizedBox( - width: _sideBarProvider.isSidebarExpanded - ? MixedConstants.SIDEBAR_WIDTH_EXPANDED - : MixedConstants.SIDEBAR_WIDTH_COLLAPSED, - ); - }), - Expanded( - child: Navigator( - key: NavService.nestedNavKey, - initialRoute: DesktopRoutes.DESKTOP_HOME_NESTED_INITIAL, - onGenerateRoute: (routeSettings) { - var routeBuilders = - DesktopSetupRoutes.routeBuilders(context, routeSettings); - return MaterialPageRoute(builder: (context) { - return routeBuilders[routeSettings.name!]!(context); - }); - }, - ), - ), - ], - ), - Consumer( - builder: (_context, _sideBarProvider, _) { - return Container( - width: _sideBarProvider.isSidebarExpanded - ? MixedConstants.SIDEBAR_WIDTH_EXPANDED - : MixedConstants.SIDEBAR_WIDTH_COLLAPSED, - height: SizeConfig().screenHeight, - margin: EdgeInsets.only(right: 2), - padding: EdgeInsets.symmetric(horizontal: 20), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topRight: Radius.circular(30), - bottomRight: Radius.circular(30), - ), - boxShadow: [ - BoxShadow( - // color: Colors.grey.withOpacity(0.5), - color: ColorConstants.light_grey, - spreadRadius: 0, - blurRadius: 1, - offset: Offset(1, 2), // changes position of shadow - ), - ], - ), - child: ProviderHandler( - functionName: 'routes', - showError: true, - load: (provider) { - provider.init(); - }, - successBuilder: (provider) => SingleChildScrollView( - child: Column( - crossAxisAlignment: _sideBarProvider.isSidebarExpanded - ? CrossAxisAlignment.start - : CrossAxisAlignment.center, - children: [ - SizedBox(height: 20.toHeight), - InkWell( - onTap: () { - DesktopSetupRoutes.nested_pop(); - }, - child: Image.asset(ImageConstants.logoIcon, - height: 58.toHeight), - ), - SizedBox(height: 20.toHeight), - if (_sideBarProvider.isSidebarExpanded) - GradientButton( - onPressed: () {}, - height: 50.toHeight, - width: MixedConstants.SIDEBAR_WIDTH_EXPANDED - 41, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - TextStrings().sidebarSendFiles, - style: CustomTextStyles.desktopButton15, - ), - SizedBox(width: 8.toWidth), - Image.asset( - ImageConstants.sendIcon, - height: 20.toHeight, - fit: BoxFit.cover, - color: CustomTextStyles.desktopButton15.color, - ), - ], - ), - ), - SizedBox(height: 2.toHeight), - SidebarTitleText(TextStrings().sidebarGeneral), - SizedBox(height: 2.toHeight), - SideBarIcon( - menuItemsIcons[0], - routes[0], - title: menuItemsTitle[0], - isSidebarExpanded: _sideBarProvider.isSidebarExpanded, - ), - SizedBox(height: 2.toHeight), - SideBarIcon( - menuItemsIcons[1], - routes[1], - arguments: { - 'isBlockedScreen': false, - }, - title: menuItemsTitle[1], - isSidebarExpanded: _sideBarProvider.isSidebarExpanded, - ), - SizedBox(height: 2.toHeight), - SideBarIcon( - menuItemsIcons[2], - routes[2], - title: menuItemsTitle[2], - isSidebarExpanded: _sideBarProvider.isSidebarExpanded, - ), - SizedBox(height: 2.toHeight), - SideBarIcon( - menuItemsIcons[3], - routes[3], - arguments: { - 'isBlockedScreen': true, - }, - title: menuItemsTitle[3], - isSidebarExpanded: _sideBarProvider.isSidebarExpanded, - ), - SizedBox(height: 2.toHeight), - SideBarIcon( - menuItemsIcons[4], - routes[4], - title: menuItemsTitle[4], - isSidebarExpanded: _sideBarProvider.isSidebarExpanded, - ), - SizedBox(height: 2.toHeight), - SideBarIcon( - menuItemsIcons[5], - routes[5], - title: menuItemsTitle[5], - isSidebarExpanded: _sideBarProvider.isSidebarExpanded, - ), - SizedBox(height: 2.toHeight), - SideBarIcon( - menuItemsIcons[6], - routes[6], - title: menuItemsTitle[6], - isSidebarExpanded: _sideBarProvider.isSidebarExpanded, - ), - SidebarTitleText(TextStrings().sidebarHelpCenter), - // SideBarIcon( - // menuItemsIcons[7], - // routes[7], - // isUrlLauncher: true, - // title: menuItemsTitle[7], - // isSidebarExpanded: _sideBarProvider.isSidebarExpanded, - // ), - // SizedBox(height: 40.toHeight), - SideBarIcon( - menuItemsIcons[7], - routes[10], - isUrlLauncher: true, - arguments: {"url": MixedConstants.FAQ}, - title: menuItemsTitle[7], - isSidebarExpanded: _sideBarProvider.isSidebarExpanded, - ), - SizedBox(height: 2.toHeight), - SideBarIcon( - menuItemsIcons[8], - routes[8], - isUrlLauncher: true, - arguments: {"url": MixedConstants.TERMS_CONDITIONS}, - title: menuItemsTitle[8], - isSidebarExpanded: _sideBarProvider.isSidebarExpanded, - ), - SizedBox(height: 2.toHeight), - SideBarIcon( - menuItemsIcons[9], - routes[7], - title: menuItemsTitle[9], - isSidebarExpanded: _sideBarProvider.isSidebarExpanded, - ), - // SideBarIcon( - // menuItemsIcons[10], - // routes[7], - // isEmailLauncher: true, - // arguments: {"email": 'atmospherepro@atsign.com'}, - // title: menuItemsTitle[9], - // isSidebarExpanded: _sideBarProvider.isSidebarExpanded, - // ), - SizedBox(height: 10.toHeight), - BuildAvatarWidget( - atClient: widget.atClient, - isSidebarExpanded: _sideBarProvider.isSidebarExpanded, - ), - SizedBox(height: 10.toHeight), - ], - ), - ), - errorBuilder: (provider) => Center( - child: Text(TextStrings().errorOccured), - ), - ), - ); - }, - ), - Consumer(builder: (_context, _provider, _) { - return Positioned( - top: 40, - left: _provider.isSidebarExpanded - ? MixedConstants.SIDEBAR_WIDTH_EXPANDED - 20 - : MixedConstants.SIDEBAR_WIDTH_COLLAPSED - 20, - child: Builder( - builder: (context) { - return InkWell( - onTap: () { - Provider.of(context, listen: false) - .updateSidebarWidth(); - }, - child: Container( - width: 40, - height: 40, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(30.toWidth), - color: Colors.black), - padding: EdgeInsets.only(left: 4), - child: Icon( - _provider.isSidebarExpanded - ? Icons.arrow_back_ios - : Icons.arrow_forward_ios_sharp, - size: 20, - color: Colors.white), - ), - ); - }, - ), - ); - }), - ])); - } - - Widget sendFileTo({bool isSelectContacts = false}) { - return InkWell( - onTap: () { - setState(() { - showContent = !showContent; - }); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - ), - child: ListTile( - title: showContent - ? Text( - (isSelectContacts - ? '18 contacts added' - : '2 files selected'), - style: CustomTextStyles.desktopSecondaryRegular18) - : SizedBox(), - trailing: isSelectContacts - ? Container( - padding: EdgeInsets.symmetric(vertical: 15.toHeight), - child: Image.asset( - ImageConstants.contactsIcon, - color: Colors.black, - ), - ) - : Container( - padding: EdgeInsets.symmetric(vertical: 15.toHeight), - child: Icon( - Icons.add_circle, - color: Colors.black, - ), - ), - ))); - } -} - -class BuildAvatarWidget extends StatefulWidget { - const BuildAvatarWidget({ - Key? key, - required this.atClient, - required this.isSidebarExpanded, - }) : super(key: key); - - final AtClient atClient; - final bool isSidebarExpanded; - - @override - State createState() => _BuildAvatarWidgetState(); -} - -class _BuildAvatarWidgetState extends State { - bool authenticating = false; - - String? currentatSign; - - void _showLoader(bool loaderState, String authenticatingForAtsign) { - if (mounted) { - setState(() { - if (loaderState) { - currentatSign = authenticatingForAtsign; - } - authenticating = loaderState; - }); - } - } - - /// returns list of menu items which contains list of onboarded atsigns and [add_new_atsign], [save_backup_key] - Future> getpopupMenuList() async { - var popupMenuList = []; - var atsignList = await BackendService.getInstance().getAtsignList(); - atsignList?.forEach((element) { - popupMenuList.add(element); - }); - - popupMenuList.add(TextStrings() - .addNewAtsign); //to show add option in switch atsign drop down menu. - popupMenuList.add(TextStrings().saveBackupKey); - return popupMenuList; - } - - getPopupMenuItem(List list) { - List> menuItems = []; - list.forEach((element) { - menuItems.add(PopupMenuItem( - value: element, - child: DesktopSwitchAtsign(key: Key(element), atsign: element), - )); - }); - - return menuItems; - } - - onAtsignChange(String selectedOption) async { - late var atClientPrefernce; - await BackendService.getInstance() - .getAtClientPreference() - .then((value) => atClientPrefernce = value) - .catchError((e) => print(e)); - - if (selectedOption == TextStrings().addNewAtsign) { - await CustomOnboarding.onboard( - atSign: '', - atClientPrefernce: atClientPrefernce, - showLoader: _showLoader, - ); - } else if (selectedOption == TextStrings().saveBackupKey) { - BackupKeyWidget( - atsign: AtClientManager.getInstance().atClient.getCurrentAtSign()!, - ).showBackupDialog(context); - } else if (selectedOption != - AtClientManager.getInstance().atClient.getCurrentAtSign()) { - await CustomOnboarding.onboard( - atSign: selectedOption, - atClientPrefernce: atClientPrefernce, - showLoader: _showLoader, - ); - } - } - - @override - Widget build(BuildContext context) { - return FutureBuilder( - key: Key(AtClientManager.getInstance().atClient.getCurrentAtSign()!), - future: getpopupMenuList(), - builder: (context, AsyncSnapshot> snapshot) { - if (snapshot.data != null) { - List? atsignList = snapshot.data; - var image = CommonUtilityFunctions() - .getCachedContactImage(widget.atClient.getCurrentAtSign()!); - return Container( - width: widget.isSidebarExpanded - ? MixedConstants.SIDEBAR_WIDTH_EXPANDED - : MixedConstants.SIDEBAR_WIDTH_COLLAPSED, - height: 74.toHeight, - child: PopupMenuButton( - icon: Row( - mainAxisAlignment: widget.isSidebarExpanded - ? MainAxisAlignment.start - : MainAxisAlignment.center, - children: [ - image == null - ? ContactInitialV2( - initials: widget.atClient.getCurrentAtSign(), - size: 50.toFont, - maxSize: (80.0 - 30.0), - minSize: 50, - ) - : CustomCircleAvatarV2( - byteImage: image, - nonAsset: true, - size: 50.toFont, - ), - // Icon(Icons.arrow_drop_down) - if (widget.isSidebarExpanded) - Flexible( - child: Text( - ' ' + widget.atClient.getCurrentAtSign()!, - style: - CustomTextStyles.desktopPrimaryBold12.copyWith( - overflow: TextOverflow.ellipsis, - ), - ), - ), - ], - ), - elevation: 10, - itemBuilder: (BuildContext context) { - return getPopupMenuItem(atsignList!); - }, - onSelected: onAtsignChange), - ); - } else { - return SizedBox(); - } - }); - } -} - -class SidebarTitleText extends StatelessWidget { - const SidebarTitleText( - this.text, { - Key? key, - }) : super(key: key); - - final String text; - - @override - Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.symmetric(vertical: 14.toHeight), - child: Text( - text, - style: CustomTextStyles.desktopSecondaryBold12, - ), - ); - } -} - -// ignore: must_be_immutable -class SideBarIcon extends StatelessWidget { - final String? image, routeName, title; - final Map? arguments; - final bool isUrlLauncher, isSidebarExpanded, isEmailLauncher; - SideBarIcon(this.image, this.routeName, - {this.arguments, - this.isUrlLauncher = false, - this.isEmailLauncher = false, - this.isSidebarExpanded = true, - this.title}); - bool isHovered = false; - bool isCurrentRoute = false; - var nestedProvider = Provider.of( - NavService.navKey.currentContext!, - listen: false); - - @override - Widget build(BuildContext context) { - isCurrentRoute = nestedProvider.current_route == routeName ? true : false; - if (!isCurrentRoute) { - isCurrentRoute = (nestedProvider.current_route == null && - routeName == DesktopRoutes.DESKTOP_HOME) - ? true - : false; - } - return Padding( - padding: const EdgeInsets.only(right: 8.0), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - isCurrentRoute - ? Image.asset( - ImageConstants.sidebarSelectedTile, - height: 50.toHeight, - width: 4, - ) - : SizedBox(width: 4), - Flexible( - child: Container( - width: isSidebarExpanded ? double.maxFinite : 50, - height: 50.toHeight, - padding: EdgeInsets.symmetric( - vertical: 14.toHeight, - horizontal: isSidebarExpanded ? 20 : 12, - ), - decoration: isCurrentRoute - ? BoxDecoration( - color: ColorConstants.sidebarTileSelected, - borderRadius: BorderRadius.only( - topRight: Radius.circular(8), - bottomRight: Radius.circular(8), - )) - : null, - child: InkWell( - onTap: () { - if (routeName != null && routeName != '') { - if (routeName == DesktopRoutes.DESKTOP_HOME) { - DesktopSetupRoutes.nested_pop(); - return; - } - DesktopSetupRoutes.nested_push(routeName, - arguments: arguments); - } - if ((isUrlLauncher) && - (arguments != null) && - (arguments!['url'] != null)) { - _launchInBrowser(arguments!['url']); - } - if ((isEmailLauncher) && - (arguments != null) && - (arguments!['email'] != null)) { - _launchInEmail(arguments!['email']); - } - }, - child: routeName == DesktopRoutes.DESKTOP_HISTORY - ? Stack( - clipBehavior: Clip.none, - children: [ - BuildSidebarIconTitle( - image: image, - isCurrentRoute: isCurrentRoute, - isSidebarExpanded: isSidebarExpanded, - title: title, - ), - Consumer( - builder: (context, _fileDownloadChecker, _) { - return _fileDownloadChecker - .undownloadedFilesExist - ? Positioned( - left: 12, - top: -4, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - shape: BoxShape.circle, - ), - padding: EdgeInsets.all(1.toHeight), - child: CircleAvatar( - backgroundColor: Colors.red, - radius: 5.toWidth, - ), - ), - ) - : SizedBox(); - }, - ), - ], - ) - : BuildSidebarIconTitle( - image: image, - isCurrentRoute: isCurrentRoute, - isSidebarExpanded: isSidebarExpanded, - title: title, - ), - )), - ), - ], - ), - ); - } - - Future _launchInBrowser(String url) async { - try { - await launchUrl( - Uri( - scheme: 'https', - path: url, - ), - ); - } catch (e) { - throw 'Could not launch $url'; - } - } - - Future _launchInEmail(String email) async { - await launchUrl( - Uri( - scheme: 'mailto', - path: email, - ), - ); - } -} - -class BuildSidebarIconTitle extends StatelessWidget { - const BuildSidebarIconTitle({ - Key? key, - required this.image, - required this.isCurrentRoute, - required this.isSidebarExpanded, - required this.title, - }) : super(key: key); - - final String? image; - final bool isCurrentRoute; - final bool isSidebarExpanded; - final String? title; - - @override - Widget build(BuildContext context) { - return Row( - mainAxisSize: MainAxisSize.min, - children: [ - Image.asset( - image!, - height: 22.toFont, - color: isCurrentRoute - ? ColorConstants.sidebarTextSelected - : ColorConstants.sidebarTextUnselected, - ), - SizedBox(width: isSidebarExpanded ? 10 : 0), - isSidebarExpanded - ? Text( - title!, - softWrap: true, - style: CustomTextStyles.desktopPrimaryRegular12.copyWith( - color: isCurrentRoute - ? null - : ColorConstants.sidebarTextUnselected, - fontWeight: FontWeight.w500, - ), - ) - : SizedBox() - ], - ); - } -} diff --git a/lib/desktop_screens/desktop_welcome_screen/widgets/welcome_screen_home.dart b/lib/desktop_screens/desktop_welcome_screen/widgets/welcome_screen_home.dart deleted file mode 100644 index 0289473c..00000000 --- a/lib/desktop_screens/desktop_welcome_screen/widgets/welcome_screen_home.dart +++ /dev/null @@ -1,538 +0,0 @@ -import 'package:at_client_mobile/at_client_mobile.dart'; -import 'package:at_contacts_group_flutter/screens/group_contact_view/group_contact_view.dart'; -import 'package:at_contacts_group_flutter/services/group_service.dart'; -import 'package:atsign_atmosphere_pro/dekstop_services/desktop_image_picker.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_toast.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/triple_dot_loading.dart'; -import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; -import 'package:atsign_atmosphere_pro/services/navigation_service.dart'; -import 'package:atsign_atmosphere_pro/services/snackbar_service.dart'; -import 'package:atsign_atmosphere_pro/view_models/base_model.dart'; -import 'package:atsign_atmosphere_pro/view_models/file_transfer_provider.dart'; -import 'package:atsign_atmosphere_pro/view_models/my_files_provider.dart'; -import 'package:atsign_atmosphere_pro/view_models/welcome_screen_view_model.dart'; -import 'package:atsign_atmosphere_pro/services/backend_service.dart'; -import 'package:flutter/material.dart'; -import 'package:at_common_flutter/services/size_config.dart'; -import 'package:atsign_atmosphere_pro/desktop_screens/desktop_common_widgets/desktop_selected_contacts.dart'; -import 'package:atsign_atmosphere_pro/desktop_screens/desktop_common_widgets/desktop_selected_files.dart'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:atsign_atmosphere_pro/utils/images.dart'; -import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; -import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/common_button.dart'; -import 'package:provider/provider.dart'; - -enum CurrentScreen { PlaceolderImage, ContactsScreen, SelectedItems } - -class WelcomeScreenHome extends StatefulWidget { - @override - _WelcomeScreenHomeState createState() => _WelcomeScreenHomeState(); -} - -class _WelcomeScreenHomeState extends State { - // bool showContent = false, showSelectedItems = false; - CurrentScreen _currentScreen = CurrentScreen.PlaceolderImage; - late FileTransferProvider _filePickerProvider; - late WelcomeScreenProvider _welcomeScreenProvider; - List _selectedList = []; - bool isFileSending = false, - isSentFileEntrySaved = true, - isFileShareFailed = false; - String? notes; - FocusNode _notesFocusNode = FocusNode(); - TextEditingController _notesController = TextEditingController(); - - @override - void initState() { - _filePickerProvider = - Provider.of(context, listen: false); - _welcomeScreenProvider = Provider.of( - NavService.navKey.currentContext!, - listen: false); - isFileSending = _filePickerProvider.isFileSending; - - _welcomeScreenProvider.addListener(() { - if (_selectedList.isEmpty && - _filePickerProvider.selectedFiles.isEmpty && - _currentScreen != CurrentScreen.PlaceolderImage) { - setState(() { - _currentScreen = CurrentScreen.PlaceolderImage; - }); - } - }); - - WidgetsBinding.instance.addPostFrameCallback((_) async { - await BackendService.getInstance().syncWithSecondary(); - }); - super.initState(); - } - - @override - Widget build(BuildContext context) { - if (_selectedList.isNotEmpty) { - _currentScreen = CurrentScreen.SelectedItems; - } - return Scaffold( - body: Row( - children: [ - Expanded( - child: Container( - height: SizeConfig().screenHeight - 80, - padding: EdgeInsets.symmetric(horizontal: 50), - color: ColorConstants.lightBlueBg, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - 'Welcome ' + - (AtClientManager.getInstance().atClient != null - ? '${AtClientManager.getInstance().atClient.getCurrentAtSign()}' - : ''), - style: CustomTextStyles.desktopBlackPlayfairDisplay26, - ), - SizedBox( - height: 20.toHeight, - ), - Text( - 'Select a recipient and start sending them files.', - style: CustomTextStyles.desktopSecondaryRegular18, - ), - SizedBox( - height: 50.toHeight, - ), - Text( - TextStrings().welcomeSendFilesTo, - style: CustomTextStyles.desktopSecondaryRegular18, - ), - SizedBox( - height: 20.toHeight, - ), - sendFileTo(isSelectContacts: true), - SizedBox( - height: 30, - ), - Text(TextStrings().welcomeFilePlaceholder, - style: CustomTextStyles.desktopSecondaryRegular18), - SizedBox( - height: 20.toHeight, - ), - sendFileTo(), - SizedBox( - height: 20.toHeight, - ), - (_welcomeScreenProvider.selectedContacts != null && - _welcomeScreenProvider.selectedContacts.isNotEmpty && - _filePickerProvider.selectedFiles.isNotEmpty) - ? Container( - color: Colors.white, - child: Row( - children: [ - Expanded( - child: TextFormField( - focusNode: _notesFocusNode, - controller: _notesController, - decoration: InputDecoration( - hintText: TextStrings().welcomeAddTranscripts, - hintStyle: CustomTextStyles - .desktopSecondaryRegular16, - border: InputBorder.none, - fillColor: Colors.white, - focusColor: Colors.white, - hoverColor: Colors.white, - filled: true, - ), - style: - CustomTextStyles.desktopSecondaryRegular18, - onChanged: (String txt) { - setState(() { - notes = txt; - }); - }, - ), - ), - notes != null - ? InkWell( - onTap: () { - setState(() { - notes = null; - }); - _notesController.clear(); - }, - child: - Icon(Icons.clear, color: Colors.black), - ) - : InkWell( - onTap: () { - FocusScope.of(context) - .requestFocus(_notesFocusNode); - }, - child: - Icon(Icons.edit, color: Colors.black), - ), - SizedBox( - width: 15, - ), - ], - ), - ) - : SizedBox(), - SizedBox( - height: (_welcomeScreenProvider.selectedContacts != null && - _welcomeScreenProvider.selectedContacts.isNotEmpty && - _filePickerProvider.selectedFiles.isNotEmpty) - ? 10.toHeight - : 0, - ), - (_filePickerProvider.selectedFiles.isNotEmpty && - _welcomeScreenProvider.selectedContacts.isNotEmpty) - ? Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Align( - alignment: Alignment.centerRight, - child: CommonButton( - 'Clear', - resetFileSelection, - color: ColorConstants.greyText, - border: 3, - height: 45, - width: 110, - fontSize: 20, - removePadding: true, - )), - SizedBox(width: 10.toWidth), - _welcomeScreenProvider.isSelectionItemChanged - ? Align( - alignment: Alignment.centerRight, - child: isFileSending - ? Container( - height: 45, - width: 110, - color: ColorConstants.orangeColor, - child: TypingIndicator( - showIndicator: true, - flashingCircleBrightColor: - Colors.white, - flashingCircleDarkColor: - ColorConstants.orangeColor, - ), - ) - : CommonButton( - isFileShareFailed ? 'Resend' : 'Send', - () async { - if (isFileSending) return; - - if (isFileShareFailed) { - await reAttemptSendingFiles(); - return; - } - - await sendFileWithFileBin(); - }, - color: isFileSending - ? ColorConstants.greyText - : ColorConstants.orangeColor, - border: 3, - height: 45, - width: 110, - fontSize: 20, - removePadding: true, - ), - ) - : SizedBox(), - ], - ) - : SizedBox() - ], - ), - ), - ), - Expanded(child: currentScreen()), - ], - )); - } - - // ignore: missing_return - Widget currentScreen() { - switch (_currentScreen) { - case CurrentScreen.PlaceolderImage: - return _selectedList.isNotEmpty - ? _selectedItems() - : _placeholderImage(); - case CurrentScreen.ContactsScreen: - return GroupContactView( - asSelectionScreen: true, - singleSelection: false, - showGroups: true, - showContacts: true, - isDesktop: true, - contactSelectedHistory: _welcomeScreenProvider.selectedContacts, - onContactsTap: (_list) { - Provider.of( - NavService.navKey.currentContext!, - listen: false) - .updateSelectedContacts(_list, notifyListeners: false); - _welcomeScreenProvider.isSelectionItemChanged = true; - }, - selectedList: (_list) { - Provider.of( - NavService.navKey.currentContext!, - listen: false) - .updateSelectedContacts(_list); - _welcomeScreenProvider.isSelectionItemChanged = true; - }, - onBackArrowTap: (selectedGroupContacts) { - if (selectedGroupContacts!.isNotEmpty) { - CommonUtilityFunctions().shownConfirmationDialog( - TextStrings().contactSelectionConfirmation, () { - //// TODO: If we want to clear the selected list of contacts if user goes back - // Provider.of( - // NavService.navKey.currentContext!, - // listen: false) - // .updateSelectedContacts([]); - - Navigator.of(NavService.navKey.currentContext!).pop(); - setState(() { - _currentScreen = CurrentScreen.PlaceolderImage; - }); - }); - } else { - Provider.of( - NavService.navKey.currentContext!, - listen: false) - .updateSelectedContacts( - []); // clear selected list if nothing is selected - setState(() { - _currentScreen = CurrentScreen.PlaceolderImage; - }); - } - }, - onDoneTap: () { - setState(() { - _currentScreen = CurrentScreen.SelectedItems; - }); - }); - - case CurrentScreen.SelectedItems: - return _selectedItems(); - } - } - - Widget _selectedItems() { - return Container( - height: SizeConfig().screenHeight - 80, - color: ColorConstants.lightBlueBg, - padding: EdgeInsets.symmetric(horizontal: 40, vertical: 30), - child: SingleChildScrollView( - child: Column( - children: [ - DesktopSelectedContacts((val) { - if (_welcomeScreenProvider.selectedContacts.isEmpty && - _filePickerProvider.selectedFiles.isEmpty) { - _currentScreen = CurrentScreen.PlaceolderImage; - } - setState(() { - isFileShareFailed = false; - _welcomeScreenProvider.isSelectionItemChanged = true; - }); - }), - Divider( - height: 20, - thickness: 5, - ), - DesktopSelectedFiles((val) { - if (_welcomeScreenProvider.selectedContacts.isEmpty && - _filePickerProvider.selectedFiles.isEmpty) { - _currentScreen = CurrentScreen.PlaceolderImage; - } - isFileShareFailed = false; - setState(() {}); - }, showCancelIcon: !isFileSending), - ], - ), - ), - ); - } - - Widget _placeholderImage() { - return Container( - height: SizeConfig().screenHeight - 80, - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage( - ImageConstants.welcomeDesktop, - ), - fit: BoxFit.fill, - ), - ), - ); - } - - Widget sendFileTo({bool isSelectContacts = false}) { - return InkWell( - onTap: () async { - if (isSelectContacts) { - _currentScreen = CurrentScreen.ContactsScreen; - } else { - var file = await desktopImagePicker(); - if (file != null) { - GroupService().selectedGroupContacts = []; - GroupService().selectedContactsSink.add([]); - _filePickerProvider.selectedFiles = file; - _welcomeScreenProvider.isSelectionItemChanged = true; - _currentScreen = CurrentScreen.SelectedItems; - } - } - setState(() {}); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - ), - child: ListTile( - title: _currentScreen != CurrentScreen.PlaceolderImage - ? Text( - (isSelectContacts - ? _welcomeScreenProvider.selectedContacts.length == 1 - ? '${_welcomeScreenProvider.selectedContacts.length} contact selected' - : '${_welcomeScreenProvider.selectedContacts.length} contacts selected' - : _filePickerProvider.selectedFiles.length == 1 - ? '${_filePickerProvider.selectedFiles.length} file selected' - : '${_filePickerProvider.selectedFiles.length} files selected'), - style: CustomTextStyles.desktopSecondaryRegular18) - : SizedBox(), - trailing: isSelectContacts - ? Container( - padding: EdgeInsets.symmetric(vertical: 15), - child: Image.asset( - ImageConstants.contactsIcon, - color: Colors.black, - ), - ) - : Container( - padding: EdgeInsets.symmetric(vertical: 15.toHeight), - child: Icon( - Icons.add_circle, - color: Colors.black, - ), - ), - ))); - } - - resetFileSelection() { - if (mounted) { - setState(() { - isFileShareFailed = false; - _filePickerProvider.selectedFiles = []; - _welcomeScreenProvider.selectedContacts = []; - _currentScreen = CurrentScreen.PlaceolderImage; - _welcomeScreenProvider.isSelectionItemChanged = false; - notes = null; - _notesController.clear(); - }); - } - } - - reAttemptSendingFiles() async { - if (mounted) { - setState(() { - isFileShareFailed = false; - isFileSending = true; - _filePickerProvider.updateFileSendingStatus(true); - }); - } - - // when entry is not added in sent history. - if (!isSentFileEntrySaved) { - sendFileWithFileBin(); - return; - } - - // when entry is added in sent history but notifications didn't go through. - var res = await _filePickerProvider.reAttemptInSendingFiles(); - - if (!res) { - SnackbarService().showSnackbar( - context, - TextStrings().oopsSomethingWentWrong, - bgColor: ColorConstants.redAlert, - ); - if (mounted) { - setState(() { - isFileShareFailed = true; - }); - } - } - - if (mounted) { - setState(() { - isFileSending = false; - _filePickerProvider.updateFileSendingStatus(false); - }); - } - } - - sendFileWithFileBin() async { - _filePickerProvider.updateFileSendingStatus(true); - if (mounted) { - setState(() { - // assuming file share record will be saved in sent history. - isSentFileEntrySaved = true; - isFileShareFailed = false; - isFileSending = true; - }); - } - _welcomeScreenProvider.resetSelectedContactsStatus(); - _filePickerProvider.resetSelectedFilesStatus(); - - var res = await _filePickerProvider.sendFileWithFileBin( - _filePickerProvider.selectedFiles, - _welcomeScreenProvider.selectedContacts, - groupName: _welcomeScreenProvider.groupName, - notes: notes, - ); - - if (mounted && res is bool) { - setState(() { - isFileShareFailed = !res; - }); - - if (!isFileShareFailed) { - SnackbarService().showSnackbar( - context, - TextStrings().fileSentSuccessfully, - bgColor: Color(0xFF5FAA45), - ); - _welcomeScreenProvider.isSelectionItemChanged = false; - } else { - SnackbarService().showSnackbar( - context, - TextStrings().oopsSomethingWentWrong, - bgColor: ColorConstants.redAlert, - ); - } - } else if (res == null) { - SnackbarService().showSnackbar( - context, - TextStrings().oopsSomethingWentWrong, - bgColor: ColorConstants.redAlert, - ); - - if (mounted) { - setState(() { - isFileShareFailed = true; - isSentFileEntrySaved = false; - }); - } - } - - if (mounted) { - setState(() { - _filePickerProvider.updateFileSendingStatus(false); - isFileSending = false; - }); - } - } -} diff --git a/lib/desktop_screens/trusted_sender/desktop_trusted_sender.dart b/lib/desktop_screens/trusted_sender/desktop_trusted_sender.dart index 7eb2cf83..07f5a42c 100644 --- a/lib/desktop_screens/trusted_sender/desktop_trusted_sender.dart +++ b/lib/desktop_screens/trusted_sender/desktop_trusted_sender.dart @@ -8,7 +8,7 @@ import 'package:atsign_atmosphere_pro/desktop_screens/desktop_common_widgets/des import 'package:atsign_atmosphere_pro/screens/common_widgets/error_dialog.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/provider_callback.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/provider_handler.dart'; -import 'package:atsign_atmosphere_pro/screens/trusted_contacts/widgets/remove_trusted_contact_dialog.dart'; +import 'package:atsign_atmosphere_pro/desktop_screens_new/trusted_senders_screen/widgets/remove_trusted_contact_dialog.dart'; import 'package:at_common_flutter/services/size_config.dart'; import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; import 'package:atsign_atmosphere_pro/utils/colors.dart'; @@ -16,8 +16,6 @@ import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; import 'package:atsign_atmosphere_pro/view_models/trusted_sender_view_model.dart'; import 'package:flutter/material.dart'; import 'package:at_contact/at_contact.dart'; -import 'package:provider/provider.dart'; -import 'package:at_contacts_flutter/services/contact_service.dart'; class DesktopTrustedSender extends StatefulWidget { @override @@ -106,18 +104,6 @@ class _DesktopTrustedSenderState extends State { ), ), SizedBox(width: 15.toWidth), - //TODO: filter option is removed from ui for now. - // InkWell( - // onTap: () { - // setState(() { - // _isFilterOption = !_isFilterOption; - // }); - // }, - // child: Container( - // child: Icon(Icons.filter_list_sharp), - // ), - // ), - // SizedBox(width: 10), ], ), SizedBox(height: 20), diff --git a/lib/desktop_screens/trusted_sender/desktop_empty_trusted_sender.dart b/lib/desktop_screens/trusted_sender/widgets/desktop_empty_trusted_sender.dart similarity index 95% rename from lib/desktop_screens/trusted_sender/desktop_empty_trusted_sender.dart rename to lib/desktop_screens/trusted_sender/widgets/desktop_empty_trusted_sender.dart index 79dbb11c..f7a704d5 100644 --- a/lib/desktop_screens/trusted_sender/desktop_empty_trusted_sender.dart +++ b/lib/desktop_screens/trusted_sender/widgets/desktop_empty_trusted_sender.dart @@ -20,7 +20,7 @@ class DesktopEmptySender extends StatefulWidget { } class _DesktopEmptySenderState extends State { - bool isContactSelecttion = false, isLoading = true; + bool isContactSelection = false, isLoading = true; List trustedContacts = []; @override @@ -90,7 +90,7 @@ class _DesktopEmptySenderState extends State { TextButton( onPressed: () { setState(() { - isContactSelecttion = !isContactSelecttion; + isContactSelection = !isContactSelection; }); }, style: ButtonStyle(backgroundColor: @@ -115,7 +115,7 @@ class _DesktopEmptySenderState extends State { ), ), ), - isContactSelecttion + isContactSelection ? Expanded( child: GroupContactView( asSelectionScreen: true, @@ -132,7 +132,7 @@ class _DesktopEmptySenderState extends State { .addTrustedContacts(element.contact!); } }); - isContactSelecttion = false; + isContactSelection = false; }, taskName: (provider) => provider.AddTrustedContacts, onSuccess: (provider) {}, @@ -142,7 +142,7 @@ class _DesktopEmptySenderState extends State { onBackArrowTap: (selectedGroupContacts) { if (mounted) { setState(() { - isContactSelecttion = !isContactSelecttion; + isContactSelection = !isContactSelection; }); } }, diff --git a/lib/desktop_screens_new/common_widgets/file_tile.dart b/lib/desktop_screens_new/common_widgets/file_tile.dart index 119f8c8c..c8f95797 100644 --- a/lib/desktop_screens_new/common_widgets/file_tile.dart +++ b/lib/desktop_screens_new/common_widgets/file_tile.dart @@ -2,7 +2,7 @@ import 'dart:io'; import 'package:at_backupkey_flutter/utils/size_config.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; -import 'package:atsign_atmosphere_pro/screens/my_files/widgets/recents.dart'; +import 'package:atsign_atmosphere_pro/screens/my_files/widgets/recent.dart'; import 'package:atsign_atmosphere_pro/utils/app_utils.dart'; import 'package:atsign_atmosphere_pro/utils/colors.dart'; import 'package:atsign_atmosphere_pro/utils/constants.dart'; diff --git a/lib/desktop_screens_new/contacts_screen/desktop_contact_screen.dart b/lib/desktop_screens_new/contacts_screen/desktop_contact_screen.dart index d482aaff..cef61d3a 100644 --- a/lib/desktop_screens_new/contacts_screen/desktop_contact_screen.dart +++ b/lib/desktop_screens_new/contacts_screen/desktop_contact_screen.dart @@ -15,7 +15,7 @@ import 'package:atsign_atmosphere_pro/view_models/trusted_sender_view_model.dart import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -enum contactSidebar { contactDetails, addContact } +enum ContactSidebar { contactDetails, addContact } class DesktopContactScreen extends StatefulWidget { const DesktopContactScreen({Key? key}) : super(key: key); @@ -25,7 +25,7 @@ class DesktopContactScreen extends StatefulWidget { } class _DesktopContactScreenState extends State { - contactSidebar? sidebarView; + ContactSidebar? sidebarView; var _filteredList = []; String searchText = ''; BaseContact? selectedContact; @@ -148,7 +148,7 @@ class _DesktopContactScreenState extends State { setState(() { selectedContact = contact; sidebarView = - contactSidebar.contactDetails; + ContactSidebar.contactDetails; showGroup = false; }); }, @@ -308,7 +308,7 @@ class _DesktopContactScreenState extends State { 'Add contact', () { setState(() { - sidebarView = contactSidebar.addContact; + sidebarView = ContactSidebar.addContact; showGroup = false; }); }, @@ -328,7 +328,7 @@ class _DesktopContactScreenState extends State { } Widget getSidebarWidget() { - if (sidebarView == contactSidebar.contactDetails) { + if (sidebarView == ContactSidebar.contactDetails) { return InformationCardExpanded( key: UniqueKey(), atContact: selectedContact!.contact!, @@ -338,7 +338,7 @@ class _DesktopContactScreenState extends State { }); }, ); - } else if (sidebarView == contactSidebar.addContact) { + } else if (sidebarView == ContactSidebar.addContact) { return DesktopAddContactScreen( onBack: () { GroupService().fetchGroupsAndContacts(); diff --git a/lib/desktop_screens_new/contacts_screen/widgets/add_contacts_screen.dart b/lib/desktop_screens_new/contacts_screen/widgets/add_contacts_screen.dart index be9f0c0d..feb3fff2 100644 --- a/lib/desktop_screens_new/contacts_screen/widgets/add_contacts_screen.dart +++ b/lib/desktop_screens_new/contacts_screen/widgets/add_contacts_screen.dart @@ -1,6 +1,5 @@ import 'package:at_common_flutter/services/size_config.dart'; import 'package:at_server_status/at_server_status.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/gradient_text_field_widget.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/input_widget.dart'; import 'package:atsign_atmosphere_pro/utils/colors.dart'; import 'package:atsign_atmosphere_pro/utils/vectors.dart'; diff --git a/lib/desktop_screens_new/contacts_screen/widgets/information_card_expanded.dart b/lib/desktop_screens_new/contacts_screen/widgets/information_card_expanded.dart index c2c33165..7f5fc759 100644 --- a/lib/desktop_screens_new/contacts_screen/widgets/information_card_expanded.dart +++ b/lib/desktop_screens_new/contacts_screen/widgets/information_card_expanded.dart @@ -4,7 +4,6 @@ import 'package:at_contacts_group_flutter/models/group_contacts_model.dart'; import 'package:at_contacts_group_flutter/widgets/confirmation_dialog.dart'; import 'package:atsign_atmosphere_pro/desktop_routes/desktop_routes.dart'; import 'package:atsign_atmosphere_pro/desktop_screens_new/contacts_screen/widgets/options_icon_button.dart'; -import 'package:atsign_atmosphere_pro/desktop_screens_new/contacts_screen/widgets/receive_items_list.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/contact_initial.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_circle_avatar.dart'; import 'package:atsign_atmosphere_pro/services/snackbar_service.dart'; @@ -84,11 +83,11 @@ class _InformationCardExpandedState extends State { contact.tags!['nickname'] = controller.text; var res = await ContactService().atContactImpl.add(contact); if (res == true) { - await SnackbarService() - .showSnackbar(context, "Successfully updated nickname"); + await SnackBarService() + .showSnackBar(context, "Successfully updated nickname"); } else { - await SnackbarService() - .showSnackbar(context, "Failed to update nickname"); + await SnackBarService() + .showSnackBar(context, "Failed to update nickname"); } setState(() { isLoading = false; @@ -112,11 +111,6 @@ class _InformationCardExpandedState extends State { SizedBox(height: 20), buildTransferFileButton(), SizedBox(height: 24), - - /// Hiding file attachment screen - // buildAttachmentsTitle(), - // SizedBox(height: 8), - // ReceiveItemsList(atContact: widget.atContact) ], ), ), diff --git a/lib/desktop_screens_new/contacts_screen/widgets/receive_items_list.dart b/lib/desktop_screens_new/contacts_screen/widgets/receive_items_list.dart deleted file mode 100644 index 90496b83..00000000 --- a/lib/desktop_screens_new/contacts_screen/widgets/receive_items_list.dart +++ /dev/null @@ -1,74 +0,0 @@ -import 'package:at_contact/at_contact.dart'; -import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/provider_handler.dart'; -import 'package:atsign_atmosphere_pro/screens/contact_new_version/widget/contact_attachment_card.dart'; -import 'package:atsign_atmosphere_pro/view_models/history_provider.dart'; -import 'package:flutter/material.dart'; - -class ReceiveItemsList extends StatefulWidget { - final AtContact atContact; - - const ReceiveItemsList({ - required this.atContact, - }); - - @override - State createState() => _ReceiveItemsListState(); -} - -class _ReceiveItemsListState extends State { - List filterReceivedFiles( - String atSign, List receivedFiles) { - List tempFiles = []; - - for (var file in receivedFiles) { - if (file.sender == atSign) { - tempFiles.add(file); - } - } - - return tempFiles; - } - - @override - Widget build(BuildContext context) { - return ProviderHandler( - functionName: HistoryProvider().RECEIVED_HISTORY, - showError: false, - successBuilder: (provider) { - var files = filterReceivedFiles( - widget.atContact.atSign ?? "", provider.receivedHistoryLogs); - - return ListView.builder( - shrinkWrap: true, - itemCount: files.length, - physics: NeverScrollableScrollPhysics(), - itemBuilder: (context, index) { - List list = []; - for (var file in files[index].files ?? []) { - list.add( - ContactAttachmentCard( - fileTransfer: files[index], - singleFile: file, - fromContact: true, - margin: EdgeInsets.zero, - ), - ); - } - - return Column( - mainAxisSize: MainAxisSize.min, - children: list, - ); - }, - ); - }, - // errorBuilder: (provider) => Center( - // child: Text(TextStrings().errorOccured), - // ), - load: (provider) async { - await provider.getReceivedHistory(); - }, - ); - } -} diff --git a/lib/desktop_screens_new/history_screen/widgets/desktop_card_function_list.dart b/lib/desktop_screens_new/history_screen/widgets/desktop_card_function_list.dart index f88f6327..ff34b9ac 100644 --- a/lib/desktop_screens_new/history_screen/widgets/desktop_card_function_list.dart +++ b/lib/desktop_screens_new/history_screen/widgets/desktop_card_function_list.dart @@ -78,7 +78,7 @@ class _DesktopCardFunctionListState extends State { widget.fileTransfer.files!.forEach((e) { File(getFilePath(name: e.name ?? '')).deleteSync(); }); - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( context, "Successfully deleted the file", bgColor: ColorConstants.successColor, @@ -212,7 +212,7 @@ class _DesktopCardFunctionListState extends State { .isInternetAvailable; if (!isConnected) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings.noInternetMsg, bgColor: ColorConstants.redAlert, @@ -233,7 +233,7 @@ class _DesktopCardFunctionListState extends State { ); if (result is bool && !result) { historyProvider.removeDownloadingState(file.key); - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings().downloadFailed, bgColor: ColorConstants.redAlert, @@ -244,9 +244,9 @@ class _DesktopCardFunctionListState extends State { } } historyProvider.removeDownloadingState(file.key); - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, - TextStrings().fileDownloadd, + TextStrings().fileDownload, bgColor: ColorConstants.successGreen, ); await Provider.of(NavService.navKey.currentContext!, diff --git a/lib/desktop_screens_new/history_screen/widgets/desktop_file_function_list.dart b/lib/desktop_screens_new/history_screen/widgets/desktop_file_function_list.dart index 7f42133b..bd4ddff2 100644 --- a/lib/desktop_screens_new/history_screen/widgets/desktop_file_function_list.dart +++ b/lib/desktop_screens_new/history_screen/widgets/desktop_file_function_list.dart @@ -69,7 +69,7 @@ class _DesktopFileFunctionListState extends State { .isInternetAvailable; if (!isConnected) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings.noInternetMsg, bgColor: ColorConstants.redAlert, @@ -99,14 +99,14 @@ class _DesktopFileFunctionListState extends State { isDownloaded = true; }); - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, - TextStrings().fileDownloadd, + TextStrings().fileDownload, bgColor: ColorConstants.successGreen, ); } } else if (result is bool && !result) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings().downloadFailed, bgColor: ColorConstants.redAlert, @@ -149,7 +149,7 @@ class _DesktopFileFunctionListState extends State { CommonUtilityFunctions().showConfirmationDialog( () { File(widget.filePath).deleteSync(); - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( context, "Successfully deleted the file", bgColor: ColorConstants.successColor, diff --git a/lib/desktop_screens_new/history_screen/widgets/desktop_history_file_item.dart b/lib/desktop_screens_new/history_screen/widgets/desktop_history_file_item.dart index afc5d038..318f36c9 100644 --- a/lib/desktop_screens_new/history_screen/widgets/desktop_history_file_item.dart +++ b/lib/desktop_screens_new/history_screen/widgets/desktop_history_file_item.dart @@ -4,7 +4,7 @@ import 'package:atsign_atmosphere_pro/data_models/file_modal.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; import 'package:atsign_atmosphere_pro/desktop_screens_new/history_screen/widgets/desktop_file_function_list.dart'; import 'package:atsign_atmosphere_pro/screens/my_files/widgets/downloads_folders.dart'; -import 'package:atsign_atmosphere_pro/screens/my_files/widgets/recents.dart'; +import 'package:atsign_atmosphere_pro/screens/my_files/widgets/recent.dart'; import 'package:atsign_atmosphere_pro/utils/colors.dart'; import 'package:atsign_atmosphere_pro/utils/constants.dart'; import 'package:atsign_atmosphere_pro/utils/file_types.dart'; diff --git a/lib/desktop_screens_new/history_screen/widgets/history_file_card.dart b/lib/desktop_screens_new/history_screen/widgets/history_file_card.dart deleted file mode 100644 index 29725177..00000000 --- a/lib/desktop_screens_new/history_screen/widgets/history_file_card.dart +++ /dev/null @@ -1,355 +0,0 @@ -import 'dart:io'; - -import 'package:atsign_atmosphere_pro/data_models/file_modal.dart'; -import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; -import 'package:atsign_atmosphere_pro/desktop_routes/desktop_routes.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/labelled_circular_progress.dart'; -import 'package:atsign_atmosphere_pro/screens/my_files/widgets/downloads_folders.dart'; -import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; -import 'package:atsign_atmosphere_pro/services/navigation_service.dart'; -import 'package:atsign_atmosphere_pro/services/snackbar_service.dart'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:atsign_atmosphere_pro/utils/constants.dart'; -import 'package:atsign_atmosphere_pro/utils/file_utils.dart'; -import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; -import 'package:atsign_atmosphere_pro/utils/vectors.dart'; -import 'package:atsign_atmosphere_pro/view_models/file_progress_provider.dart'; -import 'package:atsign_atmosphere_pro/view_models/history_provider.dart'; -import 'package:atsign_atmosphere_pro/view_models/internet_connectivity_checker.dart'; -import 'package:atsign_atmosphere_pro/view_models/my_files_provider.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:provider/provider.dart'; - -class HistoryFileCard extends StatefulWidget { - final FileTransfer fileTransfer; - final FileData singleFile; - final bool isShowDate; - final EdgeInsetsGeometry? margin; - final Function()? onAction; - final bool fromContact; - final HistoryType historyType; - final FileHistory fileHistory; - - const HistoryFileCard({ - Key? key, - required this.fileTransfer, - required this.singleFile, - this.isShowDate = true, - this.margin, - this.onAction, - this.fromContact = false, - required this.historyType, - required this.fileHistory, - }) : super(key: key); - - @override - State createState() => _HistoryFileCardState(); -} - -class _HistoryFileCardState extends State { - bool isDownloaded = false; - bool isDownloading = false; - - @override - void initState() { - super.initState(); - Provider.of(NavService.navKey.currentContext!, - listen: false) - .checkConnectivity(); - if (widget.historyType == HistoryType.received) { - initDownloads(); - } - } - - void initDownloads() async { - isDownloaded = await isFilePresent(widget.singleFile.name ?? ""); - setState(() { - isDownloaded; - }); - } - - Future isFilePresent(String fileName) async { - String filePath = await MixedConstants.getFileDownloadLocation( - sharedBy: widget.fileTransfer.sender!); - - File file = File(filePath + Platform.pathSeparator + fileName); - bool fileExists = await file.exists(); - return fileExists; - } - - Widget getDownloadStatus(FileTransferProgress? fileTransferProgress) { - Widget spinner = CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation( - ColorConstants.orange, - ), - ); - - if (fileTransferProgress == null) { - return spinner; - } - - if (fileTransferProgress.fileState == FileState.download && - fileTransferProgress.percent != null) { - spinner = LabelledCircularProgressIndicator( - value: (fileTransferProgress.percent! / 100)); - } - - return spinner; - } - - @override - Widget build(BuildContext context) { - return InkWell( - onTap: () async { - late String filePath; - if (widget.historyType == HistoryType.received) { - filePath = await MixedConstants.getFileDownloadLocation( - sharedBy: widget.fileTransfer.sender!); - } else if (widget.historyType == HistoryType.send) { - filePath = await MixedConstants.getFileSentLocation(); - } - - await openFilePath( - filePath + Platform.pathSeparator + (widget.singleFile.name ?? ""), - ); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - ), - margin: EdgeInsets.symmetric( - vertical: 5, - ), - padding: EdgeInsets.all(15), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Center( - child: SvgPicture.asset( - AppVectors.icFile, - height: 35, - width: 35, - )), - SizedBox(width: 20), - Expanded( - child: Text( - widget.singleFile.name ?? "", - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 12, - ), - ), - ), - Spacer(), - Text( - double.parse(widget.singleFile.size.toString()) <= 1024 - ? '${widget.singleFile.size} ' + TextStrings().kb - : '${(widget.singleFile.size! / (1024 * 1024)).toStringAsFixed(2)} ' + - TextStrings().mb, - style: TextStyle( - color: ColorConstants.grey, - fontSize: 10, - ), - ), - SizedBox( - width: 20, - ), - widget.fileHistory.type == HistoryType.received - ? Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Consumer( - builder: (_c, provider, _) { - var fileTransferProgress = provider - .receivedFileProgress[widget.fileTransfer.key]; - - return CommonUtilityFunctions() - .checkForDownloadAvailability( - widget.fileTransfer, - ) - ? fileTransferProgress != null && - fileTransferProgress.fileName == - widget.singleFile.name - ? getDownloadStatus(fileTransferProgress) - : isDownloaded - ? SvgPicture.asset( - AppVectors.icCloudDownloaded, - ) - : InkWell( - onTap: () async { - await downloadFiles( - widget.fileTransfer, - fileName: widget.singleFile.name, - ); - }, - child: SvgPicture.asset( - AppVectors.icDownloadFile, - ), - ) - : SizedBox(); - }, - ), - const SizedBox( - width: 10, - ), - isDownloaded - ? GestureDetector( - onTap: () async { - if (widget.fromContact) { - Navigator.pop(context); - } - await FileUtils.moveToSendFile( - await MixedConstants - .getFileDownloadLocation( - sharedBy: widget - .fileTransfer.sender!) + - Platform.pathSeparator + - widget.singleFile.name!); - - await DesktopSetupRoutes.nested_pop(); - }, - child: SvgPicture.asset( - AppVectors.icSendNew, - ), - ) - : SizedBox(), - isDownloaded - ? Padding( - padding: const EdgeInsets.only(left: 6.0), - child: GestureDetector( - onTap: () async { - String filePath = await MixedConstants - .getFileDownloadLocation( - sharedBy: - widget.fileTransfer.sender!) + - Platform.pathSeparator + - (widget.singleFile.name ?? ""); - - File file = File(filePath); - bool fileExists = await file.exists(); - if (fileExists == false) { - await SnackbarService().showSnackbar( - context, - "File does not exist on your device", - bgColor: ColorConstants.redAlert, - ); - } else { - file.deleteSync(); - SnackbarService().showSnackbar( - context, - "Successfully deleted the file", - bgColor: ColorConstants.successColor, - ); - widget.onAction?.call(); - setState(() { - isDownloaded = false; - }); - } - }, - child: SvgPicture.asset( - AppVectors.icDeleteGray, - ), - ), - ) - : SizedBox(), - ], - ) - : SizedBox(), - ], - ), - ), - ); - } - - Future downloadFiles( - FileTransfer? file, { - String? fileName, - bool isPreview = false, - }) async { - setState(() { - isDownloading = true; - }); - var fileTransferProgress = Provider.of( - NavService.navKey.currentContext!, - listen: false) - .receivedFileProgress[file!.key]; - - if (fileTransferProgress != null) { - return; //returning because download is still in progress - } - - var isConnected = Provider.of( - NavService.navKey.currentContext!, - listen: false) - .isInternetAvailable; - - if (!isConnected) { - SnackbarService().showSnackbar( - NavService.navKey.currentContext!, - TextStrings.noInternetMsg, - bgColor: ColorConstants.redAlert, - ); - return; - } - - var result; - if (fileName != null) { - result = await Provider.of( - NavService.navKey.currentContext!, - listen: false) - .downloadSingleFile( - file.key, - file.sender, - false, - fileName, - ); - } else { - result = await Provider.of( - NavService.navKey.currentContext!, - listen: false) - .downloadFiles( - file.key, - file.sender!, - false, - ); - } - - if (result is bool && result) { - if (mounted) { - setState(() { - if (!isPreview) isDownloading = false; - isDownloaded = true; - }); - } - await Provider.of(NavService.navKey.currentContext!, - listen: false) - .saveNewDataInMyFiles(file); - print(file.url); - widget.onAction?.call(); - SnackbarService().showSnackbar( - NavService.navKey.currentContext!, - TextStrings().fileDownloadd, - bgColor: ColorConstants.successGreen, - ); - // send download acknowledgement - await Provider.of(NavService.navKey.currentContext!, - listen: false) - .sendFileDownloadAcknowledgement(file); - } else if (result is bool && !result) { - SnackbarService().showSnackbar( - NavService.navKey.currentContext!, - TextStrings().downloadFailed, - bgColor: ColorConstants.redAlert, - ); - if (mounted) { - setState(() { - if (!isPreview) isDownloading = false; - isDownloaded = false; - }); - } - } - } -} diff --git a/lib/desktop_screens_new/history_screen/widgets/history_list_tile.dart b/lib/desktop_screens_new/history_screen/widgets/history_list_tile.dart deleted file mode 100644 index 10e83231..00000000 --- a/lib/desktop_screens_new/history_screen/widgets/history_list_tile.dart +++ /dev/null @@ -1,511 +0,0 @@ -import 'dart:io'; - -import 'package:at_common_flutter/at_common_flutter.dart'; -import 'package:atsign_atmosphere_pro/data_models/enums/file_category_type.dart'; -import 'package:atsign_atmosphere_pro/data_models/file_modal.dart'; -import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; -import 'package:atsign_atmosphere_pro/data_models/file_transfer_status.dart'; -import 'package:atsign_atmosphere_pro/desktop_screens_new/history_screen/widgets/history_file_card.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/labelled_circular_progress.dart'; -import 'package:atsign_atmosphere_pro/screens/history/widgets/file_recipients.dart'; -import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; -import 'package:atsign_atmosphere_pro/services/navigation_service.dart'; -import 'package:atsign_atmosphere_pro/services/snackbar_service.dart'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:atsign_atmosphere_pro/utils/constants.dart'; -import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; -import 'package:atsign_atmosphere_pro/utils/vectors.dart'; -import 'package:atsign_atmosphere_pro/view_models/file_progress_provider.dart'; -import 'package:atsign_atmosphere_pro/view_models/file_transfer_provider.dart'; -import 'package:atsign_atmosphere_pro/view_models/history_provider.dart'; -import 'package:atsign_atmosphere_pro/view_models/internet_connectivity_checker.dart'; -import 'package:atsign_atmosphere_pro/view_models/my_files_provider.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:intl/intl.dart'; -import 'package:provider/provider.dart'; - -class HistoryCardWidget extends StatefulWidget { - final FileHistory? fileHistory; - final List tags; - final Function()? onDownloaded; - - const HistoryCardWidget({ - Key? key, - this.fileHistory, - this.onDownloaded, - required this.tags, - }) : super(key: key); - - @override - State createState() => _HistoryCardWidgetState(); -} - -class _HistoryCardWidgetState extends State { - bool isExpanded = false, - isDownloading = false, - isDownloaded = false, - isFileSentSuccess = true; - List? filesList = []; - int numberOfFinished = 0; - int numberOfAllFiles = 0; - - @override - void initState() { - filesList = widget.fileHistory!.fileDetails!.files; - if (widget.fileHistory!.sharedWith != null) { - widget.fileHistory!.sharedWith!.forEach((ShareStatus sharedWith) { - if (sharedWith.isNotificationSend == false) { - isFileSentSuccess = false; - } - }); - } - numberOfAllFiles = widget.fileHistory?.fileDetails?.files?.length ?? 0; - super.initState(); - if (widget.fileHistory?.type == HistoryType.received) { - isFilesPresent(widget.fileHistory!.fileDetails!); - } - } - - @override - Widget build(BuildContext context) { - return Consumer(builder: (context, provider, child) { - if (provider.isDownloadDone) { - WidgetsBinding.instance.addPostFrameCallback((_) { - isFilesPresent(widget.fileHistory!.fileDetails!); - }); - } - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - Container( - padding: EdgeInsets.symmetric( - horizontal: 16, - vertical: 12, - ), - decoration: BoxDecoration( - color: isExpanded ? Color(0xFFE9E9E9) : Colors.white, - borderRadius: BorderRadius.circular(10), - ), - child: InkWell( - onTap: () { - setState(() { - isExpanded = !isExpanded; - }); - }, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Expanded( - flex: 1, - child: Text( - widget.fileHistory?.type == HistoryType.received - ? "${widget.fileHistory?.fileDetails?.sender ?? ''}" - : (widget.fileHistory?.sharedWith ?? []) - .map((shareStatus) => shareStatus.atsign) - .join(",") - .toString(), - style: TextStyle( - fontSize: 12.toFont, - color: Colors.black, - fontWeight: FontWeight.bold, - overflow: TextOverflow.ellipsis, - ), - ), - ), - Expanded( - flex: 0, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 40), - child: Text( - "${filesList!.length}", - style: TextStyle( - fontSize: 13.toFont, - fontWeight: FontWeight.bold, - color: ColorConstants.textBlack, - ), - ), - ), - ), - Expanded( - flex: 1, - child: Row( - children: [ - // Container( - // height: 15, - // width: 15, - // decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(10), - // color: ColorConstants.lightGreen, - // ), - // child: Icon( - // Icons.check, - // size: 10, - // color: ColorConstants.textGreen, - // ), - // ), - SizedBox(width: 4), - Container( - padding: EdgeInsets.symmetric( - horizontal: 16, - vertical: 5, - ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(33), - color: isFileSentSuccess - ? ColorConstants.lightGreen - : Colors.red.withOpacity(0.3), - ), - child: Center( - child: Text( - widget.fileHistory?.type == - HistoryType.received - ? "Received" - : "Sent", - style: TextStyle( - color: isFileSentSuccess - ? ColorConstants.textGreen - : Colors.red, - fontSize: 10.toFont, - ), - ), - ), - ), - ], - ), - ), - Expanded( - flex: 2, - child: Text( - widget.fileHistory?.type == HistoryType.send - ? widget.fileHistory?.notes ?? '' - : widget.fileHistory?.fileDetails?.notes ?? '', - style: TextStyle( - fontSize: 12.toFont, - color: Color(0xFF747474), - ), - ), - ), - Expanded( - flex: 1, - child: Column( - children: [ - Text( - '${DateFormat("MM/dd/yy").format(widget.fileHistory!.fileDetails!.date!)}', - style: TextStyle( - fontSize: 11.toFont, - color: ColorConstants.oldSliver, - fontWeight: FontWeight.bold, - ), - ), - Text( - '${DateFormat('kk:mm').format(widget.fileHistory!.fileDetails!.date!)}', - style: TextStyle( - fontSize: 10.toFont, - color: ColorConstants.oldSliver, - fontWeight: FontWeight.bold, - ), - ), - ], - ), - ), - Expanded( - flex: 1, - child: Wrap( - alignment: WrapAlignment.center, - spacing: 5, - runSpacing: 5, - children: [ - ...widget.tags.map((tag) { - return Container( - decoration: BoxDecoration( - color: ColorConstants.MILD_GREY, - borderRadius: BorderRadius.circular(10), - ), - padding: EdgeInsets.symmetric( - vertical: 2, horizontal: 8), - child: Text( - tag.text, - style: TextStyle( - color: Color(0xFF909090), - fontSize: 10, - ), - ), - ); - }).toList(), - ], - ), - ), - Expanded( - flex: 1, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - context.watch().typeSelected == - HistoryType.send - ? InkWell( - onTap: () { - openFileReceiptBottomSheet(); - }, - child: Icon( - Icons.done_all, - size: 14, - color: Color(0xFF909090), - ), - ) - : buildDownloadMultipleFilesButton(), - ], - ), - ), - SizedBox(width: 6), - isExpanded - ? SvgPicture.asset(AppVectors.icArrowUpOutline) - : SvgPicture.asset(AppVectors.icArrowDownOutline), - ], - ), - ], - ), - ), - ), - isExpanded - ? ListView.builder( - shrinkWrap: true, - itemCount: - widget.fileHistory?.fileDetails?.files?.length ?? 0, - physics: NeverScrollableScrollPhysics(), - padding: EdgeInsets.only(top: 4), - itemBuilder: (context, index) { - return HistoryFileCard( - key: UniqueKey(), - fileTransfer: widget.fileHistory!.fileDetails!, - singleFile: - widget.fileHistory!.fileDetails!.files![index], - isShowDate: false, - margin: EdgeInsets.fromLTRB(36, 6, 20, 0), - onAction: () async { - await isFilesPresent(widget.fileHistory!.fileDetails!); - }, - historyType: widget.fileHistory!.type ?? HistoryType.send, - fileHistory: widget.fileHistory!, - ); - }, - ) - : SizedBox(), - ], - ); - }); - } - - Widget buildDownloadMultipleFilesButton() { - return Consumer( - builder: (_c, provider, _) { - var fileTransferProgress = - provider.receivedFileProgress[widget.fileHistory?.fileDetails?.key]; - return Row( - mainAxisSize: MainAxisSize.min, - children: [ - CommonUtilityFunctions().checkForDownloadAvailability( - widget.fileHistory!.fileDetails!) - ? fileTransferProgress != null - ? getDownloadStatus(fileTransferProgress) - : isDownloaded - ? SvgPicture.asset( - AppVectors.icCloudDownloaded, - ) - : isDownloading - ? CircularProgressIndicator( - color: ColorConstants.orange) - : InkWell( - onTap: () async { - await downloadFiles( - widget.fileHistory?.fileDetails); - }, - child: SvgPicture.asset( - AppVectors.icDownloadFile, - ), - ) - : SizedBox(), - SizedBox(width: 12), - Text( - '$numberOfFinished/$numberOfAllFiles', - style: TextStyle( - fontSize: 11.toFont, - color: ColorConstants.oldSliver, - fontWeight: FontWeight.bold, - ), - ) - ], - ); - }, - ); - } - - openFileReceiptBottomSheet({FileRecipientSection? fileRecipientSection}) { - Provider.of(context, listen: false) - .selectedFileHistory = widget.fileHistory; - - showDialog( - context: context, - barrierColor: Colors.transparent, - barrierDismissible: true, - builder: (_context) { - return StatefulBuilder( - builder: (context, setDialogState) { - return Dialog( - insetPadding: EdgeInsets.zero, - alignment: Alignment.centerRight, - elevation: 5.0, - clipBehavior: Clip.hardEdge, - child: Container( - width: 400, - height: MediaQuery.of(context).size.height, - decoration: BoxDecoration( - color: Theme.of(context).scaffoldBackgroundColor, - borderRadius: BorderRadius.only( - topLeft: const Radius.circular(12.0), - topRight: const Radius.circular(12.0), - ), - ), - child: FileRecipients( - widget.fileHistory!.sharedWith, - fileRecipientSection: fileRecipientSection, - key: UniqueKey(), - ), - ), - ); - }, - ); - }); - } - - Future isFilesPresent(FileTransfer files) async { - isDownloaded = true; - numberOfFinished = 0; - for (FileData i in files.files ?? []) { - final bool isExist = - await checkFileExist(data: i, sender: files.sender ?? ''); - if (!isExist) { - isDownloaded = false; - } else { - numberOfFinished++; - } - } - if (context.read().isDownloadDone) { - context.read().resetIsDownloadDone(); - } - setState(() {}); - } - - Future checkFileExist( - {required FileData data, required String sender}) async { - String filePath = - await MixedConstants.getFileDownloadLocation(sharedBy: sender); - - File file = File(filePath + Platform.pathSeparator + (data.name ?? '')); - return await file.exists(); - } - - Future downloadFiles(FileTransfer? file) async { - setState(() { - isDownloading = true; - }); - var fileTransferProgress = Provider.of( - NavService.navKey.currentContext!, - listen: false) - .receivedFileProgress[file!.key]; - - if (fileTransferProgress != null) { - return; //returning because download is still in progress - } - - var isConnected = Provider.of( - NavService.navKey.currentContext!, - listen: false) - .isInternetAvailable; - - if (!isConnected) { - SnackbarService().showSnackbar( - NavService.navKey.currentContext!, - TextStrings.noInternetMsg, - bgColor: ColorConstants.redAlert, - ); - return; - } - - for (FileData i in file.files ?? []) { - if (!(await checkFileExist(data: i, sender: file.sender ?? ''))) { - var result = await Provider.of( - NavService.navKey.currentContext!, - listen: false) - .downloadSingleFile( - file.key, - file.sender, - false, - i.name ?? '', - ); - if (result is bool && result) { - setState(() { - numberOfFinished++; - }); - await Provider.of(NavService.navKey.currentContext!, - listen: false) - .saveNewDataInMyFiles(file); - print(file.url); - // send download acknowledgement - await Provider.of(NavService.navKey.currentContext!, - listen: false) - .sendFileDownloadAcknowledgement(file); - } else if (result is bool && !result) { - SnackbarService().showSnackbar( - NavService.navKey.currentContext!, - TextStrings().downloadFailed, - bgColor: ColorConstants.redAlert, - ); - if (mounted) { - setState(() { - isDownloading = false; - isDownloaded = false; - }); - await isFilesPresent(widget.fileHistory!.fileDetails!); - return; - } - } - } - } - if (mounted) { - setState(() { - isDownloading = false; - - isDownloaded = true; - }); - await isFilesPresent(widget.fileHistory!.fileDetails!); - SnackbarService().showSnackbar( - NavService.navKey.currentContext!, - TextStrings().fileDownloadd, - bgColor: ColorConstants.successGreen, - ); - } - } - - Widget getDownloadStatus(FileTransferProgress? fileTransferProgress) { - Widget spinner = CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation( - ColorConstants.orange, - ), - ); - - if (fileTransferProgress == null) { - return spinner; - } - - if (fileTransferProgress.fileState == FileState.download && - fileTransferProgress.percent != null) { - spinner = LabelledCircularProgressIndicator( - value: (fileTransferProgress.percent! / 100)); - } - - return spinner; - } -} diff --git a/lib/desktop_screens_new/my_files_screen/widgets/category_screen.dart b/lib/desktop_screens_new/my_files_screen/widgets/category_screen.dart index e1f6fc70..4d510649 100644 --- a/lib/desktop_screens_new/my_files_screen/widgets/category_screen.dart +++ b/lib/desktop_screens_new/my_files_screen/widgets/category_screen.dart @@ -9,7 +9,7 @@ import 'package:atsign_atmosphere_pro/desktop_screens_new/common_widgets/file_ti import 'package:atsign_atmosphere_pro/desktop_screens_new/groups_screen/widgets/icon_button_widget.dart'; import 'package:atsign_atmosphere_pro/desktop_screens_new/my_files_screen/utils/file_category.dart'; import 'package:atsign_atmosphere_pro/desktop_screens_new/my_files_screen/widgets/file_list_tile_widget.dart'; -import 'package:atsign_atmosphere_pro/screens/my_files/widgets/recents.dart'; +import 'package:atsign_atmosphere_pro/screens/my_files/widgets/recent.dart'; import 'package:atsign_atmosphere_pro/services/backend_service.dart'; import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; import 'package:atsign_atmosphere_pro/services/snackbar_service.dart'; @@ -489,7 +489,7 @@ class _CategoryScreenState extends State { localFile.deleteSync(); } - await SnackbarService().showSnackbar( + await SnackBarService().showSnackBar( context, res ? "Successfully deleted the file" diff --git a/lib/desktop_screens_new/notification/fail_card.dart b/lib/desktop_screens_new/notification/fail_card.dart index e878962e..5ea7d92d 100644 --- a/lib/desktop_screens_new/notification/fail_card.dart +++ b/lib/desktop_screens_new/notification/fail_card.dart @@ -5,7 +5,6 @@ import 'package:atsign_atmosphere_pro/data_models/file_modal.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; import 'package:atsign_atmosphere_pro/desktop_routes/desktop_route_names.dart'; import 'package:atsign_atmosphere_pro/desktop_routes/desktop_routes.dart'; -import 'package:atsign_atmosphere_pro/desktop_screens_new/notification/notification_card_btn.dart'; import 'package:atsign_atmosphere_pro/screens/welcome_screen/welcome_screen.dart'; import 'package:flutter/material.dart'; diff --git a/lib/desktop_screens_new/notification/notification_body.dart b/lib/desktop_screens_new/notification/notification_body.dart index 9ac1e810..416031ef 100644 --- a/lib/desktop_screens_new/notification/notification_body.dart +++ b/lib/desktop_screens_new/notification/notification_body.dart @@ -85,7 +85,7 @@ class _NotificationBodyState extends State { provider.currentFileShareStatus[ notification_service .NotificationService - .flushbarStatuskey] == + .flushBarStatusKey] == null ? Center( child: Text('No notifications'), @@ -109,9 +109,9 @@ class _NotificationBodyState extends State { FileTransfer? fileTransfer = notificationServiceprovider.currentFileShareStatus[ notification_service.NotificationService.fileObjectKey]; - FLUSHBAR_STATUS? flushbarStatus = + FlushBarStatus? flushbarStatus = notificationServiceprovider.currentFileShareStatus[ - notification_service.NotificationService.flushbarStatuskey]; + notification_service.NotificationService.flushBarStatusKey]; return SendingFileCard( flushbarStatus: flushbarStatus, diff --git a/lib/desktop_screens_new/notification/sending_file_card.dart b/lib/desktop_screens_new/notification/sending_file_card.dart index babeceb3..433e6053 100644 --- a/lib/desktop_screens_new/notification/sending_file_card.dart +++ b/lib/desktop_screens_new/notification/sending_file_card.dart @@ -6,7 +6,7 @@ import 'package:atsign_atmosphere_pro/view_models/file_transfer_provider.dart'; import 'package:flutter/material.dart'; class SendingFileCard extends StatelessWidget { - final FLUSHBAR_STATUS? flushbarStatus; + final FlushBarStatus? flushbarStatus; final FileTransfer? fileTransfer; const SendingFileCard({ Key? key, @@ -16,7 +16,7 @@ class SendingFileCard extends StatelessWidget { @override Widget build(BuildContext context) { - return flushbarStatus == FLUSHBAR_STATUS.SENDING && fileTransfer != null + return flushbarStatus == FlushBarStatus.SENDING && fileTransfer != null ? Container( width: double.infinity, padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10), diff --git a/lib/desktop_screens_new/settings_screen/blocked_contacts.dart b/lib/desktop_screens_new/settings_screen/blocked_contacts.dart index 6ecc109a..8e4fe3be 100644 --- a/lib/desktop_screens_new/settings_screen/blocked_contacts.dart +++ b/lib/desktop_screens_new/settings_screen/blocked_contacts.dart @@ -38,7 +38,7 @@ class _DesktopBlockedContactsState extends State { .blockUnblockContact(contact: contact, blockAction: false); await ContactService().fetchBlockContactList(); setState(() {}); - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( context, res ? "Succesfully unblocked the contact" : "Failed to unblock contact", bgColor: res ? ColorConstants.successGreen : ColorConstants.redAlert, diff --git a/lib/desktop_screens_new/settings_screen/settings_desktop.dart b/lib/desktop_screens_new/settings_screen/settings_desktop.dart index 938da771..8d927744 100644 --- a/lib/desktop_screens_new/settings_screen/settings_desktop.dart +++ b/lib/desktop_screens_new/settings_screen/settings_desktop.dart @@ -157,8 +157,8 @@ class _SettingsScreenDesktopState extends State { .changeIsSwitchingAtSign(); }, child: DesktopSettingsCard( - title: TextStrings().switchatSign, - subtitle: TextStrings().switchatSignSubtitle, + title: TextStrings().switchAtSign, + subtitle: TextStrings().switchAtSignSubtitle, vectorIcon: AppVectors.icSettingSwitch, ), ), @@ -167,11 +167,11 @@ class _SettingsScreenDesktopState extends State { child: InkWell( onTap: () async { await CommonUtilityFunctions() - .showResetAtsignDialog(); + .showResetAtSignDialog(); }, child: DesktopSettingsCard( - title: TextStrings().deleteAtsigns, - subtitle: TextStrings().deleteAtsignsSubtitle, + title: TextStrings().deleteAtSigns, + subtitle: TextStrings().deleteAtSignsSubtitle, vectorIcon: AppVectors.icSettingDelete, ), ), diff --git a/lib/desktop_screens_new/transfer_screen/file_transfer_screen.dart b/lib/desktop_screens_new/transfer_screen/file_transfer_screen.dart index ab07e788..4fceb0a2 100644 --- a/lib/desktop_screens_new/transfer_screen/file_transfer_screen.dart +++ b/lib/desktop_screens_new/transfer_screen/file_transfer_screen.dart @@ -98,7 +98,7 @@ class _FileTransferScreenState extends State { }); if (!isFileShareFailed) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( context, TextStrings().fileSentSuccessfully, bgColor: Color(0xFF5FAA45), @@ -108,7 +108,7 @@ class _FileTransferScreenState extends State { _filePickerProvider.selectedFiles.clear(); _filePickerProvider.notify(); } else { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( context, TextStrings().oopsSomethingWentWrong, bgColor: ColorConstants.redAlert, @@ -116,7 +116,7 @@ class _FileTransferScreenState extends State { await showRetrySending(); } } else if (res == null) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( context, TextStrings().oopsSomethingWentWrong, bgColor: ColorConstants.redAlert, diff --git a/lib/desktop_screens_new/transfer_screen/widgets/add_file_tile.dart b/lib/desktop_screens_new/transfer_screen/widgets/add_file_tile.dart deleted file mode 100644 index 193a1b58..00000000 --- a/lib/desktop_screens_new/transfer_screen/widgets/add_file_tile.dart +++ /dev/null @@ -1,85 +0,0 @@ -import 'package:at_backupkey_flutter/utils/size_config.dart'; -import 'package:atsign_atmosphere_pro/screens/my_files/widgets/recents.dart'; -import 'package:atsign_atmosphere_pro/utils/app_utils.dart'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:file_picker/file_picker.dart'; -import 'package:flutter/material.dart'; - -class AddFileTile extends StatelessWidget { - const AddFileTile({ - Key? key, - required this.file, - }) : super(key: key); - - final PlatformFile file; - - @override - Widget build(BuildContext context) { - return Padding( - padding: EdgeInsets.only(right: 20, top: 20, bottom: 20), - child: Column( - children: [ - Container( - width: 300, - height: 100, - child: thumbnail(file.extension ?? "", file.path ?? ""), - decoration: BoxDecoration( - color: ColorConstants.MILD_GREY, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(10), - topRight: Radius.circular(10), - ), - ), - ), - Container( - width: 300, - padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(10), - bottomRight: Radius.circular(10), - ), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - file.name, - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 16, - overflow: TextOverflow.ellipsis, - ), - ), - SizedBox(height: 10.toHeight), - Text( - DateTime.now().toString(), - textAlign: TextAlign.start, - style: TextStyle( - fontSize: 12, - color: ColorConstants.gray, - ), - ), - ], - ), - ), - Text( - AppUtils.getFileSizeString(bytes: file.size.toDouble()), - style: TextStyle( - fontSize: 12, - color: ColorConstants.gray, - ), - ), - ], - ), - ) - ], - ), - ); - } -} diff --git a/lib/screens/trusted_contacts/widgets/remove_trusted_contact_dialog.dart b/lib/desktop_screens_new/trusted_senders_screen/widgets/remove_trusted_contact_dialog.dart similarity index 98% rename from lib/screens/trusted_contacts/widgets/remove_trusted_contact_dialog.dart rename to lib/desktop_screens_new/trusted_senders_screen/widgets/remove_trusted_contact_dialog.dart index 688920c5..ab36172a 100644 --- a/lib/screens/trusted_contacts/widgets/remove_trusted_contact_dialog.dart +++ b/lib/desktop_screens_new/trusted_senders_screen/widgets/remove_trusted_contact_dialog.dart @@ -3,8 +3,6 @@ import 'dart:typed_data'; import 'package:at_contact/at_contact.dart'; import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; import 'package:at_contacts_flutter/utils/text_strings.dart'; -import 'package:atsign_atmosphere_pro/utils/text_strings.dart' - as pro_text_strings; import 'package:atsign_atmosphere_pro/screens/common_widgets/contact_initial.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_button.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_circle_avatar.dart'; diff --git a/lib/desktop_screens_new/welcome_screen/widgets/circular_icon.dart b/lib/desktop_screens_new/welcome_screen/widgets/circular_icon.dart index a69e3b80..57d22e26 100644 --- a/lib/desktop_screens_new/welcome_screen/widgets/circular_icon.dart +++ b/lib/desktop_screens_new/welcome_screen/widgets/circular_icon.dart @@ -1,10 +1,14 @@ import 'package:flutter/material.dart'; class CircularIcon extends StatelessWidget { - IconData icon; - Color? iconColor; - CircularIcon({Key? key, required this.icon, this.iconColor}) - : super(key: key); + final IconData icon; + final Color? iconColor; + + CircularIcon({ + Key? key, + required this.icon, + this.iconColor, + }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/desktop_screens_new/welcome_screen/widgets/sidebar_new.dart b/lib/desktop_screens_new/welcome_screen/widgets/sidebar_new.dart index 24fff139..bc1fe487 100644 --- a/lib/desktop_screens_new/welcome_screen/widgets/sidebar_new.dart +++ b/lib/desktop_screens_new/welcome_screen/widgets/sidebar_new.dart @@ -329,7 +329,7 @@ class _SideBarNewState extends State { ), ), errorBuilder: (provider) => Center( - child: Text(TextStrings().errorOccured), + child: Text(TextStrings().errorOccurred), ), ), ), diff --git a/lib/desktop_screens_new/welcome_screen/widgets/switch_atsign_tile.dart b/lib/desktop_screens_new/welcome_screen/widgets/switch_atsign_tile.dart deleted file mode 100644 index 69acf3a6..00000000 --- a/lib/desktop_screens_new/welcome_screen/widgets/switch_atsign_tile.dart +++ /dev/null @@ -1,97 +0,0 @@ -import 'package:at_client_mobile/at_client_mobile.dart'; -import 'package:at_contact/at_contact.dart'; -import 'package:at_contacts_flutter/utils/init_contacts_service.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/contact_initial.dart'; -import 'package:flutter/material.dart'; - -class SwitchAtSignTile extends StatefulWidget { - const SwitchAtSignTile({ - Key? key, - required this.atSign, - this.isExpanded = false, - }) : super(key: key); - - final String atSign; - final bool isExpanded; - - - @override - State createState() => _SwitchAtSignTileState(); -} - -class _SwitchAtSignTileState extends State { - var image; - String? nickname; - String currentAtSign = ""; - - @override - void initState() { - super.initState(); - getContactDetails(); - currentAtSign = - AtClientManager.getInstance().atClient.getCurrentAtSign() ?? ""; - } - - void getContactDetails() { - AtContact contact = checkForCachedContactDetail(widget.atSign); - if (contact.tags?["image"] != null) { - image = contact.tags?["image"]; - } - if (contact.tags?["nickname"] != null) { - nickname = contact.tags?["nickname"]; - } - } - - @override - Widget build(BuildContext context) { - return Container( - color: currentAtSign == widget.atSign - ? Theme.of(context).primaryColor - : Colors.transparent, - padding: EdgeInsets.symmetric( - horizontal: 20, - vertical: 10, - ), - width: 300, - child: Row( - children: [ - Center( - // child: image != null - // ? CustomCircleAvatar( - // image: image.toString(), - // size: 10, - // ) - // : ContactInitialV2(initials: widget.atSign), - child: ContactInitialV2(initials: widget.atSign), - ), - SizedBox( - width: widget.isExpanded ? 20 : 0, - ), - widget.isExpanded ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - nickname ?? widget.atSign, - style: TextStyle( - fontSize: 10, - color: currentAtSign == widget.atSign - ? Colors.white - : Colors.black, - ), - ), - Text( - widget.atSign, - style: TextStyle( - fontSize: 16, - color: currentAtSign == widget.atSign - ? Colors.white - : Colors.black, - ), - ), - ], - ) : SizedBox(), - ], - ), - ); - } -} diff --git a/lib/main.dart b/lib/main.dart index 6ee89d8a..3f147f50 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -15,7 +15,6 @@ void main() async { } }); } - // AtSignLogger.root_level = 'finer'; if (Platform.isLinux || Platform.isMacOS) { await DesktopWindow.setWindowSize(Size(1280, 832)); await DesktopWindow.setMinWindowSize(Size(1280, 832)); diff --git a/lib/screens/common_widgets/app_bar.dart b/lib/screens/common_widgets/app_bar.dart index b2721275..545d152e 100644 --- a/lib/screens/common_widgets/app_bar.dart +++ b/lib/screens/common_widgets/app_bar.dart @@ -27,28 +27,29 @@ class CustomAppBar extends StatefulWidget implements PreferredSizeWidget { final String? title; final bool showTitle; final bool showBackButton; - final bool showLeadingicon; + final bool showLeadingIcon; final bool showTrailingButton; final bool showMenu; final bool showClosedBtnText; final IconData trailingIcon; final bool isHistory; - final onActionpressed; + final onActionPressed; final bool isTrustedContactScreen; final double elevation; + const CustomAppBar( {Key? key, this.title, this.showTitle = false, this.showBackButton = false, - this.showLeadingicon = false, + this.showLeadingIcon = false, this.showTrailingButton = false, this.showClosedBtnText = true, this.showMenu = false, this.trailingIcon = Icons.add, this.isHistory = false, this.elevation = 0, - this.onActionpressed, + this.onActionPressed, this.isTrustedContactScreen = false}) : super(key: key); @@ -65,7 +66,7 @@ class _CustomAppBarState extends State { return AppBar( elevation: widget.elevation, centerTitle: false, - leading: (widget.showLeadingicon) + leading: (widget.showLeadingIcon) ? Image.asset(ImageConstants.logoIcon) : (widget.showBackButton) ? IconButton( @@ -86,7 +87,7 @@ class _CustomAppBarState extends State { height: 40.toHeight, margin: EdgeInsets.only(top: 5.toHeight), child: (!widget.showBackButton && - !widget.showLeadingicon && + !widget.showLeadingIcon && widget.showClosedBtnText) ? Center( child: GestureDetector( @@ -148,12 +149,13 @@ class _CustomAppBarState extends State { .isGranted, ); } else { - String url = 'shareddocuments://' + + final path = 'shareddocuments://' + BackendService.getInstance() .atClientPreference .downloadPath!; - if (await canLaunch(url)) { - await launch(url); + final url = Uri.parse(path); + if (await canLaunchUrl(url)) { + await launchUrl(url); } else { throw 'Could not launch $url'; } @@ -206,7 +208,7 @@ class _CustomAppBarState extends State { Scaffold.of(context).openEndDrawer(); }, alignment: Alignment.topCenter, - tooltip: _fileDownloadChecker.undownloadedFilesExist + tooltip: _fileDownloadChecker.unDownloadedFilesExist ? 'Hamburger Menu & Dot' : 'Hamburger Menu', padding: EdgeInsets.zero, @@ -223,7 +225,7 @@ class _CustomAppBarState extends State { semanticLabel: '', ), ), - _fileDownloadChecker.undownloadedFilesExist + _fileDownloadChecker.unDownloadedFilesExist ? Positioned( right: -4, top: 2, diff --git a/lib/screens/common_widgets/card_widget.dart b/lib/screens/common_widgets/card_widget.dart deleted file mode 100644 index 72ef70e7..00000000 --- a/lib/screens/common_widgets/card_widget.dart +++ /dev/null @@ -1,55 +0,0 @@ -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; - -class CardButton extends StatelessWidget { - final String icon; - final String title; - final TextStyle? style; - final Function()? onTap; - final Color? backgroundColor; - final Color? borderColor; - - const CardButton({ - Key? key, - required this.icon, - required this.title, - this.style, - this.onTap, - this.backgroundColor, - this.borderColor, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return InkWell( - onTap: onTap, - child: Container( - height: 62, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: backgroundColor ?? ColorConstants.lightGrey, - border: Border.all( - color: borderColor ?? ColorConstants.grey, - ), - ), - padding: const EdgeInsets.symmetric(horizontal: 32), - child: Row( - children: [ - SvgPicture.asset(icon), - const SizedBox(width: 8), - Text( - title, - style: style ?? - TextStyle( - fontSize: 18, - fontWeight: FontWeight.w500, - color: ColorConstants.grey, - ), - ) - ], - ), - ), - ); - } -} diff --git a/lib/screens/common_widgets/contact_initial.dart b/lib/screens/common_widgets/contact_initial.dart index 4b048f32..a89b63ad 100644 --- a/lib/screens/common_widgets/contact_initial.dart +++ b/lib/screens/common_widgets/contact_initial.dart @@ -6,14 +6,12 @@ import 'package:at_common_flutter/services/size_config.dart'; class ContactInitial extends StatelessWidget { final double? size, maxSize, minSize, borderRadius; final String? initials; - int? index; - Color? background; + final Color? background; ContactInitial({ Key? key, this.size = 40, required this.initials, - this.index, this.background, this.maxSize, this.minSize, @@ -22,11 +20,7 @@ class ContactInitial extends StatelessWidget { @override Widget build(BuildContext context) { - if (initials!.length < 3) { - index = initials!.length; - } else { - index = 2; - } + final index = (initials!.length < 3) ? initials!.length : 2; return Container( height: size!.toFont, @@ -35,7 +29,7 @@ class ContactInitial extends StatelessWidget { color: background ?? ContactInitialsColors.getColor(initials!), // borderRadius: BorderRadius.circular(size.toWidth), // color: ContactInitialsColors.getColor(initials), - borderRadius: BorderRadius.circular(( borderRadius ?? size!.toFont)), + borderRadius: BorderRadius.circular((borderRadius ?? size!.toFont)), ), child: Center( child: Text( @@ -46,48 +40,3 @@ class ContactInitial extends StatelessWidget { ); } } - -class ContactInitialV2 extends StatelessWidget { - final double? size, maxSize, minSize; - final String? initials; - final int? index; - final Color? background; - - ContactInitialV2({ - Key? key, - this.size = 40, - required this.initials, - this.index, - this.background, - this.maxSize, - this.minSize, - }) : super(key: key); - - int get startIndex => (index == 1) ? 0 : 1; - int get endIndex => (initials!.length < 3) ? initials!.length : 3; - - Widget build(BuildContext context) { - return Container( - height: size!.toFont, - width: size!.toFont, - decoration: BoxDecoration( - color: background ?? ContactInitialsColors.getColor(initials!), - borderRadius: BorderRadius.circular((size!.toFont * 0.2)), - boxShadow: [ - BoxShadow( - color: ColorConstants.light_grey, - spreadRadius: 1, - blurRadius: 10, - offset: Offset(0, 4), // changes position of shadow - ), - ], - ), - child: Center( - child: Text( - initials!.substring(startIndex, endIndex).toUpperCase(), - style: CustomTextStyles.whiteBold(size: (size! ~/ 3)), - ), - ), - ); - } -} diff --git a/lib/screens/common_widgets/custom_circle_avatar.dart b/lib/screens/common_widgets/custom_circle_avatar.dart index 24f736ae..fcb805ce 100644 --- a/lib/screens/common_widgets/custom_circle_avatar.dart +++ b/lib/screens/common_widgets/custom_circle_avatar.dart @@ -2,7 +2,6 @@ /// [size] is set to [50] as default import 'dart:typed_data'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; import 'package:flutter/material.dart'; import 'package:at_common_flutter/services/size_config.dart'; @@ -48,49 +47,3 @@ class CustomCircleAvatar extends StatelessWidget { } } -class CustomCircleAvatarV2 extends StatelessWidget { - final String? image; - final double size; - final bool nonAsset; - final Uint8List? byteImage; - - const CustomCircleAvatarV2({ - Key? key, - this.image, - this.size = 50, - this.nonAsset = false, - this.byteImage, - }) : super(key: key); - @override - Widget build(BuildContext context) { - return Container( - height: size.toFont, - width: size.toFont, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(size.toWidth * 0.2), - image: DecorationImage( - image: nonAsset - ? Image.memory( - byteImage!, - errorBuilder: (BuildContext _context, _, __) { - return Container( - child: Icon( - Icons.image, - size: size.toFont, - ), - ); - }, - ).image - : AssetImage(image!), - ), - boxShadow: [ - BoxShadow( - color: ColorConstants.light_grey, - spreadRadius: 1, - blurRadius: 10, - offset: Offset(0, 4), // changes position of shadow - ), - ], - )); - } -} diff --git a/lib/screens/common_widgets/custom_heading.dart b/lib/screens/common_widgets/custom_heading.dart deleted file mode 100644 index a75dcba1..00000000 --- a/lib/screens/common_widgets/custom_heading.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:at_common_flutter/services/size_config.dart'; -import '../../utils/images.dart'; - -class Customheading extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Container( - height: 50.toHeight, - color: Colors.white, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: Container( - width: 90.toHeight, - height: 90.toHeight, - child: Image.asset( - ImageConstants.logoIcon, - ), - ), - ), - ], - ), - ); - } -} diff --git a/lib/screens/common_widgets/custom_onboarding.dart b/lib/screens/common_widgets/custom_onboarding.dart index 7d2a036a..008682e7 100644 --- a/lib/screens/common_widgets/custom_onboarding.dart +++ b/lib/screens/common_widgets/custom_onboarding.dart @@ -25,7 +25,7 @@ class CustomOnboarding { static onboard( {String? atSign, - required atClientPrefernce, + required atClientPreference, Function? showLoader, bool isInit = false, Function? onError}) async { @@ -38,7 +38,7 @@ class CustomOnboarding { result = await AtOnboarding.onboard( context: NavService.navKey.currentContext!, config: AtOnboardingConfig( - atClientPreference: atClientPrefernce!, + atClientPreference: atClientPreference!, domain: MixedConstants.ROOT_DOMAIN, rootEnvironment: RootEnvironment.Production, appAPIKey: MixedConstants.ONBOARD_API_KEY, @@ -53,7 +53,7 @@ class CustomOnboarding { OnboardingService.getInstance(); final value = _onboardingService.atClientServiceMap; await AtClientManager.getInstance().setCurrentAtSign( - atsign, MixedConstants.appNamespace, atClientPrefernce); + atsign, MixedConstants.appNamespace, atClientPreference); _backendService.atClientServiceInstance = value[atsign]; _backendService.currentAtSign = @@ -89,7 +89,7 @@ class CustomOnboarding { if (!isInit) { // if it is not init then we re-render the welcome screen - Provider.of(NavService.navKey.currentContext!, + Provider.of(NavService.navKey.currentContext!, listen: false) .update(); Provider.of(NavService.navKey.currentContext!, @@ -118,13 +118,12 @@ class CustomOnboarding { } break; case AtOnboardingResultStatus.cancel: - // TODO: Handle this case. break; } } static initServices() async { - initializeContactsService(rootDomain: MixedConstants.ROOT_DOMAIN); + await initializeContactsService(rootDomain: MixedConstants.ROOT_DOMAIN); initializeGroupService(rootDomain: MixedConstants.ROOT_DOMAIN); } @@ -153,6 +152,6 @@ class CustomOnboarding { Provider.of(NavService.navKey.currentContext!, listen: false) - .checkForUndownloadedFiles(); + .checkForUnDownloadedFiles(); } } diff --git a/lib/screens/common_widgets/custom_popup_route.dart b/lib/screens/common_widgets/custom_popup_route.dart index a54b2cee..477b6e05 100644 --- a/lib/screens/common_widgets/custom_popup_route.dart +++ b/lib/screens/common_widgets/custom_popup_route.dart @@ -9,8 +9,7 @@ class CustomPopupRoutes extends PopupRoute { Duration transitionDuration = const Duration(milliseconds: 200), RouteTransitionsBuilder? transitionBuilder, RouteSettings? settings, - }) : assert(barrierDismissible != null), - _pageBuilder = pageBuilder, + }) : _pageBuilder = pageBuilder, _barrierDismissible = barrierDismissible, _barrierLabel = barrierLabel, _barrierColor = barrierColor, diff --git a/lib/screens/common_widgets/custom_toast.dart b/lib/screens/common_widgets/custom_toast.dart index 02acaea6..53b897fa 100644 --- a/lib/screens/common_widgets/custom_toast.dart +++ b/lib/screens/common_widgets/custom_toast.dart @@ -6,32 +6,30 @@ import 'package:fluttertoast/fluttertoast.dart'; class CustomToast { CustomToast._(); + static final CustomToast _instance = CustomToast._(); + factory CustomToast() => _instance; show(String text, BuildContext context, {Color? bgColor, Color? textColor, int duration = 3, int gravity = 0}) { - // ignore: always_declare_return_types - show(String text, BuildContext context, - {Color? bgColor, Color? textColor, int duration = 3, int gravity = 0}) { - if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) { - FlutterToastr.show(text, context, - duration: FlutterToastr.lengthLong, - backgroundColor: bgColor ?? ColorConstants.orangeColor, - textStyle: TextStyle( - color: Colors.white, - fontWeight: FontWeight.normal, - )); - } else { - Fluttertoast.showToast( - msg: text, - toastLength: Toast.LENGTH_LONG, - gravity: ToastGravity.BOTTOM, - timeInSecForIosWeb: 1, - backgroundColor: bgColor ?? ColorConstants.orangeColor, - textColor: textColor ?? Colors.white, - fontSize: 16.0); - } + if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) { + FlutterToastr.show(text, context, + duration: FlutterToastr.lengthLong, + backgroundColor: bgColor ?? ColorConstants.orangeColor, + textStyle: TextStyle( + color: Colors.white, + fontWeight: FontWeight.normal, + )); + } else { + Fluttertoast.showToast( + msg: text, + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 1, + backgroundColor: bgColor ?? ColorConstants.orangeColor, + textColor: textColor ?? Colors.white, + fontSize: 16.0); } } } diff --git a/lib/screens/common_widgets/error_dialog.dart b/lib/screens/common_widgets/error_dialog.dart index 790d37ef..41441786 100644 --- a/lib/screens/common_widgets/error_dialog.dart +++ b/lib/screens/common_widgets/error_dialog.dart @@ -40,7 +40,7 @@ class ErrorDialogWidget extends StatelessWidget { children: [ SizedBox(height: 20.toHeight), Text( - TextStrings().errorOccured, + TextStrings().errorOccurred, style: CustomTextStyles.primaryBold18, ), SizedBox(height: 10.toHeight), diff --git a/lib/screens/common_widgets/error_screen.dart b/lib/screens/common_widgets/error_screen.dart index 0d129038..66d37129 100644 --- a/lib/screens/common_widgets/error_screen.dart +++ b/lib/screens/common_widgets/error_screen.dart @@ -1,4 +1,3 @@ -import 'package:at_common_flutter/at_common_flutter.dart'; import 'package:atsign_atmosphere_pro/utils/images.dart'; import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; import 'package:flutter/material.dart'; diff --git a/lib/screens/common_widgets/gradient_button.dart b/lib/screens/common_widgets/gradient_button.dart deleted file mode 100644 index fc24ac07..00000000 --- a/lib/screens/common_widgets/gradient_button.dart +++ /dev/null @@ -1,56 +0,0 @@ -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:flutter/material.dart'; - -class GradientButton extends StatelessWidget { - final double? width; - final double? height; - final VoidCallback? onPressed; - final Widget child; - final double radius; - - const GradientButton({ - Key? key, - required this.onPressed, - required this.child, - this.width, - this.radius = 8, - this.height, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return Container( - width: width, - height: height, - margin: EdgeInsets.symmetric(horizontal: 4), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - ColorConstants.orangeColor, - ColorConstants.yellow, - ], - ), - borderRadius: BorderRadius.circular(radius), - boxShadow: [ - BoxShadow( - color: ColorConstants.light_grey, - spreadRadius: 0, - blurRadius: 2, - offset: Offset(1, 2), // changes position of shadow - ), - ], - ), - child: ElevatedButton( - onPressed: onPressed, - style: ElevatedButton.styleFrom( - backgroundColor: Colors.transparent, - shadowColor: Colors.transparent, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(radius), - ), - ), - child: child, - ), - ); - } -} diff --git a/lib/screens/common_widgets/gradient_outline_input_border.dart b/lib/screens/common_widgets/gradient_outline_input_border.dart deleted file mode 100644 index 280532cd..00000000 --- a/lib/screens/common_widgets/gradient_outline_input_border.dart +++ /dev/null @@ -1,176 +0,0 @@ -import 'dart:math' as math; -import 'dart:ui'; - -import 'package:flutter/material.dart'; - -class GradientOutlineInputBorder extends InputBorder { - const GradientOutlineInputBorder({ - required this.gradient, - this.width = 1.0, - this.gapPadding = 4.0, - this.borderRadius = const BorderRadius.all(Radius.circular(4)), - }); - - final double width; - - final BorderRadius borderRadius; - - final Gradient gradient; - - final double gapPadding; - - @override - InputBorder copyWith({BorderSide? borderSide}) { - return this; - } - - @override - bool get isOutline => true; - - @override - EdgeInsetsGeometry get dimensions => EdgeInsets.all(width); - - @override - Path getInnerPath(Rect rect, {TextDirection? textDirection}) { - return Path() - ..addRRect( - borderRadius - .resolve(textDirection) - .toRRect(rect) - .deflate(borderSide.width), - ); - } - - @override - Path getOuterPath(Rect rect, {TextDirection? textDirection}) { - return Path()..addRRect(borderRadius.resolve(textDirection).toRRect(rect)); - } - - @override - void paint( - Canvas canvas, - Rect rect, { - double? gapStart, - double gapExtent = 0.0, - double gapPercentage = 0.0, - TextDirection? textDirection, - }) { - final paint = _getPaint(rect); - final outer = borderRadius.toRRect(rect); - final center = outer.deflate(borderSide.width / 2.0); - if (gapStart == null || gapExtent <= 0.0 || gapPercentage == 0.0) { - canvas.drawRRect(center, paint); - } else { - final extent = - lerpDouble(0.0, gapExtent + gapPadding * 2.0, gapPercentage)!; - switch (textDirection!) { - case TextDirection.rtl: - final path = _gapBorderPath( - canvas, - center, - math.max(0, gapStart + gapPadding - extent), - extent, - ); - canvas.drawPath(path, paint); - break; - - case TextDirection.ltr: - final path = _gapBorderPath( - canvas, - center, - math.max(0, gapStart - gapPadding), - extent, - ); - canvas.drawPath(path, paint); - break; - } - } - } - - @override - ShapeBorder scale(double t) { - return GradientOutlineInputBorder( - width: width * t, - borderRadius: borderRadius * t, - gradient: gradient, - ); - } - - Paint _getPaint(Rect rect) { - return Paint() - ..strokeWidth = width - ..shader = gradient.createShader(rect) - ..style = PaintingStyle.stroke; - } - - Path _gapBorderPath( - Canvas canvas, - RRect center, - double start, - double extent, - ) { - // When the corner radii on any side add up to be greater than the - // given height, each radius has to be scaled to not exceed the - // size of the width/height of the RRect. - final scaledRRect = center.scaleRadii(); - - final tlCorner = Rect.fromLTWH( - scaledRRect.left, - scaledRRect.top, - scaledRRect.tlRadiusX * 2.0, - scaledRRect.tlRadiusY * 2.0, - ); - final trCorner = Rect.fromLTWH( - scaledRRect.right - scaledRRect.trRadiusX * 2.0, - scaledRRect.top, - scaledRRect.trRadiusX * 2.0, - scaledRRect.trRadiusY * 2.0, - ); - final brCorner = Rect.fromLTWH( - scaledRRect.right - scaledRRect.brRadiusX * 2.0, - scaledRRect.bottom - scaledRRect.brRadiusY * 2.0, - scaledRRect.brRadiusX * 2.0, - scaledRRect.brRadiusY * 2.0, - ); - final blCorner = Rect.fromLTWH( - scaledRRect.left, - scaledRRect.bottom - scaledRRect.blRadiusY * 2.0, - scaledRRect.blRadiusX * 2.0, - scaledRRect.blRadiusX * 2.0, - ); - - const cornerArcSweep = math.pi / 2.0; - final tlCornerArcSweep = start < scaledRRect.tlRadiusX - ? math.asin((start / scaledRRect.tlRadiusX).clamp(-1.0, 1.0)) - : math.pi / 2.0; - - final path = Path() - ..addArc(tlCorner, math.pi, tlCornerArcSweep) - ..moveTo(scaledRRect.left + scaledRRect.tlRadiusX, scaledRRect.top); - - if (start > scaledRRect.tlRadiusX) { - path.lineTo(scaledRRect.left + start, scaledRRect.top); - } - - const trCornerArcStart = (3 * math.pi) / 2.0; - const trCornerArcSweep = cornerArcSweep; - if (start + extent < scaledRRect.width - scaledRRect.trRadiusX) { - path - ..relativeMoveTo(extent, 0) - ..lineTo(scaledRRect.right - scaledRRect.trRadiusX, scaledRRect.top) - ..addArc(trCorner, trCornerArcStart, trCornerArcSweep); - } else if (start + extent < scaledRRect.width) { - final dx = scaledRRect.width - (start + extent); - final sweep = math.acos(dx / scaledRRect.trRadiusX); - path.addArc(trCorner, trCornerArcStart + sweep, trCornerArcSweep - sweep); - } - - return path - ..moveTo(scaledRRect.right, scaledRRect.top + scaledRRect.trRadiusY) - ..lineTo(scaledRRect.right, scaledRRect.bottom - scaledRRect.brRadiusY) - ..addArc(brCorner, 0, cornerArcSweep) - ..lineTo(scaledRRect.left + scaledRRect.blRadiusX, scaledRRect.bottom) - ..addArc(blCorner, math.pi / 2.0, cornerArcSweep) - ..lineTo(scaledRRect.left, scaledRRect.top + scaledRRect.tlRadiusY); - } -} \ No newline at end of file diff --git a/lib/screens/common_widgets/gradient_text_field_widget.dart b/lib/screens/common_widgets/gradient_text_field_widget.dart deleted file mode 100644 index 09fd88e5..00000000 --- a/lib/screens/common_widgets/gradient_text_field_widget.dart +++ /dev/null @@ -1,82 +0,0 @@ -import 'package:at_common_flutter/services/size_config.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/gradient_outline_input_border.dart'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:flutter/material.dart'; - -class GradientTextFieldWidget extends StatefulWidget { - final String? hintText; - final TextStyle? hintTextStyle; - final TextEditingController? controller; - final Function(String value)? onchange; - final Function(String value)? onSubmitted; - final String? prefixText; - final TextStyle? prefixStyle; - - const GradientTextFieldWidget({ - Key? key, - this.hintText, - this.controller, - this.hintTextStyle, - this.onchange, - this.onSubmitted, - this.prefixText, - this.prefixStyle, - }) : super(key: key); - - @override - State createState() => - _GradientTextFieldWidgetState(); -} - -class _GradientTextFieldWidgetState extends State { - @override - Widget build(BuildContext context) { - return Container( - height: 52, - alignment: Alignment.centerLeft, - child: TextFormField( - controller: widget.controller, - onChanged: (value) { - widget.onchange?.call(value); - }, - onFieldSubmitted: (value) { - widget.onSubmitted?.call(value); - }, - style: TextStyle( - fontSize: 14.toFont, - ), - decoration: InputDecoration( - prefixText: widget.prefixText, - prefixStyle: widget.prefixStyle, - border: GradientOutlineInputBorder( - gradient: LinearGradient( - colors: [ - ColorConstants.orangeColor, - ColorConstants.yellow.withOpacity(0.65), - ], - ), - width: 2, - borderRadius: BorderRadius.circular(10), - ), - focusedBorder: GradientOutlineInputBorder( - gradient: LinearGradient( - colors: [ - ColorConstants.orangeColor, - ColorConstants.yellow.withOpacity(0.65), - ], - ), - width: 2, - borderRadius: BorderRadius.circular(10), - ), - hintText: widget.hintText, - hintStyle: widget.hintTextStyle ?? - TextStyle( - fontSize: 12.toFont, - fontWeight: FontWeight.w400, - color: ColorConstants.grey, - ), - ), - ), - ); - } -} diff --git a/lib/screens/common_widgets/header_widget.dart b/lib/screens/common_widgets/header_widget.dart deleted file mode 100644 index b54f23d1..00000000 --- a/lib/screens/common_widgets/header_widget.dart +++ /dev/null @@ -1,154 +0,0 @@ -import 'package:at_common_flutter/services/size_config.dart'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:atsign_atmosphere_pro/utils/vectors.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; - -class HeaderWidget extends StatefulWidget { - final Function()? onReloadCallback; - final TextEditingController? controller; - final Function(String)? onSearch; - final EdgeInsetsGeometry? margin; - - const HeaderWidget({ - Key? key, - this.onReloadCallback, - this.controller, - this.onSearch, - this.margin, - }) : super(key: key); - - @override - State createState() => _HeaderWidgetState(); -} - -class _HeaderWidgetState extends State { - bool isSearch = false; - - @override - Widget build(BuildContext context) { - return Container( - margin: widget.margin ?? const EdgeInsets.symmetric(horizontal: 28), - padding: const EdgeInsets.fromLTRB(14, 11, 8, 14), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8), - color: ColorConstants.textBoxBg, - ), - child: Row( - children: [ - _buildButton( - title: "Refresh", - icon: AppVectors.icReload, - onTap: widget.onReloadCallback, - ), - const SizedBox(width: 24), - Expanded( - child: _buildSearchWidget(), - ), - ], - ), - ); - } - - Widget _buildButton({ - String? title, - required String icon, - Function()? onTap, - }) { - return InkWell( - onTap: () { - onTap?.call(); - }, - child: Column( - children: [ - Text( - title ?? '', - style: TextStyle( - fontSize: 14.toFont, - fontWeight: FontWeight.w600, - color: ColorConstants.sidebarTextUnselected, - ), - ), - const SizedBox(height: 5), - Container( - height: 48, - width: 48, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - border: Border.all( - color: ColorConstants.grey, - ), - color: Colors.white, - ), - child: Center( - child: SvgPicture.asset( - icon, - color: ColorConstants.grey, - ), - ), - ) - ], - ), - ); - } - - Widget _buildSearchWidget() { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - "Search", - style: TextStyle( - fontSize: 14.toFont, - fontWeight: FontWeight.w600, - color: ColorConstants.sidebarTextUnselected, - ), - ), - const SizedBox(height: 5), - Container( - height: 48, - margin: const EdgeInsets.only(right: 12), - decoration: BoxDecoration( - border: Border.all( - color: ColorConstants.grey, - ), - color: Colors.white, - borderRadius: BorderRadius.circular(10), - ), - padding: const EdgeInsets.only(left: 6, right: 8), - child: Row( - children: [ - Expanded( - child: TextField( - controller: widget.controller, - style: TextStyle( - fontSize: 14.toFont, - ), - decoration: InputDecoration.collapsed( - hintText: 'Search History by atSign', - hintStyle: TextStyle( - color: ColorConstants.grey, - fontSize: 14.toFont, - fontWeight: FontWeight.w500, - fontStyle: FontStyle.italic, - ), - ), - onChanged: widget.onSearch, - ), - ), - SizedBox(width: 4), - SizedBox( - width: 20, - height: 20, - child: SvgPicture.asset( - AppVectors.icSearch, - ), - ), - ], - ), - ), - ], - ); - } -} diff --git a/lib/screens/common_widgets/history_app_bar.dart b/lib/screens/common_widgets/history_app_bar.dart index 4cdfb20d..35d6390d 100644 --- a/lib/screens/common_widgets/history_app_bar.dart +++ b/lib/screens/common_widgets/history_app_bar.dart @@ -16,6 +16,7 @@ import '../../utils/text_styles.dart'; class HistoryAppBar extends StatefulWidget implements PreferredSizeWidget { final String title; + HistoryAppBar({required this.title}); @override @@ -145,10 +146,11 @@ class _HistoryAppBarState extends State { await Permission.storage.request().isGranted, ); } else { - String url = 'shareddocuments://' + + final path = 'shareddocuments://' + BackendService.getInstance().atClientPreference.downloadPath!; - if (await canLaunch(url)) { - await launch(url); + final url = Uri.parse(path); + if (await canLaunchUrl(url)) { + await launchUrl(url); } else { throw 'Could not launch $url'; } diff --git a/lib/screens/common_widgets/labelled_circular_progress.dart b/lib/screens/common_widgets/labelled_circular_progress.dart index de80a6f1..f3bcacbd 100644 --- a/lib/screens/common_widgets/labelled_circular_progress.dart +++ b/lib/screens/common_widgets/labelled_circular_progress.dart @@ -4,8 +4,10 @@ import 'package:flutter/material.dart'; import '../../utils/colors.dart'; class LabelledCircularProgressIndicator extends StatelessWidget { - double? value; + final double? value; + LabelledCircularProgressIndicator({this.value}); + @override Widget build(BuildContext context) { return SizedBox( diff --git a/lib/screens/common_widgets/person_vertical_tile.dart b/lib/screens/common_widgets/person_vertical_tile.dart index 6c0dfa70..f9e91770 100644 --- a/lib/screens/common_widgets/person_vertical_tile.dart +++ b/lib/screens/common_widgets/person_vertical_tile.dart @@ -4,7 +4,6 @@ import 'package:at_contacts_flutter/at_contacts_flutter.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/contact_initial.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/triple_dot_loading.dart'; -import 'package:at_common_flutter/services/size_config.dart'; import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; import 'package:atsign_atmosphere_pro/services/navigation_service.dart'; import 'package:atsign_atmosphere_pro/services/snackbar_service.dart'; @@ -15,13 +14,13 @@ import 'package:provider/provider.dart'; class CustomPersonVerticalTile extends StatefulWidget { final ShareStatus shareStatus; - final bool isFailedAtsignList; + final bool isFailedAtSignList; @override final Key? key; CustomPersonVerticalTile( - {this.key, required this.shareStatus, this.isFailedAtsignList = false}); + {this.key, required this.shareStatus, this.isFailedAtSignList = false}); @override _CustomPersonVerticalTileState createState() => @@ -93,7 +92,7 @@ class _CustomPersonVerticalTileState extends State { initials: widget.shareStatus.atsign ?? ' ', ), ), - widget.isFailedAtsignList + widget.isFailedAtSignList ? Positioned( child: Container( height: 50.toHeight, @@ -164,7 +163,7 @@ class _CustomPersonVerticalTileState extends State { .reSendFileNotification( selectedFileHistory, widget.shareStatus.atsign!); } else { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, 'Please upload file first.', ); diff --git a/lib/screens/common_widgets/provider_callback.dart b/lib/screens/common_widgets/provider_callback.dart index 0455787d..70831efc 100644 --- a/lib/screens/common_widgets/provider_callback.dart +++ b/lib/screens/common_widgets/provider_callback.dart @@ -10,7 +10,7 @@ Future providerCallback(BuildContext context, required Function(T) onSuccess, bool showDialog = true, bool showLoader = true, - Function? onErrorHandeling, + Function? onErrorHandling, Function? onError}) async { final T _provider = Provider.of(context, listen: false); String _taskName = taskName(_provider); @@ -25,7 +25,7 @@ Future providerCallback(BuildContext context, ErrorDialog().show( _provider.error[_taskName].toString(), context: context, - onButtonPressed: onErrorHandeling, + onButtonPressed: onErrorHandling, ); } diff --git a/lib/screens/common_widgets/side_bar_backup_item.dart b/lib/screens/common_widgets/side_bar_backup_item.dart deleted file mode 100644 index 089d48af..00000000 --- a/lib/screens/common_widgets/side_bar_backup_item.dart +++ /dev/null @@ -1,44 +0,0 @@ -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:flutter/material.dart'; -import 'package:at_common_flutter/services/size_config.dart'; - -class SideBarBackupItem extends StatelessWidget { - final String? title; - final Widget? leadingIcon; - final VoidCallback? onPressed; - - SideBarBackupItem({ - Key? key, - this.title, - this.leadingIcon, - this.onPressed, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return InkWell( - onTap: onPressed, - child: Container( - height: 50.toHeight, - child: Row( - children: [ - if (leadingIcon != null) leadingIcon!, - SizedBox(width: 10), - Expanded( - child: Text( - title!, - softWrap: true, - style: TextStyle( - color: ColorConstants.fadedText, - letterSpacing: 0.1, - fontSize: 14.toFont, - fontWeight: FontWeight.normal, - ), - ), - ) - ], - ), - ), - ); - } -} diff --git a/lib/screens/common_widgets/side_bar_list_item.dart b/lib/screens/common_widgets/side_bar_list_item.dart deleted file mode 100644 index 6846334f..00000000 --- a/lib/screens/common_widgets/side_bar_list_item.dart +++ /dev/null @@ -1,106 +0,0 @@ -import 'package:at_common_flutter/services/size_config.dart'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:atsign_atmosphere_pro/view_models/welcome_screen_view_model.dart'; -import 'package:flutter/material.dart'; -import 'package:url_launcher/url_launcher.dart'; - -class SideBarItem extends StatelessWidget { - final String? image; - final String? title; - final String? routeName; - final Map? arguments; - final bool showIconOnly, isDesktop; - final WelcomeScreenProvider _welcomeScreenProvider = WelcomeScreenProvider(); - final Color displayColor; - bool isScale; - final bool showNotificationDot; - SideBarItem( - {Key? key, - this.image, - this.title, - this.routeName, - this.arguments, - this.showIconOnly = false, - this.isScale = false, - this.displayColor = ColorConstants.fadedText, - this.showNotificationDot = false, - this.isDesktop = false}) - : super(key: key); - @override - Widget build(BuildContext context) { - if (SizeConfig().isMobile(context)) { - isScale = false; - } - - return InkWell( - onTap: () { - if (SizeConfig().isMobile(context) || - _welcomeScreenProvider.isExpanded) { - Navigator.pop(context); - } - Navigator.pushNamed(context, routeName!, arguments: arguments ?? {}); - }, - child: Container( - height: 50, - child: Row( - children: [ - Stack( - children: [ - Container( - margin: EdgeInsets.only(right: isDesktop ? 20 : 10), - child: Transform.scale( - scale: isScale ? 1.2 : 1, - child: Image.asset( - image!, - height: SizeConfig().isTablet(context) ? 24 : 22.toHeight, - color: displayColor, - ), - ), - ), - if (showNotificationDot) - Positioned( - top: 0, - right: (isDesktop ? 20 : 10) - 4.toWidth, - child: Container( - width: 8.toWidth, - height: 8.toWidth, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - ), - ) - ], - ), - !showIconOnly - ? Expanded( - child: Text( - title!, - softWrap: true, - style: TextStyle( - color: displayColor, - letterSpacing: 0.1, - fontSize: 13.toFont, - fontWeight: FontWeight.normal, - ), - ), - ) - : SizedBox(), - ], - ), - ), - ); - } - - Future _launchInBrowser(String url) async { - if (await canLaunch(url)) { - await launch( - url, - forceSafariVC: false, - forceWebView: false, - ); - } else { - throw 'Could not launch $url'; - } - } -} diff --git a/lib/screens/common_widgets/triple_dot_loading.dart b/lib/screens/common_widgets/triple_dot_loading.dart index 69a72bf2..117c26da 100644 --- a/lib/screens/common_widgets/triple_dot_loading.dart +++ b/lib/screens/common_widgets/triple_dot_loading.dart @@ -1,7 +1,6 @@ import 'dart:math'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; class TypingIndicator extends StatefulWidget { const TypingIndicator({ diff --git a/lib/screens/common_widgets/website_webview.dart b/lib/screens/common_widgets/website_webview.dart index ace2617c..da822d91 100644 --- a/lib/screens/common_widgets/website_webview.dart +++ b/lib/screens/common_widgets/website_webview.dart @@ -41,7 +41,7 @@ class _WebsiteScreenState extends State { .isInternetAvailable; if (!isConnected) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings.noInternetMsg, bgColor: ColorConstants.redAlert, diff --git a/lib/screens/contact_new_version/add_contact_screen.dart b/lib/screens/contact_new_version/add_contact_screen.dart index 83190647..4ade9d75 100644 --- a/lib/screens/contact_new_version/add_contact_screen.dart +++ b/lib/screens/contact_new_version/add_contact_screen.dart @@ -1,6 +1,5 @@ import 'package:at_common_flutter/services/size_config.dart'; import 'package:at_server_status/at_server_status.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/gradient_text_field_widget.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/input_widget.dart'; import 'package:atsign_atmosphere_pro/utils/colors.dart'; import 'package:atsign_atmosphere_pro/utils/vectors.dart'; diff --git a/lib/screens/contact_new_version/blocked_contact_screen.dart b/lib/screens/contact_new_version/blocked_contact_screen.dart index 891312d5..95dbf539 100644 --- a/lib/screens/contact_new_version/blocked_contact_screen.dart +++ b/lib/screens/contact_new_version/blocked_contact_screen.dart @@ -2,12 +2,9 @@ import 'package:at_common_flutter/services/size_config.dart'; import 'package:at_contact/at_contact.dart'; import 'package:at_contacts_flutter/models/contact_base_model.dart'; import 'package:at_contacts_flutter/services/contact_service.dart'; -import 'package:at_contacts_flutter/utils/text_strings.dart'; -import 'package:at_contacts_flutter/utils/text_styles.dart'; import 'package:at_contacts_group_flutter/widgets/confirmation_dialog.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/search_widget.dart'; import 'package:atsign_atmosphere_pro/screens/contact_new_version/widget/contact_card_widget.dart'; -import 'package:atsign_atmosphere_pro/services/navigation_service.dart'; import 'package:atsign_atmosphere_pro/utils/colors.dart'; import 'package:atsign_atmosphere_pro/utils/images.dart'; import 'package:flutter/material.dart'; diff --git a/lib/screens/contact_new_version/contact_detail_screen.dart b/lib/screens/contact_new_version/contact_detail_screen.dart index 11045006..e3df1f75 100644 --- a/lib/screens/contact_new_version/contact_detail_screen.dart +++ b/lib/screens/contact_new_version/contact_detail_screen.dart @@ -88,11 +88,11 @@ class _ContactDetailScreenState extends State { contact.tags!['nickname'] = nicknameController.text; var res = await _contactService.atContactImpl.add(contact); if (res == true) { - await SnackbarService() - .showSnackbar(context, "Successfully updated nickname"); + await SnackBarService() + .showSnackBar(context, "Successfully updated nickname"); } else { - await SnackbarService() - .showSnackbar(context, "Failed to update nickname"); + await SnackBarService() + .showSnackBar(context, "Failed to update nickname"); } setState(() { isEditNickname = false; diff --git a/lib/screens/contact_new_version/group_contact_screen.dart b/lib/screens/contact_new_version/group_contact_screen.dart deleted file mode 100644 index f2ab23d1..00000000 --- a/lib/screens/contact_new_version/group_contact_screen.dart +++ /dev/null @@ -1,197 +0,0 @@ -import 'package:at_common_flutter/services/size_config.dart'; -import 'package:at_contacts_group_flutter/screens/group_view/group_view.dart'; -import 'package:at_contacts_group_flutter/services/group_service.dart'; -import 'package:atsign_atmosphere_pro/data_models/enums/contact_type.dart'; -import 'package:atsign_atmosphere_pro/screens/contact_new_version/create_group_screen.dart'; -import 'package:atsign_atmosphere_pro/screens/contact_new_version/widget/list_contact_widget.dart'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:atsign_atmosphere_pro/view_models/trusted_sender_view_model.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -class GroupContactScreen extends StatefulWidget { - const GroupContactScreen({Key? key}) : super(key: key); - - @override - State createState() => _GroupContactScreenState(); -} - -class _GroupContactScreenState extends State { - late GroupService groupService; - late TrustedContactProvider trustedProvider; - - @override - void initState() { - groupService = GroupService(); - trustedProvider = context.read(); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: Colors.transparent, - body: Align( - alignment: Alignment.bottomCenter, - child: Container( - height: MediaQuery.of(context).size.height - 120, - width: double.infinity, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: const BorderRadius.only( - topLeft: Radius.circular(20), - topRight: Radius.circular(20), - ), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.25), - offset: const Offset(0, 4), - ) - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(27, 24, 27, 0), - child: Row( - children: [ - Container( - height: 2, - width: 45, - decoration: BoxDecoration( - color: Colors.black, - borderRadius: BorderRadius.circular(20), - ), - ), - const Spacer(), - Align( - alignment: Alignment.topRight, - child: InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Container( - height: 31.toHeight, - alignment: Alignment.topRight, - padding: const EdgeInsets.symmetric( - horizontal: 30, - ), - decoration: BoxDecoration( - border: Border.all( - color: ColorConstants.grey, - ), - borderRadius: BorderRadius.circular(28), - ), - child: Center( - child: Text( - "Close", - style: TextStyle( - fontSize: 17.toFont, - fontWeight: FontWeight.w600, - color: ColorConstants.grey, - ), - ), - ), - ), - ), - ), - ], - ), - ), - const SizedBox(height: 24), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only(left: 27), - child: Text( - "My Groups", - style: TextStyle( - fontSize: 25.toFont, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - ), - const SizedBox(height: 30), - Expanded( - child: ListContactWidget( - contactsType: ListContactType.groups, - isShowAlpha: false, - onTapGroup: (group) async { - WidgetsBinding.instance - .addPostFrameCallback((_) async { - groupService.groupViewSink.add(group); - }); - - await Navigator.push( - context, - MaterialPageRoute( - builder: (context) => GroupView( - group: group, - ), - ), - ); - }, - ), - ), - SafeArea( - child: Padding( - padding: const EdgeInsets.only(bottom: 24, top: 18), - child: InkWell( - onTap: () async { - final result = await Navigator.push( - context, - MaterialPageRoute( - builder: (_) => CreateGroupScreen( - trustContacts: - trustedProvider.trustedContacts, - ), - ), - ); - - if (result == true) { - await groupService.fetchGroupsAndContacts(); - setState(() {}); - } - }, - child: Container( - height: 67.toHeight, - margin: const EdgeInsets.symmetric(horizontal: 27), - width: double.infinity, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8), - gradient: LinearGradient( - colors: [ - const Color(0xfff05e3f), - const Color(0xffeaa743).withOpacity(0.65), - ], - ), - ), - child: Center( - child: Text( - "Create Group", - style: TextStyle( - color: Colors.white, - fontSize: 20.toFont, - fontWeight: FontWeight.bold, - ), - ), - ), - ), - ), - ), - ), - ], - ), - ) - ], - ), - ), - ), - ); - } -} diff --git a/lib/screens/contact_new_version/trusted_contact_screen.dart b/lib/screens/contact_new_version/trusted_contact_screen.dart deleted file mode 100644 index 510ab62a..00000000 --- a/lib/screens/contact_new_version/trusted_contact_screen.dart +++ /dev/null @@ -1,159 +0,0 @@ -// import 'package:at_common_flutter/services/size_config.dart'; -// import 'package:at_contact/at_contact.dart'; -// import 'package:atsign_atmosphere_pro/screens/contact_new_version/contact_detail_screen.dart'; -// import 'package:atsign_atmosphere_pro/screens/contact_new_version/widget/list_contact_widget.dart'; -// import 'package:atsign_atmosphere_pro/utils/colors.dart'; -// import 'package:atsign_atmosphere_pro/view_models/trusted_sender_view_model.dart'; -// import 'package:flutter/material.dart'; -// import 'package:provider/provider.dart'; -// -// class TrustedContactScreen extends StatefulWidget { -// const TrustedContactScreen({Key? key}) : super(key: key); -// -// @override -// State createState() => _TrustedContactScreenState(); -// } -// -// class _TrustedContactScreenState extends State { -// late TrustedContactProvider provider; -// late TextEditingController searchController; -// -// List trustedContacts = []; -// -// @override -// void initState() { -// provider = context.read(); -// searchController = TextEditingController(); -// super.initState(); -// trustedContacts = provider.trustedContacts; -// } -// -// @override -// Widget build(BuildContext context) { -// return Scaffold( -// backgroundColor: Colors.transparent, -// body: Align( -// alignment: Alignment.bottomCenter, -// child: Container( -// margin: EdgeInsets.only(top: 120), -// height: double.infinity, -// width: double.infinity, -// decoration: BoxDecoration( -// color: Colors.white, -// borderRadius: const BorderRadius.only( -// topLeft: Radius.circular(20), -// topRight: Radius.circular(20), -// ), -// boxShadow: [ -// BoxShadow( -// color: Colors.black.withOpacity(0.25), -// offset: const Offset(0, 4), -// ) -// ], -// ), -// child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// mainAxisSize: MainAxisSize.min, -// children: [ -// _buildHeaderWidget(), -// const SizedBox(height: 24), -// Padding( -// padding: const EdgeInsets.symmetric(horizontal: 27), -// child: Text( -// "Trusted Senders", -// style: TextStyle( -// fontSize: 25.toFont, -// fontWeight: FontWeight.bold, -// color: Colors.black, -// ), -// ), -// ), -// const SizedBox(height: 30), -// Expanded( -// child: Consumer( -// builder: (context, myProvider, child) { -// return Scrollbar( -// child: ListContactWidget( -// isOnlyShowContactTrusted: true, -// trustedContacts: trustedContacts, -// onTapContact: (contact) async { -// await showModalBottomSheet( -// context: context, -// isScrollControlled: true, -// useRootNavigator: true, -// backgroundColor: Colors.transparent, -// builder: (BuildContext context) { -// return Padding( -// padding: const EdgeInsets.only(top: 120), -// child: ContactDetailScreen( -// contact: contact, -// onTrustFunc: () { -// Navigator.of(context).pop(); -// }, -// ), -// ); -// }, -// ); -// }, -// ), -// ); -// }, -// ), -// ), -// ], -// ), -// ), -// ), -// ); -// } -// -// Widget _buildHeaderWidget() { -// return Padding( -// padding: const EdgeInsets.fromLTRB(27, 24, 27, 0), -// child: Row( -// children: [ -// Container( -// height: 2, -// width: 45, -// decoration: BoxDecoration( -// color: Colors.black, -// borderRadius: BorderRadius.circular(20), -// ), -// ), -// const Spacer(), -// Align( -// alignment: Alignment.topRight, -// child: InkWell( -// onTap: () { -// Navigator.of(context).pop(); -// }, -// child: Container( -// height: 31.toHeight, -// alignment: Alignment.topRight, -// padding: const EdgeInsets.symmetric( -// horizontal: 30, -// ), -// decoration: BoxDecoration( -// border: Border.all( -// color: ColorConstants.grey, -// ), -// borderRadius: BorderRadius.circular(28), -// ), -// child: Center( -// child: Text( -// "Close", -// style: TextStyle( -// fontSize: 17.toFont, -// fontWeight: FontWeight.w600, -// color: ColorConstants.grey, -// ), -// ), -// ), -// ), -// ), -// ), -// ], -// ), -// ); -// } -// } diff --git a/lib/screens/contact_new_version/widget/contact_attachment_card.dart b/lib/screens/contact_new_version/widget/contact_attachment_card.dart index 77490d9b..07f7d4fd 100644 --- a/lib/screens/contact_new_version/widget/contact_attachment_card.dart +++ b/lib/screens/contact_new_version/widget/contact_attachment_card.dart @@ -4,7 +4,7 @@ import 'dart:io'; import 'package:at_contacts_group_flutter/services/group_service.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; import 'package:atsign_atmosphere_pro/desktop_routes/desktop_routes.dart'; -import 'package:atsign_atmosphere_pro/screens/my_files/widgets/recents.dart'; +import 'package:atsign_atmosphere_pro/screens/my_files/widgets/recent.dart'; import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; import 'package:atsign_atmosphere_pro/services/navigation_service.dart'; import 'package:atsign_atmosphere_pro/services/snackbar_service.dart'; @@ -373,7 +373,7 @@ class _ContactAttachmentCardState extends State .isInternetAvailable; if (!isConnected) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings.noInternetMsg, bgColor: ColorConstants.redAlert, @@ -403,14 +403,14 @@ class _ContactAttachmentCardState extends State isDownloaded = true; }); - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, - TextStrings().fileDownloadd, + TextStrings().fileDownload, bgColor: ColorConstants.successGreen, ); } } else if (result is bool && !result) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings().downloadFailed, bgColor: ColorConstants.redAlert, diff --git a/lib/screens/contact_new_version/widget/empty_contact_widget.dart b/lib/screens/contact_new_version/widget/empty_contact_widget.dart index 51e53325..ff582da3 100644 --- a/lib/screens/contact_new_version/widget/empty_contact_widget.dart +++ b/lib/screens/contact_new_version/widget/empty_contact_widget.dart @@ -1,5 +1,4 @@ import 'package:atsign_atmosphere_pro/data_models/enums/contact_type.dart'; -import 'package:atsign_atmosphere_pro/screens/contact_new_version/create_group_screen.dart'; import 'package:atsign_atmosphere_pro/utils/colors.dart'; import 'package:atsign_atmosphere_pro/utils/images.dart'; import 'package:atsign_atmosphere_pro/utils/vectors.dart'; diff --git a/lib/screens/history/history_screen.dart b/lib/screens/history/history_screen.dart deleted file mode 100644 index 93fb4a9a..00000000 --- a/lib/screens/history/history_screen.dart +++ /dev/null @@ -1,335 +0,0 @@ -import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_button.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/provider_handler.dart'; -import 'package:atsign_atmosphere_pro/screens/history/widgets/received_file_list_tile.dart'; -import 'package:atsign_atmosphere_pro/screens/history/widgets/sent_file_list_tile.dart'; -import 'package:at_common_flutter/services/size_config.dart'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; -import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; -import 'package:atsign_atmosphere_pro/view_models/base_model.dart'; -import 'package:atsign_atmosphere_pro/view_models/history_provider.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import '../common_widgets/history_app_bar.dart'; - -class HistoryScreen extends StatefulWidget { - final int tabIndex; - HistoryScreen({this.tabIndex = 0}); - @override - _HistoryScreenState createState() => _HistoryScreenState(); -} - -class _HistoryScreenState extends State - with SingleTickerProviderStateMixin { - TabController? _controller; - bool isOpen = false; - HistoryProvider? historyProvider; - - @override - void didChangeDependencies() async { - if (historyProvider == null) { - _controller = - TabController(length: 2, vsync: this, initialIndex: widget.tabIndex); - historyProvider = Provider.of(context); - } - - super.didChangeDependencies(); - } - - @override - dispose() { - // closing all open received files widgets widgets. - historyProvider!.receivedHistoryLogs.forEach((element) { - element.isWidgetOpen = false; - }); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: ColorConstants.scaffoldColor, - appBar: HistoryAppBar( - title: TextStrings().history, - ), - body: SingleChildScrollView( - child: Container( - height: SizeConfig().screenHeight - 120.toHeight, - child: Column( - children: [ - Container( - height: 40, - child: TabBar( - labelColor: ColorConstants.fontPrimary, - indicatorWeight: 5.toHeight, - indicatorColor: Colors.black, - indicatorSize: TabBarIndicatorSize.tab, - labelStyle: CustomTextStyles.primaryBold15, - unselectedLabelStyle: CustomTextStyles.secondaryRegular16, - controller: _controller, - tabs: [ - Text( - TextStrings().sent, - style: TextStyle( - letterSpacing: 0.1, - fontWeight: FontWeight.normal, - ), - ), - Text( - TextStrings().received, - style: TextStyle( - letterSpacing: 0.1, - fontWeight: FontWeight.normal, - ), - ) - ], - ), - ), - Expanded( - child: TabBarView( - controller: _controller, - children: [ - RefreshIndicator( - color: ColorConstants.orange, - onRefresh: () async { - if (historyProvider! - .status[historyProvider!.PERIODIC_REFRESH] != - Status.Loading) { - await historyProvider!.getSentHistory(); - } - }, - child: ProviderHandler( - functionName: historyProvider!.SENT_HISTORY, - showError: false, - successBuilder: (provider) { - if ((provider.sentHistory.isEmpty)) { - return ListView.separated( - padding: EdgeInsets.only(bottom: 170.toHeight), - physics: AlwaysScrollableScrollPhysics(), - separatorBuilder: (context, index) => - Divider(indent: 16.toWidth), - itemCount: 1, - itemBuilder: (context, index) => Padding( - padding: const EdgeInsets.all(8.0), - child: SizedBox( - height: - SizeConfig().screenHeight - 120.toHeight, - child: Center( - child: Text( - 'No files sent', - style: TextStyle( - fontSize: 16.toFont, - fontWeight: FontWeight.normal, - ), - ), - ), - ), - ), - ); - } else { - List filteredSentHistory = []; - provider.sentHistory.forEach((element) { - if (element.sharedWith!.any( - (ShareStatus sharedStatus) => sharedStatus - .atsign! - .contains(provider.getSearchText), - ) || - (element.groupName != null && - element.groupName!.toLowerCase().contains( - provider.getSearchText - .toLowerCase()))) { - filteredSentHistory.add(element); - } - }); - - if (filteredSentHistory.isNotEmpty) { - return getSentList(filteredSentHistory); - } else { - return Center( - child: Text('No results found'), - ); - } - } - }, - errorBuilder: (provider) => ListView.separated( - padding: EdgeInsets.only(bottom: 170.toHeight), - physics: AlwaysScrollableScrollPhysics(), - separatorBuilder: (context, index) => - Divider(indent: 16.toWidth), - itemCount: 1, - itemBuilder: (context, index) => Padding( - padding: const EdgeInsets.all(8.0), - child: SizedBox( - height: SizeConfig().screenHeight - 120.toHeight, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - 'Some error occured', - style: TextStyle( - fontSize: 16.toFont, - fontWeight: FontWeight.normal, - ), - ), - SizedBox(height: 10.toHeight), - CustomButton( - isOrange: true, - buttonText: TextStrings().retry, - height: 40.toHeight, - width: 115.toWidth, - onPressed: () { - historyProvider!.getSentHistory(); - }, - ) - ], - ), - ), - ), - ), - load: (provider) async {}, - ), - ), - RefreshIndicator( - color: ColorConstants.orange, - onRefresh: () async { - if (historyProvider! - .status[historyProvider!.PERIODIC_REFRESH] != - Status.Loading) { - await historyProvider!.getReceivedHistory(); - } - }, - child: ProviderHandler( - functionName: historyProvider!.RECEIVED_HISTORY, - load: (provider) async {}, - showError: false, - successBuilder: (provider) { - if ((provider.receivedHistoryLogs.isEmpty)) { - return ListView.separated( - padding: EdgeInsets.only(bottom: 170.toHeight), - physics: AlwaysScrollableScrollPhysics(), - separatorBuilder: (context, index) => - Divider(indent: 16.toWidth), - itemCount: 1, - itemBuilder: (context, index) => Padding( - padding: const EdgeInsets.all(8.0), - child: SizedBox( - height: SizeConfig().screenHeight - - 120.toHeight, - child: Center( - child: Text( - 'No files received', - style: TextStyle( - fontSize: 16.toFont, - fontWeight: FontWeight.normal, - ), - ), - ), - ), - ), - ); - } else { - List filteredReceivedList = []; - provider.receivedHistoryLogs.forEach((element) { - if (element.sender!.contains( - provider.getSearchText, - )) { - filteredReceivedList.add(element); - } - }); - - if (filteredReceivedList.isNotEmpty) { - return getReceivedList(filteredReceivedList); - } else { - return Center( - child: Text('No results found'), - ); - } - } - }, - errorBuilder: (provider) => ListView.separated( - padding: EdgeInsets.only(bottom: 170.toHeight), - physics: AlwaysScrollableScrollPhysics(), - separatorBuilder: (context, index) => - Divider(indent: 16.toWidth), - itemCount: 1, - itemBuilder: (context, index) => Padding( - padding: const EdgeInsets.all(8.0), - child: SizedBox( - height: SizeConfig().screenHeight - - 120.toHeight, - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Text( - 'Some error occured', - style: TextStyle( - fontSize: 16.toFont, - fontWeight: FontWeight.normal, - ), - ), - SizedBox(height: 10.toHeight), - CustomButton( - isOrange: true, - buttonText: TextStrings().retry, - height: 40.toHeight, - width: 115.toWidth, - onPressed: () { - historyProvider! - .getReceivedHistory(); - }, - ) - ], - ), - ), - ), - )), - ), - ], - ), - ) - ], - ), - ), - ), - ); - } - - Widget getSentList(List filteredSentHistory) { - return ListView.separated( - padding: EdgeInsets.only(bottom: 170.toHeight), - physics: AlwaysScrollableScrollPhysics(), - separatorBuilder: (context, index) { - return Divider( - indent: 16.toWidth, - ); - }, - itemCount: filteredSentHistory.length, - itemBuilder: (context, index) { - return SentFilesListTile( - sentHistory: filteredSentHistory[index], - key: Key(filteredSentHistory[index].fileDetails!.key), - ); - }, - ); - } - - Widget getReceivedList(List filteredReceivedList) { - return ListView.separated( - padding: EdgeInsets.only(bottom: 170.toHeight), - physics: AlwaysScrollableScrollPhysics(), - separatorBuilder: (context, index) => Divider(indent: 16.toWidth), - itemCount: filteredReceivedList.length, - itemBuilder: (context, index) => Padding( - padding: const EdgeInsets.all(8.0), - child: ReceivedFilesListTile( - key: Key(filteredReceivedList[index].key), - receivedHistory: filteredReceivedList[index], - isWidgetOpen: filteredReceivedList[index].isWidgetOpen, - ), - ), - ); - } -} diff --git a/lib/screens/history/transfer_history_screen.dart b/lib/screens/history/transfer_history_screen.dart index ec392814..ac44c2a6 100644 --- a/lib/screens/history/transfer_history_screen.dart +++ b/lib/screens/history/transfer_history_screen.dart @@ -454,7 +454,7 @@ class _TransferHistoryScreenState extends State } await Provider.of(context, listen: false) - .reuploadFiles([fileData], 0, sentHistory); + .reUploadFiles([fileData], 0, sentHistory); }, ), ); diff --git a/lib/screens/history/widgets/file_recipients.dart b/lib/screens/history/widgets/file_recipients.dart index cb0a4215..f81b25f8 100644 --- a/lib/screens/history/widgets/file_recipients.dart +++ b/lib/screens/history/widgets/file_recipients.dart @@ -10,11 +10,11 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class FileRecipients extends StatefulWidget { - final List? filesharedWith; - FileRecipientSection? fileRecipientSection; + final List? fileSharedWith; + final FileRecipientSection? fileRecipientSection; FileRecipients( - this.filesharedWith, { + this.fileSharedWith, { this.fileRecipientSection, Key? key, }); @@ -32,7 +32,7 @@ class _FileRecipientsState extends State { @override void initState() { - sortAtsigns(); + sortAtSigns(); if (widget.fileRecipientSection == FileRecipientSection.DOWNLOADED) { color = ColorConstants.blueText.withOpacity(0.5); @@ -50,12 +50,12 @@ class _FileRecipientsState extends State { super.initState(); } - sortAtsigns() { + sortAtSigns() { deliveredToList = []; downloadedByList = []; filedInDeliveringList = []; - widget.filesharedWith!.forEach((element) { + widget.fileSharedWith!.forEach((element) { if (element.isNotificationSend!) { deliveredToList.add(element); } else { @@ -75,7 +75,7 @@ class _FileRecipientsState extends State { padding: EdgeInsets.symmetric( horizontal: 20.toHeight, vertical: 25.toHeight), child: Consumer(builder: (context, provider, _) { - sortAtsigns(); + sortAtSigns(); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -218,7 +218,7 @@ class _FileRecipientsState extends State { child: CustomPersonVerticalTile( key: UniqueKey(), shareStatus: filedInDeliveringList[index], - isFailedAtsignList: true, + isFailedAtSignList: true, ), ); }), diff --git a/lib/screens/history/widgets/filter_item_widget.dart b/lib/screens/history/widgets/filter_item_widget.dart deleted file mode 100644 index c120ad26..00000000 --- a/lib/screens/history/widgets/filter_item_widget.dart +++ /dev/null @@ -1,49 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; - -class FilterItemWidget extends StatelessWidget { - final Color backgroundColor; - final Color borderColor; - final String prefixIcon; - final String title; - - const FilterItemWidget({ - Key? key, - required this.backgroundColor, - required this.borderColor, - required this.prefixIcon, - required this.title, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return Container( - height: 30, - padding: const EdgeInsets.fromLTRB(12, 7, 8, 8), - margin: EdgeInsets.symmetric(vertical: 12.5, horizontal: 16), - decoration: BoxDecoration( - color: backgroundColor, - border: Border.all( - color: borderColor, - ), - borderRadius: BorderRadius.circular(14), - ), - child: Row( - children: [ - SvgPicture.asset(prefixIcon), - Expanded( - child: Center( - child: Text( - title, - style: TextStyle( - fontSize: 13, - fontWeight: FontWeight.w500, - ), - ), - ), - ), - ], - ), - ); - } -} diff --git a/lib/screens/history/widgets/history_card_item.dart b/lib/screens/history/widgets/history_card_item.dart index 8c0d9e5b..460c4268 100644 --- a/lib/screens/history/widgets/history_card_item.dart +++ b/lib/screens/history/widgets/history_card_item.dart @@ -184,7 +184,7 @@ class _HistoryCardItemState extends State { widget.fileHistory.fileDetails!.files!.forEach((e) { File(getFilePath(e.name ?? '')).deleteSync(); }); - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( context, "Successfully deleted the file", bgColor: ColorConstants.successColor, @@ -232,7 +232,7 @@ class _HistoryCardItemState extends State { .isInternetAvailable; if (!isConnected) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings.noInternetMsg, bgColor: ColorConstants.redAlert, @@ -267,7 +267,7 @@ class _HistoryCardItemState extends State { listen: false) .sendFileDownloadAcknowledgement(file); } else if (result is bool && !result) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings().downloadFailed, bgColor: ColorConstants.redAlert, @@ -288,9 +288,9 @@ class _HistoryCardItemState extends State { }); Provider.of(context, listen: false).notify(); isFilesPresent(widget.fileHistory.fileDetails!); - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, - TextStrings().fileDownloadd, + TextStrings().fileDownload, bgColor: ColorConstants.successGreen, ); } diff --git a/lib/screens/history/widgets/history_file_item.dart b/lib/screens/history/widgets/history_file_item.dart index 64700f48..98d51323 100644 --- a/lib/screens/history/widgets/history_file_item.dart +++ b/lib/screens/history/widgets/history_file_item.dart @@ -6,7 +6,7 @@ import 'package:at_contacts_group_flutter/services/group_service.dart'; import 'package:atsign_atmosphere_pro/data_models/file_modal.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_button.dart'; -import 'package:atsign_atmosphere_pro/screens/my_files/widgets/recents.dart'; +import 'package:atsign_atmosphere_pro/screens/my_files/widgets/recent.dart'; import 'package:atsign_atmosphere_pro/services/backend_service.dart'; import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; import 'package:atsign_atmosphere_pro/services/navigation_service.dart'; @@ -621,7 +621,7 @@ class _HistoryFileItemState extends State { CommonUtilityFunctions().showConfirmationDialog( () { File(path).deleteSync(); - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( context, "Successfully deleted the file", bgColor: ColorConstants.successColor, @@ -668,7 +668,7 @@ class _HistoryFileItemState extends State { .isInternetAvailable; if (!isConnected) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings.noInternetMsg, bgColor: ColorConstants.redAlert, @@ -711,9 +711,9 @@ class _HistoryFileItemState extends State { listen: false) .saveNewDataInMyFiles(widget.fileTransfer!); Provider.of(context, listen: false).notify(); - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, - TextStrings().fileDownloadd, + TextStrings().fileDownload, bgColor: ColorConstants.successGreen, ); // send download acknowledgement @@ -721,7 +721,7 @@ class _HistoryFileItemState extends State { listen: false) .sendFileDownloadAcknowledgement(widget.fileTransfer!); } else if (result is bool && !result) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings().downloadFailed, bgColor: ColorConstants.redAlert, diff --git a/lib/screens/history/widgets/history_status_badges.dart b/lib/screens/history/widgets/history_status_badges.dart index d6e50d12..0f57d9c6 100644 --- a/lib/screens/history/widgets/history_status_badges.dart +++ b/lib/screens/history/widgets/history_status_badges.dart @@ -340,7 +340,7 @@ class _HistoryStatusBadgesState extends State { .isInternetAvailable; if (!isConnected) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings.noInternetMsg, bgColor: ColorConstants.redAlert, @@ -375,7 +375,7 @@ class _HistoryStatusBadgesState extends State { listen: false) .sendFileDownloadAcknowledgement(file); } else if (result is bool && !result) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings().downloadFailed, bgColor: ColorConstants.redAlert, @@ -396,9 +396,9 @@ class _HistoryStatusBadgesState extends State { }); Provider.of(context, listen: false).notify(); isFilesPresent(widget.fileHistory.fileDetails!); - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, - TextStrings().fileDownloadd, + TextStrings().fileDownload, bgColor: ColorConstants.successGreen, ); } diff --git a/lib/screens/history/widgets/received_file_list_tile.dart b/lib/screens/history/widgets/received_file_list_tile.dart index 7bd92767..2e309bf4 100644 --- a/lib/screens/history/widgets/received_file_list_tile.dart +++ b/lib/screens/history/widgets/received_file_list_tile.dart @@ -743,7 +743,7 @@ class _ReceivedFilesListTileState extends State { .isInternetAvailable; if (!isConnected) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings.noInternetMsg, bgColor: ColorConstants.redAlert, @@ -786,9 +786,9 @@ class _ReceivedFilesListTileState extends State { listen: false) .saveNewDataInMyFiles(widget.receivedHistory!); - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, - TextStrings().fileDownloadd, + TextStrings().fileDownload, bgColor: ColorConstants.successGreen, ); // send download acknowledgement @@ -796,7 +796,7 @@ class _ReceivedFilesListTileState extends State { listen: false) .sendFileDownloadAcknowledgement(receivedHistory!); } else if (result is bool && !result) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings().downloadFailed, bgColor: ColorConstants.redAlert, @@ -995,13 +995,13 @@ class _ReceivedFilesListTileState extends State { .deleteReceivedItem(widget.receivedHistory!); if (res) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, 'Removed from received items list', bgColor: ColorConstants.successGreen); await deleteFileWhenRecevedItemRemoved(); } else { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, 'Failed', bgColor: ColorConstants.redAlert); } @@ -1035,7 +1035,7 @@ class _ReceivedFilesListTileState extends State { await Provider.of( NavService.navKey.currentContext!, listen: false) - .deletMyFileRecord(widget.receivedHistory!.key); + .deleteMyFileRecord(widget.receivedHistory!.key); })); }); } diff --git a/lib/screens/history/widgets/sent_item_file_view.dart b/lib/screens/history/widgets/sent_item_file_view.dart index 5bb8a7c5..e28cca20 100644 --- a/lib/screens/history/widgets/sent_item_file_view.dart +++ b/lib/screens/history/widgets/sent_item_file_view.dart @@ -310,7 +310,7 @@ class _SentItemFileViewState extends State { () async { await Provider.of(context, listen: false) - .reuploadFiles(filesList!, index, widget.sentHistory); + .reUploadFiles(filesList!, index, widget.sentHistory); })); }); } else { diff --git a/lib/screens/home/home.dart b/lib/screens/home/home.dart index 346ffec3..6d0b3ef4 100644 --- a/lib/screens/home/home.dart +++ b/lib/screens/home/home.dart @@ -71,24 +71,24 @@ class _HomeState extends State { MixedConstants.ApplicationDocumentsDirectory = _dir.path; } - var atClientPrefernce; + var atClientPreference; + void _checkToOnboard() async { setState(() { authenticating = true; }); - String? currentatSign = await _backendService.getAtSign(); + String? currentAtSign = await _backendService.getAtSign(); await _backendService .getAtClientPreference() - .then((value) => atClientPrefernce = value) - .catchError((e) => print(e)); + .then((value) => atClientPreference = value); - if (currentatSign == null || currentatSign == '') { + if (currentAtSign == null || currentAtSign == '') { setState(() { authenticating = false; }); } else { await Provider.of(context, listen: false) - .onboardingLoad(atSign: currentatSign); + .onboardingLoad(atSign: currentAtSign); } } @@ -112,9 +112,7 @@ class _HomeState extends State { @override Widget build(BuildContext context) { SizeConfig().init(context); - // var cardHeight = SizeConfig().screenHeight / 0.3; - // var paddingSmall = SizeConfig().screenHeight / 0.1; - // var paddingLarge = SizeConfig().screenHeight / 0.2; + return Scaffold( body: SafeArea( child: Column( @@ -260,7 +258,7 @@ class _HomeState extends State { child: InkWell( onTap: () async { await CommonUtilityFunctions() - .showResetAtsignDialog(); + .showResetAtSignDialog(); }, child: Container( width: double.infinity, diff --git a/lib/screens/my_files/files_detail_screen.dart b/lib/screens/my_files/files_detail_screen.dart index e52406dd..82d461eb 100644 --- a/lib/screens/my_files/files_detail_screen.dart +++ b/lib/screens/my_files/files_detail_screen.dart @@ -213,7 +213,7 @@ class _FilesDetailScreenState extends State { decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), ), - child: CommonUtilityFunctions().interactableThumbnail( + child: CommonUtilityFunctions().interactThumbnail( files[index].fileName?.split(".").last ?? "", BackendService.getInstance().downloadDirectory!.path + Platform.pathSeparator + @@ -359,62 +359,58 @@ class _FilesDetailScreenState extends State { // ), // ), - , - child: InkWell( - onTap: () async { - await FileUtils.openFile( - path: BackendService.getInstance().downloadDirectory!.path + - Platform.pathSeparator + - files[index].fileName!, - extension: files[index].fileName?.split(".").last ?? "", - onDelete: () async { - await FileUtils.deleteFile( - BackendService.getInstance().downloadDirectory!.path + - Platform.pathSeparator + - files[index].fileName!); - if (mounted) { - Navigator.pop(context); - } - setState(() {}); - }, - fileDetail: files[index], - ); - }, - child: Container( - key: UniqueKey(), - padding: EdgeInsets.all(16), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - ), - child: Row( - children: [ - Container( - height: 49, - width: 38, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - ), - child: Center( - child: CommonUtilityFunctions().interactableThumbnail( - files[index].fileName?.split(".").last ?? "", - BackendService.getInstance() - .downloadDirectory! - .path + - Platform.pathSeparator + - files[index].fileName!, - files[index], () async { - await FileUtils.deleteFile( - BackendService.getInstance() - .downloadDirectory! - .path + - Platform.pathSeparator + - files[index].fileName!, - fileTransferId: files[index].fileTransferId, - onComplete: () { - files.removeAt(index); - }, - ); + , + child: InkWell( + onTap: () async { + await FileUtils.openFile( + path: BackendService.getInstance().downloadDirectory!.path + + Platform.pathSeparator + + files[index].fileName!, + extension: files[index].fileName?.split(".").last ?? "", + onDelete: () async { + await FileUtils.deleteFile( + BackendService.getInstance().downloadDirectory!.path + + Platform.pathSeparator + + files[index].fileName!); + if (mounted) { + Navigator.pop(context); + } + setState(() {}); + }, + fileDetail: files[index], + ); + }, + child: Container( + key: UniqueKey(), + padding: EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + ), + child: Row( + children: [ + Container( + height: 49, + width: 38, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + ), + child: Center( + child: CommonUtilityFunctions().interactThumbnail( + files[index].fileName?.split(".").last ?? "", + BackendService.getInstance().downloadDirectory!.path + + Platform.pathSeparator + + files[index].fileName!, + files[index], () async { + await FileUtils.deleteFile( + BackendService.getInstance().downloadDirectory!.path + + Platform.pathSeparator + + files[index].fileName!, + fileTransferId: files[index].fileTransferId, + onComplete: () { + files.removeAt(index); + }, + ); if (mounted) { Navigator.pop(context); diff --git a/lib/screens/my_files/image_view_widget.dart b/lib/screens/my_files/image_view_widget.dart deleted file mode 100644 index eb49986c..00000000 --- a/lib/screens/my_files/image_view_widget.dart +++ /dev/null @@ -1,203 +0,0 @@ -import 'dart:io'; - -import 'package:atsign_atmosphere_pro/data_models/file_modal.dart'; -import 'package:atsign_atmosphere_pro/utils/app_utils.dart'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:atsign_atmosphere_pro/utils/vectors.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:intl/intl.dart'; - -class ImageViewWidget extends StatelessWidget { - final FilesDetail image; - - const ImageViewWidget({ - Key? key, - required this.image, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - final date = DateTime.parse(image.date ?? "").toLocal(); - final shortDate = DateFormat('dd/MM/yy').format(date); - final time = DateFormat('HH:mm').format(date); - return Scaffold( - backgroundColor: Colors.transparent, - body: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.only( - left: 31, - top: 16, - bottom: 16, - ), - child: InkWell( - borderRadius: BorderRadius.circular(20), - onTap: () { - Navigator.of(context).pop(); - }, - child: Icon( - Icons.close, - color: Colors.white, - size: 33, - ), - ), - ), - 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(image.filePath ?? ''), - ), - fit: BoxFit.cover, - ), - ), - ), - ), - SizedBox(height: 24), - Align( - alignment: Alignment.center, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - SizedBox( - width: 48, - height: 48, - child: SvgPicture.asset( - AppVectors.icDownloadFile, - ), - ), - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 12, - ), - child: SizedBox( - width: 48, - height: 48, - child: SvgPicture.asset( - AppVectors.icSendFile, - ), - ), - ), - SizedBox( - width: 48, - height: 48, - child: SvgPicture.asset( - AppVectors.icDeleteFile, - ), - ), - ], - ), - ), - SizedBox(height: 32), - Container( - height: 175, - width: double.infinity, - padding: EdgeInsets.fromLTRB(24, 16, 18, 16), - margin: EdgeInsets.symmetric(horizontal: 33), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(5), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Align( - alignment: Alignment.topRight, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - "$shortDate", - style: TextStyle( - fontSize: 10, - color: ColorConstants.oldSliver, - ), - ), - Container( - width: 1, - height: 8, - color: Color(0xFFD7D7D7), - margin: EdgeInsets.symmetric( - horizontal: 3, - ), - ), - Text( - "$time", - style: TextStyle( - fontSize: 10, - color: ColorConstants.oldSliver, - ), - ), - ], - ), - ), - Text( - "${image.fileName}", - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Colors.black, - ), - ), - SizedBox(height: 5), - Text( - AppUtils.getFileSizeString( - bytes: image.size ?? 0, - decimals: 2, - ), - style: TextStyle( - fontSize: 10, - color: ColorConstants.oldSliver, - ), - ), - SizedBox(height: 10), - Text( - "${(image.contactName ?? '').split("@")[1]}", - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.w600, - fontSize: 12, - ), - ), - SizedBox(height: 1), - Text( - "${image.contactName}", - style: TextStyle( - color: Colors.black, - fontSize: 10, - ), - ), - SizedBox(height: 13), - Text( - "Message:", - style: TextStyle( - color: ColorConstants.textLightGray, - fontWeight: FontWeight.w500, - fontSize: 10, - ), - ), - SizedBox(height: 5), - Text( - "${image.date}", - style: TextStyle( - color: ColorConstants.textLightGray, - fontWeight: FontWeight.w500, - fontSize: 10, - ), - ), - ], - ), - ), - SizedBox(height: 16), - ], - ), - ); - } -} diff --git a/lib/screens/my_files/my_files.dart b/lib/screens/my_files/my_files.dart deleted file mode 100644 index 7455c1fb..00000000 --- a/lib/screens/my_files/my_files.dart +++ /dev/null @@ -1,192 +0,0 @@ -import 'package:atsign_atmosphere_pro/screens/common_widgets/provider_callback.dart'; -import 'package:atsign_atmosphere_pro/screens/my_files/widgets/photos.dart'; -import 'package:atsign_atmosphere_pro/screens/my_files/widgets/videos.dart'; -import 'package:atsign_atmosphere_pro/screens/my_files/widgets/audios.dart'; -import 'package:atsign_atmosphere_pro/screens/my_files/widgets/apk.dart'; -import 'package:atsign_atmosphere_pro/screens/my_files/widgets/documents.dart'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; -import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; -import 'package:at_common_flutter/services/size_config.dart'; -import 'package:at_common_flutter/widgets/custom_app_bar.dart'; -import 'package:atsign_atmosphere_pro/view_models/my_files_provider.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -class MyFiles extends StatefulWidget { - @override - _MyFilesState createState() => _MyFilesState(); -} - -class _MyFilesState extends State with TickerProviderStateMixin { - TabController? _controller; - bool isOpen = false; - List tabs = []; - List tabNames = []; - - bool isLoading = false; - Type runtimeType = Videos; - @override - void initState() { - getTabsInformation(); - super.initState(); - } - - getTabsInformation() async { - tabs = []; - tabNames = []; - tabs = Provider.of(context, listen: false).tabs; - tabNames = Provider.of(context, listen: false).tabNames; - _controller = - TabController(length: tabs.length, vsync: this, initialIndex: 0); - } - - @override - Widget build(BuildContext context) { - getTabsInformation(); - SizeConfig().init(context); - return Scaffold( - appBar: CustomAppBar( - showBackButton: true, - showTrailingIcon: true, - showTitle: true, - showLeadingIcon: true, - titleText: TextStrings().myFiles, - trailingIcon: (tabs.length > 1 && - (runtimeType == Videos || - runtimeType == Documents || - runtimeType == APK || - runtimeType == Audios)) - ? PopupMenuButton( - icon: Icon(Icons.more_vert), - onSelected: (dynamic s) { - switch (s) { - case TextStrings.SORT_NAME: - providerCallback(context, - task: (provider) { - if (runtimeType == Photos) { - provider.sortByName(provider.receivedPhotos); - } else if (runtimeType == Videos) { - provider.sortByName(provider.receivedVideos); - } else if (runtimeType == APK) { - provider.sortByName(provider.receivedApk); - } else if (runtimeType == Audios) { - provider.sortByName(provider.receivedAudio); - } else if (runtimeType == Documents) { - provider.sortByName(provider.receivedDocument); - } - }, - taskName: (provider) => provider.SORT_LIST, - onSuccess: (provider) {}); - break; - case TextStrings.SORT_SIZE: - providerCallback(context, - task: (provider) { - if (runtimeType == Photos) { - provider.sortBySize(provider.receivedPhotos); - } else if (runtimeType == Videos) { - provider.sortBySize(provider.receivedVideos); - } else if (runtimeType == APK) { - provider.sortBySize(provider.receivedApk); - } else if (runtimeType == Audios) { - provider.sortBySize(provider.receivedAudio); - } else if (runtimeType == Documents) { - provider.sortBySize(provider.receivedDocument); - } - }, - taskName: (provider) => provider.SORT_LIST, - onSuccess: (provider) {}); - break; - case TextStrings.SORT_DATE: - providerCallback(context, - task: (provider) { - if (runtimeType == Photos) { - provider.sortByDate(provider.receivedPhotos); - } else if (runtimeType == Videos) { - provider.sortByDate(provider.receivedVideos); - } else if (runtimeType == APK) { - provider.sortByDate(provider.receivedApk); - } else if (runtimeType == Audios) { - provider.sortByDate(provider.receivedAudio); - } else if (runtimeType == Documents) { - provider.sortByDate(provider.receivedDocument); - } - }, - taskName: (provider) => provider.SORT_LIST, - onSuccess: (provider) {}); - break; - default: - } - }, - itemBuilder: (context) { - return { - TextStrings.SORT_NAME, - TextStrings.SORT_SIZE, - TextStrings.SORT_DATE - }.map((String choice) { - return PopupMenuItem( - value: choice, - child: Text(choice), - ); - }).toList(); - }) - : Container(), - onTrailingIconPressed: () { - setState(() { - isOpen != isOpen; - }); - }, - ), - body: SingleChildScrollView( - child: (isLoading) - ? Center( - child: CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation( - ColorConstants.orange, - ), - )) - : Consumer( - builder: (BuildContext _context, _provider, _) { - if (_provider.tabs.length != tabs.length) { - getTabsInformation(); - } - - return Container( - // reducing size by 120 , so that last list item will be shown - height: SizeConfig().screenHeight - 120.toHeight, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - height: 40, - child: TabBar( - onTap: (index) async {}, - isScrollable: true, - labelColor: ColorConstants.fontPrimary, - indicatorWeight: 5.toHeight, - indicatorColor: Colors.black, - indicatorSize: TabBarIndicatorSize.tab, - labelStyle: CustomTextStyles.primaryBold14, - unselectedLabelStyle: - CustomTextStyles.secondaryRegular14, - controller: _controller, - tabs: List.generate(_provider.tabNames.length, - (index) => Text(_provider.tabNames[index])), - ), - ), - Expanded( - child: TabBarView( - controller: _controller, - physics: AlwaysScrollableScrollPhysics(), - children: _provider.tabs, - ), - ) - ], - ), - ); - }, - ), - ), - ); - } -} diff --git a/lib/screens/my_files/my_files_screen.dart b/lib/screens/my_files/my_files_screen.dart index 6cdf9ee3..fd3092fc 100644 --- a/lib/screens/my_files/my_files_screen.dart +++ b/lib/screens/my_files/my_files_screen.dart @@ -9,7 +9,7 @@ import 'package:atsign_atmosphere_pro/screens/common_widgets/skeleton_loading_wi import 'package:atsign_atmosphere_pro/screens/history/widgets/edit_bottomsheet.dart'; import 'package:atsign_atmosphere_pro/screens/my_files/files_detail_screen.dart'; import 'package:atsign_atmosphere_pro/screens/my_files/widgets/downloads_folders.dart'; -import 'package:atsign_atmosphere_pro/screens/my_files/widgets/recents.dart'; +import 'package:atsign_atmosphere_pro/screens/my_files/widgets/recent.dart'; import 'package:atsign_atmosphere_pro/screens/my_files/widgets/videos.dart'; import 'package:at_common_flutter/services/size_config.dart'; import 'package:atsign_atmosphere_pro/services/backend_service.dart'; diff --git a/lib/screens/my_files/widgets/downloads_folders.dart b/lib/screens/my_files/widgets/downloads_folders.dart index 9edac1eb..974d757e 100644 --- a/lib/screens/my_files/widgets/downloads_folders.dart +++ b/lib/screens/my_files/widgets/downloads_folders.dart @@ -23,10 +23,11 @@ Future openDownloadsFolder(BuildContext context) async { await Permission.storage.request().isGranted, ); } else { - String url = 'shareddocuments://' + + final path = 'shareddocuments://' + BackendService.getInstance().atClientPreference.downloadPath!; - if (await canLaunch(url)) { - await launch(url); + final url = Uri.parse(path); + if (await canLaunchUrl(url)) { + await launchUrl(url); } else { throw 'Could not launch $url'; } @@ -42,4 +43,3 @@ Future openFilePath(String path) async { CommonUtilityFunctions().showNoFileDialog(); } } - diff --git a/lib/screens/my_files/widgets/recents.dart b/lib/screens/my_files/widgets/recent.dart similarity index 98% rename from lib/screens/my_files/widgets/recents.dart rename to lib/screens/my_files/widgets/recent.dart index 234b71ee..e40abd1e 100644 --- a/lib/screens/my_files/widgets/recents.dart +++ b/lib/screens/my_files/widgets/recent.dart @@ -14,12 +14,12 @@ import 'package:fc_native_video_thumbnail/fc_native_video_thumbnail.dart'; import 'package:flutter/material.dart'; import 'package:video_thumbnail/video_thumbnail.dart'; -class Recents extends StatefulWidget { +class Recent extends StatefulWidget { @override - _RecentsState createState() => _RecentsState(); + _RecentState createState() => _RecentState(); } -class _RecentsState extends State { +class _RecentState extends State { @override Widget build(BuildContext context) { return ProviderHandler( diff --git a/lib/screens/my_files/widgets/sort_popup.dart b/lib/screens/my_files/widgets/sort_popup.dart deleted file mode 100644 index 51dc578c..00000000 --- a/lib/screens/my_files/widgets/sort_popup.dart +++ /dev/null @@ -1,36 +0,0 @@ -import 'package:atsign_atmosphere_pro/screens/common_widgets/provider_callback.dart'; -import 'package:atsign_atmosphere_pro/view_models/my_files_provider.dart'; -import 'package:flutter/material.dart'; - -class SortPopup extends StatefulWidget { - @override - _SortPopupState createState() => _SortPopupState(); -} - -class _SortPopupState extends State { - String? ratioItem = ''; - @override - Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - RadioListTile( - value: 'By Name', - groupValue: ratioItem, - onChanged: (dynamic s) { - setState(() { - ratioItem = s; - providerCallback(context, - task: (provider) => - provider.sortByName(provider.receivedPhotos), - taskName: (provider) => provider.SORT_LIST, - onSuccess: (provider) { - print('object'); - }); - }); - }) - ], - ), - ); - } -} diff --git a/lib/screens/settings/settings_screen.dart b/lib/screens/settings/settings_screen.dart index 79aee633..c1da2c08 100644 --- a/lib/screens/settings/settings_screen.dart +++ b/lib/screens/settings/settings_screen.dart @@ -37,8 +37,8 @@ class _SettingsScreenState extends State { final List optionTitle = [ TextStrings().blockedAtSign, TextStrings().backUpKeys, - TextStrings().switchatSign, - TextStrings().deleteAtsigns, + TextStrings().switchAtSign, + TextStrings().deleteAtSigns, TextStrings().faqs, TextStrings().contactUs, TextStrings().termsAppBar, @@ -54,7 +54,7 @@ class _SettingsScreenState extends State { AppVectors.icSettingPrivacy, ]; - void switchAtsign() async { + void switchAtSign() async { var atSignList = await KeychainUtil.getAtsignList(); await showModalBottomSheet( isScrollControlled: true, @@ -270,14 +270,14 @@ class _SettingsScreenState extends State { SizedBox(height: 16), _buildSettingButton( buttonText: optionTitle[2], - onPressed: switchAtsign, + onPressed: switchAtSign, image: optionIcons[2], ), SizedBox(height: 16), _buildSettingButton( buttonText: optionTitle[3], onPressed: () async { - CommonUtilityFunctions().showResetAtsignDialog(); + CommonUtilityFunctions().showResetAtSignDialog(); }, image: optionIcons[3], ), diff --git a/lib/screens/trusted_contacts/trusted_contacts.dart b/lib/screens/trusted_contacts/trusted_contacts.dart deleted file mode 100644 index 5717d159..00000000 --- a/lib/screens/trusted_contacts/trusted_contacts.dart +++ /dev/null @@ -1,228 +0,0 @@ -import 'dart:typed_data'; - -import 'package:at_contacts_flutter/screens/contacts_screen.dart'; -import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; -import 'package:atsign_atmosphere_pro/utils/text_strings.dart' - as pro_text_strings; -import 'package:atsign_atmosphere_pro/screens/common_widgets/app_bar.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/contact_initial.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_button.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_circle_avatar.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/provider_handler.dart'; -import 'package:atsign_atmosphere_pro/screens/group_contacts_screen/widgets/group_contact_list_tile.dart'; -import 'package:atsign_atmosphere_pro/screens/trusted_contacts/widgets/remove_trusted_contact_dialog.dart'; -import 'package:atsign_atmosphere_pro/utils/images.dart'; -import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; -import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; -import 'package:at_common_flutter/services/size_config.dart'; -import 'package:atsign_atmosphere_pro/view_models/trusted_sender_view_model.dart'; -import 'package:flutter/material.dart'; -import 'package:showcaseview/showcaseview.dart'; - -class TrustedContacts extends StatefulWidget { - @override - _TrustedContactsState createState() => _TrustedContactsState(); -} - -class _TrustedContactsState extends State { - bool toggleList = false; - GlobalKey _one = GlobalKey(); - BuildContext? myContext; - - @override - Widget build(BuildContext context) { - return Container( - child: ProviderHandler( - functionName: 'get_trusted_contacts', - load: (provider) async { - await provider.getTrustedContact(); - await provider.migrateTrustedContact(); - }, - showError: false, - errorBuilder: (provider) => Scaffold( - body: Center( - child: Text(TextStrings().errorOccured), - ), - ), - successBuilder: (provider) { - return ShowCaseWidget(builder: Builder(builder: (context) { - myContext = context; - return Scaffold( - appBar: CustomAppBar( - showBackButton: true, - showTitle: true, - title: pro_text_strings.TextStrings().trustedSenders, - showTrailingButton: - provider.trustedContacts.isEmpty ? false : true, - trailingIcon: Icons.add, - isTrustedContactScreen: true, - ), - body: SafeArea( - child: Column(children: [ - Expanded( - child: provider.trustedContacts.isEmpty - ? Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Center( - child: Container( - padding: EdgeInsets.all(20.0), - decoration: BoxDecoration( - color: Color(0xffFCF9F9), - borderRadius: BorderRadius.circular( - 80.toHeight)), - height: 160.toHeight, - width: 160.toHeight, - child: Image.asset( - ImageConstants.emptyTrustedSenders), - ), - ), - SizedBox(height: 20.toHeight), - Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Showcase( - key: _one, - description: - 'When someone on your Trusted Senders list sends you a file while you’re in the app, it will be automatically downloaded. If they send it when you’re not in the app, it will download the next time you open it.', - targetShapeBorder: CircleBorder(), - disableMovingAnimation: true, - disableScaleAnimation: true, - targetBorderRadius: BorderRadius.all( - Radius.circular(40)), - showArrow: false, - targetPadding: EdgeInsets.all(5), - blurValue: 2, - child: Padding( - padding: EdgeInsets.symmetric( - horizontal: 10, vertical: 5), - child: Text( - pro_text_strings.TextStrings() - .noTrustedSenders, - style: CustomTextStyles - .primaryBold18, - ), - ), - ), - GestureDetector( - onTap: () { - ShowCaseWidget.of(myContext!) - .startShowCase([_one]); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.grey.shade400, - borderRadius: - BorderRadius.circular(50)), - margin: EdgeInsets.all(0), - height: 20, - width: 20, - child: Icon( - Icons.question_mark, - size: 15, - ), - ), - ), - ], - ), - SizedBox(height: 10.toHeight), - Text( - pro_text_strings.TextStrings() - .addTrustedSender, - style: - CustomTextStyles.secondaryRegular16, - textAlign: TextAlign.center, - ), - SizedBox( - height: 25.toHeight, - ), - CustomButton( - isOrange: true, - buttonText: - pro_text_strings.TextStrings().add, - height: 40.toHeight, - width: 115.toWidth, - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - ContactsScreen( - asSelectionScreen: true, - selectedContactsHistory: [], - selectedList: (s) async { - for (var element in s) { - await provider - .addTrustedContacts( - element!); - } - })), - ); - }, - ) - ], - ) - : ListView.builder( - itemCount: provider.trustedContacts.length, - itemBuilder: (context, index) { - Uint8List? byteImage = - CommonUtilityFunctions() - .getCachedContactImage( - provider.trustedContacts[index].atSign!, - ); - - return ContactListTile( - plainView: true, - isSelected: false, - onlyRemoveMethod: true, - onTileTap: () { - showDialog( - context: context, - barrierDismissible: false, - builder: (context) => - RemoveTrustedContact( - pro_text_strings.TextStrings() - .removeTrustedSender, - contact: - provider.trustedContacts[index], - image: byteImage, - ), - ); - }, - onAdd: () {}, - onRemove: () {}, - name: provider.trustedContacts[index] - .tags != - null && - provider.trustedContacts[index] - .tags!['name'] != - null - ? provider.trustedContacts[index] - .tags!['name'] - : provider - .trustedContacts[index].atSign! - .substring(1), - atSign: provider - .trustedContacts[index].atSign, - image: byteImage != null - ? CustomCircleAvatar( - byteImage: byteImage, - nonAsset: true, - ) - : ContactInitial( - initials: provider - .trustedContacts[index] - .atSign, - ), - ); - }, - )), - ]), - ), - ); - })); - })); - } -} diff --git a/lib/screens/welcome_screen/welcome_screen.dart b/lib/screens/welcome_screen/welcome_screen.dart index 773cb27d..73b223b9 100644 --- a/lib/screens/welcome_screen/welcome_screen.dart +++ b/lib/screens/welcome_screen/welcome_screen.dart @@ -7,7 +7,6 @@ import 'package:at_sync_ui_flutter/at_sync_ui_flutter.dart'; import 'package:atsign_atmosphere_pro/routes/route_names.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/error_screen.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/linear_progress_bar.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/skeleton_loading_widget.dart'; import 'package:atsign_atmosphere_pro/screens/contact_new_version/contact_screen.dart'; import 'package:atsign_atmosphere_pro/screens/history/transfer_history_screen.dart'; import 'package:atsign_atmosphere_pro/screens/my_files/my_files_screen.dart'; @@ -145,8 +144,8 @@ class _WelcomeScreenState extends State { }); print("Shared:" + (_sharedFiles?.map((f) => f.path).join(",") ?? "")); // check to see if atsign is paired - var atsign = await _backendService.currentAtsign; - if (atsign != null) { + var atSign = await _backendService.currentAtsign; + if (atSign != null) { BuildContext c = NavService.navKey.currentContext!; await Navigator.pushNamedAndRemoveUntil( c, Routes.WELCOME_SCREEN, (route) => false); @@ -210,15 +209,15 @@ class _WelcomeScreenState extends State { child: Container( height: 24, width: double.infinity, - child: StreamBuilder( + child: StreamBuilder( stream: FileTransferProvider() .flushBarStatusStream, builder: (context, snapshot) { final flushbarStatus = snapshot.data ?? - FLUSHBAR_STATUS.SENDING; + FlushBarStatus.SENDING; if (flushbarStatus == - FLUSHBAR_STATUS.DONE) { + FlushBarStatus.DONE) { Future.delayed( const Duration(seconds: 3), () { @@ -244,7 +243,7 @@ class _WelcomeScreenState extends State { ), ); } else if (flushbarStatus == - FLUSHBAR_STATUS.FAILED) { + FlushBarStatus.FAILED) { Future.delayed( const Duration(seconds: 3), () { diff --git a/lib/screens/welcome_screen/widgets/select_file_widget.dart b/lib/screens/welcome_screen/widgets/select_file_widget.dart deleted file mode 100644 index c87d7d09..00000000 --- a/lib/screens/welcome_screen/widgets/select_file_widget.dart +++ /dev/null @@ -1,254 +0,0 @@ -import 'dart:typed_data'; -import 'package:at_common_flutter/widgets/custom_input_field.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/error_dialog.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/provider_callback.dart'; -import 'package:at_common_flutter/services/size_config.dart'; -import 'package:atsign_atmosphere_pro/services/common_utility_functions.dart'; -import 'package:atsign_atmosphere_pro/utils/colors.dart'; -import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; -import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; -import 'package:atsign_atmosphere_pro/view_models/file_transfer_provider.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -class SelectFileWidget extends StatefulWidget { - final Function(bool) onUpdate; - final Function onNotesUpdate; - final String? initialValue; - SelectFileWidget( - this.onUpdate, - this.onNotesUpdate, { - this.initialValue, - }); - @override - _SelectFileWidgetState createState() => _SelectFileWidgetState(); -} - -class _SelectFileWidgetState extends State { - bool isLoading = false; - - Uint8List? videoThumbnail; - FileTransferProvider? filePickerProvider; - - @override - void initState() { - filePickerProvider = - Provider.of(context, listen: false); - super.initState(); - } - - @override - void didChangeDependencies() async { - if (filePickerProvider == null) { - filePickerProvider = - Provider.of(context, listen: false); - await filePickerProvider!.setFiles(); - } - super.didChangeDependencies(); - } - - void _showFileChoice() { - showDialog( - context: context, - builder: (BuildContext context) { - return Dialog( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12.0)), - child: Container( - padding: EdgeInsets.only(left: 10.toWidth), - height: 200.0.toHeight < 170 ? 170 : 200.0.toHeight, - width: 300.0.toWidth, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding(padding: EdgeInsets.only(top: 15.0)), - Text( - TextStrings().fileChoiceQuestion, - style: CustomTextStyles.primaryBold16, - ), - Padding(padding: EdgeInsets.only(top: 15.0)), - TextButton( - onPressed: () { - Navigator.pop(context); - providerCallback(context, - task: (provider) => - provider.pickFiles(provider.MEDIA), - taskName: (provider) => provider.PICK_FILES, - onSuccess: (provider) {}, - onError: (err) => ErrorDialog() - .show(err.toString(), context: context)); - }, - child: Row(children: [ - Icon( - Icons.camera, - size: 30.toFont, - color: Colors.black, - ), - Padding( - padding: EdgeInsets.only(left: 20), - child: Text( - TextStrings().choice1, - style: CustomTextStyles.primaryBold14, - )) - ])), - Padding(padding: EdgeInsets.only(top: 15.0)), - TextButton( - onPressed: () { - Navigator.pop(context); - providerCallback(context, - task: (provider) => - provider.pickFiles(provider.FILES), - taskName: (provider) => provider.PICK_FILES, - onSuccess: (provider) {}, - onError: (err) => ErrorDialog() - .show(err.toString(), context: context)); - }, - child: Row(children: [ - Icon( - Icons.file_copy, - size: 30.toFont, - color: Colors.black, - ), - Padding( - padding: EdgeInsets.only(left: 20), - child: Text( - TextStrings().choice2, - style: CustomTextStyles.primaryBold14, - )) - ])) - ], - ), - ), - ); - }); - } - - @override - Widget build(BuildContext context) { - return ClipRRect( - child: Container( - // padding: SizeConfig().isTablet(context) - // ? EdgeInsets.symmetric(vertical: 10.toFont, horizontal: 10.toFont) - // : EdgeInsets.only(left: 10.toFont, right: 10.toFont), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15.toFont), - color: ColorConstants.inputFieldColor, - ), - child: Column( - children: [ - ListTile( - // contentPadding: EdgeInsets.all(0), - title: Text( - filePickerProvider!.selectedFiles.isEmpty - ? TextStrings().welcomeFilePlaceholder - : TextStrings().welcomeAddFilePlaceholder, - semanticsLabel: 'Select file to transfer button', - style: TextStyle( - color: ColorConstants.fadedText, - fontSize: 14.toFont, - fontWeight: FontWeight.normal, - )), - subtitle: filePickerProvider!.selectedFiles.isEmpty - ? null - : Text( - double.parse(filePickerProvider!.totalSize.toString()) <= - 1024 - ? '${filePickerProvider!.totalSize} Kb . ${filePickerProvider!.selectedFiles.length} file(s)' - : '${(filePickerProvider!.totalSize / (1024 * 1024)).toStringAsFixed(2)} Mb . ${filePickerProvider!.selectedFiles.length} file(s)', - style: TextStyle( - color: ColorConstants.fadedText, - fontSize: 10.toFont, - fontWeight: FontWeight.normal, - ), - ), - onTap: () { - _showFileChoice(); - }, - trailing: Container( - padding: EdgeInsets.symmetric(vertical: 15.toHeight), - child: Icon( - Icons.add_circle, - color: Colors.black, - ), - ), - ), - filePickerProvider!.selectedFiles.isNotEmpty - ? ListView.builder( - shrinkWrap: true, - physics: ClampingScrollPhysics(), - itemCount: filePickerProvider!.selectedFiles.isNotEmpty - ? int.parse( - filePickerProvider!.selectedFiles.length.toString()) - : 0, - itemBuilder: (c, index) { - return Consumer( - builder: (context, provider, _) { - if (provider.selectedFiles.isEmpty) { - return SizedBox(); - } - return Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: ColorConstants.dividerColor - .withOpacity(0.1), - width: 1.toHeight, - ), - ), - ), - child: ListTile( - title: Text( - provider.selectedFiles[index].name.toString(), - style: TextStyle( - color: Colors.black, - fontSize: 14.toFont, - fontWeight: FontWeight.normal, - ), - ), - subtitle: Text( - double.parse(provider.selectedFiles[index].size - .toString()) <= - 1024 - ? '${provider.selectedFiles[index].size} Kb' + - ' . ${provider.selectedFiles[index].extension}' - : '${(provider.selectedFiles[index].size / (1024 * 1024)).toStringAsFixed(2)} Mb' + - ' . ${provider.selectedFiles[index].extension}', - style: TextStyle( - color: ColorConstants.fadedText, - fontSize: 14.toFont, - fontWeight: FontWeight.normal, - ), - ), - leading: CommonUtilityFunctions().thumbnail( - provider.selectedFiles[index].extension - .toString(), - provider.selectedFiles[index].path.toString()), - trailing: IconButton( - icon: Icon( - Icons.clear, - ), - onPressed: () { - setState(() { - provider.selectedFiles.removeAt(index); - provider.calculateSize(); - provider.hasSelectedFilesChanged = true; - }); - if (provider.selectedFiles.isEmpty) { - widget.onUpdate(false); - } else { - widget.onUpdate(true); - } - }, - ), - ), - ); - }); - }, - ) - : SizedBox(), - ], - ), - ), - ); - } -} diff --git a/lib/screens/welcome_screen/widgets/welcome_sceen_home.dart b/lib/screens/welcome_screen/widgets/welcome_sceen_home.dart index 1e9431a2..fc173092 100644 --- a/lib/screens/welcome_screen/widgets/welcome_sceen_home.dart +++ b/lib/screens/welcome_screen/widgets/welcome_sceen_home.dart @@ -498,7 +498,7 @@ class _WelcomeScreenHomeState extends State { sendFileWithFileBin() async { if (filePickerModel.selectedFiles.isEmpty) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( context, 'No files selected', bgColor: ColorConstants.redAlert, @@ -507,7 +507,7 @@ class _WelcomeScreenHomeState extends State { } if (_welcomeScreenProvider.selectedContacts.isEmpty) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( context, 'No atSign selected', bgColor: ColorConstants.redAlert, @@ -567,7 +567,7 @@ class _WelcomeScreenHomeState extends State { final result = await OpenFile.open(file.path); if (result.type != ResultType.done) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( context, result.message, ); diff --git a/lib/screens/welcome_screen/widgets/welcome_screen_received_files.dart b/lib/screens/welcome_screen/widgets/welcome_screen_received_files.dart deleted file mode 100644 index afaa9562..00000000 --- a/lib/screens/welcome_screen/widgets/welcome_screen_received_files.dart +++ /dev/null @@ -1,56 +0,0 @@ -import 'package:atsign_atmosphere_pro/screens/common_widgets/provider_handler.dart'; -import 'package:atsign_atmosphere_pro/screens/history/widgets/received_file_list_tile.dart'; -import 'package:at_common_flutter/services/size_config.dart'; -import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; -import 'package:atsign_atmosphere_pro/view_models/history_provider.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -class WelcomeScreenReceivedFiles extends StatefulWidget { - @override - _WelcomeScreenReceivedFilesState createState() => - _WelcomeScreenReceivedFilesState(); -} - -class _WelcomeScreenReceivedFilesState - extends State { - late HistoryProvider historyProvider; - - @override - Widget build(BuildContext context) { - historyProvider = Provider.of(context); - return ProviderHandler( - functionName: historyProvider.RECEIVED_HISTORY, - load: (provider) {}, - showError: false, - successBuilder: (provider) => (provider.receivedHistoryLogs.isEmpty) - ? Center( - child: Text( - TextStrings().noFilesRecieved, - style: TextStyle( - fontSize: 15.toFont, - fontWeight: FontWeight.normal, - ), - ), - ) - : ListView.separated( - padding: EdgeInsets.only(bottom: 170.toHeight), - physics: AlwaysScrollableScrollPhysics(), - separatorBuilder: (context, index) => Divider(indent: 16.toWidth), - itemCount: provider.receivedHistoryLogs.length, - itemBuilder: (context, index) => Padding( - padding: const EdgeInsets.all(8.0), - child: ReceivedFilesListTile( - key: Key(provider.receivedHistoryLogs[index].key), - receivedHistory: provider.receivedHistoryLogs[index], - isWidgetOpen: - provider.receivedHistoryLogs[index].isWidgetOpen, - ), - ), - ), - errorBuilder: (provider) => Center( - child: Text(TextStrings().errorOccured), - ), - ); - } -} diff --git a/lib/services/at_error_dialog.dart b/lib/services/at_error_dialog.dart deleted file mode 100644 index 4ea22b74..00000000 --- a/lib/services/at_error_dialog.dart +++ /dev/null @@ -1,68 +0,0 @@ -import 'package:atsign_atmosphere_pro/utils/text_strings.dart'; -import 'package:atsign_atmosphere_pro/utils/text_styles.dart'; -import 'package:flutter/material.dart'; -import 'package:at_client/at_client.dart'; -import 'package:at_commons/at_commons.dart'; - -class AtErrorDialog { - static getAlertDialog(var error, BuildContext context) { - String errorMessage = _getErrorMessage(error); - var title = TextStrings().error; - return AlertDialog( - title: Row( - children: [ - Text(title, style: CustomTextStyles.primaryMedium14), - Icon(Icons.sentiment_dissatisfied) - ], - ), - content: Text('$errorMessage'), - actions: [ - TextButton( - onPressed: () { - Navigator.pop(context); - }, - child: Text(TextStrings().buttonClose), - ) - ], - ); - } - - ///Returns corresponding errorMessage for [error]. - static String _getErrorMessage(var error) { - switch (error.runtimeType) { - case AtClientException: - return TextStrings().unableToPerform; - break; - case UnAuthenticatedException: - return TextStrings().unableToAuthenticate; - break; - case NoSuchMethodError: - return TextStrings().failedInProcessing; - break; - case AtConnectException: - return TextStrings().unableToConnectServer; - break; - case AtIOException: - return TextStrings().unableToPerformRead_Write; - break; - case AtServerException: - return TextStrings().unableToActivateServer; - break; - case SecondaryNotFoundException: - return TextStrings().serverIsUnavailable; - break; - case SecondaryConnectException: - return TextStrings().unableToConnect; - break; - case InvalidAtSignException: - return TextStrings().invalidAtSign; - break; - case String: - return error; - break; - default: - return TextStrings().unknownError; - break; - } - } -} diff --git a/lib/services/backend_service.dart b/lib/services/backend_service.dart index 7a5d6dde..817e7e42 100644 --- a/lib/services/backend_service.dart +++ b/lib/services/backend_service.dart @@ -13,7 +13,6 @@ import 'package:at_onboarding_flutter/at_onboarding_flutter.dart'; import 'package:atsign_atmosphere_pro/desktop_routes/desktop_routes.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/custom_onboarding.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/error_dialog.dart'; -import 'package:atsign_atmosphere_pro/services/exception_service.dart'; import 'package:atsign_atmosphere_pro/services/local_notification_service.dart'; import 'package:atsign_atmosphere_pro/services/snackbar_service.dart'; import 'package:atsign_atmosphere_pro/services/version_service.dart'; @@ -87,7 +86,7 @@ class BackendService { print("paths => $downloadDirectory $appSupportDirectory"); } await atClientServiceInstance.onboard( - atClientPreference: atClientPreference, atsign: atsign); + atClientPreference: atClientPreference, atSign: atsign); // atClientInstance = atClientServiceInstance.atClient; } @@ -177,7 +176,7 @@ class BackendService { .contains(MixedConstants.FILE_TRANSFER_ACKNOWLEDGEMENT)) { var decryptedMessage = response.value!; - if (decryptedMessage != null && decryptedMessage != '') { + if (decryptedMessage != '') { DownloadAcknowledgement downloadAcknowledgement = DownloadAcknowledgement.fromJson(jsonDecode(decryptedMessage)); @@ -194,14 +193,14 @@ class BackendService { var atKey = notificationKey.split(':')[1]; var decryptedMessage = response.value!; - if (decryptedMessage != null && decryptedMessage != '') { + if (decryptedMessage != '') { await Provider.of(NavService.navKey.currentContext!, listen: false) .checkForUpdatedOrNewNotification(fromAtSign, decryptedMessage); Provider.of(NavService.navKey.currentContext!, listen: false) - .checkForUndownloadedFiles(); + .checkForUnDownloadedFiles(); BuildContext context = NavService.navKey.currentContext!; bool trustedSender = false; @@ -309,7 +308,7 @@ class BackendService { Provider.of(NavService.navKey.currentContext!, listen: false) - .checkForUndownloadedFiles(); + .checkForUnDownloadedFiles(); // setPeriodicFileHistoryRefresh(); } @@ -402,19 +401,18 @@ class BackendService { value, result.atsign!, atClientPrefernce); break; case AtOnboardingResultStatus.error: - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, (result.message ?? '').isNotEmpty ? '' : 'Onboarding failed.', bgColor: ColorConstants.redAlert, ); break; case AtOnboardingResultStatus.cancel: - // TODO: Handle this case. break; } } else { CustomOnboarding.onboard( - atSign: tempAtsign, atClientPrefernce: atClientPrefernce); + atSign: tempAtsign, atClientPreference: atClientPrefernce); } } @@ -432,10 +430,7 @@ class BackendService { _onboardingService.setAtsign = atSign; - // await getAtClientPreference(); - await getAtClientPreference() - .then((value) => atClientPrefernce = value) - .catchError((e) => print(e)); + await getAtClientPreference().then((value) => atClientPrefernce = value); authenticating = false; isAuthuneticatingSink.add(authenticating); @@ -467,7 +462,7 @@ class BackendService { listen: false) .isInternetAvailable; - SnackbarService().showSnackbar(NavService.navKey.currentContext!, + SnackBarService().showSnackBar(NavService.navKey.currentContext!, !isConnected ? TextStrings.noInternetMsg : 'Onboarding failed.', bgColor: ColorConstants.redAlert); authenticating = false; @@ -528,7 +523,7 @@ class BackendService { // start monitor and package initializations. initLocalNotification(); - initializeContactsService(rootDomain: MixedConstants.ROOT_DOMAIN); + await initializeContactsService(rootDomain: MixedConstants.ROOT_DOMAIN); initializeGroupService(rootDomain: MixedConstants.ROOT_DOMAIN); await Navigator.pushNamedAndRemoveUntil( @@ -585,7 +580,7 @@ class BackendService { }, ); } else if (Platform.isMacOS) { - DesktopSetupRoutes.nested_push(DesktopRoutes.DESKTOP_HISTORY); + await DesktopSetupRoutes.nested_push(DesktopRoutes.DESKTOP_HISTORY); } } @@ -601,16 +596,16 @@ class BackendService { ErrorDialog().show(msg, context: NavService.navKey.currentContext); } - // refreshHistoryScreen() async { - // var historyProvider = Provider.of( - // NavService.navKey.currentContext!, - // listen: false); - // historyProvider.setStatus(historyProvider.PERIODIC_REFRESH, Status.Loading); - - // if (historyProvider.status[historyProvider.RECEIVED_HISTORY] != - // Status.Loading) { - // await historyProvider.refreshReceivedFile(setLoading: false); - // } - // historyProvider.setStatus(historyProvider.PERIODIC_REFRESH, Status.Done); - // } +// refreshHistoryScreen() async { +// var historyProvider = Provider.of( +// NavService.navKey.currentContext!, +// listen: false); +// historyProvider.setStatus(historyProvider.PERIODIC_REFRESH, Status.Loading); + +// if (historyProvider.status[historyProvider.RECEIVED_HISTORY] != +// Status.Loading) { +// await historyProvider.refreshReceivedFile(setLoading: false); +// } +// historyProvider.setStatus(historyProvider.PERIODIC_REFRESH, Status.Done); +// } } diff --git a/lib/services/common_utility_functions.dart b/lib/services/common_utility_functions.dart index 051787e0..3af60e6d 100644 --- a/lib/services/common_utility_functions.dart +++ b/lib/services/common_utility_functions.dart @@ -39,9 +39,9 @@ class CommonUtilityFunctions { return _singleton; } - Uint8List? getCachedContactImage(String atsign) { + Uint8List? getCachedContactImage(String atSign) { Uint8List? image; - AtContact contact = checkForCachedContactDetail(atsign); + AtContact contact = checkForCachedContactDetail(atSign); if (contact.tags != null && contact.tags!['image'] != null) { try { @@ -65,9 +65,9 @@ class CommonUtilityFunctions { return name; } - getCachedContactName(String atsign) { + getCachedContactName(String atSign) { String? _name; - AtContact contact = checkForCachedContactDetail(atsign); + AtContact contact = checkForCachedContactDetail(atSign); if (contact.tags != null && contact.tags!['name'] != null) { _name = contact.tags!['name'].toString(); @@ -82,14 +82,14 @@ class CommonUtilityFunctions { return fileExists; } - showResetAtsignDialog() async { - bool isSelectAtsign = false; + showResetAtSignDialog() async { + bool isSelectAtSign = false; bool? isSelectAll = false; - var atsignsList = await KeychainUtil.getAtsignList(); - atsignsList ??= []; - Map atsignMap = {}; - for (String atsign in atsignsList) { - atsignMap[atsign] = false; + var atSignsList = await KeychainUtil.getAtsignList(); + atSignsList ??= []; + Map atSignMap = {}; + for (String atSign in atSignsList) { + atSignMap[atSign] = false; } GlobalKey _one = GlobalKey(); await showDialog( @@ -166,7 +166,7 @@ class CommonUtilityFunctions { SizedBox( height: 15.toHeight, ), - atsignsList!.isEmpty + atSignsList!.isEmpty ? Column( mainAxisSize: MainAxisSize.min, children: [ @@ -213,7 +213,7 @@ class CommonUtilityFunctions { ), onChanged: (value) { isSelectAll = value; - atsignMap.updateAll((key, value1) => + atSignMap.updateAll((key, value1) => value1 = value); stateSet(() {}); }, @@ -235,7 +235,7 @@ class CommonUtilityFunctions { color: Colors.white, ), ), - for (var atsign in atsignsList) + for (var atsign in atSignsList) CheckboxListTile( shape: RoundedRectangleBorder( borderRadius: @@ -248,10 +248,10 @@ class CommonUtilityFunctions { color: ColorConstants.orange), ), onChanged: (value) { - atsignMap[atsign] = value; + atSignMap[atsign] = value; stateSet(() {}); }, - value: atsignMap[atsign], + value: atSignMap[atsign], activeColor: const Color(0x00473d24), checkColor: ColorConstants.orange, @@ -268,7 +268,7 @@ class CommonUtilityFunctions { ], ), ), - if (isSelectAtsign) + if (isSelectAtSign) Text('Please select at least one atSign to reset', style: TextStyle( color: Colors.red, @@ -350,20 +350,20 @@ class CommonUtilityFunctions { ))), onPressed: () async { var tempAtsignMap = {}; - tempAtsignMap.addAll(atsignMap); + tempAtsignMap.addAll(atSignMap); tempAtsignMap.removeWhere( (key, value) => value == false); int atsignsListLength = tempAtsignMap.keys.toList().length; if (tempAtsignMap.keys.toList().isEmpty) { - isSelectAtsign = true; + isSelectAtSign = true; stateSet(() {}); } else { showConfirmationDialog(() async { - isSelectAtsign = false; + isSelectAtSign = false; await _resetDevice( tempAtsignMap.keys.toList()); - await _onboardNextAtsign(); + await _onboardNextAtSign(); }, 'Remove $atsignsListLength atSign${atsignsListLength > 1 ? 's' : ''} from this device?'); } }, @@ -396,7 +396,7 @@ class CommonUtilityFunctions { }); } - _onboardNextAtsign() async { + _onboardNextAtSign() async { var _backendService = BackendService.getInstance(); var atSignList = await KeychainUtil.getAtsignList(); if (atSignList != null && @@ -773,7 +773,7 @@ class CommonUtilityFunctions { return res['nickname'] ?? ""; } - Widget interactableThumbnail(String extension, String path, + Widget interactThumbnail(String extension, String path, FilesDetail fileDetail, Function onDelete) { GroupService().allContacts; String nickname = ""; diff --git a/lib/services/desktop_context_menu.dart b/lib/services/desktop_context_menu.dart deleted file mode 100644 index 39cae710..00000000 --- a/lib/services/desktop_context_menu.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'package:flutter/material.dart'; - -class DesktopContextMenu { - static OverlayEntry? contextMenu; - - static void setContextMenu(Widget widget) { - contextMenu = OverlayEntry( - builder: (context) { - return widget; - }, - ); - } - - static void show(BuildContext context) { - if (contextMenu != null) { - Overlay.of(context).insert(contextMenu!); - } - } - - static void hide() { - if (contextMenu != null) { - contextMenu!.remove(); - } - } -} diff --git a/lib/services/exception_service.dart b/lib/services/exception_service.dart index f84124ae..4cf47854 100644 --- a/lib/services/exception_service.dart +++ b/lib/services/exception_service.dart @@ -76,7 +76,7 @@ class ExceptionService { _showExceptionOverlay(String error, {Function? onRetry}) async { hideOverlay(); - exceptionOverlayEntry = _buildexceptionOverlayEntry( + exceptionOverlayEntry = _buildExceptionOverlayEntry( error, onRetry: onRetry, ); @@ -91,7 +91,7 @@ class ExceptionService { exceptionOverlayEntry = null; } - OverlayEntry _buildexceptionOverlayEntry(String error, {Function? onRetry}) { + OverlayEntry _buildExceptionOverlayEntry(String error, {Function? onRetry}) { Color bgColor = ColorConstants.redAlert; return OverlayEntry(builder: (context) { diff --git a/lib/services/file_transfer_service.dart b/lib/services/file_transfer_service.dart index 9a3f8dec..ca107f30 100644 --- a/lib/services/file_transfer_service.dart +++ b/lib/services/file_transfer_service.dart @@ -5,7 +5,6 @@ import 'dart:isolate'; // import 'package:at_client/src/stream/file_transfer_object.dart'; import 'package:at_client_mobile/at_client_mobile.dart'; -import 'package:at_commons/at_commons.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer_object.dart'; import 'package:atsign_atmosphere_pro/services/backend_service.dart'; @@ -16,7 +15,6 @@ import 'package:atsign_atmosphere_pro/view_models/file_progress_provider.dart'; import 'package:provider/provider.dart'; import 'package:uuid/uuid.dart'; import 'package:http/http.dart' as http; -import 'package:at_client/src/service/notification_service.dart'; import 'package:at_client/src/service/encryption_service.dart'; class FileTransferService { @@ -260,10 +258,7 @@ class FileTransferService { ..sharedBy = sharedByAtSign; var result = await AtClientManager.getInstance().atClient.get(atKey).catchError( - (e) { - print('Error in get $e'); - ExceptionService.instance.showGetExceptionOverlay(e); - }, + (e) => ExceptionService.instance.showGetExceptionOverlay(e), ); FileTransferObject fileTransferObject; @@ -278,15 +273,15 @@ class FileTransferService { } var downloadedFiles = []; - var fileDownloadReponse = await downloadAllFiles( + var fileDownloadResponse = await downloadAllFiles( fileTransferObject, downloadPath, ); - if (fileDownloadReponse.isError) { + if (fileDownloadResponse.isError) { throw Exception('download fail'); } - var encryptedFileList = Directory(fileDownloadReponse.filePath!).listSync(); + var encryptedFileList = Directory(fileDownloadResponse.filePath!).listSync(); try { for (var encryptedFile in encryptedFileList) { updateFileTransferState( @@ -307,7 +302,7 @@ class FileTransferService { decryptedFile.deleteSync(); } // deleting temp directory - Directory(fileDownloadReponse.filePath!).deleteSync(recursive: true); + Directory(fileDownloadResponse.filePath!).deleteSync(recursive: true); return downloadedFiles; } catch (e) { throw Exception('Error in saving file'); diff --git a/lib/services/local_notification_service.dart b/lib/services/local_notification_service.dart index 089428e0..3bd6407e 100644 --- a/lib/services/local_notification_service.dart +++ b/lib/services/local_notification_service.dart @@ -8,9 +8,9 @@ class LocalNotificationService { LocalNotificationService._() { init(); } - static LocalNotificationService _instace = + static LocalNotificationService _instance = LocalNotificationService._(); - factory LocalNotificationService() => _instace; + factory LocalNotificationService() => _instance; late FlutterLocalNotificationsPlugin _notificationsPlugin; late InitializationSettings initializationSettings; final BehaviorSubject @@ -99,15 +99,7 @@ class LocalNotificationService { await _notificationsPlugin.show( 0, '$from sent you a file', message, platformChannelSpecifics, payload: jsonEncode(payload)); - } /*else if (Platform.isWindows) { - final localNotifier = LocalNotifier.instance; - LocalNotification notification = LocalNotification( - identifier: 'identifier', - title: '$from sent you a file', - subtitle: message, - ); - await localNotifier.notify(notification); - }*/ + } } cancelNotifications() async { diff --git a/lib/services/notification_service.dart b/lib/services/notification_service.dart index 451c3e93..03bb3bab 100644 --- a/lib/services/notification_service.dart +++ b/lib/services/notification_service.dart @@ -1,19 +1,18 @@ import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; -import 'package:atsign_atmosphere_pro/data_models/file_transfer_object.dart'; import 'package:atsign_atmosphere_pro/view_models/file_transfer_provider.dart'; import 'package:flutter/foundation.dart'; class NotificationService extends ChangeNotifier { - NotificationService._() {} - static NotificationService _instace = NotificationService._(); - factory NotificationService() => _instace; + NotificationService._(); + static NotificationService _instance = NotificationService._(); + factory NotificationService() => _instance; static final fileObjectKey = 'fileObject'; - static final flushbarStatuskey = 'flushbarStatus'; + static final flushBarStatusKey = 'flushbarStatus'; List _recentNotifications = []; Map _currentFileShareStatus = { fileObjectKey: null, - flushbarStatuskey: null + flushBarStatusKey: null }; List get recentNotification => _recentNotifications; @@ -28,10 +27,10 @@ class NotificationService extends ChangeNotifier { } updateCurrentFileShareStatus( - FileTransfer? fileObject, FLUSHBAR_STATUS flushbar_status) { + FileTransfer? fileObject, FlushBarStatus flushBarStatus) { _currentFileShareStatus = { fileObjectKey: fileObject, - flushbarStatuskey: flushbar_status + flushBarStatusKey: flushBarStatus }; notifyListeners(); } diff --git a/lib/services/overlay_service.dart b/lib/services/overlay_service.dart index d529d3e9..55d6de5d 100644 --- a/lib/services/overlay_service.dart +++ b/lib/services/overlay_service.dart @@ -45,18 +45,18 @@ class OverlayService { builder: (context) { return BackdropFilter( filter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0), - child: StreamBuilder( + child: StreamBuilder( stream: FileTransferProvider().flushBarStatusStream, builder: (context, snapshot) { - final flushbarStatus = snapshot.data ?? FLUSHBAR_STATUS.SENDING; + final flushBarStatus = snapshot.data ?? FlushBarStatus.SENDING; return Consumer( builder: (_context, provider, _) { String text = _getText( - flushbarStatus, + flushBarStatus, fileTransferProgress: provider.sentFileTransferProgress, ); - String icon = getImage(flushbarStatus); + String icon = getImage(flushBarStatus); return Scaffold( backgroundColor: bgColor.withOpacity(0.7), body: SafeArea( @@ -71,10 +71,10 @@ class OverlayService { child: InkWell( onTap: () { hideOverlay(); - if (flushbarStatus != - FLUSHBAR_STATUS.DONE && - flushbarStatus != - FLUSHBAR_STATUS.FAILED) { + if (flushBarStatus != + FlushBarStatus.DONE && + flushBarStatus != + FlushBarStatus.FAILED) { WelcomeScreenProvider() .changeOverlayStatus(false); } @@ -112,7 +112,7 @@ class OverlayService { ), ), SizedBox(height: 30), - flushbarStatus == FLUSHBAR_STATUS.SENDING + flushBarStatus == FlushBarStatus.SENDING ? getProgressBar() : _buildHistoryButton(), ], @@ -171,10 +171,10 @@ class OverlayService { ); } - String _getText(FLUSHBAR_STATUS flushbarStatus, + String _getText(FlushBarStatus flushBarStatus, {FileTransferProgress? fileTransferProgress}) { - switch (flushbarStatus) { - case FLUSHBAR_STATUS.SENDING: + switch (flushBarStatus) { + case FlushBarStatus.SENDING: String sendingMessage = transferMessages[0]; if (fileTransferProgress != null) { if (fileTransferProgress.fileState == FileState.encrypt) { @@ -186,22 +186,22 @@ class OverlayService { } } return sendingMessage; - case FLUSHBAR_STATUS.DONE: + case FlushBarStatus.DONE: return transferMessages[1]; - case FLUSHBAR_STATUS.FAILED: + case FlushBarStatus.FAILED: return transferMessages[2]; default: return ''; } } - String getImage(FLUSHBAR_STATUS flushbarStatus) { - switch (flushbarStatus) { - case FLUSHBAR_STATUS.SENDING: + String getImage(FlushBarStatus flushBarStatus) { + switch (flushBarStatus) { + case FlushBarStatus.SENDING: return ImageConstants.sendFileIcon; - case FLUSHBAR_STATUS.DONE: + case FlushBarStatus.DONE: return ImageConstants.iconSuccess; - case FLUSHBAR_STATUS.FAILED: + case FlushBarStatus.FAILED: return ImageConstants.iconWarning; default: return ImageConstants.sendFileIcon; diff --git a/lib/services/snackbar_service.dart b/lib/services/snackbar_service.dart index 1d5339f6..428ab6b1 100644 --- a/lib/services/snackbar_service.dart +++ b/lib/services/snackbar_service.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; -class SnackbarService { - static final SnackbarService _singleton = SnackbarService._internal(); - SnackbarService._internal(); - factory SnackbarService() { +class SnackBarService { + static final SnackBarService _singleton = SnackBarService._internal(); + SnackBarService._internal(); + factory SnackBarService() { return _singleton; } - showSnackbar(BuildContext context, String title, {Color? bgColor}) { + showSnackBar(BuildContext context, String title, {Color? bgColor}) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( backgroundColor: bgColor, diff --git a/lib/services/version_service.dart b/lib/services/version_service.dart index d1f1e7d4..42838bc1 100644 --- a/lib/services/version_service.dart +++ b/lib/services/version_service.dart @@ -15,7 +15,9 @@ import 'package:http/http.dart' as http; class VersionService { VersionService._(); + static VersionService _internal = VersionService._(); + factory VersionService.getInstance() { return _internal; } @@ -46,13 +48,13 @@ class VersionService { minVersion: decodedResponse['minimumVersion'], ); } else { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings.appVersionFetchError, ); } } catch (e) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings.releaseTagError, ); @@ -67,7 +69,7 @@ class VersionService { desktopUpgradeDialog(); } } catch (e) { - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, TextStrings.upgradeDialogShowError, ); @@ -175,20 +177,19 @@ class VersionService { } desktopUpdateHandler() async { - late String url; + late String path; if (Platform.isMacOS) { - url = MixedConstants.MACOS_STORE_LINK; + path = MixedConstants.MACOS_STORE_LINK; } else if (Platform.isWindows) { - url = MixedConstants.WINDOWS_STORE_LINK; + path = MixedConstants.WINDOWS_STORE_LINK; } else if (Platform.isLinux) { - url = MixedConstants.LINUX_STORE_LINK; + path = MixedConstants.LINUX_STORE_LINK; } + final url = Uri.parse(path); - if (await canLaunch(url)) { - await launch( + if (await canLaunchUrl(url)) { + await launchUrl( url, - forceSafariVC: false, - forceWebView: false, ); } } diff --git a/lib/utils/colors.dart b/lib/utils/colors.dart index 4d754bef..d3514641 100644 --- a/lib/utils/colors.dart +++ b/lib/utils/colors.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; class ColorConstants { static const Color successColor = Colors.green; static const Color fadedText = Color(0xFF6D6D79); - static const Color fadedbackground = Color(0xFFFDF9F9); + static const Color fadedBackground = Color(0xFFFDF9F9); static const Color appBarColor = Colors.white; static const Color scaffoldColor = Colors.white; static const Color appBarCloseColor = Color(0xff03A2E0); diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index 8fe5c758..bbafbacc 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -80,7 +80,7 @@ class MixedConstants { ]; /// we change the directory after successful login - static setNewApplicationDocumentsDirectory(String? _atsign) async { + static setNewApplicationDocumentsDirectory(String? _atSign) async { late var _dir; if (Platform.isMacOS || Platform.isWindows || Platform.isLinux) { _dir = await getApplicationDocumentsDirectory(); @@ -89,7 +89,7 @@ class MixedConstants { Platform.pathSeparator + '@mosphere-pro' + Platform.pathSeparator + - (_atsign ?? '')); + (_atSign ?? '')); /// we create directory if it does not exist if (!(await path.exists())) { diff --git a/lib/utils/images.dart b/lib/utils/images.dart index ff23e36d..63f6df3a 100644 --- a/lib/utils/images.dart +++ b/lib/utils/images.dart @@ -6,7 +6,7 @@ class ImageConstants { static String logoWhiteIcon = '$_basePath/logo_white.png'; // static String myFiles = '$_basePath/myfiles.png'; static String group = '$_basePath/group.png'; - static String trustedsenders = '$_basePath/trustedsenders.png'; + static String trustedSenders = '$_basePath/trustedsenders.png'; static String drawerIcon = '$_basePath/menu.png'; static String contactsIcon = '$_basePath/contacts.png'; static String blockedIcon = '$_basePath/blocked.png'; @@ -62,7 +62,7 @@ class ImageConstants { static String faqs = '$_basePath/faq.png'; static String contactUsLogo = '$_basePath/contact_us.png'; static String termsAndConditions = '$_basePath/terms.png'; - static String deleteAtsigns = '$_basePath/delete_atsigns.png'; + static String deleteAtSigns = '$_basePath/delete_atsigns.png'; // Sample profile pictures static String barbara = '$_basePath/barbara.jpg'; @@ -78,9 +78,9 @@ class ImageConstants { static String homeIcon = '$_basePath/home_icon.png'; static String backgroundDesktop = '$_basePath/desktop_bg.png'; - static String homeCaraousel1 = '$_basePath/home_caraousel_2.png'; - static String homeCaraousel2 = '$_basePath/home_caraousel_1.png'; - static String homeCaraousel3 = '$_basePath/home_caraousel_3.png'; + static String homeCarousel1 = '$_basePath/home_caraousel_2.png'; + static String homeCarousel2 = '$_basePath/home_caraousel_1.png'; + static String homeCarousel3 = '$_basePath/home_caraousel_3.png'; static String sidebarSelectedTile = '$_basePath/selected_sidebar.png'; static String sidebarSettings = '$_basePath/settings.png'; diff --git a/lib/utils/text_strings.dart b/lib/utils/text_strings.dart index 1e7a4ba6..d90266f4 100644 --- a/lib/utils/text_strings.dart +++ b/lib/utils/text_strings.dart @@ -83,7 +83,7 @@ class TextStrings { String addContactSearch = 'Search atSign'; String contactSearchResults = 'Search Results'; String addContact = 'Add Contact'; - String addtoContact = 'Add to Contacts'; + String addToContact = 'Add to Contacts'; // buttons text String buttonStart = 'Start'; @@ -140,7 +140,7 @@ class TextStrings { //my files String myFiles = 'My Files'; - String recents = 'Recents'; + String recent = 'Recents'; String photos = 'Photos'; String videos = 'Videos'; String audio = 'Audio'; @@ -150,7 +150,7 @@ class TextStrings { // trusted sender screens String trustedSenders = 'Trusted Senders'; - String selectperson = 'Select Person'; + String selectPerson = 'Select Person'; String noTrustedSenders = 'No Trusted Senders'; String addTrustedSender = 'Would you like to add people to your trusted senders list?'; @@ -163,7 +163,7 @@ class TextStrings { String groups = 'Groups'; String downloadAllFiles = 'Download all files'; String downloadFailed = 'Download failed, please try again.'; - String fileDownloadd = 'File(s) downloaded'; + String fileDownload = 'File(s) downloaded'; String noGroups = 'No Groups'; String newGroup = 'New Group'; String addGroups = 'Would you like to create a group'; @@ -186,7 +186,7 @@ class TextStrings { String websiteTitle = 'Atsign'; //error texts - String errorOccured = 'An Error Occurred'; + String errorOccurred = 'An Error Occurred'; // File choice dialog texts String fileChoiceQuestion = 'What would you like to send?'; @@ -203,11 +203,11 @@ class TextStrings { 'image.persona', ]; - String unknownAtsign(String atSign) => + String unknownAtSign(String atSign) => '$atSign is not found. Please check and try again.'; - String atsignExists(String atSign) => '$atSign already exists'; - String emptyAtsign = 'Please enter an atSign'; + String atSignExists(String atSign) => '$atSign already exists'; + String emptyAtSign = 'Please enter an atSign'; // sort strings static const String SORT_NAME = 'Sort By Name'; @@ -236,7 +236,7 @@ class TextStrings { String others = 'others'; // desktop text constants - String addNewAtsign = 'add_new_atsign'; + String addNewAtSign = 'add_new_atsign'; String saveBackupKey = 'save_backup_key'; String contactSelectionConfirmation = 'Your contact selection will be cleared if you leave this screen. Would you like to continue with your new action?'; @@ -245,7 +245,7 @@ class TextStrings { String selectedFiles = 'Selected files'; // Desktop download all files - String recievedFileDownloadMsg = + String receivedFileDownloadMsg = 'All the files you have received will be downloaded in the folder you select.'; String selectedDownloadFolder = 'Selected download folder: '; static const String selectDownloadFolder = 'Select download folder'; @@ -265,7 +265,7 @@ class TextStrings { String overWriteMsg = '\nDo you want to overwrite them?'; // Desktop sent file details - String successfullyTransfered = 'Successfully transfered'; + String successfullyTransfer = 'Successfully transfered'; String file_s = 'File(s) . '; // Desktop transfer overlapping @@ -340,13 +340,13 @@ class TextStrings { String to = 'to'; //New UI Setting Screen - String switchatSign = 'Switch atSign'; - String switchatSignSubtitle = 'Toggle between your atSigns'; + String switchAtSign = 'Switch atSign'; + String switchAtSignSubtitle = 'Toggle between your atSigns'; String backUpKeys = 'Backup Your Keys'; String backUpKeysSubtitle = "Save a Pair of your atKeys"; String contactUs = 'Contact Us'; - String deleteAtsigns = 'Remove Your Key'; - String deleteAtsignsSubtitle = 'Delete your active atkey'; + String deleteAtSigns = 'Remove Your Key'; + String deleteAtSignsSubtitle = 'Delete your active atkey'; String blockedAtSign = 'Blocked Contacts'; String blockedAtSignSubtitle = 'View list of blocked atSign'; diff --git a/lib/utils/theme.dart b/lib/utils/theme.dart index 5317be25..2a40936f 100644 --- a/lib/utils/theme.dart +++ b/lib/utils/theme.dart @@ -12,7 +12,6 @@ class Themes { brightness: Brightness.light, primaryColor: ColorConstants.desktopPrimary, primaryColorDark: ColorConstants.raisinBlack, - backgroundColor: getBackgroundColor(highlightColor), canvasColor: Colors.white, highlightColor: highlightColor, scaffoldBackgroundColor: ColorConstants.scaffoldBackgroundColor, @@ -21,6 +20,7 @@ class Themes { colorScheme: ThemeData.dark().colorScheme.copyWith( brightness: Brightness.light, primary: ColorConstants.desktopPrimary, + background: getBackgroundColor(highlightColor), ), ); } diff --git a/lib/view_models/base_model.dart b/lib/view_models/base_model.dart index 709255fb..8dabf481 100644 --- a/lib/view_models/base_model.dart +++ b/lib/view_models/base_model.dart @@ -3,19 +3,15 @@ import 'package:flutter/material.dart'; class BaseModel with ChangeNotifier { Map status = {'main': Status.Idle}; Map error = {}; + setStatus(String function, Status _status) { this.status[function] = _status; notifyListeners(); } setError(String function, String _error, [Status? _status]) { - if (_error != null) { - error[function] = _error; - status[function] = Status.Error; - } else { - this.error[function] = null; - this.status[function] = _status ?? Status.Idle; - } + error[function] = _error; + status[function] = Status.Error; notifyListeners(); } @@ -27,19 +23,18 @@ class BaseModel with ChangeNotifier { // used while fetching the count bool isCountLoading = true; + // used for pagination calculation int? pageNumber; + // used while fetching next page bool isNextPageLoading = true; + // used for storing the response body var data; + // used for displaying the exceptions during API calls String? errorMessage; - // for search screen loader - // bool isPostLoading = true; - // bool isUserLoading = true; - // bool hasError = false; - // bool netwotkIssue = false; } enum Status { Loading, Done, Error, Idle } diff --git a/lib/view_models/file_download_checker.dart b/lib/view_models/file_download_checker.dart index f72e06f8..c375c7a9 100644 --- a/lib/view_models/file_download_checker.dart +++ b/lib/view_models/file_download_checker.dart @@ -11,11 +11,11 @@ import 'history_provider.dart'; class FileDownloadChecker extends BaseModel { FileDownloadChecker(); - bool undownloadedFilesExist = false; + bool unDownloadedFilesExist = false; HistoryProvider? historyProvider; late FileTransfer receivedHistory; - void checkForUndownloadedFiles() async { + void checkForUnDownloadedFiles() async { if (historyProvider == null) { historyProvider = Provider.of( NavService.navKey.currentContext!, @@ -30,14 +30,14 @@ class FileDownloadChecker extends BaseModel { var _isFilesAvailableOffline = await _isFilesAlreadyDownloaded(value.sender); if (!_isFilesAvailableOffline) { - undownloadedFilesExist = true; + unDownloadedFilesExist = true; notifyListeners(); return; } } } - undownloadedFilesExist = false; + unDownloadedFilesExist = false; notifyListeners(); } diff --git a/lib/view_models/file_transfer_provider.dart b/lib/view_models/file_transfer_provider.dart index bdd092b3..669e21e4 100644 --- a/lib/view_models/file_transfer_provider.dart +++ b/lib/view_models/file_transfer_provider.dart @@ -5,7 +5,6 @@ import 'package:at_common_flutter/at_common_flutter.dart'; import 'package:at_contact/at_contact.dart'; import 'package:at_contacts_group_flutter/at_contacts_group_flutter.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; -import 'package:atsign_atmosphere_pro/data_models/file_transfer_object.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer_status.dart'; import 'package:atsign_atmosphere_pro/routes/route_names.dart'; import 'package:atsign_atmosphere_pro/screens/common_widgets/permission_dialog.dart'; @@ -47,7 +46,7 @@ class FileTransferProvider extends BaseModel { List? _sharedFiles; FilePickerResult? result; PlatformFile? file; - FLUSHBAR_STATUS? flushbarStatus; + FlushBarStatus? flushBarStatus; List selectedFiles = []; List selectedContacts = []; List transferStatus = []; @@ -59,11 +58,11 @@ class FileTransferProvider extends BaseModel { List temporaryContactList = []; bool hasSelectedFilesChanged = false, scrollToBottom = false; - final _flushBarStream = StreamController.broadcast(); + final _flushBarStream = StreamController.broadcast(); - Stream get flushBarStatusStream => _flushBarStream.stream; + Stream get flushBarStatusStream => _flushBarStream.stream; - StreamSink get flushBarStatusSink => _flushBarStream.sink; + StreamSink get flushBarStatusSink => _flushBarStream.sink; FileHistory? _selectedFileHistory; @@ -232,7 +231,7 @@ class FileTransferProvider extends BaseModel { Future sendFileWithFileBin( List selectedFiles, List contactList, {String? groupName, String? notes}) async { - flushBarStatusSink.add(FLUSHBAR_STATUS.SENDING); + flushBarStatusSink.add(FlushBarStatus.SENDING); var notifProvider = Provider.of( NavService.navKey.currentContext!, listen: false); @@ -276,7 +275,7 @@ class FileTransferProvider extends BaseModel { _files.map((File e) => FileData(name: e.path, size: 0)).toList(), atSigns: _atSigns, ), - FLUSHBAR_STATUS.SENDING, + FlushBarStatus.SENDING, ); var uploadResult = await FileTransferService.getInstance().uploadFile( @@ -295,18 +294,18 @@ class FileTransferProvider extends BaseModel { _historyProvider.changeIsUpcomingEvent(); // checking if everyone received the notification or not. - for (var atsignStatus in uploadResult.entries) { - if (atsignStatus.value.sharedStatus != null && - !atsignStatus.value.sharedStatus!) { + for (var atSignStatus in uploadResult.entries) { + if (atSignStatus.value.sharedStatus != null && + !atSignStatus.value.sharedStatus!) { fileUploadProvider.removeSentFileProgress(); setStatus(SEND_FILES, Status.Error); setError( SEND_FILES, ExceptionService.instance.notifyExceptions( - atsignStatus.value.atClientException ?? Exception(), + atSignStatus.value.atClientException ?? Exception(), ), ); - flushBarStatusSink.add(FLUSHBAR_STATUS.FAILED); + flushBarStatusSink.add(FlushBarStatus.FAILED); await showRetrySending(); shareStatus = false; } @@ -320,26 +319,26 @@ class FileTransferProvider extends BaseModel { ); notifProvider.updateCurrentFileShareStatus( null, - FLUSHBAR_STATUS.DONE, + FlushBarStatus.DONE, ); notifProvider.addRecentNotifications(fileHistory); fileUploadProvider.removeSentFileProgress(); - flushBarStatusSink.add(FLUSHBAR_STATUS.DONE); + flushBarStatusSink.add(FlushBarStatus.DONE); setStatus(SEND_FILES, Status.Done); return shareStatus; } catch (e) { fileUploadProvider.removeSentFileProgress(); notifProvider.updateCurrentFileShareStatus( null, - FLUSHBAR_STATUS.FAILED, + FlushBarStatus.FAILED, ); setStatus(SEND_FILES, Status.Error); setError( SEND_FILES, 'Something went wrong', ); - flushBarStatusSink.add(FLUSHBAR_STATUS.FAILED); + flushBarStatusSink.add(FlushBarStatus.FAILED); await showRetrySending(); } } @@ -427,12 +426,12 @@ class FileTransferProvider extends BaseModel { } try { - flushBarStatusSink.add(FLUSHBAR_STATUS.SENDING); + flushBarStatusSink.add(FlushBarStatus.SENDING); // reuploading files for (var fileData in _fileHistory.fileDetails!.files!) { if (fileData.isUploaded != null && !fileData.isUploaded!) { - await reuploadFiles([fileData], 0, _fileHistory); + await reUploadFiles([fileData], 0, _fileHistory); } } @@ -449,19 +448,19 @@ class FileTransferProvider extends BaseModel { for (var element in _fileHistory.sharedWith!) { if (element.isNotificationSend != null && !element.isNotificationSend!) { - flushBarStatusSink.add(FLUSHBAR_STATUS.FAILED); + flushBarStatusSink.add(FlushBarStatus.FAILED); return false; } } - flushBarStatusSink.add(FLUSHBAR_STATUS.DONE); + flushBarStatusSink.add(FlushBarStatus.DONE); return true; } catch (e) { - flushBarStatusSink.add(FLUSHBAR_STATUS.FAILED); + flushBarStatusSink.add(FlushBarStatus.FAILED); return false; } } - reuploadFiles( + reUploadFiles( List _filesList, int _index, FileHistory _sentHistory) async { setStatus(RETRY_NOTIFICATION, Status.Loading); Provider.of(NavService.navKey.currentContext!, @@ -604,4 +603,4 @@ class FileTransferProvider extends BaseModel { } } -enum FLUSHBAR_STATUS { IDLE, SENDING, FAILED, DONE } +enum FlushBarStatus { IDLE, SENDING, FAILED, DONE } diff --git a/lib/view_models/history_provider.dart b/lib/view_models/history_provider.dart index ba092d13..7dc58740 100644 --- a/lib/view_models/history_provider.dart +++ b/lib/view_models/history_provider.dart @@ -8,7 +8,6 @@ import 'package:atsign_atmosphere_pro/data_models/file_entity.dart'; import 'package:atsign_atmosphere_pro/data_models/file_modal.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer.dart'; import 'package:atsign_atmosphere_pro/data_models/file_transfer_object.dart'; -import 'package:atsign_atmosphere_pro/desktop_screens/desktop_my_files/widgets/desktop_recent.dart'; import 'package:atsign_atmosphere_pro/services/backend_service.dart'; import 'package:atsign_atmosphere_pro/services/exception_service.dart'; import 'package:atsign_atmosphere_pro/services/file_transfer_service.dart'; @@ -26,7 +25,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'package:atsign_atmosphere_pro/services/notification_service.dart' - as notificationService; + as notification_service; import 'trusted_sender_view_model.dart'; class HistoryProvider extends BaseModel { @@ -74,7 +73,6 @@ class HistoryProvider extends BaseModel { sentDocument = []; List recentFile = []; - List desktopTabs = [DesktopRecents()]; Map sendFileHistory = {'history': []}; String? app_lifecycle_state; HistoryType typeSelected = HistoryType.received; @@ -261,25 +259,20 @@ class HistoryProvider extends BaseModel { // checking, if new keys are available to show in sent history AtClient atClient = AtClientManager.getInstance().atClient; - List sentFileAtkeys = await atClient.getAtKeys( + List sentFileAtKeys = await atClient.getAtKeys( regex: MixedConstants.FILE_TRANSFER_KEY, sharedBy: atClient.getCurrentAtSign(), ); - sentFileAtkeys.retainWhere( + sentFileAtKeys.retainWhere( (element) => !element.key! .contains(MixedConstants.FILE_TRANSFER_ACKNOWLEDGEMENT) && compareAtSign(element.sharedBy!, atClient.getCurrentAtSign()!), ); - bool isNewKeyAvailable = false; - - sentFileAtkeys.forEach((AtKey atkey) { - if (individualSentFileId[atkey.key] == null) { - isNewKeyAvailable = true; - } - individualSentFileId[atkey.key] = true; + sentFileAtKeys.forEach((AtKey atKey) { + individualSentFileId[atKey.key] = true; }); // if (!isNewKeyAvailable) { @@ -302,7 +295,7 @@ class HistoryProvider extends BaseModel { return AtValue(); }); - if (keyValue != null && keyValue.value != null) { + if (keyValue.value != null) { try { Map historyFile = json.decode((keyValue.value) as String) as Map; sendFileHistory['history'] = historyFile['history']; @@ -311,7 +304,7 @@ class HistoryProvider extends BaseModel { (value) { FileHistory filesModel = FileHistory.fromJson(value); // checking for download acknowledged - filesModel.sharedWith = checkIfileDownloaded( + filesModel.sharedWith = checkIfFileDownloaded( filesModel.sharedWith, filesModel.fileTransferObject!.transferId, ); @@ -374,20 +367,20 @@ class HistoryProvider extends BaseModel { getIndividuallySavedSentFileItems() async { AtClient atClient = AtClientManager.getInstance().atClient; - List sentFileAtkeys = await atClient.getAtKeys( + List sentFileAtKeys = await atClient.getAtKeys( regex: MixedConstants.FILE_TRANSFER_KEY, sharedBy: atClient.getCurrentAtSign(), ); - sentFileAtkeys.retainWhere( + sentFileAtKeys.retainWhere( (element) => !element.key! .contains(MixedConstants.FILE_TRANSFER_ACKNOWLEDGEMENT) && compareAtSign(element.sharedBy!, atClient.getCurrentAtSign()!), ); - await Future.forEach(sentFileAtkeys, (AtKey atkey) async { - AtValue atvalue = + await Future.forEach(sentFileAtKeys, (AtKey atkey) async { + AtValue atValue = await AtClientManager.getInstance().atClient.get(atkey).catchError( (e) { print("Exception in getting atValue: $e"); @@ -397,10 +390,10 @@ class HistoryProvider extends BaseModel { }, ); - if (atvalue != null && atvalue.value != null) { + if (atValue.value != null) { try { FileHistory fileHistory = FileHistory.fromJson( - jsonDecode(atvalue.value), + jsonDecode(atValue.value), ); individualSentFileId[fileHistory.fileDetails!.key] = true; tempSentHistory.insert(0, fileHistory); @@ -441,7 +434,7 @@ class HistoryProvider extends BaseModel { .sort((a, b) => b.fileDetails!.date!.compareTo(a.fileDetails!.date!)); } - List? checkIfileDownloaded( + List? checkIfFileDownloaded( List? shareStatus, String transferId) { if (downloadedFileAcknowledgement[transferId] != null) { for (int i = 0; i < shareStatus!.length; i++) { @@ -538,10 +531,10 @@ class HistoryProvider extends BaseModel { downloadAcknowledgement.transferId] != null) { downloadedFileAcknowledgement[downloadAcknowledgement.transferId]![ - formatAtsign(atKey.sharedBy!)] = true; + formatAtSign(atKey.sharedBy!)] = true; } else { downloadedFileAcknowledgement[downloadAcknowledgement.transferId] = - {formatAtsign(atKey.sharedBy!): true}; + {formatAtSign(atKey.sharedBy!): true}; } } } catch (e) { @@ -629,7 +622,7 @@ class HistoryProvider extends BaseModel { FileTransferObject fileTransferObject = FileTransferObject.fromJson((jsonDecode(decodedMsg)))!; FileTransfer filesModel = - convertFiletransferObjectToFileTransfer(fileTransferObject); + convertFileTransferObjectToFileTransfer(fileTransferObject); filesModel.sender = sharedBy; //check id data with same key already present @@ -689,7 +682,7 @@ class HistoryProvider extends BaseModel { fileTransferObject, ); - Provider.of( + Provider.of( NavService.navKey.currentContext!, listen: false) .addRecentNotifications(fileHistory); @@ -798,10 +791,10 @@ class HistoryProvider extends BaseModel { } for (var atKey in fileTransferAtkeys) { - var isCurrentAtsign = compareAtSign( + var isCurrentAtSign = compareAtSign( atKey.sharedBy!, BackendService.getInstance().currentAtSign!); - if (!isCurrentAtsign && !checkRegexFromBlockedAtsign(atKey.sharedBy!)) { + if (!isCurrentAtSign && !checkRegexFromBlockedAtsign(atKey.sharedBy!)) { receivedItemsId[atKey.key] = true; AtValue atvalue = @@ -817,7 +810,7 @@ class HistoryProvider extends BaseModel { FileTransferObject fileTransferObject = FileTransferObject.fromJson(jsonDecode(atvalue.value))!; FileTransfer filesModel = - convertFiletransferObjectToFileTransfer(fileTransferObject); + convertFileTransferObjectToFileTransfer(fileTransferObject); filesModel.sender = atKey.sharedBy!; if ((listFileTypeSelect ?? []).isNotEmpty) { @@ -861,20 +854,14 @@ class HistoryProvider extends BaseModel { tempReceivedFiles.insert(0, file); } } else { - if (filesModel.key != null) { - tempReceivedHistoryLogs.insert(0, filesModel); - } - + tempReceivedHistoryLogs.insert(0, filesModel); final file = FileHistory( filesModel, [], HistoryType.received, fileTransferObject, ); - - if (filesModel.key != null) { - tempReceivedFiles.insert(0, file); - } + tempReceivedFiles.insert(0, file); } } catch (e) { print('error in getAllFileTransferData file model conversion: $e'); @@ -943,7 +930,7 @@ class HistoryProvider extends BaseModel { } } - getrecentHistoryFiles() async { + getRecentHistoryFiles() async { // finding last 15 received files data for recent tab setStatus(RECENT_HISTORY, Status.Loading); try { @@ -1006,7 +993,7 @@ class HistoryProvider extends BaseModel { return isBlocked; } - FileTransfer convertFiletransferObjectToFileTransfer( + FileTransfer convertFileTransferObjectToFileTransfer( FileTransferObject fileTransferObject) { List files = []; fileTransferObject.fileStatus.forEach((fileDetail) { @@ -1059,12 +1046,12 @@ class HistoryProvider extends BaseModel { FileHistory convertFileTransferObjectToFileHistory( FileTransferObject fileTransferObject, - List sharedWithAtsigns, + List sharedWithAtSigns, Map fileShareResult, { String? groupName, }) { List files = []; - var sthareStatus = []; + var shareStatus = []; fileTransferObject.fileStatus.forEach((fileDetail) { files.add(FileData( @@ -1081,14 +1068,14 @@ class HistoryProvider extends BaseModel { fileEncryptionKey: fileTransferObject.fileEncryptionKey, ); - sharedWithAtsigns.forEach((atsign) { - sthareStatus + sharedWithAtSigns.forEach((atsign) { + shareStatus .add(ShareStatus(atsign, fileShareResult[atsign]!.sharedStatus)); }); return FileHistory( fileTransfer, - sthareStatus, + shareStatus, HistoryType.send, fileTransferObject, groupName: groupName, @@ -1118,7 +1105,7 @@ class HistoryProvider extends BaseModel { Provider.of(NavService.navKey.currentContext!, listen: false) .removeReceiveProgressItem(transferId); - SnackbarService().showSnackbar( + SnackBarService().showSnackBar( NavService.navKey.currentContext!, e.toString(), bgColor: ColorConstants.redAlert, @@ -1128,7 +1115,7 @@ class HistoryProvider extends BaseModel { Provider.of(NavService.navKey.currentContext!, listen: false) - .checkForUndownloadedFiles(); + .checkForUnDownloadedFiles(); Provider.of(NavService.navKey.currentContext!, listen: false) @@ -1171,25 +1158,19 @@ class HistoryProvider extends BaseModel { } notifyListeners(); - var files = - await _downloadSingleFileFromWeb(transferId, sharedBy, fileName); + await _downloadSingleFileFromWeb(transferId, sharedBy, fileName); allFilesHistory[index].fileDetails?.files![_fileIndex!].isDownloading = false; Provider.of(NavService.navKey.currentContext!, listen: false) - .checkForUndownloadedFiles(); + .checkForUnDownloadedFiles(); - if (files is List) { - await Provider.of(NavService.navKey.currentContext!, - listen: false) - .saveNewDataInMyFiles(allFilesHistory[index].fileDetails!); - setStatus(DOWNLOAD_FILE, Status.Done); - return true; - } else { - setStatus(DOWNLOAD_FILE, Status.Done); - return false; - } + await Provider.of(NavService.navKey.currentContext!, + listen: false) + .saveNewDataInMyFiles(allFilesHistory[index].fileDetails!); + setStatus(DOWNLOAD_FILE, Status.Done); + return true; } catch (e) { print('error in downloading file: $e'); Provider.of(NavService.navKey.currentContext!, @@ -1208,9 +1189,6 @@ class HistoryProvider extends BaseModel { downloadPath ??= await MixedConstants.getFileDownloadLocation( sharedBy: sharedByAtSign, ); - if (downloadPath == null) { - throw Exception('downloadPath not found'); - } FileTransferObject? fileTransferObject; @@ -1326,37 +1304,37 @@ class HistoryProvider extends BaseModel { } updateSendingNotificationStatus( - String transferId, String atsign, bool isSending) { + String transferId, String atSign, bool isSending) { var index = sentHistory.indexWhere( (element) => element.fileTransferObject!.transferId == transferId); if (index != -1) { - var atsignIndex = sentHistory[index] + var atSignIndex = sentHistory[index] .sharedWith! - .indexWhere((element) => element.atsign == atsign); - if (atsignIndex != -1) { - sentHistory[index].sharedWith![atsignIndex].isSendingNotification = + .indexWhere((element) => element.atsign == atSign); + if (atSignIndex != -1) { + sentHistory[index].sharedWith![atSignIndex].isSendingNotification = isSending; } } notifyListeners(); } - bool compareAtSign(String atsign1, String atsign2) { - if (atsign1[0] != '@') { - atsign1 = '@' + atsign1; + bool compareAtSign(String atSign1, String atSign2) { + if (atSign1[0] != '@') { + atSign1 = '@' + atSign1; } - if (atsign2[0] != '@') { - atsign2 = '@' + atsign2; + if (atSign2[0] != '@') { + atSign2 = '@' + atSign2; } - return atsign1.toLowerCase() == atsign2.toLowerCase() ? true : false; + return atSign1.toLowerCase() == atSign2.toLowerCase() ? true : false; } - String formatAtsign(String atsign) { - if (atsign[0] != '@') { - atsign = '@' + atsign; + String formatAtSign(String atSign) { + if (atSign[0] != '@') { + atSign = '@' + atSign; } - return atsign; + return atSign; } Future updateSentHistory() async { @@ -1462,22 +1440,22 @@ class HistoryProvider extends BaseModel { setStatus(RECEIVED_HISTORY, Status.Loading); } - List fileTransferAtkeys = + List fileTransferAtKeys = await AtClientManager.getInstance().atClient.getAtKeys( regex: MixedConstants.FILE_TRANSFER_KEY, ); - fileTransferAtkeys.retainWhere((element) => + fileTransferAtKeys.retainWhere((element) => !element.key!.contains(MixedConstants.FILE_TRANSFER_ACKNOWLEDGEMENT) && receivedItemsId[element.key] != true); - for (var atKey in fileTransferAtkeys) { - var isCurrentAtsign = compareAtSign( + for (var atKey in fileTransferAtKeys) { + var isCurrentAtSign = compareAtSign( atKey.sharedBy!, BackendService.getInstance().currentAtSign!); - if (!isCurrentAtsign && !checkRegexFromBlockedAtsign(atKey.sharedBy!)) { + if (!isCurrentAtSign && !checkRegexFromBlockedAtsign(atKey.sharedBy!)) { receivedItemsId[atKey.key] = true; - AtValue atvalue = await AtClientManager.getInstance() + AtValue atValue = await AtClientManager.getInstance() .atClient .get(atKey) // ignore: return_of_invalid_type_from_catch_error @@ -1488,12 +1466,12 @@ class HistoryProvider extends BaseModel { return AtValue(); }); - if (atvalue.value != null) { + if (atValue.value != null) { try { FileTransferObject fileTransferObject = - FileTransferObject.fromJson(jsonDecode(atvalue.value))!; + FileTransferObject.fromJson(jsonDecode(atValue.value))!; FileTransfer filesModel = - convertFiletransferObjectToFileTransfer(fileTransferObject); + convertFileTransferObjectToFileTransfer(fileTransferObject); filesModel.sender = atKey.sharedBy!; receivedHistoryLogs.insert(0, filesModel); @@ -1510,15 +1488,4 @@ class HistoryProvider extends BaseModel { setStatus(RECEIVED_HISTORY, Status.Done); } - -// save file in gallery function is not in use as of now. -// saveFilesInGallery(List files) async { -// for (var file in files) { -// if (FileTypes.IMAGE_TYPES.contains(file.path.split('.').last) || -// FileTypes.VIDEO_TYPES.contains(file.path.split('.').last)) { -// // saving image,video in gallery. -// await ImageGallerySaver.saveFile(file.path); -// } -// } -// } } diff --git a/lib/view_models/my_files_provider.dart b/lib/view_models/my_files_provider.dart index ec9b2699..36a64724 100644 --- a/lib/view_models/my_files_provider.dart +++ b/lib/view_models/my_files_provider.dart @@ -24,7 +24,7 @@ import 'package:atsign_atmosphere_pro/utils/file_types.dart'; import 'package:atsign_atmosphere_pro/view_models/base_model.dart'; import 'package:flutter/material.dart'; -import '../screens/my_files/widgets/recents.dart'; +import '../screens/my_files/widgets/recent.dart'; class MyFilesProvider extends BaseModel { var myFiles = []; @@ -49,7 +49,7 @@ class MyFilesProvider extends BaseModel { String FETCH_AND_SORT = "fetch_and_sort"; String fileSearchText = ''; - List tabs = [Recents()]; + List tabs = [Recent()]; Map> filesByAlpha = {}; FileType? typeSelected; @@ -70,7 +70,7 @@ class MyFilesProvider extends BaseModel { recentFile = []; receivedUnknown = []; allFiles = []; - tabs = [Recents()]; + tabs = [Recent()]; tabNames = ['Recents']; } @@ -106,18 +106,18 @@ class MyFilesProvider extends BaseModel { var myFilesAtKeys = await atClient.getAtKeys(regex: MixedConstants.MY_FILES_KEY); - await Future.forEach(myFilesAtKeys, (AtKey atkey) async { - AtValue atvalue = await atClient.get(atkey).catchError( + await Future.forEach(myFilesAtKeys, (AtKey atKey) async { + AtValue atValue = await atClient.get(atKey).catchError( (e) { print("Exception in getting my files atValue: $e"); return AtValue(); }, ); - if (atvalue.value != null) { + if (atValue.value != null) { try { FileTransfer fileTransferObject = - FileTransfer.fromJson(jsonDecode(atvalue.value)); + FileTransfer.fromJson(jsonDecode(atValue.value)); myFilesRecord.insert(0, fileTransferObject); } catch (e) { @@ -141,17 +141,17 @@ class MyFilesProvider extends BaseModel { await atClient.getAtKeys(regex: MixedConstants.MY_FILES_KEY); await Future.forEach(myFilesAtKeys, (AtKey atkey) async { - AtValue atvalue = await atClient.get(atkey).catchError( + AtValue atValue = await atClient.get(atkey).catchError( (e) { print("Exception in getting my files atValue: $e"); return AtValue(); }, ); - if (atvalue.value != null) { + if (atValue.value != null) { try { FileTransfer fileTransferObject = - FileTransfer.fromJson(jsonDecode(atvalue.value)); + FileTransfer.fromJson(jsonDecode(atValue.value)); myFilesRecord.insert(0, fileTransferObject); } catch (e) { @@ -182,20 +182,20 @@ class MyFilesProvider extends BaseModel { recentFile = []; await Future.forEach(allFiles, (FilesDetail file) async { - var fileExtention = file.fileName?.split('.').last ?? ""; - if (FileTypes.AUDIO_TYPES.contains(fileExtention)) { + var fileExtension = file.fileName?.split('.').last ?? ""; + if (FileTypes.AUDIO_TYPES.contains(fileExtension)) { int index = receivedAudio .indexWhere((element) => element.fileName == file.fileName); if (index == -1) { receivedAudio.add(file); } - } else if (FileTypes.VIDEO_TYPES.contains(fileExtention)) { + } else if (FileTypes.VIDEO_TYPES.contains(fileExtension)) { int index = receivedVideos .indexWhere((element) => element.fileName == file.fileName); if (index == -1) { receivedVideos.add(file); } - } else if (FileTypes.IMAGE_TYPES.contains(fileExtention)) { + } else if (FileTypes.IMAGE_TYPES.contains(fileExtension)) { int index = receivedPhotos .indexWhere((element) => element.fileName == file.fileName); if (index == -1) { @@ -208,16 +208,16 @@ class MyFilesProvider extends BaseModel { receivedPhotos.add(file); // } } - } else if (FileTypes.TEXT_TYPES.contains(fileExtention) || - FileTypes.PDF_TYPES.contains(fileExtention) || - FileTypes.WORD_TYPES.contains(fileExtention) || - FileTypes.EXEL_TYPES.contains(fileExtention)) { + } else if (FileTypes.TEXT_TYPES.contains(fileExtension) || + FileTypes.PDF_TYPES.contains(fileExtension) || + FileTypes.WORD_TYPES.contains(fileExtension) || + FileTypes.EXEL_TYPES.contains(fileExtension)) { int index = receivedDocument .indexWhere((element) => element.fileName == file.fileName); if (index == -1) { receivedDocument.add(file); } - } else if (FileTypes.ZIP_TYPES.contains(fileExtention)) { + } else if (FileTypes.ZIP_TYPES.contains(fileExtension)) { int index = receivedZip .indexWhere((element) => element.fileName == file.fileName); if (index == -1) { @@ -278,11 +278,6 @@ class MyFilesProvider extends BaseModel { message: fileData.notes, fileTransferId: fileData.key); - // check if file exists - // File tempFile = File(fileDetail.filePath!); - // bool isFileDownloaded = await tempFile.exists(); - - // if (isFileDownloaded) { if (FileTypes.AUDIO_TYPES.contains(fileExtension)) { int index = receivedAudio.indexWhere( (element) => element.fileName == fileDetail.fileName); @@ -299,14 +294,7 @@ class MyFilesProvider extends BaseModel { int index = receivedPhotos.indexWhere( (element) => element.fileName == fileDetail.fileName); if (index == -1) { - // checking is photo is downloaded or not - //if photo is downloaded then only it's shown in my files screen - // File file = File(fileDetail.filePath!); - // bool isFileDownloaded = await file.exists(); - - // if (isFileDownloaded) { receivedPhotos.add(fileDetail); - // } } } else if (FileTypes.TEXT_TYPES.contains(fileExtension) || FileTypes.PDF_TYPES.contains(fileExtension) || @@ -363,7 +351,7 @@ class MyFilesProvider extends BaseModel { isDesktop = true; } tabs = []; - tabs = [isDesktop ? DesktopRecents() : Recents()]; + tabs = [isDesktop ? DesktopRecent() : Recent()]; try { setStatus(POPULATE_TABS, Status.Loading); @@ -588,44 +576,9 @@ class MyFilesProvider extends BaseModel { notifyListeners(); } - /// loops over receivedHistoryData and checks if my files is saved for a particular item. - // saveMyFilesItems(List receivedHistoryLogs) async { - // var _atClient = AtClientManager.getInstance().atClient; - // var keyStore = _atClient.getLocalSecondary()!.keyStore!; - // bool _isNewKeyAdded = false; - - // for (int i = 0; i < receivedHistoryLogs.length; i++) { - // String transferUniqueId = receivedHistoryLogs[i] - // .key - // .replaceAll(MixedConstants.FILE_TRANSFER_KEY, ''); - // var fileAtKey = formMyFileAtKey(transferUniqueId); - - // print( - // 'transferId : ${transferUniqueId}: ${_atClient.getLocalSecondary()!.keyStore!.isKeyExists(fileAtKey.key!)}'); - // if (!keyStore.isKeyExists(fileAtKey.key!)) { - // _isNewKeyAdded = true; - // var res = await _atClient.put( - // fileAtKey, - // jsonEncode(receivedHistoryLogs[i].toJson()), - // ); - - // if (res) { - // myFiles.insert(0, receivedHistoryLogs[i]); - // } - - // print('res: ${res}'); - // } - // } - - // if (_isNewKeyAdded) { - // await sortFiles(); - // populateTabs(); - // } - // } - saveNewDataInMyFiles(FileTransfer fileTransfer) async { - for (FileTransfer myfile in myFiles) { - if (myfile.key == fileTransfer.key) { + for (FileTransfer myFile in myFiles) { + if (myFile.key == fileTransfer.key) { return; } } @@ -719,7 +672,7 @@ class MyFilesProvider extends BaseModel { bool res = false; if (myFiles[myFileIndex].files!.isEmpty) { - res = await deletMyFileRecord(fileTransferId); + res = await deleteMyFileRecord(fileTransferId); } else { res = await updateMyFilesData(myFiles[myFileIndex]); } @@ -749,7 +702,7 @@ class MyFilesProvider extends BaseModel { ..metadata!.ttr = -1; } - Future deletMyFileRecord(String fileTransferId) async { + Future deleteMyFileRecord(String fileTransferId) async { var _atClient = AtClientManager.getInstance().atClient; var myFileAtKey = formMyFileAtKey(fileTransferId); var res = await _atClient.delete(myFileAtKey); @@ -767,13 +720,13 @@ class MyFilesProvider extends BaseModel { } /// for testing only - deleteMyfilekeys() async { + deleteMyFileKeys() async { var atClient = AtClientManager.getInstance().atClient; var myFilesAtKeys = await atClient.getAtKeys(regex: MixedConstants.MY_FILES_KEY); - await Future.forEach(myFilesAtKeys, (AtKey atkey) async { - var deleted = await atClient.delete(atkey); + await Future.forEach(myFilesAtKeys, (AtKey atKey) async { + var deleted = await atClient.delete(atKey); print('deleted : ${deleted}'); }); diff --git a/lib/view_models/switch_atsign_provider.dart b/lib/view_models/switch_atsign_provider.dart index 9e537406..c7e6387b 100644 --- a/lib/view_models/switch_atsign_provider.dart +++ b/lib/view_models/switch_atsign_provider.dart @@ -1,10 +1,10 @@ import 'package:atsign_atmosphere_pro/view_models/base_model.dart'; -class SwitchAtsignProvider extends BaseModel { - SwitchAtsignProvider(); - String switchAtsign = 'switchAtsign'; +class SwitchAtSignProvider extends BaseModel { + SwitchAtSignProvider(); + String switchAtSign = 'switchAtsign'; update() { - setStatus(switchAtsign, Status.Done); + setStatus(switchAtSign, Status.Done); } } diff --git a/lib/view_models/trusted_sender_view_model.dart b/lib/view_models/trusted_sender_view_model.dart index 4afcf915..8ebb1984 100644 --- a/lib/view_models/trusted_sender_view_model.dart +++ b/lib/view_models/trusted_sender_view_model.dart @@ -7,10 +7,13 @@ import 'package:atsign_atmosphere_pro/view_models/base_model.dart'; class TrustedContactProvider extends BaseModel { TrustedContactProvider._(); + static TrustedContactProvider _instance = TrustedContactProvider._(); + factory TrustedContactProvider() => _instance; String AddTrustedContacts = 'add_trusted_contacts'; List _trustedContacts = []; + List get trustedContacts => _trustedContacts; var jsonValue; diff --git a/lib/view_models/welcome_screen_view_model.dart b/lib/view_models/welcome_screen_view_model.dart index 051c7567..d15882de 100644 --- a/lib/view_models/welcome_screen_view_model.dart +++ b/lib/view_models/welcome_screen_view_model.dart @@ -30,7 +30,7 @@ class WelcomeScreenProvider extends BaseModel { notifyListeners(); } - void _addtoContactsList(GroupContactsModel _obj) { + void _addToContactsList(GroupContactsModel _obj) { selectedContacts.add(_obj); } @@ -44,7 +44,7 @@ class WelcomeScreenProvider extends BaseModel { } for (var _obj in updatedList) { - _addtoContactsList(_obj!); + _addToContactsList(_obj!); } hasSelectedContactsChanged = true; diff --git a/test/widget_tests/common_widget_test/side_bar_backup_item_test.dart b/test/widget_tests/common_widget_test/side_bar_backup_item_test.dart deleted file mode 100644 index 902c72c1..00000000 --- a/test/widget_tests/common_widget_test/side_bar_backup_item_test.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:at_common_flutter/at_common_flutter.dart'; -import 'package:atsign_atmosphere_pro/screens/common_widgets/side_bar_backup_item.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import '../../test_material_app.dart'; - -void main() { - Widget _wrapWidgetWithMaterialApp({required Widget sideBarBackupItem}) { - return TestMaterialApp(home: Builder(builder: (BuildContext context) { - SizeConfig().init(context); - return Scaffold(drawer: sideBarBackupItem); - })); - } - - /// Functional test cases for Side bar backup item widget - group('Side bar backup item Widget Tests:', () { - final sideBarBackupItem = SideBarBackupItem( - title: 'SideBar', - leadingIcon: Icon(Icons.menu), - onPressed: () { - print('Sidebar displayed'); - }, - ); - // Test case to check text is given - testWidgets("Side bar backup item text is given", - (WidgetTester tester) async { - await tester.pumpWidget( - _wrapWidgetWithMaterialApp(sideBarBackupItem: sideBarBackupItem)); - expect(sideBarBackupItem.title, 'SideBar'); - }); - }); -}