import 'dart:async';

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:peasmartcare/models/notification_model.dart';
import 'package:peasmartcare/models/result_data_model.dart';
import 'package:peasmartcare/services/notification_service.dart';

part 'notification_event.dart';
part 'notification_state.dart';

class NotificationBloc extends Bloc<NotificationEvent, NotificationState> {
  NotificationImpService service = NotificationImpService();
  ResultData resultData;

  NotificationBloc() : super(NotificationInitial());

  @override
  Stream<NotificationState> mapEventToState(NotificationEvent event) async* {
    try {
      if (event is NotificationGetList) {
        yield NotificationLoading();
        // resultData = await service.getList(authenKey: ShareDataUtil.getAuthenKey());

        // List<NotificationModel> activityList = resultData.result;

        // yield NotificationLoaded(result: activityList, deleteSuccess: null);
      }
    } catch (e) {
      yield NotificationError(message: "เกิดปัญหาขัดข้อง");
    }
  }
}
