fix: 搜索页面不刷新
This commit is contained in:
@ -13,7 +13,9 @@ import 'widgets/video_panel.dart';
|
||||
class SearchPanel extends StatefulWidget {
|
||||
String? keyword;
|
||||
SearchType? searchType;
|
||||
SearchPanel({required this.keyword, required this.searchType, Key? key})
|
||||
String? tag;
|
||||
SearchPanel(
|
||||
{required this.keyword, required this.searchType, this.tag, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@ -37,7 +39,7 @@ class _SearchPanelState extends State<SearchPanel>
|
||||
keyword: widget.keyword,
|
||||
searchType: widget.searchType,
|
||||
),
|
||||
tag: widget.searchType!.type,
|
||||
tag: widget.searchType!.type + widget.tag!,
|
||||
);
|
||||
ScrollController scrollController =
|
||||
_searchPanelController!.scrollController;
|
||||
|
@ -1,6 +1,4 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/models/common/search_type.dart';
|
||||
import 'package:pilipala/pages/searchPanel/index.dart';
|
||||
|
||||
class SearchResultController extends GetxController {
|
||||
String? keyword;
|
||||
|
@ -13,17 +13,19 @@ class SearchResultPage extends StatefulWidget {
|
||||
|
||||
class _SearchResultPageState extends State<SearchResultPage>
|
||||
with TickerProviderStateMixin {
|
||||
final SearchResultController _searchResultController =
|
||||
Get.put(SearchResultController());
|
||||
late SearchResultController? _searchResultController;
|
||||
late TabController? _tabController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_searchResultController = Get.put(SearchResultController(),
|
||||
tag: DateTime.now().millisecondsSinceEpoch.toString());
|
||||
|
||||
_tabController = TabController(
|
||||
vsync: this,
|
||||
length: SearchType.values.length,
|
||||
initialIndex: _searchResultController.tabIndex,
|
||||
initialIndex: _searchResultController!.tabIndex,
|
||||
);
|
||||
}
|
||||
|
||||
@ -44,7 +46,7 @@ class _SearchResultPageState extends State<SearchResultPage>
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
'${_searchResultController.keyword}',
|
||||
'${_searchResultController!.keyword}',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
@ -77,12 +79,12 @@ class _SearchResultPageState extends State<SearchResultPage>
|
||||
dividerColor: Colors.transparent,
|
||||
unselectedLabelColor: Theme.of(context).colorScheme.outline,
|
||||
onTap: (index) {
|
||||
if (index == _searchResultController.tabIndex) {
|
||||
if (index == _searchResultController!.tabIndex) {
|
||||
Get.find<SearchPanelController>(
|
||||
tag: SearchType.values[index].type)
|
||||
.animateToTop();
|
||||
}
|
||||
_searchResultController.tabIndex = index;
|
||||
_searchResultController!.tabIndex = index;
|
||||
},
|
||||
),
|
||||
),
|
||||
@ -92,8 +94,9 @@ class _SearchResultPageState extends State<SearchResultPage>
|
||||
children: [
|
||||
for (var i in SearchType.values) ...{
|
||||
SearchPanel(
|
||||
keyword: _searchResultController.keyword,
|
||||
keyword: _searchResultController!.keyword,
|
||||
searchType: i,
|
||||
tag: DateTime.now().millisecondsSinceEpoch.toString(),
|
||||
)
|
||||
}
|
||||
],
|
||||
|
Reference in New Issue
Block a user