import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

part 'main_event.dart';

part 'main_state.dart';

class MainBloc extends Bloc<MainEvent, MainState> {
  MainBloc() : super(const MainState(tab: MainTab.home)) {
    on<ChangeTabEvent>(_changeTab);
  }

  void _changeTab(ChangeTabEvent event, Emitter<MainState> emit) {
    // if (state.tab != event.tab) {
    //   changeTap(event.tab);
    // }
    emit(state.copyWith(tab: event.tab));
  }

  // void changeTap(MainTab tab) {
  //   switch (tab) {
  //     case MainTab.home:
  //       Navigator.of(
  //         shellRootNavigatorKey.currentContext!,
  //       ).pushNamedAndRemoveUntil(Routes.home, (route) => false);
  //       break;
  //     case MainTab.calculation:
  //       Navigator.of(
  //         shellRootNavigatorKey.currentContext!,
  //       ).pushNamedAndRemoveUntil(Routes.calculation, (route) => false);
  //       break;
  //     case MainTab.profile:
  //       Navigator.of(
  //         shellRootNavigatorKey.currentContext!,
  //       ).pushNamedAndRemoveUntil(Routes.profile, (route) => false);
  //       break;
  //   }
  // }
}

enum MainTab { home, calculation, profile }
