diff --git a/lib/main.dart b/lib/main.dart index 52a741c9..f63e56d6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,110 +1,66 @@ import 'package:flutter/material.dart'; -import 'package:english_words/english_words.dart'; void main() => runApp(new MyApp()); +class JournalList extends StatefulWidget { + @override + createState() => new JournalListState(); +} + +class JournalListState extends State { + final _biggerFont = const TextStyle(fontSize: 18.0); + + @override + Widget build(BuildContext context) { + var createButton = new FloatingActionButton( + onPressed: _newPost, + child: new Icon(Icons.add), + ); + + return new Scaffold( + appBar: new AppBar( + title: new Text('Journal'), + ), + body: _buildSuggestions(), + floatingActionButton: createButton, + ); + } + + Widget _buildRow() { + var body = "The quick brown fox jumped over the very lazy dog, who then ran" + "all around the garden untill he fell down"; + + return new ListTile( + isThreeLine: true, + title: new Text( + "May 5, 2018", + style: _biggerFont, + ), + subtitle: new Text("10:24" + "\n" + body), + onTap: () { + setState(() {}); + }, + ); + } + + Widget _buildSuggestions() { + return new ListView.builder( + padding: const EdgeInsets.all(8.0), + itemBuilder: (context, i) { + if (i.isOdd) return new Divider(); + return _buildRow(); + }, + ); + } + + void _newPost() { + print("FOoOO"); + } +} + class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( - title: 'Startup Name Generator', home: new RandomWords()); - } -} - -class RandomWords extends StatefulWidget { - @override - createState() => new RandomWordsState(); -} - -class RandomWordsState extends State { - final _suggestions = []; - final _saved = new Set(); - - final _biggerFont = const TextStyle(fontSize: 18.0); - - Widget _buildSuggestions() { - return new ListView.builder( - padding: const EdgeInsets.all(16.0), - itemBuilder: (context, i) { - if (i.isOdd) return new Divider(); - final index = i ~/ 2; - if (index >= _suggestions.length) { - _suggestions.addAll(generateWordPairs().take(10)); - } - return _buildRow(_suggestions[index]); - }, - ); - } - - Widget _buildRow(WordPair pair) { - final alreadySaved = _saved.contains(pair); - - return new ListTile( - title: new Text( - pair.asPascalCase, - style: _biggerFont, - ), - trailing: new Icon( - alreadySaved ? Icons.favorite : Icons.favorite_border, - color: alreadySaved ? Colors.red : null, - ), - onTap: () { - setState(() { - if (alreadySaved) { - _saved.remove(pair); - } else { - _saved.add(pair); - } - }); - }, - ); - } - - @override - Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( - title: new Text('Startup Name Generator'), - actions: [ - new IconButton( - icon: new Icon(Icons.list), - onPressed: _pushSaved, - ), - ], - ), - body: _buildSuggestions(), - ); - } - - void _pushSaved() { - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - final tiles = _saved.map( - (pair) { - return new ListTile( - title: new Text( - pair.asPascalCase, - style: _biggerFont, - ), - ); - }, - ); - final divided = ListTile - .divideTiles( - context: context, - tiles: tiles, - ) - .toList(); - - return new Scaffold( - appBar: new AppBar( - title: new Text('Saved Suggestions'), - ), - body: new ListView(children: divided), - ); - }, - ), - ); + return new MaterialApp(title: 'Journal', home: new JournalList()); } } diff --git a/pubspec.lock b/pubspec.lock index a7c5503e..f05c3a11 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -85,13 +85,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.2" - english_words: - dependency: "direct main" - description: - name: english_words - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0" flutter: dependency: "direct main" description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index c3ea1075..2590556f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: journal -description: A new Flutter project. +description: A simple journaling app. dependencies: flutter: @@ -8,8 +8,6 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.0 - english_words: ^3.1.0 - dev_dependencies: flutter_test: @@ -55,5 +53,5 @@ flutter: # - asset: fonts/TrajanPro_Bold.ttf # weight: 700 # - # For details regarding fonts from package dependencies, + # For details regarding fonts from package dependencies, # see https://flutter.io/custom-fonts/#from-packages