Skip to content

Commit d550bef

Browse files
committed
feat(local_ads_management): add option to save local video ad as draft
- Implement a dialog to choose between publishing or saving as draft - Update save button functionality to handle both options - Add new events to CreateLocalVideoAdBloc for publishing and saving as draft
1 parent d99dbcd commit d550bef

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

lib/local_ads_management/view/create_local_video_ad_page.dart

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,28 @@ class _CreateLocalVideoAdViewState extends State<_CreateLocalVideoAdView> {
5454
super.dispose();
5555
}
5656

57+
/// Shows a dialog to the user to choose between publishing or saving as draft.
58+
Future<ContentStatus?> _showSaveOptionsDialog(BuildContext context) async {
59+
final l10n = AppLocalizationsX(context).l10n;
60+
return showDialog<ContentStatus>(
61+
context: context,
62+
builder: (context) => AlertDialog(
63+
title: Text(l10n.saveAdTitle),
64+
content: Text(l10n.saveAdMessage),
65+
actions: [
66+
TextButton(
67+
onPressed: () => Navigator.of(context).pop(ContentStatus.draft),
68+
child: Text(l10n.saveAsDraft),
69+
),
70+
TextButton(
71+
onPressed: () => Navigator.of(context).pop(ContentStatus.active),
72+
child: Text(l10n.publish),
73+
),
74+
],
75+
),
76+
);
77+
}
78+
5779
@override
5880
Widget build(BuildContext context) {
5981
final l10n = AppLocalizationsX(context).l10n;
@@ -77,9 +99,22 @@ class _CreateLocalVideoAdViewState extends State<_CreateLocalVideoAdView> {
7799
icon: const Icon(Icons.save),
78100
tooltip: l10n.saveChanges,
79101
onPressed: state.isFormValid
80-
? () => context.read<CreateLocalVideoAdBloc>().add(
81-
const CreateLocalVideoAdSubmitted(),
82-
)
102+
? () async {
103+
final selectedStatus = await _showSaveOptionsDialog(
104+
context,
105+
);
106+
if (selectedStatus == ContentStatus.active &&
107+
context.mounted) {
108+
context.read<CreateLocalVideoAdBloc>().add(
109+
const CreateLocalVideoAdPublished(),
110+
);
111+
} else if (selectedStatus == ContentStatus.draft &&
112+
context.mounted) {
113+
context.read<CreateLocalVideoAdBloc>().add(
114+
const CreateLocalVideoAdSavedAsDraft(),
115+
);
116+
}
117+
}
83118
: null,
84119
);
85120
},

0 commit comments

Comments
 (0)