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/2] 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/2] 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, + )), + ], + ), + ) + ], + ), + ); + } +}