import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';

class ProviderAppointmentSliderWidget extends StatelessWidget {
  const ProviderAppointmentSliderWidget({Key? key}) : super(key: key);


  @override
  Widget build(BuildContext context) {
    return CarouselSlider.builder(
      options: CarouselOptions(
        height: 160,
        viewportFraction: 1.0,
        enlargeCenterPage: false,
        enableInfiniteScroll: false,
        //
        // onPageChanged: (index) {
        //   setState(() {
        //     _current = index;
        //   });
        // },
      ),
      itemCount: 10,
      itemBuilder: (BuildContext context, int itemIndex, int pageViewIndex) => const BuildAppointmentContainerForProvider(),
    );
  }


}

class BuildAppointmentContainerForProvider extends StatelessWidget {
  const BuildAppointmentContainerForProvider({Key? key}) : super(key: key);

  Widget showServices(String title, String icon) {
    return Row(
      children: [
        SvgPicture.asset(icon),
        8.width,
        title.toText(
          fontSize: 14,
          isBold: true,
        ),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(bottom: 21, left: 21, right: 21, top: 7),
      child: Column(
        children: [
          Row(
            children: [
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: [
                    "Olaya Brach".toText(
                      color: MyColors.lightTextColor,
                      isBold: true,
                    ),
                    "Abdullah Alhbas".toText(
                      isBold: true,
                      fontSize: 14,
                    ),
                    Row(
                      children: [
                        "Appt. On:".toText(
                          color: MyColors.lightTextColor,
                        ),
                        2.width,
                        "19-Mar-2023 11:48 AM".toText(),
                      ],
                    ),
                  ],
                ),
              ),
              "1+ Requests".toText(fontSize: 10).toContainer(
                borderRadius: 15,
                backgroundColor: MyColors.lightGreyEAColor,
                padding: const EdgeInsets.symmetric(
                  vertical: 6,
                  horizontal: 12,
                ),
              ),
            ],
          ),
          8.height,
          Row(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              Expanded(
                child: Column(
                  children: [
                    showServices("Maintenance", MyAssets.maintenanceIcon ),
                    2.height,
                    showServices("Accessories and Modification", MyAssets.modificationsIcon,),
                  ],
                ),
              ),
              const Icon(
                Icons.arrow_forward,
              ),
            ],
          ),
        ],
      ).toWhiteContainer(width: double.infinity, allPading: 12),
    );
  }
}

