import 'package:flutter/material.dart';
import 'package:test_sa/extensions/int_extensions.dart';

import '../../app_style/app_color.dart';

class DashboardPageIndicator extends StatelessWidget {
  final PageController controller;
  final int index, currentPage;
  const DashboardPageIndicator({
    Key key,
    @required this.controller,
    @required this.index,
    @required this.currentPage,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final bool isActive = currentPage == (index + 1);
    return InkWell(
      onTap: () {
        controller.animateToPage(index, duration: const Duration(milliseconds: 500), curve: Curves.ease);
      },
      child: Container(
        width: (isActive ? 30 : 16).toScreenWidth,
        height: 9.toScreenHeight,
        decoration: BoxDecoration(color: isActive ? AppColor.green50 : AppColor.neutral40, borderRadius: BorderRadius.circular(8)),
      ),
    );
  }
}
