-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
272 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v1.3.6 | ||
v1.3.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:permission_handler/permission_handler.dart'; | ||
|
||
import '../basic/commons.dart'; | ||
import '../basic/methods.dart'; | ||
import 'android_version.dart'; | ||
import 'is_pro.dart'; | ||
|
||
late String _currentDownloadAndExportTo; | ||
const _propertyName = "DownloadAndExportTo"; | ||
|
||
Future<String?> initDownloadAndExportTo() async { | ||
_currentDownloadAndExportTo = await methods.getDownloadAndExportTo(); | ||
return null; | ||
} | ||
|
||
String currentDownloadAndExportToName() { | ||
return _currentDownloadAndExportTo == "" | ||
? "未设置" | ||
: _currentDownloadAndExportTo; | ||
} | ||
|
||
String get currentDownloadAndExportTo => _currentDownloadAndExportTo; | ||
|
||
Widget downloadAndExportToSetting() { | ||
if (!isPro) { | ||
return SwitchListTile( | ||
title: const Text("下载时同时导出", style: TextStyle(color: Colors.grey)), | ||
subtitle: const Text("发电才能使用", style: TextStyle(color: Colors.grey)), | ||
value: false, | ||
onChanged: (_) {}, | ||
); | ||
} | ||
if (Platform.isIOS) { | ||
return StatefulBuilder( | ||
builder: (BuildContext context, void Function(void Function()) setState) { | ||
return SwitchListTile( | ||
title: const Text("下载时同时导出"), | ||
subtitle: Text(_currentDownloadAndExportTo), | ||
value: _currentDownloadAndExportTo.isNotEmpty, | ||
onChanged: (e) async { | ||
|
||
var root = | ||
e ? ((await methods.iosGetDocumentDir()) + "/exports") : ""; | ||
await methods.setDownloadAndExportTo(root); | ||
_currentDownloadAndExportTo = root; | ||
setState(() {}); | ||
}, | ||
); | ||
}, | ||
); | ||
} | ||
return StatefulBuilder( | ||
builder: (BuildContext context, void Function(void Function()) setState) { | ||
return ListTile( | ||
title: const Text("下载的同时导出到某个目录(填完整路径)"), | ||
subtitle: Text(currentDownloadAndExportToName()), | ||
onTap: () async { | ||
var result = await chooseListDialog(context, | ||
values: ["选择新位置", "清除设置"], title: "下载的时候同时导出"); | ||
if (result != null) { | ||
if ("选择新位置" == result) { | ||
if (Platform.isAndroid) { | ||
if (androidVersion >= 30) { | ||
if (!(await Permission.manageExternalStorage.request()) | ||
.isGranted) { | ||
throw Exception("申请权限被拒绝"); | ||
} | ||
} else { | ||
if (!(await Permission.storage.request()).isGranted) { | ||
throw Exception("申请权限被拒绝"); | ||
} | ||
} | ||
} | ||
String? root = await chooseFolder(context); | ||
if (root != null) { | ||
await methods.setDownloadAndExportTo(root); | ||
_currentDownloadAndExportTo = root; | ||
setState(() {}); | ||
} | ||
} else if ("清除设置" == result) { | ||
const root = ""; | ||
await methods.setDownloadAndExportTo(root); | ||
_currentDownloadAndExportTo = root; | ||
setState(() {}); | ||
} | ||
} | ||
}, | ||
); | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import '../basic/commons.dart'; | ||
import '../basic/methods.dart'; | ||
import 'is_pro.dart'; | ||
|
||
const _propertyName = "exportRename"; | ||
late bool _exportRename; | ||
|
||
Future<void> initExportRename() async { | ||
_exportRename = (await methods.loadProperty(_propertyName)) == "true"; | ||
} | ||
|
||
bool currentExportRename() { | ||
return _exportRename; | ||
} | ||
|
||
Future<void> _chooseExportRename(BuildContext context) async { | ||
String? result = await chooseListDialog<String>(context, | ||
title: "导出的时候重新命名", values: ["是", "否"]); | ||
if (result != null) { | ||
var target = result == "是"; | ||
await methods.saveProperty(_propertyName, "$target"); | ||
_exportRename = target; | ||
} | ||
} | ||
|
||
Widget exportRenameSetting() { | ||
return StatefulBuilder( | ||
builder: (BuildContext context, void Function(void Function()) setState) { | ||
return ListTile( | ||
title: Text( | ||
"导出的时候重新命名", | ||
style: TextStyle( | ||
color: !isPro ? Colors.grey : null, | ||
), | ||
), | ||
subtitle: Text( | ||
_exportRename ? "是" : "否", | ||
style: TextStyle( | ||
color: !isPro ? Colors.grey : null, | ||
), | ||
), | ||
onTap: () async { | ||
if (!isPro) { | ||
return; | ||
} | ||
await _chooseExportRename(context); | ||
setState(() {}); | ||
}, | ||
); | ||
}, | ||
); | ||
} |
Oops, something went wrong.