feat: 首页搜索页点击tab返回顶部
This commit is contained in:
@ -40,7 +40,7 @@ class MyApp extends StatelessWidget {
|
||||
return GetMaterialApp(
|
||||
title: 'PiLiPaLa',
|
||||
theme: ThemeData(
|
||||
fontFamily: 'HarmonyOS',
|
||||
// fontFamily: 'HarmonyOS',
|
||||
colorScheme: lightDynamic ??
|
||||
ColorScheme.fromSeed(
|
||||
seedColor: Colors.green,
|
||||
@ -56,7 +56,7 @@ class MyApp extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
darkTheme: ThemeData(
|
||||
fontFamily: 'HarmonyOS',
|
||||
// fontFamily: 'HarmonyOS',
|
||||
colorScheme: darkDynamic ??
|
||||
ColorScheme.fromSeed(
|
||||
seedColor: Colors.green,
|
||||
|
@ -54,4 +54,15 @@ class BangumiController extends GetxController {
|
||||
} else {}
|
||||
return result;
|
||||
}
|
||||
|
||||
// 返回顶部并刷新
|
||||
void animateToTop() async {
|
||||
if (scrollController.offset >=
|
||||
MediaQuery.of(Get.context!).size.height * 5) {
|
||||
scrollController.jumpTo(0);
|
||||
} else {
|
||||
await scrollController.animateTo(0,
|
||||
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,8 +100,13 @@ class _HomePageState extends State<HomePage>
|
||||
dividerColor: Colors.transparent,
|
||||
unselectedLabelColor:
|
||||
Theme.of(context).colorScheme.outline,
|
||||
onTap: (value) =>
|
||||
{feedBack(), _homeController.initialIndex = value},
|
||||
onTap: (value) {
|
||||
feedBack();
|
||||
if (_homeController.initialIndex == value) {
|
||||
_homeController.ctrList[value]().animateToTop();
|
||||
}
|
||||
_homeController.initialIndex = value;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -142,8 +142,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
currentIndex: selectedIndex,
|
||||
// type: BottomNavigationBarType.shifting,
|
||||
selectedItemColor: Theme.of(context).colorScheme.primary,
|
||||
unselectedItemColor:
|
||||
Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
unselectedItemColor: Theme.of(context).colorScheme.outline,
|
||||
selectedFontSize: 12.4,
|
||||
onTap: (value) => setIndex(value),
|
||||
items: [
|
||||
|
@ -25,7 +25,7 @@ class SearchPanel extends StatefulWidget {
|
||||
|
||||
class _SearchPanelState extends State<SearchPanel>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
late SearchPanelController? _searchPanelController;
|
||||
late SearchPanelController _searchPanelController;
|
||||
|
||||
bool _isLoadingMore = false;
|
||||
late Future _futureBuilderFuture;
|
||||
@ -41,10 +41,9 @@ class _SearchPanelState extends State<SearchPanel>
|
||||
keyword: widget.keyword,
|
||||
searchType: widget.searchType,
|
||||
),
|
||||
tag: widget.searchType!.type + widget.tag!,
|
||||
tag: widget.searchType!.type,
|
||||
);
|
||||
ScrollController scrollController =
|
||||
_searchPanelController!.scrollController;
|
||||
ScrollController scrollController = _searchPanelController.scrollController;
|
||||
scrollController.addListener(() async {
|
||||
if (scrollController.position.pixels >=
|
||||
scrollController.position.maxScrollExtent - 100) {
|
||||
@ -55,7 +54,7 @@ class _SearchPanelState extends State<SearchPanel>
|
||||
}
|
||||
}
|
||||
});
|
||||
_futureBuilderFuture = _searchPanelController!.onSearch();
|
||||
_futureBuilderFuture = _searchPanelController.onSearch();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -63,7 +62,7 @@ class _SearchPanelState extends State<SearchPanel>
|
||||
super.build(context);
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await _searchPanelController!.onRefresh();
|
||||
await _searchPanelController.onRefresh();
|
||||
},
|
||||
child: FutureBuilder(
|
||||
future: _futureBuilderFuture,
|
||||
@ -71,7 +70,7 @@ class _SearchPanelState extends State<SearchPanel>
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
Map data = snapshot.data;
|
||||
var ctr = _searchPanelController;
|
||||
List list = ctr!.resultList;
|
||||
List list = ctr.resultList;
|
||||
if (data['status']) {
|
||||
return Obx(() {
|
||||
switch (widget.searchType) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/models/common/search_type.dart';
|
||||
import 'package:pilipala/pages/rcmd/index.dart';
|
||||
import 'package:pilipala/pages/searchPanel/index.dart';
|
||||
import 'controller.dart';
|
||||
|
||||
@ -88,6 +89,7 @@ class _SearchResultPageState extends State<SearchResultPage>
|
||||
tag: SearchType.values[index].type)
|
||||
.animateToTop();
|
||||
}
|
||||
|
||||
_searchResultController!.tabIndex = index;
|
||||
},
|
||||
),
|
||||
|
Reference in New Issue
Block a user