mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
io utils; single favorite folder exporting and importing
This commit is contained in:
@@ -27,10 +27,26 @@ Future<void> newFolder() async {
|
||||
});
|
||||
}
|
||||
},
|
||||
)
|
||||
),
|
||||
],
|
||||
).paddingHorizontal(16),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text("Import from file".tl),
|
||||
onPressed: () async {
|
||||
var file = await selectFile(ext: ['json']);
|
||||
if(file == null) return;
|
||||
var data = await file.readAsBytes();
|
||||
try {
|
||||
LocalFavoritesManager().fromJson(utf8.decode(data));
|
||||
}
|
||||
catch(e) {
|
||||
context.showMessage(message: "Failed to import".tl);
|
||||
return;
|
||||
}
|
||||
context.pop();
|
||||
},
|
||||
).paddingRight(4),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
var e = validateFolderName(controller.text);
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -9,6 +10,7 @@ import 'package:venera/foundation/comic_source/comic_source.dart';
|
||||
import 'package:venera/foundation/comic_type.dart';
|
||||
import 'package:venera/foundation/favorites.dart';
|
||||
import 'package:venera/foundation/res.dart';
|
||||
import 'package:venera/utils/io.dart';
|
||||
import 'package:venera/utils/translations.dart';
|
||||
|
||||
part 'favorite_actions.dart';
|
||||
@@ -134,7 +136,12 @@ class _FavoritesPageState extends State<FavoritesPage> {
|
||||
)
|
||||
: null,
|
||||
),
|
||||
title: Text("Unselected".tl),
|
||||
title: GestureDetector(
|
||||
onTap: context.width < _kTwoPanelChangeWidth
|
||||
? showFolderSelector
|
||||
: null,
|
||||
child: Text("Unselected".tl),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
@@ -15,8 +15,10 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
|
||||
late List<FavoriteItem> comics;
|
||||
|
||||
void updateComics() {
|
||||
print(comics.length);
|
||||
setState(() {
|
||||
comics = LocalFavoritesManager().getAllComics(widget.folder);
|
||||
print(comics.length);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,7 +66,6 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
|
||||
favPage.setFolder(false, null);
|
||||
LocalFavoritesManager().deleteFolder(widget.folder);
|
||||
favPage.folderList?.updateFolders();
|
||||
context.pop();
|
||||
},
|
||||
);
|
||||
}),
|
||||
@@ -110,6 +111,18 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
|
||||
},
|
||||
);
|
||||
}),
|
||||
MenuEntry(
|
||||
icon: Icons.upload_file,
|
||||
text: "Export".tl,
|
||||
onClick: () {
|
||||
var json = LocalFavoritesManager().folderToJson(
|
||||
widget.folder,
|
||||
);
|
||||
saveFile(
|
||||
data: utf8.encode(json),
|
||||
filename: "${widget.folder}.json",
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
@@ -211,11 +211,13 @@ class _LeftBarState extends State<_LeftBar> implements FolderList {
|
||||
|
||||
@override
|
||||
void update() {
|
||||
if(!mounted) return;
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
void updateFolders() {
|
||||
if(!mounted) return;
|
||||
setState(() {
|
||||
folders = LocalFavoritesManager().folderNames;
|
||||
networkFolders = ComicSource.all()
|
||||
|
Reference in New Issue
Block a user