From c706715a46bcb0c9b2ceabe74632fcb36cfe78fc Mon Sep 17 00:00:00 2001 From: Nazarko12 Date: Mon, 27 Sep 2021 14:57:19 +0200 Subject: [PATCH 1/4] Information was added --- lib/main.dart | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 19dace7..e1298e8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -42,8 +42,8 @@ class _RandomWordsState extends State { style: _biggerFont, ), trailing: Icon( - alreadySaved ? Icons.favorite : Icons.favorite_border, - color: alreadySaved ? Colors.red : null, + alreadySaved ? Icons.done : Icons.attach_money, + color: alreadySaved ? null : Colors.green, semanticLabel: alreadySaved ? 'Remove from saved' : 'Save', ), onTap: () { @@ -65,7 +65,7 @@ class _RandomWordsState extends State { title: const Text('Startup Name Generator'), actions: [ IconButton( - icon: const Icon(Icons.list), + icon: const Icon(Icons.shopping_basket), onPressed: _pushSaved, tooltip: 'Saved Suggestions', ), @@ -99,6 +99,16 @@ class _RandomWordsState extends State { return Scaffold( appBar: AppBar( title: const Text('Saved Suggestions'), + actions: [ + IconButton( + icon: const Icon(Icons.info), + onPressed: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => Info())); + }, + tooltip: 'Saved Suggestions', + ), + ], ), body: ListView(children: divided), ); @@ -108,6 +118,23 @@ class _RandomWordsState extends State { } } +class Info extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text("Info"), + ), + body: const Center( + child: Text( + "Here you can add your words to the cart. \nYes!!! You can buy them. \n The future is now, wake up", + style: TextStyle( + fontSize: 14, color: Colors.black, fontWeight: FontWeight.normal), + )), + ); + } +} + class RandomWords extends StatefulWidget { @override State createState() => _RandomWordsState(); From 259c727d70427558cda36f0dc71cb3c1466f5787 Mon Sep 17 00:00:00 2001 From: Nazarko12 Date: Wed, 29 Sep 2021 09:03:52 +0200 Subject: [PATCH 2/4] The catalog in the form of the menu is created --- lib/main.dart | 137 ++++++++++++++------------------------------------ 1 file changed, 39 insertions(+), 98 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index e1298e8..9983f9d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,31 +1,44 @@ -import 'package:english_words/english_words.dart'; import 'package:flutter/material.dart'; +import 'package:english_words/english_words.dart'; + void main() => runApp(MyApp()); class MyApp extends StatelessWidget { + @override Widget build(BuildContext context) { return MaterialApp( title: 'Startup Name Generator', - theme: ThemeData( - primaryColor: Colors.white, - ), home: RandomWords(), ); } } +class RandomWords extends StatefulWidget { + @override + _RandomWordsState createState() => _RandomWordsState(); +} + class _RandomWordsState extends State { final _suggestions = []; - final _saved = {}; - final _biggerFont = const TextStyle(fontSize: 18.0); + final _biggerFont = const TextStyle(fontSize: 18); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Startup Name Generator'), + ), + body: _buildSuggestions(), + ); + } + Widget _buildSuggestions() { return ListView.builder( padding: const EdgeInsets.all(16.0), itemBuilder: (context, i) { if (i.isOdd) return const Divider(); - final index = i ~/ 2; if (index >= _suggestions.length) { _suggestions.addAll(generateWordPairs().take(10)); @@ -35,107 +48,35 @@ class _RandomWordsState extends State { } Widget _buildRow(WordPair pair) { - final alreadySaved = _saved.contains(pair); return ListTile( title: Text( pair.asPascalCase, style: _biggerFont, ), - trailing: Icon( - alreadySaved ? Icons.done : Icons.attach_money, - color: alreadySaved ? null : Colors.green, - semanticLabel: alreadySaved ? 'Remove from saved' : 'Save', - ), + trailing: const Text('Marked in the list!'), onTap: () { - setState(() { - if (alreadySaved) { - _saved.remove(pair); - } else { - _saved.add(pair); - } - }); + _showInformation(context); }, ); } +} - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text('Startup Name Generator'), - actions: [ - IconButton( - icon: const Icon(Icons.shopping_basket), - onPressed: _pushSaved, - tooltip: 'Saved Suggestions', +void _showInformation(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text("Notification!"), + content: const Text("Added to catalog"), + actions: [ + FlatButton( + child: const Text("Okey"), + onPressed: () { + Navigator.of(context).pop(); + }, ), ], - ), - body: _buildSuggestions(), - ); - } - - void _pushSaved() { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) { - final tiles = _saved.map( - (pair) { - return ListTile( - title: Text( - pair.asPascalCase, - style: _biggerFont, - ), - ); - }, - ); - final divided = tiles.isNotEmpty - ? ListTile.divideTiles( - context: context, - tiles: tiles, - ).toList() - : []; - - return Scaffold( - appBar: AppBar( - title: const Text('Saved Suggestions'), - actions: [ - IconButton( - icon: const Icon(Icons.info), - onPressed: () { - Navigator.push(context, - MaterialPageRoute(builder: (context) => Info())); - }, - tooltip: 'Saved Suggestions', - ), - ], - ), - body: ListView(children: divided), - ); - }, - ), - ); - } -} - -class Info extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text("Info"), - ), - body: const Center( - child: Text( - "Here you can add your words to the cart. \nYes!!! You can buy them. \n The future is now, wake up", - style: TextStyle( - fontSize: 14, color: Colors.black, fontWeight: FontWeight.normal), - )), - ); - } -} - -class RandomWords extends StatefulWidget { - @override - State createState() => _RandomWordsState(); + ); + }, + ); } \ No newline at end of file From 8854bf8b08ccf88033272aeef25b909c031de8bd Mon Sep 17 00:00:00 2001 From: Nazar <57871748+Nazarko12@users.noreply.github.com> Date: Wed, 29 Sep 2021 11:55:17 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 63f1d06..2b68c84 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# flutter-course \ No newline at end of file +# Flutter + +The directory was created using the Flutter framework and the Dart programming language. From 92969ee96f2e064a0134e2b5dc1abb3f1ee6f0a4 Mon Sep 17 00:00:00 2001 From: Nazar <57871748+Nazarko12@users.noreply.github.com> Date: Wed, 29 Sep 2021 17:24:08 +0200 Subject: [PATCH 4/4] Update main.dart --- lib/main.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 9983f9d..775af0a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -70,7 +70,7 @@ void _showInformation(BuildContext context) { content: const Text("Added to catalog"), actions: [ FlatButton( - child: const Text("Okey"), + child: const Text("Okay"), onPressed: () { Navigator.of(context).pop(); }, @@ -79,4 +79,4 @@ void _showInformation(BuildContext context) { ); }, ); -} \ No newline at end of file +}