Skip to content

Commit

Permalink
{interceptors}: apply review tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
slovnicki committed Oct 16, 2024
1 parent df074ef commit c3e6711
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package/lib/beamer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library beamer;

export 'src/beam_guard.dart';
export 'src/beam_interceptor.dart';
export 'src/beam_interceptor_pop_scope.dart';
export 'src/beam_interceptor_scope.dart';
export 'src/beam_page.dart';
export 'src/beam_stack.dart';
export 'src/beam_state.dart';
Expand Down
2 changes: 1 addition & 1 deletion package/lib/src/beam_guard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BeamGuard {
/// but will not match '/books'. To match '/books' and everything after it,
/// use '/books*'.
///
/// See [canHandleGuard] for more details.
/// See [BeamStack.shouldCheckGuard] for more details.
///
/// For RegExp:
/// You can use RegExp instances and the delegate will check for a match using [RegExp.hasMatch]
Expand Down
7 changes: 5 additions & 2 deletions package/lib/src/beam_interceptor.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import 'package:beamer/beamer.dart';
import 'package:flutter/widgets.dart';

/// IDK LOL
class BeamInterceptor {
/// Creates a [BeamInterceptor] with defined properties.
///
/// [pathPatterns] and [intercept] must not be null.
/// [name] and [intercept] must not be null.
const BeamInterceptor({
this.enabled = true,
required this.name,
required this.intercept,
});

/// A name of the interceptor.
///
/// It is used to compare interceptors.
final String name;

/// Whether the interceptor is enabled.
final bool enabled;

/// The interceptor function.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import 'package:flutter/widgets.dart';
///
/// If any of the interceptors return true, the pop will not be invoked.
///
/// This works on Navigator.maybePop as well as all the Beamer.beamTo, Beamer.beamToNamed, Beamer.beamBack... operations.
/// This works on Navigator.pop as well as all the Beamer's beaming functions.
///
/// ```dart
/// BeamInterceptorPopScope(
/// BeamInterceptorScope(
/// interceptors: [BeamInterceptor(...), ...],
/// child: Center(
/// child: ElevatedButton(
Expand All @@ -20,8 +20,8 @@ import 'package:flutter/widgets.dart';
/// ),
/// );
/// ```
class BeamInterceptorPopScope extends StatefulWidget {
const BeamInterceptorPopScope({
class BeamInterceptorScope extends StatefulWidget {
const BeamInterceptorScope({
required this.child,
required this.interceptors,
this.beamerDelegate,
Expand All @@ -30,18 +30,17 @@ class BeamInterceptorPopScope extends StatefulWidget {

final Widget child;

/// The interceptors to check when a maybePop, or beamTo, beamToNamed, beamBack... is triggered.
/// The interceptors to check upon any beaming or popping.
final List<BeamInterceptor> interceptors;

/// The beamerDelegate to apply the interceptors to.
/// The [BeamerDelegate] to apply the interceptors to.
final BeamerDelegate? beamerDelegate;

@override
State<BeamInterceptorPopScope> createState() =>
_BeamInterceptorPopScopeState();
State<BeamInterceptorScope> createState() => _BeamInterceptorScopeState();
}

class _BeamInterceptorPopScopeState extends State<BeamInterceptorPopScope> {
class _BeamInterceptorScopeState extends State<BeamInterceptorScope> {
late BeamerDelegate beamerDelegate;

@override
Expand Down
2 changes: 0 additions & 2 deletions package/lib/src/beam_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,6 @@ class BeamPage extends Page {
transitionDuration: transitionDuration ?? Duration.zero,
reverseTransitionDuration: reverseTransitionDuration ?? Duration.zero,
pageBuilder: (context, animation, secondaryAnimation) => child,
transitionDuration: Duration.zero,
reverseTransitionDuration: Duration.zero,
);
default:
return MaterialPageRoute(
Expand Down

0 comments on commit c3e6711

Please sign in to comment.