Skip to content

Commit

Permalink
feat: #7/공고 상세 화면에서 수정 화면으로 이동 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Younggun-Kim committed Nov 10, 2024
1 parent eff8853 commit 9406a13
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class JobPostingDetailBloc
on<OnGettingDetailData>(_onGettingDetailData);
on<OnClosedJobPosting>(_onClosedJobPosting);
on<OnDeletedJobPosting>(_onDeletedJobPosting);
on<OnPressedUpdate>(_onPressedUpdate);
on<OnPopForm>(_onPopForm);
}

/// 메시지 초기화 이벤트.
Expand Down Expand Up @@ -131,4 +133,17 @@ class JobPostingDetailBloc
},
);
}

/// 수정 클릭 이벤트
void _onPressedUpdate(
OnPressedUpdate event,
Emitter<JobPostingDetailState> emit,
) {
emit(state.copyWith(status: JobPostingDetailStatus.pushUpdate));
}

/// 수정화면에서 돌아왔을 때 이벤트.
void _onPopForm(OnPopForm event, Emitter<JobPostingDetailState> emit) {
emit(state.copyWith(status: JobPostingDetailStatus.success));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ class OnClosedJobPosting extends JobPostingDetailEvent {}

/// 공고 삭제
class OnDeletedJobPosting extends JobPostingDetailEvent {}

/// 수정 클릭 이벤트
class OnPressedUpdate extends JobPostingDetailEvent {}

/// 수정화면에서 돌아왔을 때
class OnPopForm extends JobPostingDetailEvent {}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -37,7 +38,7 @@ class _JobPostingDetailPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocConsumer<JobPostingDetailBloc, JobPostingDetailState>(
listener: (context, state) {
listener: (context, state) async {
if (state.message.isNotEmpty) {
CustomAlertDialog.showContentAlert(
context: context,
Expand All @@ -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<JobPostingDetailBloc>();
await context.router.push(const JobPostingFormRoute());
bloc.add(OnPopForm());
}
},
builder: (context, state) {
return PageRoot(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
};
}

/// 공고 삭제
Expand Down

0 comments on commit 9406a13

Please sign in to comment.