// ignore_for_file: non_constant_identifier_names, library_private_types_in_public_api, import_of_legacy_library_into_null_safe

import 'package:card_swiper/card_swiper.dart';
import 'package:flutter/material.dart';
import 'package:special_equipment_flutter/dio/api.dart';

import '../model/banner_list_bo.dart';

class SlideBanner extends StatefulWidget {
  const SlideBanner({super.key, required this.bannerList});

  final List<Data>? bannerList;

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

class _SwiperPageState extends State<SlideBanner> {
  List<Map> imgList = [
    {"url": "assets/images/image0.png"},
    {"url": "assets/images/image1.png"},
    {"url": "assets/images/image2.png"},
    {"url": "assets/images/image3.png"},
    {"url": "assets/images/image4.png"},
    {"url": "assets/images/image5.png"},
  ];

//  List<Map> imgList = [
//    {
//      "url":
//      "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcdn.aitecar.com%2Fwp-content%2Fuploads%2F2014%2F11%2F20141119113831dc84baa9b3e7d0c7a37a.jpg&refer=http%3A%2F%2Fcdn.aitecar.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671264681&t=d919a7187f42bd7c0ac775ce08fc63bd"
//    },
//    {
//      "url":
//      "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww2.autoimg.cn%2Fchejiahaodfs%2Fg8%2FM12%2FA3%2F22%2Fautohomecar__ChwEmmDmZhSAUiI3AAHEf6vp_kw118.png&refer=http%3A%2F%2Fwww2.autoimg.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671264664&t=0a7d80e389aab22d6e724df0183e8f57"
//    },
//    {
//      "url":
//      "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fp4.itc.cn%2Fimages01%2F20211023%2F55209e5c4f324f2ba3a0a27e51c7486a.jpeg&refer=http%3A%2F%2Fp4.itc.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671264668&t=c0395ee14ae1b7674d3283c4ba4bb4bc"
//    },
//    {
//      "url":
//      "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww2.autoimg.cn%2Fchejiahaodfs%2Fg8%2FM12%2FA3%2F22%2Fautohomecar__ChwEmmDmZhSAUiI3AAHEf6vp_kw118.png&refer=http%3A%2F%2Fwww2.autoimg.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671264664&t=0a7d80e389aab22d6e724df0183e8Qf57"
//    },
//  ];

  @override
  Widget build(BuildContext context) {
    var MySwiperWidget = Swiper(
      itemBuilder: (BuildContext context, int index) {
        //每次循环遍历时，将i赋值给index
        // return Image.asset(
        //   imgList[index]['url'],
        //   fit: BoxFit.fill,
        // );
        return Image.network(
          '${Api.URL}special${widget.bannerList![index].advertisUrl!}',
          fit: BoxFit.fill,
        );
      },
      autoplay: true,
      duration: 2000,
      autoplayDelay: 5000,
      itemCount: widget.bannerList!.length,
      // pagination: const SwiperPagination(
      //     builder: DotSwiperPaginationBuilder(
      //         color: Color(0xFFD39C7F), activeColor: Color(0xFFFF4646))),
//      layout: SwiperLayout.DEFAULT,
//      scale: 0.93,
//      viewportFraction: 0.9,
      //指示器样式
      // pagination: const SwiperPagination(
      //     alignment: Alignment.bottomRight,
      //     builder: DotSwiperPaginationBuilder(
      //       color: Colors.black54,
      //       activeColor: Colors.white,
      //       size: 10,
      //       activeSize: 12,
      //     )),
    );
    return Scaffold(
        body: SizedBox(
      height: 200,
      width: double.infinity,
      child: MySwiperWidget,
    ));
  }
}
