mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-07 08:14:41 +08:00
Move Editor to its own file
This commit is contained in:
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
|
import 'note_editor.dart';
|
||||||
|
|
||||||
class Note {
|
class Note {
|
||||||
final DateTime createdAt;
|
final DateTime createdAt;
|
||||||
@ -33,23 +34,6 @@ Future<List<Note>> fetchNotes() async {
|
|||||||
return notes;
|
return notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// How to load this dynamically?
|
|
||||||
// I can put this in a widget with a state
|
|
||||||
// and do an async call.
|
|
||||||
/*
|
|
||||||
var state = <Note>[
|
|
||||||
Note(
|
|
||||||
createdAt: new DateTime.now(),
|
|
||||||
body: "The quick brown fox jumped over the very lazy dog, who then ran"
|
|
||||||
"all around the garden untill he fell down",
|
|
||||||
),
|
|
||||||
Note(
|
|
||||||
createdAt: new DateTime.now().subtract(new Duration(days: 1)),
|
|
||||||
body: "This is the body",
|
|
||||||
),
|
|
||||||
];
|
|
||||||
*/
|
|
||||||
|
|
||||||
void main() => runApp(new MyApp());
|
void main() => runApp(new MyApp());
|
||||||
|
|
||||||
class JournalList extends StatelessWidget {
|
class JournalList extends StatelessWidget {
|
||||||
@ -146,26 +130,7 @@ So now what is going to happen?
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _newPost(BuildContext context) {
|
void _newPost(BuildContext context) {
|
||||||
var bodyWidget = new Container(
|
var route = new MaterialPageRoute(builder: (context) => new NoteEditor());
|
||||||
child: new TextField(
|
|
||||||
autofocus: true,
|
|
||||||
keyboardType: TextInputType.multiline,
|
|
||||||
maxLines: 500,
|
|
||||||
decoration: new InputDecoration(
|
|
||||||
hintText: 'Write here',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
);
|
|
||||||
|
|
||||||
var newJournalScreen = new Scaffold(
|
|
||||||
appBar: new AppBar(
|
|
||||||
title: new Text("May 15, 17:35"),
|
|
||||||
),
|
|
||||||
body: bodyWidget,
|
|
||||||
);
|
|
||||||
|
|
||||||
var route = new MaterialPageRoute(builder: (context) => newJournalScreen);
|
|
||||||
Navigator.of(context).push(route);
|
Navigator.of(context).push(route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
27
lib/note_editor.dart
Normal file
27
lib/note_editor.dart
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class NoteEditor extends StatelessWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
var bodyWidget = new Container(
|
||||||
|
child: new TextField(
|
||||||
|
autofocus: true,
|
||||||
|
keyboardType: TextInputType.multiline,
|
||||||
|
maxLines: 5000,
|
||||||
|
decoration: new InputDecoration(
|
||||||
|
hintText: 'Write here',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
);
|
||||||
|
|
||||||
|
var newJournalScreen = new Scaffold(
|
||||||
|
appBar: new AppBar(
|
||||||
|
title: new Text("May 15, 17:35"),
|
||||||
|
),
|
||||||
|
body: bodyWidget,
|
||||||
|
);
|
||||||
|
|
||||||
|
return newJournalScreen;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user