From 6cbd78e836bdf4ac653b7ba4b7a7597f47c38aa5 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 2 Aug 2024 04:59:35 +0800 Subject: [PATCH] :dizzy: Optimize post editor transition --- lib/router.dart | 29 +++++++++++++++++++++-------- lib/screens/posts/post_detail.dart | 29 ++++++++++++----------------- lib/widgets/posts/post_list.dart | 19 ++++++++----------- 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/lib/router.dart b/lib/router.dart index fe08bb5..12cfea3 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -1,3 +1,5 @@ +import 'package:animations/animations.dart'; +import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:solian/models/realm.dart'; import 'package:solian/screens/about.dart'; @@ -93,15 +95,26 @@ abstract class AppRouter { GoRoute( path: '/posts/editor', name: 'postEditor', - builder: (context, state) { + pageBuilder: (context, state) { final arguments = state.extra as PostPublishArguments?; - return PostPublishScreen( - edit: arguments?.edit, - reply: arguments?.reply, - repost: arguments?.repost, - realm: arguments?.realm, - postListController: arguments?.postListController, - mode: int.tryParse(state.uri.queryParameters['mode'] ?? '0') ?? 0, + return CustomTransitionPage( + child: PostPublishScreen( + edit: arguments?.edit, + reply: arguments?.reply, + repost: arguments?.repost, + realm: arguments?.realm, + postListController: arguments?.postListController, + mode: int.tryParse(state.uri.queryParameters['mode'] ?? '0') ?? 0, + ), + transitionsBuilder: + (context, animation, secondaryAnimation, child) { + return FadeThroughTransition( + fillColor: Theme.of(context).scaffoldBackgroundColor, + animation: animation, + secondaryAnimation: secondaryAnimation, + child: child, + ); + }, ); }, ), diff --git a/lib/screens/posts/post_detail.dart b/lib/screens/posts/post_detail.dart index 8425616..c3d175e 100644 --- a/lib/screens/posts/post_detail.dart +++ b/lib/screens/posts/post_detail.dart @@ -3,7 +3,6 @@ import 'package:get/get.dart'; import 'package:solian/exts.dart'; import 'package:solian/models/post.dart'; import 'package:solian/providers/content/posts.dart'; -import 'package:solian/widgets/sized_container.dart'; import 'package:solian/widgets/posts/post_item.dart'; import 'package:solian/widgets/posts/post_replies.dart'; @@ -58,14 +57,12 @@ class _PostDetailScreenState extends State { return CustomScrollView( slivers: [ SliverToBoxAdapter( - child: CenteredContainer( - child: PostItem( - item: item!, - isClickable: true, - isFullDate: true, - isShowReply: false, - isContentSelectable: true, - ), + child: PostItem( + item: item!, + isClickable: true, + isFullDate: true, + isShowReply: false, + isContentSelectable: true, ), ), SliverToBoxAdapter( @@ -73,14 +70,12 @@ class _PostDetailScreenState extends State { .paddingOnly(top: 4), ), SliverToBoxAdapter( - child: CenteredContainer( - child: Align( - alignment: Alignment.centerLeft, - child: Text( - 'postReplies'.tr, - style: Theme.of(context).textTheme.headlineSmall, - ).paddingOnly(left: 24, right: 24, top: 16), - ), + child: Align( + alignment: Alignment.centerLeft, + child: Text( + 'postReplies'.tr, + style: Theme.of(context).textTheme.headlineSmall, + ).paddingOnly(left: 24, right: 24, top: 16), ), ), PostReplyList(item: item!), diff --git a/lib/widgets/posts/post_list.dart b/lib/widgets/posts/post_list.dart index 9c4d929..3b42e99 100644 --- a/lib/widgets/posts/post_list.dart +++ b/lib/widgets/posts/post_list.dart @@ -4,7 +4,6 @@ import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:solian/models/post.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/router.dart'; -import 'package:solian/widgets/sized_container.dart'; import 'package:solian/widgets/posts/post_action.dart'; import 'package:solian/widgets/posts/post_item.dart'; @@ -29,16 +28,14 @@ class PostListWidget extends StatelessWidget { pagingController: controller, builderDelegate: PagedChildBuilderDelegate( itemBuilder: (context, item, index) { - return CenteredContainer( - child: PostListEntryWidget( - isShowEmbed: isShowEmbed, - isNestedClickable: isNestedClickable, - isClickable: isClickable, - item: item, - onUpdate: () { - controller.refresh(); - }, - ), + return PostListEntryWidget( + isShowEmbed: isShowEmbed, + isNestedClickable: isNestedClickable, + isClickable: isClickable, + item: item, + onUpdate: () { + controller.refresh(); + }, ); }, ),