From 0bb250b5158db35d44dd7df64b1294d13f916c47 Mon Sep 17 00:00:00 2001 From: Conner Date: Thu, 24 Oct 2024 09:36:43 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20#7/=EA=B3=B5=EA=B3=A0=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=ED=99=94=EB=A9=B4=EC=97=90=EC=84=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=ED=99=94=EB=A9=B4=EC=9C=BC=EB=A1=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blocs/detail/job_posting_detail_bloc.dart | 15 +++++++++++++++ .../blocs/detail/job_posting_detail_event.dart | 6 ++++++ .../blocs/detail/job_posting_detail_state.dart | 12 +++++++++++- .../pages/job_posting_detail_page.dart | 10 ++++++++-- .../detail_bottom_sheet_factory.dart | 6 +++++- 5 files changed, 45 insertions(+), 4 deletions(-) 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 7de27ba..c3d46c7 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()); + } + }; } /// 공고 삭제