import 'dart:async';

import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/repository/customer_repository.dart';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';

part 'development_sizes_event.dart';
part 'development_sizes_state.dart';

class DevelopmentSizesBloc extends Bloc<DevelopmentSizesEvent, DevelopmentSizesState> {
  final CustomerRepository customerRepository;
  DevelopmentSizesBloc({required this.customerRepository}) : super(DevelopmentSizesInitial()) {
    isMan = Cache().userLoggedIn!.sex == "m";
  }

  late bool isMan;

  @override
  Stream<DevelopmentSizesState> mapEventToState(
    DevelopmentSizesEvent event,
  ) async* {
    try {
      if (state is DevelopmentSizesLoad) {
        yield DevelopmentSizesLoading();
        yield DevelopmentSizesReady();
      }
    } on Exception catch (e) {
      yield DevelopmentSizesError(message: e.toString());
    }
  }
}
