mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-08 20:09:24 +00:00
Merge pull request #783 from cake-tech/fix-share-backup-on-ipad
Fix Share issue on iPad
This commit is contained in:
commit
db861c036e
4 changed files with 37 additions and 15 deletions
|
@ -1,10 +1,9 @@
|
|||
import 'dart:io';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/utils/share_util.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:cross_file/cross_file.dart';
|
||||
import 'package:cake_wallet/utils/show_bar.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
|
@ -110,7 +109,7 @@ class BackupPage extends BasePage {
|
|||
if (Platform.isAndroid) {
|
||||
onExportAndroid(context, backup);
|
||||
} else {
|
||||
await share(backup);
|
||||
await share(backup, context);
|
||||
}
|
||||
},
|
||||
actionLeftButton: () => Navigator.of(dialogContext).pop());
|
||||
|
@ -140,18 +139,14 @@ class BackupPage extends BasePage {
|
|||
},
|
||||
actionLeftButton: () async {
|
||||
Navigator.of(dialogContext).pop();
|
||||
await share(backup);
|
||||
await share(backup, context);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> share(BackupExportFile backup) async {
|
||||
const mimeType = 'application/*';
|
||||
Future<void> share(BackupExportFile backup, BuildContext context) async {
|
||||
final path = await backupViewModelBase.saveBackupFileLocally(backup);
|
||||
await Share.shareXFiles(<XFile>[XFile(
|
||||
path,
|
||||
name: backup.name,
|
||||
mimeType: mimeType)]);
|
||||
await ShareUtil.shareFile(filePath: path, fileName: backup.name, context: context);
|
||||
await backupViewModelBase.removeBackupFileLocally(backup);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -229,7 +229,8 @@ class DashboardPage extends BasePage {
|
|||
}
|
||||
|
||||
await Future<void>.delayed(Duration(seconds: 1));
|
||||
await showPopUp<void>(
|
||||
if (context.mounted) {
|
||||
await showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithOneAction(
|
||||
|
@ -239,6 +240,7 @@ class DashboardPage extends BasePage {
|
|||
buttonText: S.of(context).understand,
|
||||
buttonAction: () => Navigator.of(context).pop());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var needToPresentYat = false;
|
||||
|
|
|
@ -125,6 +125,7 @@ class ExceptionHandler {
|
|||
"errno = 9", // SocketException: Bad file descriptor
|
||||
"errno = 32", // SocketException: Write failed (OS Error: Broken pipe)
|
||||
"errno = 60", // SocketException: Operation timed out
|
||||
"errno = 110", // SocketException: Connection timed out
|
||||
"errno = 54", // SocketException: Connection reset by peer
|
||||
"errno = 49", // SocketException: Can't assign requested address
|
||||
"errno = 28", // OS Error: No space left on device
|
||||
|
|
|
@ -1,13 +1,37 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:cross_file/cross_file.dart';
|
||||
|
||||
class ShareUtil {
|
||||
static void share({required String text, required BuildContext context}) {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
static const _mimeType = 'application/*';
|
||||
|
||||
static void share({required String text, required BuildContext context}) {
|
||||
Share.share(
|
||||
text,
|
||||
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
|
||||
sharePositionOrigin: _sharePosition(context),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> shareFile({
|
||||
required String filePath,
|
||||
required String fileName,
|
||||
required BuildContext context,
|
||||
}) async {
|
||||
Share.shareXFiles(
|
||||
<XFile>[
|
||||
XFile(
|
||||
filePath,
|
||||
name: fileName,
|
||||
mimeType: _mimeType,
|
||||
)
|
||||
],
|
||||
sharePositionOrigin: _sharePosition(context),
|
||||
);
|
||||
}
|
||||
|
||||
static Rect? _sharePosition(BuildContext context) {
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
|
||||
return box!.localToGlobal(Offset.zero) & box.size;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue