mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 17:29:50 +08:00
Note Editing: Add the NoteHeader
It looks much prettier this way.
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:journal/note.dart';
|
||||
import 'package:journal/state_container.dart';
|
||||
import 'package:journal/widgets/note_header.dart';
|
||||
|
||||
class NoteEditor extends StatefulWidget {
|
||||
final Note note;
|
||||
@ -37,8 +38,7 @@ class NoteEditorState extends State<NoteEditor> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var bodyWidget = new Container(
|
||||
child: new Form(
|
||||
var bodyWidget = Form(
|
||||
// Show a dialog if discarding non-empty notes
|
||||
onWillPop: () {
|
||||
return Future(() {
|
||||
@ -55,14 +55,13 @@ class NoteEditorState extends State<NoteEditor> {
|
||||
child: TextFormField(
|
||||
autofocus: true,
|
||||
keyboardType: TextInputType.multiline,
|
||||
maxLines: 5000,
|
||||
maxLines: null,
|
||||
decoration: new InputDecoration(
|
||||
hintText: 'Write here',
|
||||
border: InputBorder.none,
|
||||
),
|
||||
controller: _textController,
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
);
|
||||
|
||||
var title = newNote ? "New Journal Entry" : "Edit Journal Entry";
|
||||
@ -70,7 +69,17 @@ class NoteEditorState extends State<NoteEditor> {
|
||||
appBar: new AppBar(
|
||||
title: new Text(title),
|
||||
),
|
||||
body: bodyWidget,
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
NoteHeader(note),
|
||||
bodyWidget,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: Icon(Icons.check),
|
||||
onPressed: () {
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:journal/widgets/swipe_detector.dart';
|
||||
import 'package:journal/widgets/note_header.dart';
|
||||
|
||||
import 'note_editor.dart';
|
||||
import 'note.dart';
|
||||
@ -79,9 +79,9 @@ class NoteViewer extends StatelessWidget {
|
||||
var view = new SingleChildScrollView(
|
||||
child: new Column(
|
||||
children: <Widget>[
|
||||
_buildHeader(context),
|
||||
new Text(note.body, style: _biggerFont),
|
||||
_buildFooter(context),
|
||||
NoteHeader(note),
|
||||
Text(note.body, style: _biggerFont),
|
||||
// _buildFooter(context),
|
||||
],
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
),
|
||||
@ -95,47 +95,6 @@ class NoteViewer extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader(BuildContext context) {
|
||||
var dateStr = DateFormat('MMM, yyyy').format(note.created);
|
||||
var timeStr = DateFormat('EEEE H:m').format(note.created);
|
||||
|
||||
var bigNum = new Text(
|
||||
note.created.day.toString(),
|
||||
style: TextStyle(fontSize: 40.0),
|
||||
);
|
||||
|
||||
var dateText = new Text(
|
||||
dateStr,
|
||||
style: TextStyle(fontSize: 18.0),
|
||||
);
|
||||
|
||||
var timeText = new Text(
|
||||
timeStr,
|
||||
style: TextStyle(fontSize: 18.0),
|
||||
);
|
||||
|
||||
var w = new Row(
|
||||
children: <Widget>[
|
||||
bigNum,
|
||||
new Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Column(
|
||||
children: <Widget>[
|
||||
dateText,
|
||||
timeText,
|
||||
],
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
return new Padding(
|
||||
padding: new EdgeInsets.only(top: 6.0, bottom: 6.0 * 3),
|
||||
child: w,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFooter(BuildContext context) {
|
||||
return new Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
|
||||
|
52
lib/widgets/note_header.dart
Normal file
52
lib/widgets/note_header.dart
Normal file
@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:journal/note.dart';
|
||||
|
||||
class NoteHeader extends StatelessWidget {
|
||||
final Note note;
|
||||
|
||||
NoteHeader(this.note);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var dateStr = DateFormat('MMM, yyyy').format(note.created);
|
||||
var timeStr = DateFormat('EEEE H:m').format(note.created);
|
||||
|
||||
var bigNum = new Text(
|
||||
note.created.day.toString(),
|
||||
style: TextStyle(fontSize: 40.0),
|
||||
);
|
||||
|
||||
var dateText = new Text(
|
||||
dateStr,
|
||||
style: TextStyle(fontSize: 18.0),
|
||||
);
|
||||
|
||||
var timeText = new Text(
|
||||
timeStr,
|
||||
style: TextStyle(fontSize: 18.0),
|
||||
);
|
||||
|
||||
var w = new Row(
|
||||
children: <Widget>[
|
||||
bigNum,
|
||||
new Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: new Column(
|
||||
children: <Widget>[
|
||||
dateText,
|
||||
timeText,
|
||||
],
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
return new Padding(
|
||||
padding: new EdgeInsets.only(top: 6.0, bottom: 6.0 * 3),
|
||||
child: w,
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user