Allow sharing of notes

This commit is contained in:
Vishesh Handa
2020-05-01 12:20:55 +02:00
parent 39d495a1a4
commit a995a88028

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gitjournal/core/note.dart'; import 'package:gitjournal/core/note.dart';
import 'package:share/share.dart';
typedef NoteCallback = void Function(Note); typedef NoteCallback = void Function(Note);
@ -16,7 +17,7 @@ abstract class EditorState {
Note getNote(); Note getNote();
} }
enum DropDownChoices { Rename, MoveToFolder, DiscardChanges } enum DropDownChoices { Rename, MoveToFolder, DiscardChanges, Share }
AppBar buildEditorAppBar( AppBar buildEditorAppBar(
Editor editor, Editor editor,
@ -66,6 +67,11 @@ AppBar buildEditorAppBar(
var note = editorState.getNote(); var note = editorState.getNote();
editor.discardChangesSelected(note); editor.discardChangesSelected(note);
return; return;
case DropDownChoices.Share:
var note = editorState.getNote();
Share.share(note.body);
return;
} }
}, },
itemBuilder: (BuildContext context) => itemBuilder: (BuildContext context) =>
@ -82,6 +88,10 @@ AppBar buildEditorAppBar(
value: DropDownChoices.DiscardChanges, value: DropDownChoices.DiscardChanges,
child: Text('Discard Changes'), child: Text('Discard Changes'),
), ),
const PopupMenuItem<DropDownChoices>(
value: DropDownChoices.Share,
child: Text('Share Note'),
),
], ],
), ),
], ],