From 1ce12f9f28ce5ebb1c29af237b07e3408eb7e8c3 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 25 Jun 2023 23:38:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=90=9C=E7=B4=A2=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=B8=8D=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/searchPanel/view.dart | 6 ++++-- lib/pages/searchResult/controller.dart | 2 -- lib/pages/searchResult/view.dart | 17 ++++++++++------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/pages/searchPanel/view.dart b/lib/pages/searchPanel/view.dart index 98139f8a..e37366a1 100644 --- a/lib/pages/searchPanel/view.dart +++ b/lib/pages/searchPanel/view.dart @@ -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 keyword: widget.keyword, searchType: widget.searchType, ), - tag: widget.searchType!.type, + tag: widget.searchType!.type + widget.tag!, ); ScrollController scrollController = _searchPanelController!.scrollController; diff --git a/lib/pages/searchResult/controller.dart b/lib/pages/searchResult/controller.dart index 0efc65bd..9914d82b 100644 --- a/lib/pages/searchResult/controller.dart +++ b/lib/pages/searchResult/controller.dart @@ -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; diff --git a/lib/pages/searchResult/view.dart b/lib/pages/searchResult/view.dart index 783934c9..d320b97d 100644 --- a/lib/pages/searchResult/view.dart +++ b/lib/pages/searchResult/view.dart @@ -13,17 +13,19 @@ class SearchResultPage extends StatefulWidget { class _SearchResultPageState extends State 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 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 dividerColor: Colors.transparent, unselectedLabelColor: Theme.of(context).colorScheme.outline, onTap: (index) { - if (index == _searchResultController.tabIndex) { + if (index == _searchResultController!.tabIndex) { Get.find( tag: SearchType.values[index].type) .animateToTop(); } - _searchResultController.tabIndex = index; + _searchResultController!.tabIndex = index; }, ), ), @@ -92,8 +94,9 @@ class _SearchResultPageState extends State children: [ for (var i in SearchType.values) ...{ SearchPanel( - keyword: _searchResultController.keyword, + keyword: _searchResultController!.keyword, searchType: i, + tag: DateTime.now().millisecondsSinceEpoch.toString(), ) } ],