mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
Improve the UI of comic source list.
This commit is contained in:
@@ -387,9 +387,10 @@
|
|||||||
"Screen center": "屏幕中心",
|
"Screen center": "屏幕中心",
|
||||||
"Suggestions": "建议",
|
"Suggestions": "建议",
|
||||||
"Do not report any issues related to sources to App repo.": "请不要向App仓库报告任何与源相关的问题",
|
"Do not report any issues related to sources to App repo.": "请不要向App仓库报告任何与源相关的问题",
|
||||||
"Click the setting icon to change the source list url.": "点击设置图标更改源列表URL",
|
|
||||||
"Show single image on first page": "在首页显示单张图片",
|
"Show single image on first page": "在首页显示单张图片",
|
||||||
"Click to select an image": "点击选择一张图片"
|
"Click to select an image": "点击选择一张图片",
|
||||||
|
"Source URL": "源地址",
|
||||||
|
"The URL should point to a 'index.json' file": "该URL应指向一个'index.json'文件"
|
||||||
},
|
},
|
||||||
"zh_TW": {
|
"zh_TW": {
|
||||||
"Home": "首頁",
|
"Home": "首頁",
|
||||||
@@ -779,8 +780,9 @@
|
|||||||
"Screen center": "螢幕中心",
|
"Screen center": "螢幕中心",
|
||||||
"Suggestions": "建議",
|
"Suggestions": "建議",
|
||||||
"Do not report any issues related to sources to App repo.": "請不要向App倉庫報告任何與源相關的問題",
|
"Do not report any issues related to sources to App repo.": "請不要向App倉庫報告任何與源相關的問題",
|
||||||
"Click the setting icon to change the source list url.": "點擊設定圖示更改源列表URL",
|
|
||||||
"Show single image on first page": "在首頁顯示單張圖片",
|
"Show single image on first page": "在首頁顯示單張圖片",
|
||||||
"Click to select an image": "點擊選擇一張圖片"
|
"Click to select an image": "點擊選擇一張圖片",
|
||||||
|
"Source URL": "源地址",
|
||||||
|
"The URL should point to a 'index.json' file": "該URL應指向一個'index.json'文件"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -178,8 +178,7 @@ class Settings with ChangeNotifier {
|
|||||||
'customImageProcessing': defaultCustomImageProcessing,
|
'customImageProcessing': defaultCustomImageProcessing,
|
||||||
'sni': true,
|
'sni': true,
|
||||||
'autoAddLanguageFilter': 'none', // none, chinese, english, japanese
|
'autoAddLanguageFilter': 'none', // none, chinese, english, japanese
|
||||||
'comicSourceListUrl':
|
'comicSourceListUrl': defaultComicSourceUrl,
|
||||||
"https://cdn.jsdelivr.net/gh/venera-app/venera-configs@latest/index.json",
|
|
||||||
'preloadImageCount': 4,
|
'preloadImageCount': 4,
|
||||||
'followUpdatesFolder': null,
|
'followUpdatesFolder': null,
|
||||||
'initialPage': '0',
|
'initialPage': '0',
|
||||||
@@ -220,3 +219,5 @@ function processImage(image, cid, eid, page, sourceKey) {
|
|||||||
return futureImage;
|
return futureImage;
|
||||||
}
|
}
|
||||||
''';
|
''';
|
||||||
|
|
||||||
|
const defaultComicSourceUrl = "https://cdn.jsdelivr.net/gh/venera-app/venera-configs@latest/index.json";
|
||||||
|
@@ -322,85 +322,127 @@ class _ComicSourceList extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ComicSourceListState extends State<_ComicSourceList> {
|
class _ComicSourceListState extends State<_ComicSourceList> {
|
||||||
bool loading = true;
|
|
||||||
List? json;
|
List? json;
|
||||||
|
bool changed = false;
|
||||||
|
var controller = TextEditingController();
|
||||||
|
|
||||||
void load() async {
|
void load() async {
|
||||||
var dio = AppDio();
|
if (json != null) {
|
||||||
var res = await dio.get<String>(appdata.settings['comicSourceListUrl']);
|
setState(() {
|
||||||
if (res.statusCode != 200) {
|
json = null;
|
||||||
context.showMessage(message: "Network error".tl);
|
});
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
var dio = AppDio();
|
||||||
|
try {
|
||||||
|
var res = await dio.get<String>(controller.text);
|
||||||
|
if (res.statusCode != 200) {
|
||||||
|
throw "error";
|
||||||
|
}
|
||||||
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
json = jsonDecode(res.data!);
|
json = jsonDecode(res.data!);
|
||||||
loading = false;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
context.showMessage(message: "Network error".tl);
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
json = [];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
controller.text = appdata.settings['comicSourceListUrl'];
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
if (changed) {
|
||||||
|
appdata.settings['comicSourceListUrl'] = controller.text;
|
||||||
|
appdata.saveData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return PopUpWidgetScaffold(
|
return PopUpWidgetScaffold(
|
||||||
title: "Comic Source".tl,
|
title: "Comic Source".tl,
|
||||||
tailing: [
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.settings),
|
|
||||||
onPressed: () async {
|
|
||||||
await showInputDialog(
|
|
||||||
context: context,
|
|
||||||
title: "Set comic source list url".tl,
|
|
||||||
initialValue: appdata.settings['comicSourceListUrl'],
|
|
||||||
onConfirm: (value) {
|
|
||||||
appdata.settings['comicSourceListUrl'] = value;
|
|
||||||
appdata.saveData();
|
|
||||||
setState(() {
|
|
||||||
loading = true;
|
|
||||||
json = null;
|
|
||||||
});
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
body: buildBody(),
|
body: buildBody(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildBody() {
|
Widget buildBody() {
|
||||||
if (loading) {
|
|
||||||
load();
|
|
||||||
return const Center(child: CircularProgressIndicator());
|
|
||||||
} else {
|
|
||||||
var currentKey = ComicSource.all().map((e) => e.key).toList();
|
var currentKey = ComicSource.all().map((e) => e.key).toList();
|
||||||
|
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemCount: json!.length + 1,
|
itemCount: (json?.length ?? 1) + 1,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 12),
|
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||||
padding: const EdgeInsets.all(8),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(8),
|
border: Border.all(
|
||||||
color: context.colorScheme.primaryContainer,
|
color: Theme.of(context).colorScheme.outlineVariant,
|
||||||
|
width: 0.6,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
const Icon(Icons.info_outline),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text("Do not report any issues related to sources to App repo.".tl),
|
ListTile(
|
||||||
Text("Click the setting icon to change the source list url.".tl),
|
leading: Icon(Icons.source_outlined),
|
||||||
|
title: Text("Source URL".tl),
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
controller: controller,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "URL",
|
||||||
|
border: const UnderlineInputBorder(),
|
||||||
|
contentPadding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 12),
|
||||||
|
),
|
||||||
|
onChanged: (value) {
|
||||||
|
changed = true;
|
||||||
|
},
|
||||||
|
).paddingHorizontal(16).paddingBottom(8),
|
||||||
|
Text("The URL should point to a 'index.json' file".tl).paddingLeft(16),
|
||||||
|
Text("Do not report any issues related to sources to App repo.".tl).paddingLeft(16),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
controller.text = defaultComicSourceUrl;
|
||||||
|
changed = true;
|
||||||
|
},
|
||||||
|
child: Text("Reset".tl),
|
||||||
|
),
|
||||||
|
FilledButton.tonal(
|
||||||
|
onPressed: load,
|
||||||
|
child: Text("Refresh".tl),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 16),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (index == 1 && json == null) {
|
||||||
|
return Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
|
|
||||||
index--;
|
index--;
|
||||||
|
|
||||||
var key = json![index]["key"];
|
var key = json![index]["key"];
|
||||||
@@ -443,7 +485,6 @@ class _ComicSourceListState extends State<_ComicSourceList> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _validatePages() {
|
void _validatePages() {
|
||||||
|
@@ -1100,4 +1100,4 @@ packages:
|
|||||||
version: "0.0.12"
|
version: "0.0.12"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.7.0 <4.0.0"
|
dart: ">=3.7.0 <4.0.0"
|
||||||
flutter: ">=3.29.2"
|
flutter: ">=3.29.3"
|
||||||
|
Reference in New Issue
Block a user