import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:intl/intl.dart';
import 'package:krezus/domains/budget/budget_bloc.dart';

class BudgetCompareSelector extends StatelessWidget {
  const BudgetCompareSelector({super.key});

  @override
  Widget build(BuildContext context) {
    return BlocBuilder<BudgetBloc, BudgetState>(
      builder: (context, state) => Row(
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          IconButton(
            onPressed: () => context.read<BudgetBloc>().add(BudgetComparePrevious()),
            icon: const Icon(Icons.skip_previous)
          ),
          Text('${NumberFormat('00', 'fr_FR').format(state.compareMonth)} - ${state.compareYear}'),
          IconButton(
            onPressed: () => context.read<BudgetBloc>().add(BudgetCompareNext()),
            icon: const Icon(Icons.skip_next)
          ),
        ],
      )
    );
  }
}