Browse Source

Merge pull request #376 from Leptopoda/refactor/use_records

neon_news, neon_notes: use records in dialogs
pull/378/head
Nikolas Rimikis 1 year ago committed by GitHub
parent
commit
5a7e60e846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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