mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
data exporting & importing
This commit is contained in:
@@ -86,6 +86,36 @@ class _AppSettingsState extends State<AppSettings> {
|
||||
},
|
||||
actionTitle: 'Set'.tl,
|
||||
).toSliver(),
|
||||
_CallbackSetting(
|
||||
title: "Export App Data".tl,
|
||||
callback: () async {
|
||||
var controller = showLoadingDialog(context);
|
||||
var file = await exportAppData();
|
||||
await saveFile(filename: "data.venera", file: file);
|
||||
controller.close();
|
||||
},
|
||||
actionTitle: 'Export'.tl,
|
||||
).toSliver(),
|
||||
_CallbackSetting(
|
||||
title: "Import App Data".tl,
|
||||
callback: () async {
|
||||
var controller = showLoadingDialog(context);
|
||||
var file = await selectFile(ext: ['venera']);
|
||||
if(file != null) {
|
||||
var cacheFile = File(FilePath.join(App.cachePath, "temp.venera"));
|
||||
await file.saveTo(cacheFile.path);
|
||||
try {
|
||||
await importAppData(cacheFile);
|
||||
}
|
||||
catch(e, s) {
|
||||
Log.error("Import data", e.toString(), s);
|
||||
context.showMessage(message: "Failed to import data".tl);
|
||||
}
|
||||
}
|
||||
controller.close();
|
||||
},
|
||||
actionTitle: 'Import'.tl,
|
||||
).toSliver(),
|
||||
_SettingPartTitle(
|
||||
title: "Log".tl,
|
||||
icon: Icons.error_outline,
|
||||
|
@@ -21,6 +21,9 @@ class _AppearanceSettingsState extends State<AppearanceSettings> {
|
||||
"light": "Light".tl,
|
||||
"dark": "Dark".tl,
|
||||
},
|
||||
onChanged: () async {
|
||||
App.forceRebuild();
|
||||
},
|
||||
).toSliver(),
|
||||
SelectSetting(
|
||||
title: "Theme Color".tl,
|
||||
|
@@ -434,7 +434,7 @@ class _CallbackSetting extends StatelessWidget {
|
||||
return ListTile(
|
||||
title: Text(title),
|
||||
subtitle: subtitle == null ? null : Text(subtitle!),
|
||||
trailing: FilledButton(
|
||||
trailing: Button.normal(
|
||||
onPressed: callback,
|
||||
child: Text(actionTitle),
|
||||
).fixHeight(28),
|
||||
|
@@ -14,6 +14,7 @@ import 'package:venera/foundation/consts.dart';
|
||||
import 'package:venera/foundation/local.dart';
|
||||
import 'package:venera/foundation/log.dart';
|
||||
import 'package:venera/network/app_dio.dart';
|
||||
import 'package:venera/utils/data.dart';
|
||||
import 'package:venera/utils/io.dart';
|
||||
import 'package:venera/utils/translations.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
Reference in New Issue
Block a user