Skip to content

Commit

Permalink
chore: Temporary removed functionality from shared_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-bak committed Oct 23, 2024
1 parent 156f0f5 commit ba2048a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 33 deletions.
23 changes: 12 additions & 11 deletions lib/core/helpers/backup/backup_export.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand Down
12 changes: 7 additions & 5 deletions lib/core/helpers/backup/backup_general.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -132,18 +132,20 @@ class BackupGeneral {
}

static Future<Uri?> 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<Uint8List?> 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();
Expand Down
5 changes: 3 additions & 2 deletions lib/core/helpers/backup/backup_import.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
32 changes: 17 additions & 15 deletions lib/core/helpers/backup/csv_export.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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) {
Expand All @@ -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();
Expand Down

0 comments on commit ba2048a

Please sign in to comment.