mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 17:29:50 +08:00
Note: Rename 'createdAt' to 'created'
My notes already use the key 'created', and I don't want to have to change that.
This commit is contained in:
@ -4,10 +4,10 @@ typedef NoteUpdator(Note note);
|
||||
|
||||
class Note implements Comparable {
|
||||
String id;
|
||||
DateTime createdAt;
|
||||
DateTime created;
|
||||
String body;
|
||||
|
||||
Note({this.createdAt, this.body, this.id});
|
||||
Note({this.created, this.body, this.id});
|
||||
|
||||
factory Note.fromJson(Map<String, dynamic> json) {
|
||||
String id;
|
||||
@ -22,21 +22,21 @@ class Note implements Comparable {
|
||||
|
||||
return new Note(
|
||||
id: id,
|
||||
createdAt: DateTime.parse(json['createdAt']),
|
||||
created: DateTime.parse(json['created']),
|
||||
body: json['body'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"createdAt": createdAt.toIso8601String(),
|
||||
"created": created.toIso8601String(),
|
||||
"body": body,
|
||||
"id": id,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => id.hashCode ^ createdAt.hashCode ^ body.hashCode;
|
||||
int get hashCode => id.hashCode ^ created.hashCode ^ body.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
@ -45,15 +45,15 @@ class Note implements Comparable {
|
||||
runtimeType == other.runtimeType &&
|
||||
id == other.id &&
|
||||
body == other.body &&
|
||||
createdAt == other.createdAt;
|
||||
created == other.created;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Note{id: $id, body: $body, createdAt: $createdAt}';
|
||||
return 'Note{id: $id, body: $body, createdAt: $created}';
|
||||
}
|
||||
|
||||
@override
|
||||
int compareTo(other) => createdAt.compareTo(other.createdAt);
|
||||
int compareTo(other) => created.compareTo(other.created);
|
||||
}
|
||||
|
||||
class AppState {
|
||||
|
@ -80,7 +80,7 @@ class NoteEditorState extends State<NoteEditor> {
|
||||
onPressed: () {
|
||||
var noteContent = noteTextKey.currentState.value;
|
||||
var note = new Note(
|
||||
createdAt: _createdAt,
|
||||
created: _createdAt,
|
||||
body: noteContent,
|
||||
);
|
||||
container.addNote(note);
|
||||
|
@ -85,11 +85,11 @@ class NoteViewer extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildHeader(BuildContext context) {
|
||||
var dateStr = DateFormat('MMM dd, yyyy').format(note.createdAt);
|
||||
var timeStr = DateFormat('EEEE H:m').format(note.createdAt);
|
||||
var dateStr = DateFormat('MMM dd, yyyy').format(note.created);
|
||||
var timeStr = DateFormat('EEEE H:m').format(note.created);
|
||||
|
||||
var bigNum = new Text(
|
||||
note.createdAt.day.toString(),
|
||||
note.created.day.toString(),
|
||||
style: TextStyle(fontSize: 40.0),
|
||||
);
|
||||
|
||||
|
@ -53,10 +53,10 @@ class JournalList extends StatelessWidget {
|
||||
|
||||
Widget _buildRow(BuildContext context, Note journal, int noteIndex) {
|
||||
var formatter = new DateFormat('dd MMM, yyyy');
|
||||
var title = formatter.format(journal.createdAt);
|
||||
var title = formatter.format(journal.created);
|
||||
|
||||
var timeFormatter = new DateFormat('Hm');
|
||||
var time = timeFormatter.format(journal.createdAt);
|
||||
var time = timeFormatter.format(journal.created);
|
||||
|
||||
var body = journal.body;
|
||||
body = body.replaceAll("\n", " ");
|
||||
|
@ -8,7 +8,7 @@ import 'package:test/test.dart';
|
||||
main() {
|
||||
group('Serializers', () {
|
||||
var note =
|
||||
Note(id: "2", body: "This is the body", createdAt: new DateTime.now());
|
||||
Note(id: "2", body: "This is the body", created: new DateTime.now());
|
||||
|
||||
test('JSON Serializer', () {
|
||||
var jsonSerializer = new JsonNoteSerializer();
|
||||
|
Reference in New Issue
Block a user