import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:kasy_kit/core/navigation/kasy_navigation_config.dart';
import 'package:kasy_kit/core/navigation/kasy_route_transition.dart';
import 'package:kasy_kit/core/navigation/kasy_transition_kind.dart';

/// GoRouter page with a [KasyNavigationConfig]-driven transition.
CustomTransitionPage<T> kasyTransitionPage<T>({
  required LocalKey key,
  required Widget child,
  KasyTransitionKind? transition,
  Color? fillColor,
  Duration? transitionDuration,
  Duration? reverseTransitionDuration,
}) {
  final KasyTransitionKind kind = transition ?? KasyNavigationConfig.push;
  return CustomTransitionPage<T>(
    key: key,
    transitionDuration:
        transitionDuration ?? kasyTransitionDurationFor(kind),
    reverseTransitionDuration:
        reverseTransitionDuration ?? kasyReverseTransitionDurationFor(kind),
    child: child,
    transitionsBuilder: (
      context,
      animation,
      secondaryAnimation,
      pageChild,
    ) {
      return kasyBuildRouteTransition(
        context: context,
        animation: animation,
        secondaryAnimation: secondaryAnimation,
        child: pageChild,
        kind: kind,
        fillColor: fillColor,
      );
    },
  );
}
