mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-24 11:36:21 +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 'dart:io';
|
||||||
import 'package:cake_wallet/palette.dart';
|
import 'package:cake_wallet/palette.dart';
|
||||||
|
import 'package:cake_wallet/utils/share_util.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_mobx/flutter_mobx.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/utils/show_bar.dart';
|
||||||
import 'package:cake_wallet/routes.dart';
|
import 'package:cake_wallet/routes.dart';
|
||||||
import 'package:cake_wallet/generated/i18n.dart';
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
|
@ -110,7 +109,7 @@ class BackupPage extends BasePage {
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
onExportAndroid(context, backup);
|
onExportAndroid(context, backup);
|
||||||
} else {
|
} else {
|
||||||
await share(backup);
|
await share(backup, context);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actionLeftButton: () => Navigator.of(dialogContext).pop());
|
actionLeftButton: () => Navigator.of(dialogContext).pop());
|
||||||
|
@ -140,18 +139,14 @@ class BackupPage extends BasePage {
|
||||||
},
|
},
|
||||||
actionLeftButton: () async {
|
actionLeftButton: () async {
|
||||||
Navigator.of(dialogContext).pop();
|
Navigator.of(dialogContext).pop();
|
||||||
await share(backup);
|
await share(backup, context);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> share(BackupExportFile backup) async {
|
Future<void> share(BackupExportFile backup, BuildContext context) async {
|
||||||
const mimeType = 'application/*';
|
|
||||||
final path = await backupViewModelBase.saveBackupFileLocally(backup);
|
final path = await backupViewModelBase.saveBackupFileLocally(backup);
|
||||||
await Share.shareXFiles(<XFile>[XFile(
|
await ShareUtil.shareFile(filePath: path, fileName: backup.name, context: context);
|
||||||
path,
|
|
||||||
name: backup.name,
|
|
||||||
mimeType: mimeType)]);
|
|
||||||
await backupViewModelBase.removeBackupFileLocally(backup);
|
await backupViewModelBase.removeBackupFileLocally(backup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,8 @@ class DashboardPage extends BasePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
await Future<void>.delayed(Duration(seconds: 1));
|
await Future<void>.delayed(Duration(seconds: 1));
|
||||||
await showPopUp<void>(
|
if (context.mounted) {
|
||||||
|
await showPopUp<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return AlertWithOneAction(
|
return AlertWithOneAction(
|
||||||
|
@ -239,6 +240,7 @@ class DashboardPage extends BasePage {
|
||||||
buttonText: S.of(context).understand,
|
buttonText: S.of(context).understand,
|
||||||
buttonAction: () => Navigator.of(context).pop());
|
buttonAction: () => Navigator.of(context).pop());
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var needToPresentYat = false;
|
var needToPresentYat = false;
|
||||||
|
|
|
@ -125,6 +125,7 @@ class ExceptionHandler {
|
||||||
"errno = 9", // SocketException: Bad file descriptor
|
"errno = 9", // SocketException: Bad file descriptor
|
||||||
"errno = 32", // SocketException: Write failed (OS Error: Broken pipe)
|
"errno = 32", // SocketException: Write failed (OS Error: Broken pipe)
|
||||||
"errno = 60", // SocketException: Operation timed out
|
"errno = 60", // SocketException: Operation timed out
|
||||||
|
"errno = 110", // SocketException: Connection timed out
|
||||||
"errno = 54", // SocketException: Connection reset by peer
|
"errno = 54", // SocketException: Connection reset by peer
|
||||||
"errno = 49", // SocketException: Can't assign requested address
|
"errno = 49", // SocketException: Can't assign requested address
|
||||||
"errno = 28", // OS Error: No space left on device
|
"errno = 28", // OS Error: No space left on device
|
||||||
|
|
|
@ -1,13 +1,37 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
import 'package:cross_file/cross_file.dart';
|
||||||
|
|
||||||
class ShareUtil {
|
class ShareUtil {
|
||||||
static void share({required String text, required BuildContext context}) {
|
static const _mimeType = 'application/*';
|
||||||
final box = context.findRenderObject() as RenderBox?;
|
|
||||||
|
|
||||||
|
static void share({required String text, required BuildContext context}) {
|
||||||
Share.share(
|
Share.share(
|
||||||
text,
|
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