feat: record search history option

Closes #592

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-04 12:00:03 +08:00
parent 849329b66b
commit 8c259205f5
5 changed files with 72 additions and 8 deletions

View File

@@ -1,7 +1,9 @@
import 'package:PiliPlus/common/widgets/loading_widget.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models/search/suggest.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';
import 'controller.dart';
import 'widgets/hot_keyword.dart';
@@ -199,15 +201,60 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
Padding(
padding: const EdgeInsets.fromLTRB(6, 0, 6, 6),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'搜索历史',
strutStyle: StrutStyle(leading: 0, height: 1),
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(fontWeight: FontWeight.bold),
.copyWith(height: 1, fontWeight: FontWeight.bold),
),
const SizedBox(width: 12),
Obx(
() => SizedBox(
width: 34,
height: 34,
child: IconButton(
iconSize: 22,
tooltip: _searchController.recordSearchHistory.value
? '记录搜索'
: '无痕搜索',
icon: _searchController.recordSearchHistory.value
? Icon(
Icons.history,
color: Theme.of(context)
.colorScheme
.onSurfaceVariant
.withOpacity(0.8),
)
: SvgPicture.string(
width: 22,
height: 22,
colorFilter: ColorFilter.mode(
Theme.of(context)
.colorScheme
.outline
.withOpacity(0.8),
BlendMode.srcIn,
),
_searchController.historyOff,
),
style: IconButton.styleFrom(
padding: EdgeInsets.zero,
),
onPressed: () {
_searchController.recordSearchHistory.value =
!_searchController.recordSearchHistory.value;
GStorage.setting.put(
SettingBoxKey.recordSearchHistory,
_searchController.recordSearchHistory.value,
);
},
),
),
),
const Spacer(),
SizedBox(
height: 34,
child: TextButton.icon(