|
- import 'package:bloc/bloc.dart';
- import 'package:equatable/equatable.dart';
- import 'package:flutter/material.dart';
-
- import '../../../../data/api/app_exception.dart';
- import '../../../../data/repository/repository.dart';
- import '../../../../models/item_dropdown.dart';
-
- part 'code_update_timeline_state.dart';
-
- class CodeUpdateTimelineCubit extends Cubit<CodeUpdateTimelineState> {
- CodeUpdateTimelineCubit() : super(CodeUpdateTimelineInitial());
-
- final repository = Repository();
- final formKey = GlobalKey<FormState>();
- var actionDate = ValueNotifier(DateTime.now());
- final descriptionCtl = TextEditingController();
- var actionTypes = [
- ItemDropDown(key: 'hoat dong 1', value: 'hoat dong 1'),
- ItemDropDown(key: 'hoat dong 2', value: 'hoat dong 2'),
- ];
- var selectedActionType = ValueNotifier('');
- // var existedCodeUpdateTimeline = UpdateCodeUpdateTimeline();
-
- void dispose() {
- descriptionCtl.dispose();
- }
-
- Future<void> preparedData() async {
- try {
- await Future.delayed(const Duration(seconds: 0));
- emit(CodeUpdateTimelineLoading());
-
- emit(CodeUpdateTimelinePrepareDataSuccessful());
- } catch (e) {
- emit(CodeUpdateTimelineFailure(AppException.handleError(e)));
- }
- }
-
- Future<void> onSubmit() async {
- if (formKey.currentState!.validate()) {
- // var gioiTinh = gioiTinhs.firstWhere(
- // (element) => selectedGioiTinh.value == element.key,
- // orElse: () => ItemDropDown(),
- // );
-
- // existedCodeUpdateTimeline
- // ..gioiTinhBe = gioiTinh.value
- // ..ghiChu = noteCtl.text
- // ..ngayTiemUngKhiThan = ungKhiThanDate.value.convertLocalDateTimeToServer();
-
- // UtilWidget.showLoading();
- // await repository.updateCodeUpdateTimeline(
- // (success) {
- // UtilWidget.hideDialog();
- // UtilWidget.showToastSuccess('Thêm thành công');
- // Get.back();
- // },
- // (errorMessage) {
- // UtilWidget.hideDialog();
- // UtilWidget.showToastError(errorMessage);
- // },
- // item: existedCodeUpdateTimeline,
- // );
- }
- }
- }
|