import 'package:flutter/material.dart';

import 'loadable_state_consumer.dart';

class LoadableStateBackgroundLoading extends StatelessWidget {
  final bool visible;
  const LoadableStateBackgroundLoading({required this.visible, super.key});

  @override
  Widget build(BuildContext context) => AnimatedSwitcher(
    duration: LoadableStateConsumer.animationDuration,
    transitionBuilder: (Widget child, Animation<double> animation) =>
        SlideTransition(
          position: Tween<Offset>(
            begin: const Offset(0.0, -1.0),
            end: Offset.zero,
          ).animate(animation),
          child: child,
        ),
    child: visible ? const LinearProgressIndicator() : const SizedBox.shrink(),
  );
}
