From 9528a6f462ad52abaf010a9dc7a16e6786d77c82 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 27 Aug 2023 12:12:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=9A=90=E8=97=8F=E7=83=AD=E6=90=9C?= =?UTF-8?q?=E7=83=AD=E6=A6=9C=E7=9A=84=E5=8A=9F=E8=83=BD=20issues#35?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/search/controller.dart | 3 +++ lib/pages/search/view.dart | 4 +++- lib/pages/setting/extra_setting.dart | 8 ++++++++ lib/utils/storage.dart | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/pages/search/controller.dart b/lib/pages/search/controller.dart index 20277b89..64f3cb65 100644 --- a/lib/pages/search/controller.dart +++ b/lib/pages/search/controller.dart @@ -21,6 +21,8 @@ class SSearchController extends GetxController { Debouncer(delay: const Duration(milliseconds: 200)); // 设置延迟时间 String hintText = '搜索'; RxString defaultSearch = '输入关键词搜索'.obs; + Box setting = GStrorage.setting; + bool enableHotKey = true; @override void onInit() { @@ -38,6 +40,7 @@ class SSearchController extends GetxController { } historyCacheList = histiryWord.get('cacheList') ?? []; historyList.value = historyCacheList; + enableHotKey = setting.get(SettingBoxKey.enableHotKey, defaultValue: true); } void onChange(value) { diff --git a/lib/pages/search/view.dart b/lib/pages/search/view.dart index 04af9ed4..ea902365 100644 --- a/lib/pages/search/view.dart +++ b/lib/pages/search/view.dart @@ -146,7 +146,9 @@ class _SearchPageState extends State with RouteAware { // 搜索建议 _searchSuggest(), // 热搜 - hotSearch(_searchController), + Visibility( + visible: _searchController.enableHotKey, + child: hotSearch(_searchController)), // 搜索历史 _history() ], diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index 29ad5aac..4ed55f96 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/models/common/dynamics_type.dart'; import 'package:pilipala/models/common/reply_sort_type.dart'; @@ -47,6 +48,13 @@ class _ExtraSettingState extends State { ), body: ListView( children: [ + SetSwitchItem( + title: '大家都在搜', + subTitle: '是否展示「大家都在搜」', + setKey: SettingBoxKey.enableHotKey, + defaultVal: true, + callFn: (val) => {SmartDialog.showToast('下次启动时生效')}, + ), ListTile( dense: false, title: Text('评论展示', style: titleStyle), diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index d92384a0..21a8060b 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -105,6 +105,7 @@ class SettingBoxKey { static const String autoUpdate = 'autoUpdate'; static const String replySortType = 'replySortType'; static const String defaultDynamicType = 'defaultDynamicType'; + static const String enableHotKey = 'enableHotKey'; /// 外观 static const String themeMode = 'themeMode';