From a473a71decd804175a8235d00ed3ae2d8735bf31 Mon Sep 17 00:00:00 2001 From: mateusz-bak <32651935+mateusz-bak@users.noreply.github.com> Date: Wed, 23 Oct 2024 22:36:45 +0200 Subject: [PATCH] chore: Temporary removed functionality from shared_storage --- lib/core/helpers/backup/backup_export.dart | 23 ++++++++------- lib/core/helpers/backup/backup_general.dart | 12 ++++---- lib/core/helpers/backup/backup_import.dart | 5 ++-- lib/core/helpers/backup/csv_export.dart | 32 +++++++++++---------- 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/lib/core/helpers/backup/backup_export.dart b/lib/core/helpers/backup/backup_export.dart index 7f68f41d..02c40794 100644 --- a/lib/core/helpers/backup/backup_export.dart +++ b/lib/core/helpers/backup/backup_export.dart @@ -8,7 +8,7 @@ import 'package:archive/archive.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:package_info_plus/package_info_plus.dart'; -import 'package:shared_storage/shared_storage.dart'; +// import 'package:shared_storage/shared_storage.dart'; // TODO: Migrate to another package import 'package:openreads/core/helpers/backup/backup.dart'; import 'package:openreads/generated/locale_keys.g.dart'; @@ -43,16 +43,17 @@ class BackupExport { try { if (Platform.isAndroid) { - final selectedUriDir = await openDocumentTree(); - if (selectedUriDir == null) { - return; - } - createFileAsBytes( - selectedUriDir, - mimeType: '', - displayName: fileName, - bytes: File(tmpBackupPath).readAsBytesSync(), - ); + // TODO: Migrate to another package + // final selectedUriDir = await openDocumentTree(); + // if (selectedUriDir == null) { + // return; + // } + // createFileAsBytes( + // selectedUriDir, + // mimeType: '', + // displayName: fileName, + // bytes: File(tmpBackupPath).readAsBytesSync(), + // ); } else if (Platform.isIOS) { String? selectedDirectory = await FilePicker.platform.getDirectoryPath(); diff --git a/lib/core/helpers/backup/backup_general.dart b/lib/core/helpers/backup/backup_general.dart index 4812db34..325a79b2 100644 --- a/lib/core/helpers/backup/backup_general.dart +++ b/lib/core/helpers/backup/backup_general.dart @@ -13,7 +13,7 @@ import 'package:openreads/ui/settings_screen/download_missing_covers_screen.dart import 'package:permission_handler/permission_handler.dart'; import 'package:openreads/generated/locale_keys.g.dart'; -import 'package:shared_storage/shared_storage.dart'; +// import 'package:shared_storage/shared_storage.dart'; // TODO: Migrate to another package class BackupGeneral { static showInfoSnackbar(String message) { @@ -132,18 +132,20 @@ class BackupGeneral { } static Future pickFileAndroid() async { - final selectedUris = await openDocument(multiple: false); + // TODO: Migrate to another package + // final selectedUris = await openDocument(multiple: false); - if (selectedUris == null || selectedUris.isEmpty) return null; + // if (selectedUris == null || selectedUris.isEmpty) return null; - return selectedUris[0]; + // return selectedUris[0]; } static Future pickFileAndGetContent() async { if (Platform.isAndroid) { final fileLocation = await pickFileAndroid(); if (fileLocation != null) { - return await getDocumentContent(fileLocation); + // TODO: Migrate to another package + // return await getDocumentContent(fileLocation); } } else if (Platform.isIOS) { FilePickerResult? result = await FilePicker.platform.pickFiles(); diff --git a/lib/core/helpers/backup/backup_import.dart b/lib/core/helpers/backup/backup_import.dart index 8b7c71b8..a6ab2ca6 100644 --- a/lib/core/helpers/backup/backup_import.dart +++ b/lib/core/helpers/backup/backup_import.dart @@ -11,7 +11,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:openreads/core/constants/constants.dart'; import 'package:openreads/logic/cubit/backup_progress_cubit.dart'; import 'package:openreads/ui/books_screen/books_screen.dart'; -import 'package:shared_storage/shared_storage.dart'; +// import 'package:shared_storage/shared_storage.dart'; // TODO: Migrate to another package import 'package:sqflite/sqflite.dart'; import 'package:path/path.dart' as path; import 'package:blurhash_dart/blurhash_dart.dart' as blurhash_dart; @@ -89,7 +89,8 @@ class BackupImport { fileLocation = await BackupGeneral.pickFileAndroid(); if (fileLocation != null) { - backupFile = await getDocumentContent(fileLocation); + // TODO: Migrate to another package + // backupFile = await getDocumentContent(fileLocation); } } else if (Platform.isIOS) { FilePickerResult? result = await FilePicker.platform.pickFiles(); diff --git a/lib/core/helpers/backup/csv_export.dart b/lib/core/helpers/backup/csv_export.dart index 5c260be8..cac4f296 100644 --- a/lib/core/helpers/backup/csv_export.dart +++ b/lib/core/helpers/backup/csv_export.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; import 'package:csv/csv.dart'; import 'package:easy_localization/easy_localization.dart'; -import 'package:shared_storage/shared_storage.dart'; +// import 'package:shared_storage/shared_storage.dart'; // TODO: Migrate to another package import 'package:openreads/core/constants/enums/enums.dart'; import 'package:openreads/core/helpers/backup/backup.dart'; @@ -27,12 +27,13 @@ class CSVExport { final filePath = '$exportPath/$fileName'; try { - createFileAsBytes( - Uri(path: filePath), - mimeType: 'text/csv', - displayName: fileName, - bytes: Uint8List.fromList(utf8.encode(csv)), - ); + // TODO: Migrate to another package + // createFileAsBytes( + // Uri(path: filePath), + // mimeType: 'text/csv', + // displayName: fileName, + // bytes: Uint8List.fromList(utf8.encode(csv)), + // ); BackupGeneral.showInfoSnackbar(LocaleKeys.export_successful.tr()); } catch (e) { @@ -49,16 +50,17 @@ class CSVExport { try { if (Platform.isAndroid) { - final selectedUriDir = await openDocumentTree(); + // TODO: Migrate to another package + // final selectedUriDir = await openDocumentTree(); - if (selectedUriDir == null) return; + // if (selectedUriDir == null) return; - createFileAsBytes( - selectedUriDir, - mimeType: 'text/csv', - displayName: fileName, - bytes: csv, - ); + // createFileAsBytes( + // selectedUriDir, + // mimeType: 'text/csv', + // displayName: fileName, + // bytes: csv, + // ); } else if (Platform.isIOS) { String? selectedDirectory = await FilePicker.platform.getDirectoryPath();