import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.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 AppointmentSliderWidget extends StatelessWidget {
  const AppointmentSliderWidget({Key? key}) : super(key: key);

  Widget buildAppointmentContainerForProvider() {
    return Container(
      margin: 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"),
                    2.height,
                    showServices("Accessories and Modification"),
                  ],
                ),
              ),
              const Icon(
                Icons.arrow_forward,
              ),
            ],
          ),
        ],
      ).toWhiteContainer(width: double.infinity, allPading: 12),
    );
  }

  Widget buildAppointmentSliderForConsumer() {
    return Container(
      margin: 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"),
                    2.height,
                    showServices("Accessories and Modification"),
                  ],
                ),
              ),
              const Icon(
                Icons.arrow_forward,
              ),
            ],
          ),
        ],
      ).toWhiteContainer(width: double.infinity, allPading: 12),
    );
  }

  @override
  Widget build(BuildContext context) {
    return CarouselSlider.builder(
        options: CarouselOptions(
          height: 160,
          viewportFraction: 1.0,
          enlargeCenterPage: true,
          enableInfiniteScroll: false,

          // onPageChanged: (index) {
          //   setState(() {
          //     _current = index;
          //   });
          // },
        ),
        itemCount: 10,
        itemBuilder: (BuildContext context, int itemIndex, int pageViewIndex) => buildAppointmentSliderForConsumer());
  }

  Widget showServices(String title) {
    return Row(
      children: [
        const Icon(
          Icons.ac_unit,
          color: MyColors.primaryColor,
          size: 18,
        ),
        8.width,
        title.toText(
          fontSize: 14,
          isBold: true,
        ),
      ],
    );
  }
}
