import '../../../../../../food_delivery_client.dart';

class WDeliveryDuration extends StatelessWidget with FilterMixins {
  WDeliveryDuration({super.key});

  @override
  Widget build(BuildContext context) {
    return BlocBuilder<HomeBloc, HomeState>(
      builder: (context, state) {
        return Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              context.loc.delivery,
              style: AppTextStyles.size18Medium,
            ).paddingSymmetric(horizontal: 20),
            15.verticalSpace,
            SizedBox(
              height: 60,
              child: Stack(
                alignment: AlignmentGeometry.center,
                children: [
                  SizedBox(
                    height: 40,
                    width: context.w,
                    child: DecoratedBox(
                      decoration: BoxDecoration(
                        borderRadius: AppUtils.kBorderRadius8,
                        color: AppColors.cE6E6E6.newWithOpacity(.6),
                      ),
                    ),
                  ),
                  Material(
                    color: AppColors.cTransparent,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      children: List.generate(deliveryDurations.length, (
                        index,
                      ) {
                        final isActive =
                            state.deliveryDuration == deliveryDurations[index];
                        return InkWell(
                          onTap: () {
                            context.read<HomeBloc>().add(
                              HomeEvent.durationChanged(
                                deliveryDurations[index],
                              ),
                            );
                          },
                          borderRadius: AppUtils.kBorderRadius40,
                          child: Ink(
                            height: 60,
                            width: 60,
                            decoration: BoxDecoration(
                              color: isActive
                                  ? AppColors.c34A853
                                  : AppColors.cTransparent,
                              borderRadius: AppUtils.kBorderRadius40,
                            ),
                            child: Center(
                              child: Text(
                                deliveryDurations[index],
                                style: AppTextStyles.size16Medium.copyWith(
                                  color: isActive
                                      ? AppColors.cFFFFFF
                                      : AppColors.c000000,
                                ),
                              ),
                            ),
                          ),
                        );
                      }),
                    ),
                  ),
                ],
              ),
            ).paddingSymmetric(horizontal: 20),
            25.verticalSpace,
          ],
        );
      },
    );
  }
}
