Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ios export directory #596

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ PODS:
- Flutter
- image_cropper (0.0.4):
- Flutter
- TOCropViewController (~> 2.6.1)
- TOCropViewController (~> 2.7.4)
- image_picker_ios (0.0.1):
- Flutter
- MTBBarcodeScanner (5.0.11)
Expand All @@ -77,7 +77,7 @@ PODS:
- FlutterMacOS
- SwiftProtobuf (1.24.0)
- SwiftyGif (5.4.4)
- TOCropViewController (2.6.1)
- TOCropViewController (2.7.4)
- url_launcher_ios (0.0.1):
- Flutter

Expand Down Expand Up @@ -158,23 +158,23 @@ SPEC CHECKSUMS:
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
file_picker: ce3938a0df3cc1ef404671531facef740d03f920
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_email_sender: 02d7443217d8c41483223627972bfdc09f74276b
flutter_email_sender: 10a22605f92809a11ef52b2f412db806c6082d40
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
image_cropper: a3291c624a953049bc6a02e1f8c8ceb162a24b25
image_picker_ios: b545a5f16c0fa88e3ecbbce3ed4de45567a8ec18
image_cropper: 37d40f62177c101ff4c164906d259ea2c3aa70cf
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
pointer_interceptor_ios: 9280618c0b2eeb80081a343924aa8ad756c21375
pointer_interceptor_ios: 508241697ff0947f853c061945a8b822463947c1
SDWebImage: 96e0c18ef14010b7485210e92fac888587ebb958
share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
SwiftProtobuf: bcfd2bc231cf9ae552cdc7c4e877bd3b41fe57b1
SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f
TOCropViewController: edfd4f25713d56905ad1e0b9f5be3fbe0f59c863
url_launcher_ios: 6116280ddcfe98ab8820085d8d76ae7449447586
TOCropViewController: 80b8985ad794298fb69d3341de183f33d1853654
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe

PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796

Expand Down
2 changes: 1 addition & 1 deletion ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Flutter

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
11 changes: 4 additions & 7 deletions lib/core/helpers/backup/backup_export.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:convert';
import 'dart:io';

import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';

import 'package:archive/archive.dart';
Expand Down Expand Up @@ -55,14 +54,12 @@ class BackupExport {
// bytes: File(tmpBackupPath).readAsBytesSync(),
// );
} else if (Platform.isIOS) {
String? selectedDirectory =
await FilePicker.platform.getDirectoryPath();

if (selectedDirectory == null) return;

File('$selectedDirectory/$fileName').writeAsBytesSync(
final directory = await getApplicationDocumentsDirectory();
String path = '${directory.path}/$fileName';
File(path).writeAsBytesSync(
File(tmpBackupPath).readAsBytesSync(),
);
await Share.shareXFiles([XFile(path)]);
}

BackupGeneral.showInfoSnackbar(LocaleKeys.backup_successfull.tr());
Expand Down
11 changes: 5 additions & 6 deletions lib/core/helpers/backup/csv_export.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import 'dart:convert';
import 'dart:io';

import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import 'package:csv/csv.dart';
import 'package:easy_localization/easy_localization.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';
import 'package:openreads/generated/locale_keys.g.dart';
Expand Down Expand Up @@ -62,12 +62,11 @@ class CSVExport {
// bytes: csv,
// );
} else if (Platform.isIOS) {
String? selectedDirectory =
await FilePicker.platform.getDirectoryPath();

if (selectedDirectory == null) return;
final directory = await getApplicationDocumentsDirectory();
String path = '${directory.path}/$fileName';

File('$selectedDirectory/$fileName').writeAsBytesSync(csv);
File(path).writeAsBytesSync(csv);
await Share.shareXFiles([XFile(path)]);
}

BackupGeneral.showInfoSnackbar(LocaleKeys.export_successful.tr());
Expand Down
Loading