Skip to content

Commit e218852

Browse files
committed
feat: fix hero animation
1 parent 6d3e393 commit e218852

File tree

5 files changed

+37
-48
lines changed

5 files changed

+37
-48
lines changed

lib/route.dart

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'package:flutter/foundation.dart';
55
import 'package:flutter/material.dart';
66
import 'package:flutter_bloc/flutter_bloc.dart';
77
import 'package:go_router/go_router.dart';
8-
import 'package:local_hero/local_hero.dart';
98
import 'package:tuihub_protos/librarian/sephirah/v1/gebura.pb.dart';
109
import 'package:tuihub_protos/librarian/sephirah/v1/tiphereth.pb.dart';
1110
import 'package:tuihub_protos/librarian/v1/common.pb.dart';
@@ -366,13 +365,6 @@ class GeburaRoute extends StatefulShellBranchData {
366365
const GeburaRoute();
367366

368367
static final GlobalKey<NavigatorState> $navigatorKey = _geburaNavigateKey;
369-
370-
static Widget rootWidget({required Widget child}) {
371-
return LocalHeroScope(
372-
curve: Curves.easeInOut,
373-
child: child,
374-
);
375-
}
376368
}
377369

378370
class GeburaRootRoute extends GoRouteData {
@@ -389,14 +381,12 @@ class GeburaStoreRoute extends GoRouteData {
389381

390382
@override
391383
Page<void> buildPage(BuildContext context, GoRouterState state) {
392-
return NoTransitionPage(
393-
child: GeburaRoute.rootWidget(
394-
child: const ModuleFramePage(
395-
leftPart: GeburaNav(
396-
function: GeburaFunctions.store,
397-
),
398-
middlePart: GeburaStorePage(),
384+
return const NoTransitionPage(
385+
child: ModuleFramePage(
386+
leftPart: GeburaNav(
387+
function: GeburaFunctions.store,
399388
),
389+
middlePart: GeburaStorePage(),
400390
),
401391
);
402392
}
@@ -407,14 +397,12 @@ class GeburaLibraryRoute extends GoRouteData {
407397

408398
@override
409399
Page<void> buildPage(BuildContext context, GoRouterState state) {
410-
return NoTransitionPage(
411-
child: GeburaRoute.rootWidget(
412-
child: const ModuleFramePage(
413-
leftPart: GeburaNav(
414-
function: GeburaFunctions.library,
415-
),
416-
middlePart: GeburaLibraryOverview(),
400+
return const NoTransitionPage(
401+
child: ModuleFramePage(
402+
leftPart: GeburaNav(
403+
function: GeburaFunctions.library,
417404
),
405+
middlePart: GeburaLibraryOverview(),
418406
),
419407
);
420408
}
@@ -438,14 +426,12 @@ class GeburaLibrarySettingsRoute extends GoRouteData {
438426
),
439427
};
440428
return NoTransitionPage(
441-
child: GeburaRoute.rootWidget(
442-
child: ModuleFramePage(
443-
leftPart: const GeburaNav(
444-
function: GeburaFunctions.librarySettings,
445-
),
446-
middlePart: const GeburaLibrarySettingsPage(),
447-
rightPart: actions[action] ?? Container(),
429+
child: ModuleFramePage(
430+
leftPart: const GeburaNav(
431+
function: GeburaFunctions.librarySettings,
448432
),
433+
middlePart: const GeburaLibrarySettingsPage(),
434+
rightPart: actions[action] ?? Container(),
449435
),
450436
);
451437
}
@@ -493,17 +479,19 @@ class GeburaLibraryDetailRoute extends GoRouteData {
493479
: null,
494480
),
495481
};
496-
return NoTransitionPage(
497-
child: GeburaRoute.rootWidget(
498-
child: ModuleFramePage(
499-
leftPart: GeburaNav(
500-
function: GeburaFunctions.library,
501-
selectedItem: uuid,
502-
),
503-
middlePart: GeburaLibraryDetailPage(uuid: uuid),
504-
rightPart: actions[action] ?? Container(),
482+
return CustomTransitionPage(
483+
child: ModuleFramePage(
484+
leftPart: GeburaNav(
485+
function: GeburaFunctions.library,
486+
selectedItem: uuid,
505487
),
488+
middlePart: GeburaLibraryDetailPage(uuid: uuid),
489+
rightPart: actions[action] ?? Container(),
506490
),
491+
transitionsBuilder: (BuildContext context, Animation<double> animation,
492+
Animation<double> secondaryAnimation, Widget child) {
493+
return child;
494+
},
507495
);
508496
}
509497
}

lib/view/pages/gebura/gebura_library_detail.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import 'package:flutter/material.dart';
1010
import 'package:flutter_bloc/flutter_bloc.dart';
1111
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
1212
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
13-
import 'package:local_hero/local_hero.dart';
1413
import 'package:smooth_scroll_multiplatform/smooth_scroll_multiplatform.dart';
1514
import 'package:universal_io/io.dart';
1615
import 'package:universal_ui/universal_ui.dart';
@@ -164,12 +163,10 @@ class GeburaLibraryDetailPage extends StatelessWidget {
164163
md: 3,
165164
child: Padding(
166165
padding: const EdgeInsets.fromLTRB(8, 16, 8, 8),
167-
child: LocalHero(
168-
key: ValueKey(item.uuid),
166+
child: Hero(
169167
tag: item.uuid,
170168
child: GeburaAppCoverImage(
171169
path: item.coverImagePath,
172-
url: item.coverImageUrl,
173170
),
174171
),
175172
),

lib/view/pages/gebura/gebura_library_overview.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_bloc/flutter_bloc.dart';
3-
import 'package:local_hero/local_hero.dart';
43
import 'package:smooth_scroll_multiplatform/smooth_scroll_multiplatform.dart';
54
import 'package:universal_ui/universal_ui.dart';
65

@@ -177,7 +176,7 @@ class _GeburaLibraryOverviewItemState
177176
),
178177
),
179178
Center(
180-
child: LocalHero(
179+
child: Hero(
181180
tag: widget.item.uuid,
182181
child: GeburaAppCoverImage(path: widget.item.coverImagePath),
183182
),

packages/universal_ui/lib/src/page.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class UniversalPageRoute<T> extends PageRoute<T> {
1515
assert(opaque);
1616
}
1717

18-
/// Builds the primary contents of the route.
1918
final WidgetBuilder builder;
2019

2120
@override
@@ -30,17 +29,24 @@ class UniversalPageRoute<T> extends PageRoute<T> {
3029
@override
3130
Widget buildPage(BuildContext context, Animation<double> animation,
3231
Animation<double> secondaryAnimation) {
32+
return builder(context);
33+
}
34+
35+
@override
36+
Widget buildTransitions(BuildContext context, Animation<double> animation,
37+
Animation<double> secondaryAnimation, Widget child) {
3338
final design = UniversalUI.of(context).design;
39+
3440
switch (design) {
3541
case UIDesign.material:
3642
final material.PageTransitionsTheme theme =
3743
material.Theme.of(context).pageTransitionsTheme;
3844
return theme.buildTransitions<T>(
39-
this, context, animation, secondaryAnimation, builder(context));
45+
this, context, animation, secondaryAnimation, child);
4046
case UIDesign.fluent:
4147
return fluent.DrillInPageTransition(
4248
animation: animation,
43-
child: builder(context),
49+
child: child,
4450
);
4551
}
4652
}

pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ dependencies:
9292
extended_image: ^9.0.3
9393
font_awesome_flutter: ^10.7.0
9494
buttons_tabbar: ^1.3.10
95-
local_hero: ^0.3.0
9695
auto_size_text: ^3.0.0
9796
flip_card: ^0.7.0
9897
flutter_multi_select_items: ^0.4.3

0 commit comments

Comments
 (0)