books
This commit is contained in:
@@ -62,7 +62,6 @@ class MenuStore with ChangeNotifier {
|
||||
?.label;
|
||||
|
||||
void selectMenuPath(String path) {
|
||||
print("======================selectMenuPath:$path======${_shouldAddHistory}==============");
|
||||
MenuNode root = MenuNode(
|
||||
path: '',
|
||||
label: '',
|
||||
@@ -160,6 +159,14 @@ class MenuStore with ChangeNotifier {
|
||||
}
|
||||
|
||||
void select(MenuNode menu) {
|
||||
bool hasHistory = _history.where((e) => e.menuPath==menu.path).isNotEmpty;
|
||||
if(hasHistory){
|
||||
_shouldAddHistory = false;
|
||||
selectMenuPath(menu.path);
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
|
||||
if (menu.isLeaf) {
|
||||
_state = state.copyWith(activeMenu: menu.path);
|
||||
goRouter.go(menu.path);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:components/components.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:iroute/navigation/router/routers/anima.dart';
|
||||
@@ -7,13 +8,13 @@ import 'package:iroute/navigation/router/routers/render.dart';
|
||||
import 'package:iroute/navigation/router/routers/scroll.dart';
|
||||
import 'package:iroute/navigation/router/routers/touch.dart';
|
||||
|
||||
import '../../transition/size_clip_transition.dart';
|
||||
import '../../views/app_navigation.dart';
|
||||
import '../../../pages/empty/empty_panel.dart';
|
||||
import 'dashboard.dart';
|
||||
import 'draw.dart';
|
||||
import 'layout.dart';
|
||||
|
||||
|
||||
final RouteBase appRoute = ShellRoute(
|
||||
builder: (BuildContext context, GoRouterState state, Widget child) {
|
||||
return TolyBookNavigation(content: child);
|
||||
@@ -29,9 +30,27 @@ final RouteBase appRoute = ShellRoute(
|
||||
animaRouters,
|
||||
GoRoute(
|
||||
path: '/code',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
pageBuilder: (BuildContext context, GoRouterState state) {
|
||||
String? path = state.uri.queryParameters['path'];
|
||||
return CodeView(path: path??'',);
|
||||
return CustomTransitionPage(
|
||||
transitionDuration: const Duration(milliseconds: 500),
|
||||
reverseTransitionDuration: const Duration(milliseconds: 500),
|
||||
child: CodeView(
|
||||
path: path ?? '',
|
||||
),
|
||||
transitionsBuilder: (_, a1, a2, child) =>
|
||||
SizeClipTransition(
|
||||
animation: a1,
|
||||
secondaryAnimation: a2,
|
||||
child: child,
|
||||
)
|
||||
// CupertinoPageTransition(
|
||||
// primaryRouteAnimation: a1,
|
||||
// secondaryRouteAnimation: a2,
|
||||
// linearTransition: true,
|
||||
// child: child,
|
||||
// ),
|
||||
);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
|
||||
@@ -5,32 +5,76 @@ import 'package:iroute/pages/empty/empty_panel.dart';
|
||||
|
||||
final RouteBase drawRouters = GoRoute(
|
||||
path: '/draw/chapter:index',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
pageBuilder: (BuildContext context, GoRouterState state) {
|
||||
String? index = state.pathParameters['index'];
|
||||
switch(index){
|
||||
Widget child = const EmptyPanel(msg: '暂未实现');
|
||||
switch (index) {
|
||||
case '1':
|
||||
return const P01Page();
|
||||
child = const P01Page();
|
||||
break;
|
||||
case '2':
|
||||
return const P02Page();
|
||||
child = const P02Page();
|
||||
break;
|
||||
case '3':
|
||||
return const P03Page();
|
||||
child = const P03Page();
|
||||
break;
|
||||
case '4':
|
||||
return const P04Page();
|
||||
child = const P04Page();
|
||||
break;
|
||||
case '5':
|
||||
return const P05Page();
|
||||
child = const P05Page();
|
||||
break;
|
||||
case '6':
|
||||
return const P06Page();
|
||||
child = const P06Page();
|
||||
break;
|
||||
case '7':
|
||||
return const P07Page();
|
||||
child = const P07Page();
|
||||
break;
|
||||
case '8':
|
||||
return const P08Page();
|
||||
child = const P08Page();
|
||||
break;
|
||||
case '9':
|
||||
return const P09Page();
|
||||
child = const P09Page();
|
||||
break;
|
||||
case '10':
|
||||
return const P10Page();
|
||||
case '11':
|
||||
return const P11Page();
|
||||
child = const P10Page();
|
||||
break;
|
||||
case '11':
|
||||
child = const P11Page();
|
||||
break;
|
||||
case '12':
|
||||
child = const P12Page();
|
||||
break;
|
||||
case '13':
|
||||
child = const P13Page();
|
||||
break;
|
||||
case '14':
|
||||
child = const P14Page();
|
||||
break;
|
||||
case '15':
|
||||
child = const P15Page();
|
||||
break;
|
||||
case '16':
|
||||
child = const P16Page();
|
||||
break;
|
||||
case '17':
|
||||
child = const P17Page();
|
||||
break;
|
||||
case '18':
|
||||
child = const P18Page();
|
||||
break;
|
||||
}
|
||||
return const EmptyPanel(msg: '暂未实现');
|
||||
|
||||
return CustomTransitionPage(
|
||||
child: child,
|
||||
transitionsBuilder: (ctx, a1, a2, child) => FadeTransition(
|
||||
opacity: a1.drive(CurveTween(curve: Curves.easeIn)),
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: Offset.zero, end: const Offset(-1.0, 0.0))
|
||||
.animate(a2),
|
||||
child: child,
|
||||
),
|
||||
));
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,43 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class FadePageTransitionsBuilder extends PageTransitionsBuilder {
|
||||
|
||||
const FadePageTransitionsBuilder();
|
||||
|
||||
@override
|
||||
Widget buildTransitions<T>(
|
||||
PageRoute<T>? route,
|
||||
BuildContext? context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child,
|
||||
) {
|
||||
return _FadePagePageTransition(
|
||||
animation: animation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
PageRoute<T>? route,
|
||||
BuildContext? context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child,
|
||||
) {
|
||||
return FadeTransition(
|
||||
opacity: animation.drive(CurveTween(curve: Curves.easeIn)),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _FadePagePageTransition extends StatelessWidget {
|
||||
|
||||
const _FadePagePageTransition({
|
||||
required this.animation,
|
||||
required this.secondaryAnimation,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
final Animation<double> animation;
|
||||
final Animation<double> secondaryAnimation;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var curveTween = CurveTween(curve: Curves.easeIn);
|
||||
return FadeTransition(
|
||||
opacity: animation.drive(curveTween),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
105
lib/navigation/transition/size_clip_transition.dart
Normal file
105
lib/navigation/transition/size_clip_transition.dart
Normal file
@@ -0,0 +1,105 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class SizeClipTransition extends StatelessWidget {
|
||||
final Animation<double> animation;
|
||||
final Animation<double> secondaryAnimation;
|
||||
final Widget child;
|
||||
|
||||
const SizeClipTransition({
|
||||
super.key,
|
||||
required this.animation,
|
||||
required this.secondaryAnimation,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ClipPath(
|
||||
clipper: CirclePathClipper(Curves.easeIn.transform(animation.value)),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SizePathClipper extends CustomClipper<Path> {
|
||||
final double progress;
|
||||
|
||||
SizePathClipper(this.progress);
|
||||
|
||||
@override
|
||||
Path getClip(Size size) {
|
||||
Rect box = Rect.fromLTWH(0, 0, size.width, size.height);
|
||||
Rect center = Rect.fromCenter(
|
||||
center: Offset(size.width / 2, size.height / 2),
|
||||
width: size.width * (1 - progress),
|
||||
height: size.height,
|
||||
);
|
||||
|
||||
return Path()
|
||||
..addRect(box)
|
||||
..addRect(center)
|
||||
..fillType = PathFillType.evenOdd;
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldReclip(covariant SizePathClipper oldClipper) {
|
||||
return oldClipper.progress != progress;
|
||||
}
|
||||
}
|
||||
|
||||
class ScalePathClipper extends CustomClipper<Path> {
|
||||
final double progress;
|
||||
|
||||
ScalePathClipper(this.progress);
|
||||
|
||||
@override
|
||||
Path getClip(Size size) {
|
||||
Rect box = Rect.fromLTWH(0, 0, size.width, size.height);
|
||||
Rect center = Rect.fromCenter(
|
||||
center: Offset(size.width / 2, size.height / 2),
|
||||
width: size.width * (1 - progress),
|
||||
height: size.height* (1 - progress),
|
||||
);
|
||||
|
||||
return Path()
|
||||
..addRect(box)
|
||||
..addRect(center)
|
||||
..fillType = PathFillType.evenOdd;
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldReclip(covariant ScalePathClipper oldClipper) {
|
||||
return oldClipper.progress != progress;
|
||||
}
|
||||
}
|
||||
|
||||
class CirclePathClipper extends CustomClipper<Path> {
|
||||
final double progress;
|
||||
|
||||
CirclePathClipper(this.progress);
|
||||
|
||||
@override
|
||||
Path getClip(Size size) {
|
||||
print('progress:$progress');
|
||||
if(progress==0){
|
||||
return Path();
|
||||
}
|
||||
Rect box = Rect.fromLTWH(0, 0, size.width, size.height);
|
||||
Rect center = Rect.fromCircle(
|
||||
center: Offset(size.width , 0),
|
||||
radius: sqrt(size.width*size.width+size.height*size.height) * (progress),
|
||||
);
|
||||
|
||||
Path zone = Path()..addRect(box);
|
||||
Path cliper = Path()..addOval(center);
|
||||
|
||||
return Path.combine(PathOperation.intersect, zone, cliper );
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldReclip(covariant CirclePathClipper oldClipper) {
|
||||
return oldClipper.progress != progress;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ class TolyBookNavigation extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Scaffold(
|
||||
body: Row(
|
||||
children: [
|
||||
|
||||
@@ -10,23 +10,26 @@ class AppTopBar extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
// String? lable = MenuScope.of(context).currentNode?.label;
|
||||
return DragToMoveWrap(
|
||||
child: Stack(
|
||||
alignment: Alignment.centerRight,
|
||||
children: [Row(
|
||||
children: [
|
||||
SizedBox(width: 20,),
|
||||
RouteBackIndicator(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
||||
child: RouterIndicator(),
|
||||
),
|
||||
// Text(
|
||||
// '$lable',
|
||||
// style: TextStyle(fontSize: 14),
|
||||
// ),
|
||||
Spacer(),
|
||||
],
|
||||
),WindowButtons()]
|
||||
child: SizedBox(
|
||||
height: 36,
|
||||
child: Stack(
|
||||
alignment: Alignment.centerRight,
|
||||
children: [Row(
|
||||
children: [
|
||||
SizedBox(width: 20,),
|
||||
RouteBackIndicator(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
||||
child: RouterIndicator(),
|
||||
),
|
||||
// Text(
|
||||
// '$lable',
|
||||
// style: TextStyle(fontSize: 14),
|
||||
// ),
|
||||
Spacer(),
|
||||
],
|
||||
),WindowButtons()]
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user