mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
fix: moveBg during share
This commit is contained in:
@@ -12,6 +12,8 @@ import 'package:toolbox/locator.dart';
|
|||||||
import '../../view/widget/rebuild.dart';
|
import '../../view/widget/rebuild.dart';
|
||||||
import 'platform.dart';
|
import 'platform.dart';
|
||||||
|
|
||||||
|
final _app = locator<AppProvider>();
|
||||||
|
|
||||||
Future<bool> shareFiles(BuildContext context, List<String> filePaths) async {
|
Future<bool> shareFiles(BuildContext context, List<String> filePaths) async {
|
||||||
for (final filePath in filePaths) {
|
for (final filePath in filePaths) {
|
||||||
if (!await File(filePath).exists()) {
|
if (!await File(filePath).exists()) {
|
||||||
@@ -24,25 +26,21 @@ Future<bool> shareFiles(BuildContext context, List<String> filePaths) async {
|
|||||||
} else {
|
} else {
|
||||||
text = '${filePaths.length} ${S.of(context)!.files}';
|
text = '${filePaths.length} ${S.of(context)!.files}';
|
||||||
}
|
}
|
||||||
|
_app.setMoveBg(false);
|
||||||
// ignore: deprecated_member_use
|
// ignore: deprecated_member_use
|
||||||
await Share.shareFiles(filePaths, text: 'ServerBox -> $text');
|
await Share.shareFiles(filePaths, text: 'ServerBox -> $text');
|
||||||
|
_app.setMoveBg(true);
|
||||||
return filePaths.isNotEmpty;
|
return filePaths.isNotEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> shareText(String text) async {
|
|
||||||
final result = await Share.shareWithResult(text, subject: 'ServerBox backup');
|
|
||||||
return result.status == ShareResultStatus.success;
|
|
||||||
}
|
|
||||||
|
|
||||||
void copy(String text) {
|
void copy(String text) {
|
||||||
Clipboard.setData(ClipboardData(text: text));
|
Clipboard.setData(ClipboardData(text: text));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> pickOneFile() async {
|
Future<String?> pickOneFile() async {
|
||||||
final app = locator<AppProvider>();
|
_app.setMoveBg(false);
|
||||||
app.setMoveBg(false);
|
|
||||||
final result = await FilePicker.platform.pickFiles(type: FileType.any);
|
final result = await FilePicker.platform.pickFiles(type: FileType.any);
|
||||||
app.setMoveBg(true);
|
_app.setMoveBg(true);
|
||||||
return result?.files.single.path;
|
return result?.files.single.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user