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

part 'counter_state.dart';
part 'counter_event.dart';

class CounterBloc extends Bloc<CounterEvent, CounterState> {
  CounterBloc() : super(const CounterHomePageState()) {
    on<NavigationBottomEvent>((event, emit) async {
      await _requestNavigationBottom(event, emit);
    });
  }

  Future<void> _requestNavigationBottom(NavigationBottomEvent event, Emitter<CounterState> emit) async{
    if(event.indexNavigationBottom == 0){
      emit(const CounterHomePageState());
      return;
    }
    if(event.indexNavigationBottom == 1){
      emit(const CounterButAboutPageState());
      return;
    }
    if(event.indexNavigationBottom == 2){
      emit(const CounterCameraPageState());
      return;
    }
    if(event.indexNavigationBottom == 3){
      emit(const CounterButAnswerPageState());
      return;
    }
    if(event.indexNavigationBottom == 4){
      emit(const CounterAccountPageState());
      return;
    }else {
      emit(const CounterHomePageState());
      return;
    }

  }

  @override
  Future<void> close() {
    return super.close();
  }

}

