Skip to content

Commit

Permalink
Feat: 导航栏自动隐藏
Browse files Browse the repository at this point in the history
  • Loading branch information
honjow committed Jun 12, 2021
1 parent 5198e32 commit 690392e
Show file tree
Hide file tree
Showing 13 changed files with 344 additions and 279 deletions.
8 changes: 2 additions & 6 deletions lib/pages/gallery/controller/gallery_fav_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class GalleryFavController extends GetxController {

/// 点击收藏按钮处理
Future<bool?> tapFav() async {
logger.v('tapFav');
// logger.v('tapFav');

/// 网络收藏或者本地收藏
if (favcat.isNotEmpty || _pageController.localFav) {
Expand Down Expand Up @@ -148,15 +148,12 @@ class GalleryFavController extends GetxController {
)
: <Favcat>[];

// favList.add({'favId': 'l', 'favTitle': S.of(context).local_favorite});
favList.add(Favcat(favId: 'l', favTitle: S.of(context).local_favorite));

// diaolog 获取选择结果
final Map<String, String>? result =
await _favController.showFav(context, favList);

// logger.v('$result ${result.runtimeType}');

if (result != null && result is Map) {
logger.v('add fav $result');

Expand Down Expand Up @@ -200,9 +197,8 @@ class GalleryFavController extends GetxController {
isLoading = true;

try {
logger.v('[${_pageController.galleryItem.favcat}]');
if (favcat.isNotEmpty && favcat != 'l') {
logger.v('取消网络收藏');
logger.v('删除网络收藏');
await GalleryFavParser.galleryAddfavorite(
_pageController.galleryItem.gid!,
_pageController.galleryItem.token!,
Expand Down
17 changes: 7 additions & 10 deletions lib/pages/item/controller/galleryitem_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,14 @@ class GalleryItemController extends GetxController {
set isFav(bool val) => _isFav.value = val;

void setFavTitle({String favTitle = '', String? favcat}) {
// galleryItem.favTitle = favTitle;
galleryItem.copyWith(favTitle: favTitle);
// logger.d('setFavTitle ');
galleryItem = galleryItem.copyWith(favTitle: favTitle);
isFav = favTitle.isNotEmpty;
if (favcat != null) {
// galleryItem.favcat = favcat;
galleryItem.copyWith(favcat: favcat);
// logger.d('item show fav');
if (favcat != null || (favcat?.isNotEmpty ?? false)) {
galleryItem = galleryItem.copyWith(favcat: favcat);
logger.d('item set favcat $favcat');
} else {
// galleryItem.favcat = '';
// galleryItem.favTitle = '';
galleryItem.copyWith(favcat: '', favTitle: '');
galleryItem = galleryItem.copyWith(favcat: '', favTitle: '');
}
}

Expand Down Expand Up @@ -96,7 +93,7 @@ class GalleryItemController extends GetxController {
void firstPutPreview(List<GalleryPreview> galleryPreview) {
if (galleryPreview.isNotEmpty) {
// galleryItem.galleryPreview = galleryPreview;
galleryItem.copyWith(galleryPreview: galleryPreview);
galleryItem = galleryItem.copyWith(galleryPreview: galleryPreview);
}

firstPagePreview =
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/item/gallery_item_flow_large.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ class GalleryItemFlowLarge extends StatelessWidget {
//阴影
BoxShadow(
color: CupertinoDynamicColor.resolve(
CupertinoColors.systemGrey5, context),
blurRadius: 5,
CupertinoColors.systemGrey4, context),
blurRadius: 10,
)
]),
child: Column(
Expand Down
5 changes: 5 additions & 0 deletions lib/pages/tab/controller/search_page_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ class SearchPageController extends TabViewController {

/// 点击键盘完成
Future<void> onEditingComplete({bool clear = true}) async {
isBackgroundRefresh = false;
if (!cancelToken.isCancelled) {
cancelToken.cancel();
}
change(state, status: RxStatus.success());
listType = ListType.gallery;
await _startSearch(clear: clear);
}
Expand Down
94 changes: 45 additions & 49 deletions lib/pages/tab/view/favorite_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import 'package:fehviewer/pages/tab/view/gallery_base.dart';
import 'package:fehviewer/pages/tab/view/tab_base.dart';
import 'package:fehviewer/route/navigator_util.dart';
import 'package:fehviewer/route/routes.dart';
import 'package:fehviewer/utils/cust_lib/persistent_header_builder.dart';
import 'package:fehviewer/utils/cust_lib/sliver/sliver_persistent_header.dart';
import 'package:fehviewer/utils/logger.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -221,32 +223,30 @@ class FavoriteTab extends GetView<FavoriteViewController> {
);

return CupertinoPageScaffold(
navigationBar: navigationBar,
child: SafeArea(
top: false,
bottom: false,
child: CupertinoScrollbar(
// navigationBar: navigationBar,
child: CupertinoScrollbar(
controller: scrollController,
child: CustomScrollView(
controller: scrollController,
child: CustomScrollView(
controller: scrollController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: <Widget>[
// sliverNavigationBar,
SliverPadding(
padding: EdgeInsets.only(
top: context.mediaQueryPadding.top +
kMinInteractiveDimensionCupertino),
sliver: CupertinoSliverRefreshControl(
onRefresh: controller.onRefresh,
),
),
SliverSafeArea(
top: false,
sliver: _getGalleryList(),
physics: const AlwaysScrollableScrollPhysics(),
slivers: <Widget>[
// sliverNavigationBar,
SliverFloatingPinnedPersistentHeader(
delegate: SliverFloatingPinnedPersistentHeaderBuilder(
minExtentProtoType: const SizedBox(),
maxExtentProtoType: navigationBar,
builder: (_, __, ___) => navigationBar,
),
_endIndicator(),
],
),
),
CupertinoSliverRefreshControl(
onRefresh: controller.onRefresh,
),
SliverSafeArea(
top: false,
sliver: _getGalleryList(),
),
_endIndicator(),
],
),
),
);
Expand All @@ -264,32 +264,28 @@ class FavoriteTab extends GetView<FavoriteViewController> {
);

return CupertinoPageScaffold(
navigationBar: navigationBar,
child: SafeArea(
top: false,
bottom: false,
child: CupertinoScrollbar(
controller: scrollController,
child: CustomScrollView(slivers: <Widget>[
// sliverNavigationBar,
SliverPadding(
padding: EdgeInsets.only(
top: Get.context?.mediaQueryPadding.top ??
0 + kMinInteractiveDimensionCupertino),
sliver: CupertinoSliverRefreshControl(
onRefresh: () async {
await controller.reloadData();
},
),
),
// todo 可能要设置刷新?
SliverSafeArea(
top: false,
sliver: _getGalleryList(),
// navigationBar: navigationBar,
child: CupertinoScrollbar(
controller: scrollController,
child: CustomScrollView(slivers: <Widget>[
// sliverNavigationBar,
SliverFloatingPinnedPersistentHeader(
delegate: SliverFloatingPinnedPersistentHeaderBuilder(
minExtentProtoType: const SizedBox(),
maxExtentProtoType: navigationBar,
builder: (_, __, ___) => navigationBar,
),
_endIndicator(),
]),
),
),
CupertinoSliverRefreshControl(
onRefresh: controller.onRefresh,
),
// todo 可能要设置刷新?
SliverSafeArea(
top: false,
sliver: _getGalleryList(),
),
_endIndicator(),
]),
),
);
}
Expand Down
Loading

0 comments on commit 690392e

Please sign in to comment.