-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #5/공고 상세 바텀 시트 factory 방식으로 변경
1. OCP 원칙 준수를 위해 switch-case 문 방식에서 Factory를 이용한 방식으로 변경
- Loading branch information
1 parent
2d97a08
commit 36f0e4f
Showing
14 changed files
with
123 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export 'job_postings_page.dart'; | ||
export 'job_posting_form_page.dart'; | ||
export 'types/types.dart'; |
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
lib/feature/job_posting/presentation/widgets/detail_bottom_sheet/detail_bottom_sheet.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'detail_bottom_sheet_type.dart'; | ||
export 'detail_bottom_sheet_factory.dart'; |
61 changes: 61 additions & 0 deletions
61
...ure/job_posting/presentation/widgets/detail_bottom_sheet/detail_bottom_sheet_factory.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:withu_app/core/core.dart'; | ||
import 'package:withu_app/feature/feature.dart'; | ||
import 'package:withu_app/feature/job_posting/presentation/widgets/detail_bottom_sheet/detail_bottom_sheet_type.dart'; | ||
import 'package:withu_app/shared/bottom_sheet/bottom_sheet.dart'; | ||
|
||
/// 공고 상세보기 바텀 시트 Factory | ||
class DetailBottomSheetFactory { | ||
static final Map<DetailBottomSheetType, DescriptionBottomSheetOption> | ||
_options = { | ||
DetailBottomSheetType.update: _UpdateBottomSheet(), | ||
DetailBottomSheetType.delete: _DeleteBottomSheet(), | ||
DetailBottomSheetType.close: _CloseBottomSheet(), | ||
}; | ||
|
||
static DescriptionBottomSheetOption? getOption( | ||
DetailBottomSheetType type, | ||
) { | ||
return _options[type]; | ||
} | ||
} | ||
|
||
/// 공고 수정 | ||
class _UpdateBottomSheet implements DescriptionBottomSheetOption { | ||
@override | ||
String get actionText => StringRes.update.tr; | ||
|
||
@override | ||
String get description => StringRes.isNotDeadlineYetConfirmClose.tr; | ||
|
||
@override | ||
Function(Bloc? bloc) get exec => (Bloc? bloc) {}; | ||
} | ||
|
||
/// 공고 삭제 | ||
class _DeleteBottomSheet implements DescriptionBottomSheetOption { | ||
@override | ||
String get actionText => StringRes.delete.tr; | ||
|
||
@override | ||
String get description => StringRes.canRevertFromPostingManagement.tr; | ||
|
||
@override | ||
Function(Bloc? bloc) get exec => (Bloc? bloc) {}; | ||
} | ||
|
||
/// 공고 마감 | ||
class _CloseBottomSheet implements DescriptionBottomSheetOption { | ||
@override | ||
String get actionText => StringRes.close.tr; | ||
|
||
@override | ||
String get description => StringRes.isNotDeadlineYetConfirmClose.tr; | ||
|
||
@override | ||
Function(Bloc? bloc) get exec => (Bloc? bloc) { | ||
if (bloc is JobPostingDetailBloc) { | ||
bloc.add(OnClosedJobPosting()); | ||
} | ||
}; | ||
} |
6 changes: 3 additions & 3 deletions
6
...pages/types/detail_more_options_type.dart → ...ottom_sheet/detail_bottom_sheet_type.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import 'package:withu_app/core/core.dart'; | ||
|
||
/// 공고 상세의 더보기 옵션 타입 | ||
enum DetailMoreOptionsType with L10nKeyProvider { | ||
/// 공고 상세 화면 바텀 시트 타입 | ||
enum DetailBottomSheetType with L10nKeyProvider { | ||
update(l10nKey: 'update'), | ||
delete(l10nKey: 'delete'), | ||
close(l10nKey: 'close'); | ||
|
||
@override | ||
final String l10nKey; | ||
|
||
const DetailMoreOptionsType({required this.l10nKey}); | ||
const DetailBottomSheetType({required this.l10nKey}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export 'job_postings_item.dart'; | ||
export 'detail_bottom_sheet/detail_bottom_sheet.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export 'base/base_bottom_sheet.dart'; | ||
export 'description/description_bottom_sheet.dart'; | ||
export 'description/description.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'description_bottom_sheet.dart'; | ||
export 'description_bottom_sheet_option.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
lib/shared/bottom_sheet/description/description_bottom_sheet_option.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
|
||
/// BottomSheet에서 필요한 값 | ||
abstract class DescriptionBottomSheetOption { | ||
/// 설명 | ||
final String description; | ||
|
||
/// 버튼 문구 | ||
final String actionText; | ||
|
||
/// 버튼 클릭 시 실행될 동작 | ||
final Function(Bloc? bloc) exec; | ||
|
||
DescriptionBottomSheetOption({ | ||
required this.description, | ||
required this.actionText, | ||
required this.exec, | ||
}); | ||
} |