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(), ) } ],