LCOV - code coverage report
Current view: top level - src/routing - story_router_delegate.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 39 0.0 %
Date: 2021-10-28 11:30:47 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:flutter/material.dart';
       2             : import 'package:widgetbook/src/navigation/ui/navigation_panel.dart';
       3             : import 'package:widgetbook/src/providers/canvas_provider.dart';
       4             : import 'package:widgetbook/src/providers/canvas_state.dart';
       5             : import 'package:widgetbook/src/providers/organizer_provider.dart';
       6             : import 'package:widgetbook/src/routing/story_route_path.dart';
       7             : import 'package:widgetbook/src/styled_widgets/styled_scaffold.dart';
       8             : import 'package:widgetbook/src/widgets/wrapper.dart';
       9             : 
      10             : import 'package:widgetbook/widgetbook.dart';
      11             : 
      12             : class NoAnimationTransitionDelegate extends TransitionDelegate<void> {
      13           0 :   @override
      14             :   Iterable<RouteTransitionRecord> resolve({
      15             :     required List<RouteTransitionRecord> newPageRouteHistory,
      16             :     required Map<RouteTransitionRecord?, RouteTransitionRecord>
      17             :         locationToExitingPageRoute,
      18             :     required Map<RouteTransitionRecord?, List<RouteTransitionRecord>>
      19             :         pageRouteToPagelessRoutes,
      20             :   }) {
      21           0 :     final results = <RouteTransitionRecord>[];
      22             : 
      23           0 :     for (final pageRoute in newPageRouteHistory) {
      24           0 :       if (pageRoute.isWaitingForEnteringDecision) {
      25           0 :         pageRoute.markForAdd();
      26             :       }
      27           0 :       results.add(pageRoute);
      28             :     }
      29           0 :     for (final exitingPageRoute in locationToExitingPageRoute.values) {
      30           0 :       if (exitingPageRoute.isWaitingForExitingDecision) {
      31           0 :         exitingPageRoute.markForRemove();
      32           0 :         final pagelessRoutes = pageRouteToPagelessRoutes[exitingPageRoute];
      33             :         if (pagelessRoutes != null) {
      34           0 :           for (final pagelessRoute in pagelessRoutes) {
      35           0 :             pagelessRoute.markForRemove();
      36             :           }
      37             :         }
      38             :       }
      39           0 :       results.add(exitingPageRoute);
      40             :     }
      41             :     return results;
      42             :   }
      43             : }
      44             : 
      45             : class StoryRouterDelegate extends RouterDelegate<StoryRoutePath>
      46             :     with ChangeNotifier, PopNavigatorRouterDelegateMixin<StoryRoutePath> {
      47           0 :   StoryRouterDelegate({
      48             :     required this.appInfo,
      49             :     required this.canvasState,
      50           0 :   }) : navigatorKey = GlobalKey<NavigatorState>();
      51             : 
      52             :   @override
      53             :   final GlobalKey<NavigatorState> navigatorKey;
      54             : 
      55             :   final AppInfo appInfo;
      56             :   final CanvasState canvasState;
      57             : 
      58           0 :   @override
      59             :   Widget build(BuildContext context) {
      60           0 :     return Navigator(
      61           0 :       transitionDelegate: NoAnimationTransitionDelegate(),
      62           0 :       pages: [
      63           0 :         MaterialPage<dynamic>(
      64           0 :           key: ValueKey(currentConfiguration.path),
      65           0 :           child: StyledScaffold(
      66           0 :             body: Padding(
      67             :               padding: const EdgeInsets.all(16),
      68           0 :               child: Builder(builder: (context) {
      69           0 :                 final state = OrganizerProvider.of(context)!.state;
      70           0 :                 return Row(
      71           0 :                   children: [
      72           0 :                     NavigationPanel(
      73           0 :                       appInfo: appInfo,
      74           0 :                       categories: state.filteredCategories,
      75             :                     ),
      76             :                     const SizedBox(
      77             :                       width: 16,
      78             :                     ),
      79             :                     const Expanded(
      80             :                       child: Editor(),
      81             :                     ),
      82             :                   ],
      83             :                 );
      84             :               }),
      85             :             ),
      86             :           ),
      87             :         )
      88             :       ],
      89           0 :       onPopPage: (route, dynamic result) {
      90           0 :         if (!route.didPop(result)) {
      91             :           return false;
      92             :         }
      93             : 
      94           0 :         CanvasProvider.of(context)!.deselectStory();
      95             : 
      96           0 :         notifyListeners();
      97             : 
      98             :         return true;
      99             :       },
     100             :     );
     101             :   }
     102             : 
     103           0 :   @override
     104           0 :   StoryRoutePath get currentConfiguration => StoryRoutePath(
     105           0 :         path: canvasState.selectedStory == null
     106             :             ? '/'
     107           0 :             : '/stories/${canvasState.selectedStory!.path}',
     108             :       );
     109             : 
     110             :   @override
     111           0 :   Future<void> setNewRoutePath(StoryRoutePath configuration) async {}
     112             : }

Generated by: LCOV version 1.15