Created
March 5, 2020 09:53
-
-
Save xinthink/bfb348de0e95da409d4622d9f0cd5c18 to your computer and use it in GitHub Desktop.
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
class NoteStateUpdateCommand extends NoteCommand { | |
final NoteState from; | |
final NoteState to; | |
/// Create a [NoteCommand] to update state of a note [from] the current state [to] another. | |
NoteStateUpdateCommand({ | |
@required String id, | |
@required String uid, | |
@required this.from, | |
@required this.to, | |
}) : super(id: id, uid: uid); | |
@override | |
String get message { | |
switch (to) { | |
case NoteState.deleted: | |
return 'Note moved to trash'; | |
case NoteState.archived: | |
return 'Note archived'; | |
... | |
} | |
} | |
@override | |
Future<void> execute() => updateNoteState(to, id, uid); | |
@override | |
Future<void> revert() => updateNoteState(from, id, uid); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment