From 2cbaa5c8992116ecba3d6e009e9004ec9f822c30 Mon Sep 17 00:00:00 2001 From: 3003h Date: Fri, 6 Dec 2024 17:04:42 +0800 Subject: [PATCH] Fix load previous --- .../tab/controller/tabview_controller.dart | 4 +- lib/pages/tab/view/list/tab_base.dart | 22 +- lib/pages/tab/view/search_image_page.dart | 2 +- lib/pages/tab/view/search_page.dart | 207 +++++++++--------- .../tab/view/tabbar/favorite_sub_page.dart | 3 +- lib/pages/tab/view/toplist_page.dart | 2 +- 6 files changed, 120 insertions(+), 120 deletions(-) diff --git a/lib/pages/tab/controller/tabview_controller.dart b/lib/pages/tab/controller/tabview_controller.dart index c68bb452f..e62a23986 100644 --- a/lib/pages/tab/controller/tabview_controller.dart +++ b/lib/pages/tab/controller/tabview_controller.dart @@ -386,10 +386,10 @@ abstract class TabViewController extends GetxController { change(state, status: RxStatus.success()); logger.d('prevGid: $prevGid, prevPage $prevPage, afterJump: $afterJump'); if ((prevGid.isNotEmpty || prevPage >= 0) && afterJump) { - logger.t('loadPrevious'); + logger.d('>>>>> loadPrevious'); await loadPrevious(); } else { - logger.t('reloadData'); + logger.d('>>>>> reloadData'); await reloadData(); } } diff --git a/lib/pages/tab/view/list/tab_base.dart b/lib/pages/tab/view/list/tab_base.dart index 7f93037ac..383f059b1 100644 --- a/lib/pages/tab/view/list/tab_base.dart +++ b/lib/pages/tab/view/list/tab_base.dart @@ -339,25 +339,25 @@ Widget getGallerySliverList( VoidCallback? lastComplete, Key? key, Key? centerKey, - int? lastTopitemIndex, + int? lastTopItemIndex, Rx? listMode, bool keepPosition = false, }) { final EhSettingService ehSettingService = Get.find(); final _key = key ?? ValueKey(galleryProviders.hashCode); - final BlockController _blockController = Get.find(); + final BlockController blockController = Get.find(); galleryProviders = galleryProviders?.where((GalleryProvider element) { - return !_blockController.matchRule( + return !blockController.matchRule( blockType: BlockType.title, text: element.englishTitle, ) && - !_blockController.matchRule( + !blockController.matchRule( blockType: BlockType.title, text: element.japaneseTitle, ) && - !_blockController.matchRule( + !blockController.matchRule( blockType: BlockType.uploader, text: element.uploader, ); @@ -379,7 +379,7 @@ Widget getGallerySliverList( next: next, lastComplete: lastComplete, centerKey: centerKey, - lastTopItemIndex: lastTopitemIndex, + lastTopItemIndex: lastTopItemIndex, keepPosition: keepPosition, ); case ListModeEnum.waterfall: @@ -389,7 +389,7 @@ Widget getGallerySliverList( next: next, lastComplete: lastComplete, centerKey: centerKey, - lastTopItemIndex: lastTopitemIndex, + lastTopItemIndex: lastTopItemIndex, ); case ListModeEnum.waterfallLarge: return EhWaterfallFlow( @@ -399,7 +399,7 @@ Widget getGallerySliverList( lastComplete: lastComplete, large: true, centerKey: centerKey, - lastTopItemIndex: lastTopitemIndex, + lastTopItemIndex: lastTopItemIndex, ); case ListModeEnum.simpleList: return buildGallerySliverListSimpleView( @@ -408,7 +408,7 @@ Widget getGallerySliverList( next: next, lastComplete: lastComplete, centerKey: centerKey, - lastTopItemIndex: lastTopitemIndex, + lastTopItemIndex: lastTopItemIndex, keepPosition: keepPosition, ); case ListModeEnum.grid: @@ -418,7 +418,7 @@ Widget getGallerySliverList( next: next, lastComplete: lastComplete, centerKey: centerKey, - lastTopItemIndex: lastTopitemIndex, + lastTopItemIndex: lastTopItemIndex, ); case ListModeEnum.debugSimple: return buildDebugSimple( @@ -427,7 +427,7 @@ Widget getGallerySliverList( next: next, lastComplete: lastComplete, centerKey: centerKey, - lastTopItemIndex: lastTopitemIndex, + lastTopItemIndex: lastTopItemIndex, ); case ListModeEnum.global: return const SliverFillRemaining( diff --git a/lib/pages/tab/view/search_image_page.dart b/lib/pages/tab/view/search_image_page.dart index 851aad8d6..2915fa13c 100644 --- a/lib/pages/tab/view/search_image_page.dart +++ b/lib/pages/tab/view/search_image_page.dart @@ -106,7 +106,7 @@ class SearchImagePage extends GetView { lastComplete: controller.lastComplete, // centerKey: centerKey, key: controller.sliverAnimatedListKey, - lastTopitemIndex: controller.lastTopitemIndex, + lastTopItemIndex: controller.lastTopitemIndex, ); } diff --git a/lib/pages/tab/view/search_page.dart b/lib/pages/tab/view/search_page.dart index af7a83808..fd5f794d7 100644 --- a/lib/pages/tab/view/search_page.dart +++ b/lib/pages/tab/view/search_page.dart @@ -16,7 +16,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:get/get.dart'; -import 'package:keframe/keframe.dart'; const CupertinoDynamicColor _kClearButtonColor = CupertinoDynamicColor.withBrightness( @@ -40,10 +39,10 @@ enum SearchMenuEnum { } class GallerySearchPage extends StatefulWidget { - const GallerySearchPage({Key? key}) : super(key: key); + const GallerySearchPage({super.key}); @override - _GallerySearchPageState createState() => _GallerySearchPageState(); + State createState() => _GallerySearchPageState(); } class _GallerySearchPageState extends State { @@ -121,7 +120,7 @@ class _GallerySearchPageState extends State { .paddingSymmetric(horizontal: 12, vertical: 4), ), ), - Expanded(child: _buildSearchRult(context)), + Expanded(child: _buildSearchResult(context)), ], ), ); @@ -129,90 +128,90 @@ class _GallerySearchPageState extends State { return cpf; } - Widget _buildSearchRult(BuildContext context) { - // logger.t('_buildSearchRult'); - return SizeCacheWidget( - child: CustomScrollView( - // cacheExtent: context.height * 2, - slivers: [ - // todo android上会有一次删除多个字符的问题 - // if (GetPlatform.isIOS) - // SliverFloatingPinnedPersistentHeader( - // delegate: SliverFloatingPinnedPersistentHeaderBuilder( - // minExtentProtoType: SizedBox( - // height: context.mediaQueryPadding.top, - // ), - // maxExtentProtoType: _maxExtentProtoTypeBar(context), - // builder: (_, __, maxExtent) => - // _buildSearchBar(_, __, maxExtent), - // ), - // ), - Obx(() { - return EhCupertinoSliverRefreshControl( - onRefresh: controller.listType == ListType.gallery - ? () => controller.onEditingComplete(clear: false) - : null); - }), - SliverPadding( - padding: EdgeInsets.zero, - key: centerKey, - ), - Obx(() => SliverSafeArea( - key: UniqueKey(), - bottom: false, - top: false, - sliver: () { - switch (controller.listType) { - case ListType.gallery: - return _buildListView(context); - case ListType.tag: - logger.d('tag list'); - return _getTagQryList(); - case ListType.init: - return _getInitView(); - } - }(), - )), - Obx(() { - if (controller.listType != ListType.tag) { - return EndIndicator( - pageState: controller.pageState, - loadDataMore: controller.loadDataMore, - ); - } else { - return SliverSafeArea( - bottom: false, - top: false, - sliver: SliverToBoxAdapter( - child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: controller.onEditingComplete, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - FontAwesomeIcons.magnifyingGlass, - size: 20, - color: CupertinoDynamicColor.resolve( - CupertinoColors.inactiveGray, context), - ).paddingOnly(right: 8), - Expanded( - child: Text( - '${L10n.of(context).search} ${controller.searchText}', - maxLines: 1, - softWrap: true, - overflow: TextOverflow.ellipsis, - ), + Widget _buildSearchResult(BuildContext context) { + return CustomScrollView( + // cacheExtent: context.height * 2, + slivers: [ + // todo android上会有一次删除多个字符的问题 + // if (GetPlatform.isIOS) + // SliverFloatingPinnedPersistentHeader( + // delegate: SliverFloatingPinnedPersistentHeaderBuilder( + // minExtentProtoType: SizedBox( + // height: context.mediaQueryPadding.top, + // ), + // maxExtentProtoType: _maxExtentProtoTypeBar(context), + // builder: (_, __, maxExtent) => + // _buildSearchBar(_, __, maxExtent), + // ), + // ), + Obx(() { + return EhCupertinoSliverRefreshControl( + // onRefresh: controller.listType == ListType.gallery + // ? () => controller.onEditingComplete(clear: false) + // : null); + onRefresh: controller.listType == ListType.gallery + ? () => controller.onRefresh() + : null); + }), + SliverPadding( + padding: EdgeInsets.zero, + key: centerKey, + ), + Obx(() => SliverSafeArea( + // key: UniqueKey(), + bottom: false, + top: false, + sliver: () { + switch (controller.listType) { + case ListType.gallery: + return _buildListView(context); + case ListType.tag: + logger.d('tag list'); + return _getTagQryList(); + case ListType.init: + return _getInitView(); + } + }(), + )), + Obx(() { + if (controller.listType != ListType.tag) { + return EndIndicator( + pageState: controller.pageState, + loadDataMore: controller.loadDataMore, + ); + } else { + return SliverSafeArea( + bottom: false, + top: false, + sliver: SliverToBoxAdapter( + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: controller.onEditingComplete, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + FontAwesomeIcons.magnifyingGlass, + size: 20, + color: CupertinoDynamicColor.resolve( + CupertinoColors.inactiveGray, context), + ).paddingOnly(right: 8), + Expanded( + child: Text( + '${L10n.of(context).search} ${controller.searchText}', + maxLines: 1, + softWrap: true, + overflow: TextOverflow.ellipsis, ), - ], - ).paddingSymmetric(vertical: 10, horizontal: 16), - ).autoCompressKeyboard(context), - ), - ); - } - }), - ], - ), + ), + ], + ).paddingSymmetric(vertical: 10, horizontal: 16), + ).autoCompressKeyboard(context), + ), + ); + } + }), + ], ); } @@ -224,20 +223,20 @@ class _GallerySearchPageState extends State { if (offset < transparentOffset) { iconOpacity = 1 - offset / transparentOffset; } - final _barHeigth = + final barHeight = kMinInteractiveDimensionCupertino + context.mediaQueryPadding.top; - return Container( + return SizedBox( height: maxExtentCallBackValue, child: Column( mainAxisSize: MainAxisSize.min, children: [ // const SizedBox(), Expanded( - flex: _barHeigth ~/ 1, + flex: barHeight ~/ 1, child: getNavigationBar(context), ), Expanded( - flex: (maxExtentCallBackValue - _barHeigth) ~/ 1, + flex: (maxExtentCallBackValue - barHeight) ~/ 1, child: Stack( // fit: StackFit.expand, alignment: Alignment.topCenter, @@ -299,8 +298,8 @@ class _GallerySearchPageState extends State { border: _kDefaultNavBarBorder, ), padding: const EdgeInsets.symmetric(horizontal: 8), - child: Row( - children: const [ + child: const Row( + children: [ Expanded( child: Padding( padding: EdgeInsets.only(left: 4, top: 4, bottom: 4), @@ -684,14 +683,17 @@ class _GallerySearchPageState extends State { } if (status.isSuccess) { + logger + .t('>>>>>>> controller.keepPosition ${controller.keepPosition}'); return getGallerySliverList( logic.state, controller.heroTag, next: logic.next, lastComplete: controller.lastComplete, - centerKey: centerKey, + // centerKey: centerKey, key: controller.sliverAnimatedListKey, - lastTopitemIndex: controller.lastTopitemIndex, + lastTopItemIndex: controller.lastTopitemIndex, + keepPosition: controller.keepPosition, ); } @@ -717,7 +719,7 @@ class _GallerySearchPageState extends State { } Widget _buildTrailing(BuildContext context) { - Widget _buildListBtns() { + Widget buildListButtons() { return GestureDetector( child: Row( mainAxisSize: MainAxisSize.min, @@ -859,16 +861,16 @@ class _GallerySearchPageState extends State { ); } - return _buildListBtns(); + return buildListButtons(); } } class SearchTextFieldIn extends StatelessWidget { const SearchTextFieldIn({ - Key? key, + super.key, this.multiline = false, this.iconOpacity = 0.0, - }) : super(key: key); + }); // SearchPageController get controller => Get.find(tag: searchPageCtrlTag); final bool multiline; @@ -1012,11 +1014,8 @@ class SearchSliverPinnedPersistentHeaderDelegate extends SliverPinnedPersistentHeaderDelegate { SearchSliverPinnedPersistentHeaderDelegate( {required this.child, - required Widget minExtentProtoType, - required Widget maxExtentProtoType}) - : super( - minExtentProtoType: minExtentProtoType, - maxExtentProtoType: maxExtentProtoType); + required super.minExtentProtoType, + required super.maxExtentProtoType}); final Widget child; @override diff --git a/lib/pages/tab/view/tabbar/favorite_sub_page.dart b/lib/pages/tab/view/tabbar/favorite_sub_page.dart index 417789775..8ef1e518b 100644 --- a/lib/pages/tab/view/tabbar/favorite_sub_page.dart +++ b/lib/pages/tab/view/tabbar/favorite_sub_page.dart @@ -120,7 +120,8 @@ class _FavoriteSubPageState extends State _favoriteSubListController.heroTag, next: logic.next, lastComplete: _favoriteSubListController.lastComplete, - key: _favoriteSubListController.sliverAnimatedListKey, + // key: _favoriteSubListController.sliverAnimatedListKey, + keepPosition: _favoriteSubListController.keepPosition, ); } diff --git a/lib/pages/tab/view/toplist_page.dart b/lib/pages/tab/view/toplist_page.dart index 408c90458..badcada22 100644 --- a/lib/pages/tab/view/toplist_page.dart +++ b/lib/pages/tab/view/toplist_page.dart @@ -244,7 +244,7 @@ class _ToplistTabState extends State { lastComplete: controller.lastComplete, centerKey: centerKey, key: controller.sliverAnimatedListKey, - lastTopitemIndex: controller.lastTopitemIndex, + lastTopItemIndex: controller.lastTopitemIndex, ); }