You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.1KB

  1. import 'package:bloc/bloc.dart';
  2. import 'package:equatable/equatable.dart';
  3. import 'package:flutter/material.dart';
  4. import '../../../../data/api/app_exception.dart';
  5. import '../../../../data/repository/repository.dart';
  6. import '../../../../models/item_dropdown.dart';
  7. part 'code_update_timeline_state.dart';
  8. class CodeUpdateTimelineCubit extends Cubit<CodeUpdateTimelineState> {
  9. CodeUpdateTimelineCubit() : super(CodeUpdateTimelineInitial());
  10. final repository = Repository();
  11. final formKey = GlobalKey<FormState>();
  12. var actionDate = ValueNotifier(DateTime.now());
  13. final descriptionCtl = TextEditingController();
  14. var actionTypes = [
  15. ItemDropDown(key: 'hoat dong 1', value: 'hoat dong 1'),
  16. ItemDropDown(key: 'hoat dong 2', value: 'hoat dong 2'),
  17. ];
  18. var selectedActionType = ValueNotifier('');
  19. // var existedCodeUpdateTimeline = UpdateCodeUpdateTimeline();
  20. void dispose() {
  21. descriptionCtl.dispose();
  22. }
  23. Future<void> preparedData() async {
  24. try {
  25. await Future.delayed(const Duration(seconds: 0));
  26. emit(CodeUpdateTimelineLoading());
  27. emit(CodeUpdateTimelinePrepareDataSuccessful());
  28. } catch (e) {
  29. emit(CodeUpdateTimelineFailure(AppException.handleError(e)));
  30. }
  31. }
  32. Future<void> onSubmit() async {
  33. if (formKey.currentState!.validate()) {
  34. // var gioiTinh = gioiTinhs.firstWhere(
  35. // (element) => selectedGioiTinh.value == element.key,
  36. // orElse: () => ItemDropDown(),
  37. // );
  38. // existedCodeUpdateTimeline
  39. // ..gioiTinhBe = gioiTinh.value
  40. // ..ghiChu = noteCtl.text
  41. // ..ngayTiemUngKhiThan = ungKhiThanDate.value.convertLocalDateTimeToServer();
  42. // UtilWidget.showLoading();
  43. // await repository.updateCodeUpdateTimeline(
  44. // (success) {
  45. // UtilWidget.hideDialog();
  46. // UtilWidget.showToastSuccess('Thêm thành công');
  47. // Get.back();
  48. // },
  49. // (errorMessage) {
  50. // UtilWidget.hideDialog();
  51. // UtilWidget.showToastError(errorMessage);
  52. // },
  53. // item: existedCodeUpdateTimeline,
  54. // );
  55. }
  56. }
  57. }