import 'package:bloc/bloc.dart';
import 'package:dio/dio.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/foundation.dart';
import 'package:hoshan/data/model/photo_gen_model.dart';
import 'package:hoshan/data/repository/bot_repository.dart';

part 'single_media_state.dart';

class SingleMediaCubit extends Cubit<SingleMediaState> {
  SingleMediaCubit() : super(SingleMediaInitial());

  void getMediaById(int id) async {
    emit(SingleMediaLoading());
    try {
      final response = await BotRepository.getSingleMedia(id);
      emit(SingleMediaSuccess(medias: response));
    } on DioException catch (e) {
      emit(SingleMediaFail());
      if (kDebugMode) {
        print('Dio Error is: $e');
      }
    }
  }
}
