mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: store search index
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -19,6 +19,8 @@ class SSearchController extends GetxController {
|
|||||||
|
|
||||||
Rx<LoadingState> loadingState = LoadingState.loading().obs;
|
Rx<LoadingState> loadingState = LoadingState.loading().obs;
|
||||||
|
|
||||||
|
int initIndex = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
@@ -74,9 +76,13 @@ class SSearchController extends GetxController {
|
|||||||
GStorage.historyWord.put('cacheList', historyList);
|
GStorage.historyWord.put('cacheList', historyList);
|
||||||
searchFocusNode.unfocus();
|
searchFocusNode.unfocus();
|
||||||
|
|
||||||
await Get.toNamed('/searchResult', parameters: {
|
await Get.toNamed(
|
||||||
'keyword': controller.text,
|
'/searchResult',
|
||||||
});
|
parameters: {
|
||||||
|
'keyword': controller.text,
|
||||||
|
},
|
||||||
|
arguments: initIndex,
|
||||||
|
);
|
||||||
searchFocusNode.requestFocus();
|
searchFocusNode.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:PiliPalaX/pages/search/controller.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -28,12 +29,16 @@ class _SearchResultPageState extends State<SearchResultPage>
|
|||||||
|
|
||||||
_tabController = TabController(
|
_tabController = TabController(
|
||||||
vsync: this,
|
vsync: this,
|
||||||
|
initialIndex: Get.arguments,
|
||||||
length: SearchType.values.length,
|
length: SearchType.values.length,
|
||||||
);
|
)..addListener(() {
|
||||||
|
Get.find<SSearchController>().initIndex = _tabController.index;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
_tabController.removeListener(() {});
|
||||||
_tabController.dispose();
|
_tabController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
@@ -114,15 +119,15 @@ class _SearchResultPageState extends State<SearchResultPage>
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
controller: _tabController,
|
controller: _tabController,
|
||||||
children: [
|
children: SearchType.values
|
||||||
for (var i in SearchType.values) ...{
|
.map(
|
||||||
SearchPanel(
|
(item) => SearchPanel(
|
||||||
keyword: _searchResultController.keyword,
|
keyword: _searchResultController.keyword,
|
||||||
searchType: i,
|
searchType: item,
|
||||||
tag: _tag,
|
tag: _tag,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
.toList(),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user