Skip to content

Commit

Permalink
- 调整路由代码;
Browse files Browse the repository at this point in the history
- 添加条件筛选视图展开动画参数 `final SpinnerViewTransitionsBuilder? transitionsBuilder;`;
  • Loading branch information
boomcx committed Jun 20, 2024
1 parent 109943a commit 5095101
Show file tree
Hide file tree
Showing 6 changed files with 1,225 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.1.1

- 调整路由代码;
- 添加条件筛选视图打开动画参数 `final SpinnerViewTransitionsBuilder? transitionsBuilder;`

## 0.1.0

* 升级sdk版本.
29 changes: 24 additions & 5 deletions lib/spinner/route/trans_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
import 'package:flutter/material.dart';
import './trans_route.dart';
import './trans_route_new.dart';

Widget _defaultTransitionsBuilder(
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return child;
return Align(
alignment: Alignment.topCenter,
child: SizeTransition(
sizeFactor: CurvedAnimation(
parent: animation,
curve: Curves.linear,
),
child: FadeTransition(
opacity: CurvedAnimation(
parent: animation,
curve: Curves.linear,
),
child: child,
),
),
);
}

typedef SpinnerViewTransitionsBuilder = Widget Function(
BuildContext, Animation<double>, Animation<double>, Widget);

class TransPopupRouter extends TransModalRoute {
TransPopupRouter({
super.settings,
this.offsetY,
required this.pageBuilder,
this.barrierColor,
this.barrierDismissible = true,
this.transitionsBuilder = _defaultTransitionsBuilder,
this.transitionsBuilder,
this.transitionDuration = const Duration(milliseconds: 300),
this.reverseTransitionDuration = const Duration(milliseconds: 100),
this.maintainState = true,
Expand All @@ -36,7 +54,7 @@ class TransPopupRouter extends TransModalRoute {
/// {@endtemplate}
///
/// The default transition is a jump cut (i.e. no animation).
final RouteTransitionsBuilder transitionsBuilder;
final RouteTransitionsBuilder? transitionsBuilder;

@override
final Duration transitionDuration;
Expand Down Expand Up @@ -71,7 +89,8 @@ class TransPopupRouter extends TransModalRoute {
@override
Widget buildTransitions(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
return transitionsBuilder(context, animation, secondaryAnimation, child);
return (transitionsBuilder ?? _defaultTransitionsBuilder)
.call(context, animation, secondaryAnimation, child);
}

@override
Expand Down
Loading

0 comments on commit 5095101

Please sign in to comment.