mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-20 16:18:39 +00:00
feat: InportExportDialog (#1048)
This commit is contained in:
committed by
GitHub
parent
08c3789321
commit
ed57697fdc
@@ -150,7 +150,6 @@ class SSearchController extends GetxController
|
||||
historyList
|
||||
..remove(controller.text)
|
||||
..insert(0, controller.text);
|
||||
GStorage.historyWord.put('cacheList', historyList);
|
||||
}
|
||||
|
||||
searchFocusNode.unfocus();
|
||||
@@ -198,7 +197,6 @@ class SSearchController extends GetxController
|
||||
|
||||
void onLongSelect(String word) {
|
||||
historyList.remove(word);
|
||||
GStorage.historyWord.put('cacheList', historyList);
|
||||
}
|
||||
|
||||
void onClearHistory() {
|
||||
@@ -207,13 +205,13 @@ class SSearchController extends GetxController
|
||||
title: '确定清空搜索历史?',
|
||||
onConfirm: () {
|
||||
historyList.clear();
|
||||
GStorage.historyWord.put('cacheList', []);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
GStorage.historyWord.put('cacheList', historyList);
|
||||
subDispose();
|
||||
searchFocusNode.dispose();
|
||||
controller.dispose();
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/disabled_icon.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/loading_widget.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models_new/search/search_rcmd/data.dart';
|
||||
import 'package:PiliPlus/pages/about/view.dart' show showInportExportDialog;
|
||||
import 'package:PiliPlus/pages/search/controller.dart';
|
||||
import 'package:PiliPlus/pages/search/widgets/hot_keyword.dart';
|
||||
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
||||
@@ -331,13 +334,14 @@ class _SearchPageState extends State<SearchPage> {
|
||||
);
|
||||
},
|
||||
),
|
||||
_exportHsitory(theme),
|
||||
const Spacer(),
|
||||
SizedBox(
|
||||
height: 34,
|
||||
child: TextButton.icon(
|
||||
style: ButtonStyle(
|
||||
padding: WidgetStateProperty.all(
|
||||
const EdgeInsets.symmetric(
|
||||
style: const ButtonStyle(
|
||||
padding: WidgetStatePropertyAll(
|
||||
EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 6,
|
||||
),
|
||||
@@ -380,6 +384,30 @@ class _SearchPageState extends State<SearchPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _exportHsitory(ThemeData theme) => SizedBox(
|
||||
width: 34,
|
||||
height: 34,
|
||||
child: IconButton(
|
||||
iconSize: 22,
|
||||
tooltip: '导入/导出历史记录',
|
||||
icon: Icon(
|
||||
Icons.import_export_outlined,
|
||||
color: theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.8),
|
||||
),
|
||||
style: IconButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
onPressed: () => showInportExportDialog<List>(
|
||||
context,
|
||||
title: '历史记录',
|
||||
toJson: () => jsonEncode(_searchController.historyList),
|
||||
fromJson: (json) {
|
||||
_searchController.historyList.value = json.cast<String>();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Icon historyIcon(ThemeData theme) => Icon(
|
||||
Icons.history,
|
||||
color: theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.8),
|
||||
|
||||
Reference in New Issue
Block a user