From 46153d7e2420ae54b08b8cbcf2001d644cb54c0c Mon Sep 17 00:00:00 2001 From: lordmustafa <71147959+lordmustafa@users.noreply.github.com> Date: Wed, 6 Oct 2021 16:30:39 +0300 Subject: [PATCH 1/7] IG card task --- lib/main.dart | 248 +++----------------------------------------------- 1 file changed, 12 insertions(+), 236 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 2c084ed..2b3b3b4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,255 +1,31 @@ import 'package:flutter/material.dart'; -import 'dart:math' as math; -void main() { - runApp(const MyApp()); -} - -class Contact { - String image; - String name; - String mobileNumber; - DateTime date; - bool isIncoming; +import './shape.dart'; - Contact(this.image, this.name, this.mobileNumber, this.date, this.isIncoming); -} +void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return MaterialApp( - title: 'Flutter Demo 2', - theme: ThemeData( - primarySwatch: Colors.blue, - ), - debugShowCheckedModeBanner: false, - home: const MyHomePage(title: 'Contacts App'), - ); + return const MaterialApp(title: 'Flutter App', home: MyHomePage()); } } -class MyHomePage extends StatefulWidget { - const MyHomePage({Key? key, required this.title}) : super(key: key); - - final String title; +class MyHomePage extends StatelessWidget { + const MyHomePage({Key? key}) : super(key: key); @override - State createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State { - int _selectedIndex = 2; - static const TextStyle optionStyle = - TextStyle(fontSize: 30, fontWeight: FontWeight.bold); - static late List _pages; - - _MyHomePageState() { - _pages = [ - buildContactsList(), - buildFavoritesGridView(), - // Text('hello'), - Text( - 'Index 2: School', - style: optionStyle, - ), - ]; - } - - void _onItemTapped(int index) { - setState(() { - _selectedIndex = index; - }); - } - - var contacts = [ - Contact( - 'https://i.pravatar.cc/300', - 'Ahmed', - '71766137347', - DateTime.now().add( - const Duration(seconds: 3), - ), - true, - ), - Contact( - 'https://i.pravatar.cc/301', - 'Ali', - '71766137347', - DateTime.now().add( - const Duration(days: 1), - ), - false, - ), - Contact( - 'https://i.pravatar.cc/302', - 'Kamal', - '71766137347', - DateTime.now().add( - const Duration(days: 3), - ), - true, - ), - Contact( - 'https://i.pravatar.cc/303', - 'Mohammad', - '71766137347', - DateTime.now().add( - const Duration(days: 5), - ), - true, - ), - Contact( - 'https://i.pravatar.cc/304', - 'Mohammad', - '71766137347', - DateTime.now().add( - const Duration(days: 5), - ), - false, - ), - Contact( - 'https://i.pravatar.cc/305', - 'Hussein', - '71766137347', - DateTime.now().add( - const Duration(days: 6), - ), - false, - ), - Contact( - 'https://i.pravatar.cc/306', - 'Aboud', - '71766137347', - DateTime.now().add( - const Duration(days: 7), - ), - false, - ), - Contact( - 'https://i.pravatar.cc/307', - 'Osama', - '71766137347', - DateTime.now().add( - const Duration(days: 6), - ), - false, - ), - ]; - - Widget buildFavoritesGridView() { - return Column( - children: [ - Text('Favorites'), - Divider(thickness: 4,), - Expanded( - child: GridView.count( - crossAxisCount: 3, - children: List.generate(5, (index) { - var personColor = Color((math.Random().nextDouble() * 0xFFFFFF).toInt()) - .withOpacity(1.0); - return Center( - child: Container( - width: 120, - height: 120, - child: Text( - contacts[index].name[0], - style: TextStyle(fontSize: 40), - ), - alignment: Alignment.center, - decoration: - BoxDecoration(shape: BoxShape.circle, color: personColor), - ), - ); - }), - ), - ), - ], - ); - } - - Widget buildContactItem(Contact _contact) { - return Card( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - children: [ - CircleAvatar( - backgroundImage: NetworkImage(_contact.image), - ), - Padding( - padding: const EdgeInsets.all(16), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - _contact.name, - style: const TextStyle(fontWeight: FontWeight.bold), - ), - Text(_contact.mobileNumber), - ], - ), - ), - Text(_contact.date.toIso8601String().split('T').first), - Expanded( - child: Container(), - ), - if (_contact.isIncoming) - Icon( - Icons.arrow_downward, - color: Colors.red, - ) - else - Icon( - Icons.arrow_upward, - color: Colors.green, - ) + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + backgroundColor: Colors.blueGrey, + body: ListView( + children: const [ + IgCard(), ], ), ), ); } - - Widget buildContactsList() { - return ListView.builder( - itemBuilder: (_context, index) { - return buildContactItem(contacts[index]); - }, - itemCount: contacts.length, - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text(widget.title), - ), - body: Center( - child: _pages[_selectedIndex], - ), - bottomNavigationBar: BottomNavigationBar( - items: const [ - BottomNavigationBarItem( - icon: Icon(Icons.home), - label: 'Recent', - ), - BottomNavigationBarItem( - icon: Icon(Icons.favorite), - label: 'Favorites', - ), - BottomNavigationBarItem( - icon: Icon(Icons.access_time_outlined), - label: 'School', - activeIcon: Icon(Icons.access_time_filled) - ), - ], - currentIndex: _selectedIndex, - selectedItemColor: Colors.amber[800], - onTap: _onItemTapped, - ), - ); - } } From 9454289525be7b023a40d968d715efb04d1b8948 Mon Sep 17 00:00:00 2001 From: lordmustafa <71147959+lordmustafa@users.noreply.github.com> Date: Wed, 6 Oct 2021 16:31:29 +0300 Subject: [PATCH 2/7] Add files via upload --- lib/shape.dart | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 lib/shape.dart diff --git a/lib/shape.dart b/lib/shape.dart new file mode 100644 index 0000000..42b634f --- /dev/null +++ b/lib/shape.dart @@ -0,0 +1,75 @@ +import 'package:flutter/material.dart'; + +class IgCard extends StatelessWidget { + const IgCard({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + border: Border.all(width: 4.0, style: BorderStyle.solid), + ), + child: Column( + children: [ + Image.network( + 'https://images.unsplash.com/photo-1584551882802-ca081b505b49?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=841&q=80'), + Padding( + padding: const EdgeInsets.all(10), + child: Row( + children: [ + Container( + child: const Icon( + Icons.favorite_border_outlined, + size: 36.0, + color: Colors.white, + ), + padding: EdgeInsets.all(10.0), + margin: EdgeInsets.fromLTRB(0, 10.0, 0, 0.0), + ), + const Text(' '), + Container( + child: const Icon( + Icons.location_on_outlined, + size: 36.0, + color: Colors.white, + ), + padding: EdgeInsets.all(10.0), + margin: EdgeInsets.fromLTRB(0, 10.0, 0, 0.0), + ), + Expanded( + child: Container(child: null), + ), + Container( + child: const Icon(Icons.menu_outlined, + size: 36.0, color: Colors.white), + padding: EdgeInsets.all(10.0), + margin: EdgeInsets.fromLTRB(0, 10.0, 0, 0.0), + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(16), + child: Row( + children: const [ + Text('36', + style: TextStyle( + fontSize: 24, + color: Colors.white, + fontWeight: FontWeight.bold, + )), + Text(' '), + Text('Likes', + style: TextStyle( + fontSize: 24, + color: Colors.white, + fontWeight: FontWeight.bold, + )), + ], + ), + ) + ], + ), + ); + } +} From 5d52ae2398e935c9f76da21302dc1e01f4413216 Mon Sep 17 00:00:00 2001 From: lordmustafa <71147959+lordmustafa@users.noreply.github.com> Date: Thu, 7 Oct 2021 07:46:01 +0300 Subject: [PATCH 3/7] Delete lib directory --- lib/main.dart | 31 --------------------- lib/shape.dart | 75 -------------------------------------------------- 2 files changed, 106 deletions(-) delete mode 100644 lib/main.dart delete mode 100644 lib/shape.dart diff --git a/lib/main.dart b/lib/main.dart deleted file mode 100644 index 2b3b3b4..0000000 --- a/lib/main.dart +++ /dev/null @@ -1,31 +0,0 @@ -import 'package:flutter/material.dart'; -import './shape.dart'; - -void main() => runApp(const MyApp()); - -class MyApp extends StatelessWidget { - const MyApp({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return const MaterialApp(title: 'Flutter App', home: MyHomePage()); - } -} - -class MyHomePage extends StatelessWidget { - const MyHomePage({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return SafeArea( - child: Scaffold( - backgroundColor: Colors.blueGrey, - body: ListView( - children: const [ - IgCard(), - ], - ), - ), - ); - } -} diff --git a/lib/shape.dart b/lib/shape.dart deleted file mode 100644 index 42b634f..0000000 --- a/lib/shape.dart +++ /dev/null @@ -1,75 +0,0 @@ -import 'package:flutter/material.dart'; - -class IgCard extends StatelessWidget { - const IgCard({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Container( - decoration: BoxDecoration( - border: Border.all(width: 4.0, style: BorderStyle.solid), - ), - child: Column( - children: [ - Image.network( - 'https://images.unsplash.com/photo-1584551882802-ca081b505b49?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=841&q=80'), - Padding( - padding: const EdgeInsets.all(10), - child: Row( - children: [ - Container( - child: const Icon( - Icons.favorite_border_outlined, - size: 36.0, - color: Colors.white, - ), - padding: EdgeInsets.all(10.0), - margin: EdgeInsets.fromLTRB(0, 10.0, 0, 0.0), - ), - const Text(' '), - Container( - child: const Icon( - Icons.location_on_outlined, - size: 36.0, - color: Colors.white, - ), - padding: EdgeInsets.all(10.0), - margin: EdgeInsets.fromLTRB(0, 10.0, 0, 0.0), - ), - Expanded( - child: Container(child: null), - ), - Container( - child: const Icon(Icons.menu_outlined, - size: 36.0, color: Colors.white), - padding: EdgeInsets.all(10.0), - margin: EdgeInsets.fromLTRB(0, 10.0, 0, 0.0), - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.all(16), - child: Row( - children: const [ - Text('36', - style: TextStyle( - fontSize: 24, - color: Colors.white, - fontWeight: FontWeight.bold, - )), - Text(' '), - Text('Likes', - style: TextStyle( - fontSize: 24, - color: Colors.white, - fontWeight: FontWeight.bold, - )), - ], - ), - ) - ], - ), - ); - } -} From 4e70cbc06aa80f7d707c508181659c157d927591 Mon Sep 17 00:00:00 2001 From: lordmustafa <71147959+lordmustafa@users.noreply.github.com> Date: Thu, 7 Oct 2021 07:52:02 +0300 Subject: [PATCH 4/7] Create main.dart --- lib/main.dart | 1 + 1 file changed, 1 insertion(+) create mode 100644 lib/main.dart diff --git a/lib/main.dart b/lib/main.dart new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/lib/main.dart @@ -0,0 +1 @@ + From 95c4c29eb88aa10b6d525e824d21c0acaa63ec34 Mon Sep 17 00:00:00 2001 From: lordmustafa <71147959+lordmustafa@users.noreply.github.com> Date: Thu, 7 Oct 2021 07:52:45 +0300 Subject: [PATCH 5/7] Add files via upload --- lib/contact_card.dart | 41 ++++++++++++++++++++++ lib/contact_obj.dart | 8 +++++ lib/contacts_data.dart | 77 +++++++++++++++++++++++++++++++++++++++++ lib/contacts_list.dart | 20 +++++++++++ lib/favorites_list.dart | 18 ++++++++++ lib/recent_card.dart | 60 ++++++++++++++++++++++++++++++++ lib/recent_list.dart | 22 ++++++++++++ 7 files changed, 246 insertions(+) create mode 100644 lib/contact_card.dart create mode 100644 lib/contact_obj.dart create mode 100644 lib/contacts_data.dart create mode 100644 lib/contacts_list.dart create mode 100644 lib/favorites_list.dart create mode 100644 lib/recent_card.dart create mode 100644 lib/recent_list.dart diff --git a/lib/contact_card.dart b/lib/contact_card.dart new file mode 100644 index 0000000..0165f96 --- /dev/null +++ b/lib/contact_card.dart @@ -0,0 +1,41 @@ +import 'package:flutter/material.dart'; + +class ContactCard extends StatelessWidget { + final String name, image, mobileNumber; + const ContactCard({ + Key? key, + required this.name, + required this.image, + required this.mobileNumber, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.all(10), + child: Card( + child: Row( + children: [ + CircleAvatar( + backgroundImage: NetworkImage(image), + ), + Padding( + padding: const EdgeInsets.all(16), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + name, + style: const TextStyle(fontWeight: FontWeight.bold), + ), + Text(mobileNumber), + ], + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/contact_obj.dart b/lib/contact_obj.dart new file mode 100644 index 0000000..9faf88b --- /dev/null +++ b/lib/contact_obj.dart @@ -0,0 +1,8 @@ +class Contact { + final String image, name, mobileNumber; + final DateTime callDate; + bool isIncoming; + + Contact( + this.image, this.name, this.mobileNumber, this.callDate, this.isIncoming); +} diff --git a/lib/contacts_data.dart b/lib/contacts_data.dart new file mode 100644 index 0000000..c2fc0fc --- /dev/null +++ b/lib/contacts_data.dart @@ -0,0 +1,77 @@ +import 'contact_obj.dart'; + +// ignore: non_constant_identifier_names +final contacts_data = { + Contact( + 'https://i.pravatar.cc/300', + 'Ahmed', + '71766137347', + DateTime.now().add( + Duration(seconds: 3), + ), + true, + ), + Contact( + 'https://i.pravatar.cc/301', + 'Ali', + '71766137347', + DateTime.now().add( + Duration(days: 1), + ), + false, + ), + Contact( + 'https://i.pravatar.cc/302', + 'Kamal', + '71766137347', + DateTime.now().add( + Duration(days: 3), + ), + true, + ), + Contact( + 'https://i.pravatar.cc/303', + 'Mohammad', + '71766137347', + DateTime.now().add( + Duration(days: 5), + ), + true, + ), + Contact( + 'https://i.pravatar.cc/304', + 'Mohammad', + '71766137347', + DateTime.now().add( + Duration(days: 5), + ), + false, + ), + Contact( + 'https://i.pravatar.cc/305', + 'Hussein', + '71766137347', + DateTime.now().add( + Duration(days: 6), + ), + false, + ), + Contact( + 'https://i.pravatar.cc/306', + 'Aboud', + '71766137347', + DateTime.now().add( + Duration(days: 7), + ), + false, + ), + Contact( + 'https://i.pravatar.cc/307', + 'Osama', + '71766137347', + DateTime.now().add( + Duration(days: 6), + ), + false, + ), +}; diff --git a/lib/contacts_list.dart b/lib/contacts_list.dart new file mode 100644 index 0000000..41d1232 --- /dev/null +++ b/lib/contacts_list.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; +import 'contacts_data.dart'; +import 'contact_card.dart'; + +class ContactListView extends StatelessWidget { + const ContactListView({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return ListView( + children: contacts_data + .map((recData) => ContactCard( + image: recData.image, + name: recData.name, + mobileNumber: recData.mobileNumber, + )) + .toList(), + ); + } +} diff --git a/lib/favorites_list.dart b/lib/favorites_list.dart new file mode 100644 index 0000000..4b6a9ef --- /dev/null +++ b/lib/favorites_list.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; + +class FavoriteListView extends StatelessWidget { + const FavoriteListView({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return GridView( + children: [], + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 200, + childAspectRatio: 3 / 2, + crossAxisSpacing: 20, + mainAxisSpacing: 20, + ), + ); + } +} diff --git a/lib/recent_card.dart b/lib/recent_card.dart new file mode 100644 index 0000000..b9232ed --- /dev/null +++ b/lib/recent_card.dart @@ -0,0 +1,60 @@ +import 'package:flutter/material.dart'; + +// ignore: must_be_immutable +class ResentCard extends StatelessWidget { + String image, name, mobileNumber; + DateTime callDate = DateTime.now(); + bool isIncoming; + + ResentCard( + {Key? key, + required this.image, + required this.name, + required this.mobileNumber, + required this.callDate, + required this.isIncoming}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.all(10), + child: Card( + child: Row( + children: [ + CircleAvatar( + backgroundImage: NetworkImage(image), + ), + Padding( + padding: const EdgeInsets.all(16), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + name, + style: const TextStyle(fontWeight: FontWeight.bold), + ), + Text(mobileNumber), + ], + ), + ), + Text(callDate.toIso8601String().split('T').first), + Expanded( + child: Container(), + ), + if (isIncoming) + const Icon( + Icons.arrow_downward, + color: Colors.red, + ) + else + const Icon( + Icons.arrow_upward, + color: Colors.green, + ) + ], + ), + )); + } +} diff --git a/lib/recent_list.dart b/lib/recent_list.dart new file mode 100644 index 0000000..361a88c --- /dev/null +++ b/lib/recent_list.dart @@ -0,0 +1,22 @@ +import 'package:contacts_app/contact_obj.dart'; +import 'package:flutter/material.dart'; +import 'recent_card.dart'; +import 'contacts_data.dart'; + +class RecentListView extends StatelessWidget { + const RecentListView({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return ListView( + children: contacts_data + .map((recData) => ResentCard( + image: recData.image, + name: recData.name, + mobileNumber: recData.mobileNumber, + callDate: recData.callDate, + isIncoming: recData.isIncoming)) + .toList(), + ); + } +} From a2b2270b6c9222b2ba402278674774552c635a79 Mon Sep 17 00:00:00 2001 From: lordmustafa <71147959+lordmustafa@users.noreply.github.com> Date: Thu, 7 Oct 2021 07:53:21 +0300 Subject: [PATCH 6/7] Update main.dart --- lib/main.dart | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/lib/main.dart b/lib/main.dart index 8b13789..25a2162 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1 +1,68 @@ +import 'package:flutter/material.dart'; +import 'contacts_list.dart'; +import 'favorites_list.dart'; +import 'recent_list.dart'; +void main() => runApp(const MyApp()); + +class MyApp extends StatelessWidget { + const MyApp({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter App 2', + theme: ThemeData( + primarySwatch: Colors.green, + ), + debugShowCheckedModeBanner: false, + home: const MyHomePage(), + ); + } +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({Key? key}) : super(key: key); + + @override + _MyHomePageState createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + @override + Widget build(BuildContext context) { + final tabs = [ + const RecentListView(), + const FavoriteListView(), + const ContactListView(), + ]; + int _curentIndex = 0; + return Scaffold( + appBar: AppBar( + title: const Text('Contacts'), + ), + body: tabs[_curentIndex], + bottomNavigationBar: BottomNavigationBar( + currentIndex: _curentIndex, + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.access_time_outlined), + backgroundColor: Colors.green, + label: 'Recent'), + BottomNavigationBarItem( + icon: Icon(Icons.star_outline), + backgroundColor: Colors.yellow, + label: 'Favorites'), + BottomNavigationBarItem( + icon: Icon(Icons.person_outline), + backgroundColor: Colors.orange, + label: 'Contacts'), + ], + type: BottomNavigationBarType.shifting, + onTap: (index) { + setState(() => _curentIndex = index); + }, + ), + ); + } +} From 20005ebf92127f7b4d2f71a34d4cbb377491ddad Mon Sep 17 00:00:00 2001 From: lordmustafa <71147959+lordmustafa@users.noreply.github.com> Date: Thu, 7 Oct 2021 19:16:37 +0300 Subject: [PATCH 7/7] Update main.dart --- lib/main.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 25a2162..e30cdce 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -29,14 +29,14 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { + final tabs = [ + const RecentListView(), + const FavoriteListView(), + const ContactListView(), + ]; + int _curentIndex = 0; @override Widget build(BuildContext context) { - final tabs = [ - const RecentListView(), - const FavoriteListView(), - const ContactListView(), - ]; - int _curentIndex = 0; return Scaffold( appBar: AppBar( title: const Text('Contacts'),