diff --git a/lib/feature/job_posting/presentation/blocs/detail/job_posting_detail_bloc.dart b/lib/feature/job_posting/presentation/blocs/detail/job_posting_detail_bloc.dart index f50ecf8..829be1c 100644 --- a/lib/feature/job_posting/presentation/blocs/detail/job_posting_detail_bloc.dart +++ b/lib/feature/job_posting/presentation/blocs/detail/job_posting_detail_bloc.dart @@ -23,6 +23,8 @@ class JobPostingDetailBloc on(_onGettingDetailData); on(_onClosedJobPosting); on(_onDeletedJobPosting); + on(_onPressedUpdate); + on(_onPopForm); } /// 메시지 초기화 이벤트. @@ -131,4 +133,17 @@ class JobPostingDetailBloc }, ); } + + /// 수정 클릭 이벤트 + void _onPressedUpdate( + OnPressedUpdate event, + Emitter emit, + ) { + emit(state.copyWith(status: JobPostingDetailStatus.pushUpdate)); + } + + /// 수정화면에서 돌아왔을 때 이벤트. + void _onPopForm(OnPopForm event, Emitter emit) { + emit(state.copyWith(status: JobPostingDetailStatus.success)); + } } diff --git a/lib/feature/job_posting/presentation/blocs/detail/job_posting_detail_event.dart b/lib/feature/job_posting/presentation/blocs/detail/job_posting_detail_event.dart index aa077cf..0c911ad 100644 --- a/lib/feature/job_posting/presentation/blocs/detail/job_posting_detail_event.dart +++ b/lib/feature/job_posting/presentation/blocs/detail/job_posting_detail_event.dart @@ -17,3 +17,9 @@ class OnClosedJobPosting extends JobPostingDetailEvent {} /// 공고 삭제 class OnDeletedJobPosting extends JobPostingDetailEvent {} + +/// 수정 클릭 이벤트 +class OnPressedUpdate extends JobPostingDetailEvent {} + +/// 수정화면에서 돌아왔을 때 +class OnPopForm extends JobPostingDetailEvent {} diff --git a/lib/feature/job_posting/presentation/blocs/detail/job_posting_detail_state.dart b/lib/feature/job_posting/presentation/blocs/detail/job_posting_detail_state.dart index 4bcaacb..f08d03c 100644 --- a/lib/feature/job_posting/presentation/blocs/detail/job_posting_detail_state.dart +++ b/lib/feature/job_posting/presentation/blocs/detail/job_posting_detail_state.dart @@ -6,7 +6,15 @@ part of 'job_posting_detail_bloc.dart'; /// fail: API 통신 실패 /// closed: 마감 상태 /// deleted: 삭제 상태 -enum JobPostingDetailStatus { initial, loading, success, fail, closed, deleted } +enum JobPostingDetailStatus { + initial, + loading, + success, + fail, + closed, + deleted, + pushUpdate, +} extension JobPostingDetailStatusExt on JobPostingDetailStatus { bool get isInitial => this == JobPostingDetailStatus.initial; @@ -18,6 +26,8 @@ extension JobPostingDetailStatusExt on JobPostingDetailStatus { bool get isClosed => this == JobPostingDetailStatus.closed; bool get isDeleted => this == JobPostingDetailStatus.deleted; + + bool get isPushUpdate => this == JobPostingDetailStatus.pushUpdate; } @freezed diff --git a/lib/feature/job_posting/presentation/pages/job_posting_detail_page.dart b/lib/feature/job_posting/presentation/pages/job_posting_detail_page.dart index 719469f..9588a7c 100644 --- a/lib/feature/job_posting/presentation/pages/job_posting_detail_page.dart +++ b/lib/feature/job_posting/presentation/pages/job_posting_detail_page.dart @@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:withu_app/core/core.dart'; +import 'package:withu_app/core/router/router.gr.dart'; import 'package:withu_app/feature/feature.dart'; import 'package:withu_app/feature/job_posting/domain/entities/job_posting_detail_entity.dart'; import 'package:withu_app/gen/colors.gen.dart'; @@ -37,7 +38,7 @@ class _JobPostingDetailPage extends StatelessWidget { @override Widget build(BuildContext context) { return BlocConsumer( - listener: (context, state) { + listener: (context, state) async { if (state.message.isNotEmpty) { CustomAlertDialog.showContentAlert( context: context, @@ -48,10 +49,15 @@ class _JobPostingDetailPage extends StatelessWidget { ); } - // 마감으로 변경되었을 때 if (state.status.isClosed || state.status.isDeleted) { context.router.maybePop(true); } + + if (state.status.isPushUpdate) { + final bloc = context.read(); + await context.router.push(const JobPostingFormRoute()); + bloc.add(OnPopForm()); + } }, builder: (context, state) { return PageRoot( diff --git a/lib/feature/job_posting/presentation/widgets/detail_bottom_sheet/detail_bottom_sheet_factory.dart b/lib/feature/job_posting/presentation/widgets/detail_bottom_sheet/detail_bottom_sheet_factory.dart index caa12d6..ea15d5e 100644 --- a/lib/feature/job_posting/presentation/widgets/detail_bottom_sheet/detail_bottom_sheet_factory.dart +++ b/lib/feature/job_posting/presentation/widgets/detail_bottom_sheet/detail_bottom_sheet_factory.dart @@ -28,7 +28,11 @@ class _UpdateBottomSheet implements DescriptionBottomSheetOption { String get description => StringRes.isNotDeadlineYetConfirmClose.tr; @override - Function(Bloc? bloc) get exec => (Bloc? bloc) {}; + Function(Bloc? bloc) get exec => (Bloc? bloc) { + if (bloc is JobPostingDetailBloc) { + bloc.add(OnPressedUpdate()); + } + }; } /// 공고 삭제