Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
fix: share IPad crash & Telegram image format
Browse files Browse the repository at this point in the history
  • Loading branch information
reasje committed Sep 11, 2023
1 parent 488384b commit 0bd3fdd
Showing 1 changed file with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:share_plus/share_plus.dart';
import 'package:appinio_social_share/appinio_social_share.dart';
import 'package:datadashwallet/core/core.dart';
import 'package:f_logs/f_logs.dart';
Expand All @@ -25,14 +26,23 @@ class CustomerSupportPresenter extends CompletePresenter<CustomerSupportState> {
loading = true;
try {
final file = await FLog.exportLogs();
final newFile = await changeFileName(file, 'axs-wallet.log');

await _socialShare.shareToSystem(
translate('export_logs')!,
'',
filePath: newFile.path,
final newFile = await changeFileName(
file,
'axs-wallet.txt',
);

final Size size = MediaQuery.of(context!).size;

await Share.shareXFiles([
XFile(
newFile.path,
mimeType: 'text/plain',
)
],
subject: translate('export_logs'),
sharePositionOrigin:
Rect.fromLTWH(0, 0, size.width, size.height / 2));

addMessage(translate('exported_logs_successfully'));
} catch (e, s) {
addError(e, s);
Expand All @@ -41,11 +51,11 @@ class CustomerSupportPresenter extends CompletePresenter<CustomerSupportState> {
}
}

Future<File> changeFileName(File file, String newFileName) {
Future<File> changeFileName(File file, String newFileName) async {
var path = file.path;
var lastSeparator = path.lastIndexOf(Platform.pathSeparator);
var newPath = path.substring(0, lastSeparator + 1) + newFileName;
return file.rename(newPath);
return (await file.rename(newPath));
}

Future<void> loadPage() async {
Expand Down

0 comments on commit 0bd3fdd

Please sign in to comment.