import 'package:bloc/bloc.dart';

import 'tab_event.dart';
import 'tab_state.dart';

class TabBloc extends Bloc<TabEvent, TabState> {
  TabBloc() : super(const TabState()) {
    on<LoadAvailableItems>(_onLoadAvailableItems);
    on<LoadClosedItems>(_onLoadClosedItems);
  }

  void _onLoadAvailableItems(LoadAvailableItems event, Emitter<TabState> emit) {
    // Simulate fetching available items
    final availableItems =
        List<String>.generate(10, (index) => 'Available Item $index');
    emit(state.copyWith(availableItems: availableItems));
  }

  void _onLoadClosedItems(LoadClosedItems event, Emitter<TabState> emit) {
    // Simulate fetching closed items
    final closedItems =
        List<String>.generate(10, (index) => 'Closed Item $index');
    emit(state.copyWith(closedItems: closedItems));
  }
}
