import 'package:carousel_pro/carousel_pro.dart';
import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart';
import 'package:flutter/material.dart';

class CarouselSlider extends StatelessWidget {
  const CarouselSlider({
    @required this.imagesUrlList,
    @required this.width,
    @required this.height,
    this.onImageChange,
    this.autoPlay = false,
    Key key,
  }) : super(key: key);

  final List imagesUrlList;
  final double height;
  final double width;
  final bool autoPlay;
  final Function onImageChange;
  @override
  Widget build(BuildContext context) {
    return Carousel(
      boxFit: BoxFit.cover,
      autoplay: true,
      animationCurve: Curves.fastOutSlowIn,
      animationDuration: Duration(milliseconds: 1000),
      dotSize: 0.0,
      dotIncreasedColor: Colors.transparent,
      dotBgColor: Colors.transparent,
      dotPosition: DotPosition.bottomCenter,
      dotVerticalPadding: 10.0,
      onImageChange: onImageChange,
      showIndicator: true,
      indicatorBgPadding: 7.0,

      images: imagesUrlList.map((image) {
        return Builder(builder: (BuildContext context) {
          return Container(
            child: Image.network(image, loadingBuilder: (BuildContext context,
                    Widget child, ImageChunkEvent loadingProgress) {
              if (loadingProgress == null) return child;
              return Center(
                child: SizedBox(
                  width: 40.0,
                  height: 40.0,
                  child: AppCircularProgressIndicator(
//                    background: Theme
//                        .of(context)
//                        .primaryColor,
//                    value: loadingProgress.expectedTotalBytes != null
//                        ? loadingProgress.cumulativeBytesLoaded /
//                        loadingProgress.expectedTotalBytes
//                        : 0,
                  ),
                ),
              );
            },
                width: width,
                height: height,
                fit: BoxFit.fill),
          );
        });
      }).toList(),
    );
  }
}
