import 'package:flutter/material.dart';
import 'package:flyinsono/lab/color/lab_colors.dart';

class LabLoadingWrapper extends StatelessWidget {
  const LabLoadingWrapper({
    Key? key,
    required this.child,
    required this.loading,
    this.decoration,
    this.margin,
  }) : super(key: key);

  final Widget child;
  final bool loading;
  final BoxDecoration? decoration;
  final EdgeInsetsGeometry? margin;

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        child,
        if (loading)
          Container(
            margin: margin,
            decoration: BoxDecoration(
              color: LabColors.base400.withOpacity(0.1),
              borderRadius: decoration?.borderRadius,
            ),
            child: Center(
              child: CircularProgressIndicator(
                color: LabColors.base600,
                strokeWidth: 2.5,
              ),
            ),
          ),
      ],
    );
  }
}
