mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-22 10:06:23 +08:00
fix disable search suggestion
related #923 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -39,8 +39,8 @@ class SSearchController extends GetxController {
|
|||||||
late final RxList<SearchSuggestItem> searchSuggestList;
|
late final RxList<SearchSuggestItem> searchSuggestList;
|
||||||
|
|
||||||
// trending
|
// trending
|
||||||
final bool enableHotKey = Pref.enableHotKey;
|
final bool enableTrending = Pref.enableTrending;
|
||||||
late final Rx<LoadingState<SearchTrendingData>> loadingState;
|
late final Rx<LoadingState<SearchTrendingData>> trendingState;
|
||||||
|
|
||||||
// rcmd
|
// rcmd
|
||||||
final bool enableSearchRcmd = Pref.enableSearchRcmd;
|
final bool enableSearchRcmd = Pref.enableSearchRcmd;
|
||||||
@@ -68,9 +68,9 @@ class SSearchController extends GetxController {
|
|||||||
searchSuggestList = <SearchSuggestItem>[].obs;
|
searchSuggestList = <SearchSuggestItem>[].obs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableHotKey) {
|
if (enableTrending) {
|
||||||
loadingState = LoadingState<SearchTrendingData>.loading().obs;
|
trendingState = LoadingState<SearchTrendingData>.loading().obs;
|
||||||
queryHotSearchList();
|
queryTrendingList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableSearchRcmd) {
|
if (enableSearchRcmd) {
|
||||||
@@ -97,7 +97,7 @@ class SSearchController extends GetxController {
|
|||||||
void onClear() {
|
void onClear() {
|
||||||
if (controller.value.text != '') {
|
if (controller.value.text != '') {
|
||||||
controller.clear();
|
controller.clear();
|
||||||
searchSuggestList.clear();
|
if (searchSuggestion) searchSuggestList.clear();
|
||||||
searchFocusNode.requestFocus();
|
searchFocusNode.requestFocus();
|
||||||
showUidBtn.value = false;
|
showUidBtn.value = false;
|
||||||
} else {
|
} else {
|
||||||
@@ -138,8 +138,8 @@ class SSearchController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取热搜关键词
|
// 获取热搜关键词
|
||||||
Future<void> queryHotSearchList() async {
|
Future<void> queryTrendingList() async {
|
||||||
loadingState.value = await SearchHttp.searchTrending(limit: 10);
|
trendingState.value = await SearchHttp.searchTrending(limit: 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> queryRecommendList() async {
|
Future<void> queryRecommendList() async {
|
||||||
@@ -150,7 +150,7 @@ class SSearchController extends GetxController {
|
|||||||
controller.text = keyword;
|
controller.text = keyword;
|
||||||
validateUid();
|
validateUid();
|
||||||
|
|
||||||
searchSuggestList.clear();
|
if (searchSuggestion) searchSuggestList.clear();
|
||||||
submit();
|
submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,21 +80,22 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
children: [
|
children: [
|
||||||
if (_searchController.searchSuggestion) _searchSuggest(),
|
if (_searchController.searchSuggestion) _searchSuggest(),
|
||||||
if (isPortrait) ...[
|
if (isPortrait) ...[
|
||||||
if (_searchController.enableHotKey) hotSearch(theme),
|
if (_searchController.enableTrending) hotSearch(theme),
|
||||||
_history(theme, isPortrait),
|
_history(theme, isPortrait),
|
||||||
if (_searchController.enableSearchRcmd) hotSearch(theme, false),
|
if (_searchController.enableSearchRcmd)
|
||||||
|
hotSearch(theme, isTrending: false),
|
||||||
] else
|
] else
|
||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (_searchController.enableHotKey ||
|
if (_searchController.enableTrending ||
|
||||||
_searchController.enableSearchRcmd)
|
_searchController.enableSearchRcmd)
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
if (_searchController.enableHotKey) hotSearch(theme),
|
if (_searchController.enableTrending) hotSearch(theme),
|
||||||
if (_searchController.enableSearchRcmd)
|
if (_searchController.enableSearchRcmd)
|
||||||
hotSearch(theme, false),
|
hotSearch(theme, isTrending: false),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -155,9 +156,9 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget hotSearch(ThemeData theme, [bool isHot = true]) {
|
Widget hotSearch(ThemeData theme, {bool isTrending = true}) {
|
||||||
final text = Text(
|
final text = Text(
|
||||||
isHot ? '大家都在搜' : '搜索发现',
|
isTrending ? '大家都在搜' : '搜索发现',
|
||||||
strutStyle: const StrutStyle(leading: 0, height: 1),
|
strutStyle: const StrutStyle(leading: 0, height: 1),
|
||||||
style: theme.textTheme.titleMedium!.copyWith(
|
style: theme.textTheme.titleMedium!.copyWith(
|
||||||
height: 1,
|
height: 1,
|
||||||
@@ -172,7 +173,7 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
color: outline,
|
color: outline,
|
||||||
);
|
);
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.fromLTRB(10, isHot ? 25 : 4, 4, 25),
|
padding: EdgeInsets.fromLTRB(10, isTrending ? 25 : 4, 4, 25),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -181,7 +182,7 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
isHot
|
isTrending
|
||||||
? Row(
|
? Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
@@ -224,8 +225,8 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: isHot
|
onPressed: isTrending
|
||||||
? _searchController.queryHotSearchList
|
? _searchController.queryTrendingList
|
||||||
: _searchController.queryRecommendList,
|
: _searchController.queryRecommendList,
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.refresh_outlined,
|
Icons.refresh_outlined,
|
||||||
@@ -247,10 +248,10 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
),
|
),
|
||||||
Obx(
|
Obx(
|
||||||
() => _buildHotKey(
|
() => _buildHotKey(
|
||||||
isHot
|
isTrending
|
||||||
? _searchController.loadingState.value
|
? _searchController.trendingState.value
|
||||||
: _searchController.recommendData.value,
|
: _searchController.recommendData.value,
|
||||||
isHot,
|
isTrending,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -270,7 +271,7 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
10,
|
10,
|
||||||
!isPortrait
|
!isPortrait
|
||||||
? 25
|
? 25
|
||||||
: _searchController.enableHotKey
|
: _searchController.enableTrending
|
||||||
? 0
|
? 0
|
||||||
: 6,
|
: 6,
|
||||||
6,
|
6,
|
||||||
@@ -375,7 +376,10 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
color: theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.8),
|
color: theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.8),
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget _buildHotKey(LoadingState<SearchRcmdData> loadingState, bool isHot) {
|
Widget _buildHotKey(
|
||||||
|
LoadingState<SearchRcmdData> loadingState,
|
||||||
|
bool isTrending,
|
||||||
|
) {
|
||||||
return switch (loadingState) {
|
return switch (loadingState) {
|
||||||
Success(:var response) =>
|
Success(:var response) =>
|
||||||
response.list?.isNotEmpty == true
|
response.list?.isNotEmpty == true
|
||||||
@@ -389,8 +393,8 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
: const SizedBox.shrink(),
|
: const SizedBox.shrink(),
|
||||||
Error(:var errMsg) => errorWidget(
|
Error(:var errMsg) => errorWidget(
|
||||||
errMsg: errMsg,
|
errMsg: errMsg,
|
||||||
onReload: isHot
|
onReload: isTrending
|
||||||
? _searchController.queryHotSearchList
|
? _searchController.queryTrendingList
|
||||||
: _searchController.queryRecommendList,
|
: _searchController.queryRecommendList,
|
||||||
),
|
),
|
||||||
_ => const SizedBox.shrink(),
|
_ => const SizedBox.shrink(),
|
||||||
|
|||||||
@@ -742,7 +742,7 @@ class Pref {
|
|||||||
static bool get defaultShowComment =>
|
static bool get defaultShowComment =>
|
||||||
_setting.get(SettingBoxKey.defaultShowComment, defaultValue: false);
|
_setting.get(SettingBoxKey.defaultShowComment, defaultValue: false);
|
||||||
|
|
||||||
static bool get enableHotKey =>
|
static bool get enableTrending =>
|
||||||
_setting.get(SettingBoxKey.enableHotKey, defaultValue: true);
|
_setting.get(SettingBoxKey.enableHotKey, defaultValue: true);
|
||||||
|
|
||||||
static bool get enableSearchRcmd =>
|
static bool get enableSearchRcmd =>
|
||||||
|
|||||||
Reference in New Issue
Block a user