import 'package:diplomaticquarterapp/theme/theme_value.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:gif_view/gif_view.dart';

class GifLoaderContainer extends StatefulWidget {
  bool barrierDismissible;

  GifLoaderContainer({this.barrierDismissible = true});

  @override
  _GifLoaderContainerState createState() => _GifLoaderContainerState();
}

class _GifLoaderContainerState extends State<GifLoaderContainer> with TickerProviderStateMixin {
  late GifController controller;

  @override
  void initState() {
    controller = GifController();

    WidgetsBinding.instance.addPostFrameCallback((_) {
      try {
        controller = GifController(autoPlay: true, onFinish: () {}, loop: true);
        //  controller.repeat(min: 0, max: 11, period: Duration(milliseconds: 750), reverse: true);
      } catch (ex) {}
    });
    super.initState();
  }

  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async {
        return widget.barrierDismissible;
      },
      child: Center(
        //progress-loading.gif
        child: Container(
          // margin: EdgeInsets.only(bottom: 40),
          child: CircularProgressIndicator(
            color: appColor,
          ),
        ),
      ),
    );
  }
}
