import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:rasadyar_core/presentation/common/app_color.dart';
import 'package:rasadyar_core/presentation/common/app_fonts.dart';

class PaginationFromUntil extends StatefulWidget {
  const PaginationFromUntil({super.key});

  @override
  State<PaginationFromUntil> createState() => _PaginationFromUntilState();
}

class _PaginationFromUntilState extends State<PaginationFromUntil> {
  int current = 1;
  int total = 10;

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 164,
      height: 47,
      clipBehavior: Clip.antiAlias,
      decoration: ShapeDecoration(
        color: const Color(0xFFEAEFFF),
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(50)),
      ),
      child: Row(
        children: [
          FloatingActionButton.small(
            onPressed: () {
              if(current>1){
                setState(() {
                  current--;
                });
              }

            },
            shape: CircleBorder(),
            elevation: 0,
            backgroundColor: Colors.white,
            child: Icon(CupertinoIcons.arrow_left, color: AppColor.blueNormal),
          ),
          Expanded(
            child: Text(
              '$current از $total',
              textAlign: TextAlign.center,
              textDirection: TextDirection.rtl,
              style: AppFonts.yekan16.copyWith(
                color: AppColor.blueNormal,
              ),
            ),
          ),
          FloatingActionButton.small(

            onPressed:() {
              if (current < total) {
                setState(() {
                  current++;
                });
              }
            },
            shape: CircleBorder(),
            elevation: 0,
            backgroundColor: AppColor.blueNormal,
            child: Icon(CupertinoIcons.arrow_right, color: Colors.white),
          ),
        ],
      ),
    );
  }

  Stack buildStack() {
    return Stack(
      children: [
        Positioned(
          left: 4,
          top: 4,
          child: Container(
            width: 40,
            height: 40,
            child: Stack(
              children: [
                Positioned(
                  left: 40,
                  top: 40,
                  child: Container(
                    transform:
                        Matrix4.identity()
                          ..translate(0.0, 0.0)
                          ..rotateZ(-3.14),
                    width: 40,
                    height: 40,
                    child: Stack(
                      children: [
                        Positioned(
                          left: 0,
                          top: 0,
                          child: Container(
                            width: 40,
                            height: 40,
                            child: Stack(
                              children: [
                                Positioned(
                                  left: 0,
                                  top: 0,
                                  child: Container(
                                    width: 40,
                                    height: 40,
                                    child: Stack(
                                      children: [
                                        Positioned(
                                          left: 0,
                                          top: 0,
                                          child: Container(
                                            width: 40,
                                            height: 40,
                                            clipBehavior: Clip.antiAlias,
                                            decoration: ShapeDecoration(
                                              color:
                                                  Colors.white /* Secondary */,
                                              shape: RoundedRectangleBorder(
                                                side: BorderSide(
                                                  width: 1,
                                                  color:
                                                      Colors
                                                          .white /* Secondary */,
                                                ),
                                                borderRadius:
                                                    BorderRadius.circular(50),
                                              ),
                                            ),
                                            child: Stack(),
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                ),
                              ],
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
                Positioned(
                  left: 8,
                  top: 8,
                  child: Container(width: 24, height: 24, child: Stack()),
                ),
              ],
            ),
          ),
        ),
        Positioned(
          left: 120,
          top: 3,
          child: Container(
            width: 40,
            height: 40,
            child: Stack(
              children: [
                Positioned(
                  left: 40,
                  top: 40,
                  child: Container(
                    transform:
                        Matrix4.identity()
                          ..translate(0.0, 0.0)
                          ..rotateZ(-3.14),
                    width: 40,
                    height: 40,
                    child: Stack(
                      children: [
                        Positioned(
                          left: 0,
                          top: 0,
                          child: Container(
                            width: 40,
                            height: 40,
                            child: Stack(
                              children: [
                                Positioned(
                                  left: 0,
                                  top: 0,
                                  child: Container(
                                    width: 40,
                                    height: 40,
                                    child: Stack(
                                      children: [
                                        Positioned(
                                          left: 0,
                                          top: 0,
                                          child: Container(
                                            width: 40,
                                            height: 40,
                                            clipBehavior: Clip.antiAlias,
                                            decoration: ShapeDecoration(
                                              color: const Color(
                                                0xFF2D5FFF,
                                              ) /* Primary */,
                                              shape: RoundedRectangleBorder(
                                                side: BorderSide(
                                                  width: 1,
                                                  color: const Color(
                                                    0xFF2D5FFF,
                                                  ) /* Primary */,
                                                ),
                                                borderRadius:
                                                    BorderRadius.circular(50),
                                              ),
                                            ),
                                            child: Stack(),
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                ),
                              ],
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
                Positioned(
                  left: 8,
                  top: 8,
                  child: Container(width: 24, height: 24, child: Stack()),
                ),
              ],
            ),
          ),
        ),
        Positioned(
          left: 63,
          top: 9,
          child: Text(
            '1 از 17',
            style: TextStyle(
              color: const Color(0xFF2D5FFF) /* Primary */,
              fontSize: 16,
              fontFamily: 'IRANYekanFN',
              fontWeight: FontWeight.w400,
              height: 1.75,
            ),
          ),
        ),
      ],
    );
  }
}
