Browse Source

neon_news, neon_notes: use records in dialogs

pull/376/head
Nikolas Rimikis 1 year ago
parent
commit
4167291d49
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 2
      packages/neon/neon_news/lib/dialogs/add_feed.dart
  2. 5
      packages/neon/neon_news/lib/widgets/feed_floating_action_button.dart
  3. 2
      packages/neon/neon_notes/lib/dialogs/create_note.dart
  4. 7
      packages/neon/neon_notes/lib/widgets/notes_floating_action_button.dart

2
packages/neon/neon_news/lib/dialogs/add_feed.dart

@ -22,7 +22,7 @@ class _NewsAddFeedDialogState extends State<NewsAddFeedDialog> {
void submit() {
if (formKey.currentState!.validate()) {
Navigator.of(context).pop([controller.text, widget.folderID ?? folder?.id]);
Navigator.of(context).pop((controller.text, widget.folderID ?? folder?.id));
}
}

5
packages/neon/neon_news/lib/widgets/feed_floating_action_button.dart

@ -13,7 +13,7 @@ class NewsFeedFloatingActionButton extends StatelessWidget {
@override
Widget build(final BuildContext context) => FloatingActionButton(
onPressed: () async {
final result = await showDialog<List>(
final result = await showDialog<(String, int?)>(
context: context,
builder: (final context) => NewsAddFeedDialog(
bloc: bloc,
@ -21,7 +21,8 @@ class NewsFeedFloatingActionButton extends StatelessWidget {
),
);
if (result != null) {
bloc.addFeed(result[0] as String, result[1] as int?);
final (url, folderId) = result;
bloc.addFeed(url, folderId);
}
},
tooltip: AppLocalizations.of(context).feedAdd,

2
packages/neon/neon_notes/lib/dialogs/create_note.dart

@ -21,7 +21,7 @@ class _NotesCreateNoteDialogState extends State<NotesCreateNoteDialog> {
void submit() {
if (formKey.currentState!.validate()) {
Navigator.of(context).pop([controller.text, widget.category ?? selectedCategory]);
Navigator.of(context).pop((controller.text, widget.category ?? selectedCategory));
}
}

7
packages/neon/neon_notes/lib/widgets/notes_floating_action_button.dart

@ -13,7 +13,7 @@ class NotesFloatingActionButton extends StatelessWidget {
@override
Widget build(final BuildContext context) => FloatingActionButton(
onPressed: () async {
final result = await showDialog<List>(
final result = await showDialog<(String, String?)>(
context: context,
builder: (final context) => NotesCreateNoteDialog(
bloc: bloc,
@ -21,9 +21,10 @@ class NotesFloatingActionButton extends StatelessWidget {
),
);
if (result != null) {
final (title, category) = result;
bloc.createNote(
title: result[0] as String,
category: result[1] as String? ?? '',
title: title,
category: category ?? '',
);
}
},

Loading…
Cancel
Save