From 8f42b4cdddca2e7c61dc4d961b4a11c63ac0d9b0 Mon Sep 17 00:00:00 2001 From: zayns97 Date: Wed, 6 Oct 2021 02:24:54 +0300 Subject: [PATCH] Task of the first week --- android/app/src/main/AndroidManifest.xml | 4 +- lib/constant/aboutme.dart | 90 ++++++++ lib/constant/team_list.dart | 126 ++++++++++++ lib/main.dart | 250 +---------------------- lib/screens/teams.dart | 71 +++++++ pubspec.lock | 71 ++++++- pubspec.yaml | 2 + 7 files changed, 373 insertions(+), 241 deletions(-) create mode 100644 lib/constant/aboutme.dart create mode 100644 lib/constant/team_list.dart create mode 100644 lib/screens/teams.dart diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 609e8ad..c15c570 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,7 +1,9 @@ + + members = [ + TeamList( + username: 'zayn_n97', + userimage: 'https://avatars.githubusercontent.com/u/38259126?v=4', + postimage: + 'https://images.unsplash.com/photo-1433832597046-4f10e10ac764?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1942&q=80', + isLiked: false), + TeamList( + username: 'bluemix', + userimage: 'https://avatars.githubusercontent.com/u/3332274?v=4', + postimage: + 'https://images.unsplash.com/photo-1628800491886-feba18ba54f0?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=735&q=80', + isLiked: true), + TeamList( + username: 'de_grandi', + userimage: + 'https://images.unsplash.com/profile-1510508149334-1afd6f4775e4?dpr=1&auto=format&fit=crop&w=150&h=150&q=60&crop=faces&bg=fff', + postimage: + 'https://images.unsplash.com/photo-1510525009512-ad7fc13eefab?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1974&q=80', + isLiked: true), + TeamList( + username: 'karsten116', + userimage: + 'https://images.unsplash.com/profile-1583427783052-3da8ceab5579image?dpr=1&auto=format&fit=crop&w=150&h=150&q=60&crop=faces&bg=fff', + postimage: + 'https://images.unsplash.com/photo-1583337130417-3346a1be7dee?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=764&q=80', + isLiked: false), +]; + +Widget buildTeamList() { + return ListView.builder( + itemCount: members.length, + itemBuilder: (_context, index) { + return buildTeamItem(members[index]); + }, + ); +} + +Widget buildTeamItem(TeamList member) { + return Padding( + padding: const EdgeInsets.all(10.0), + child: Card( + elevation: 7, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 5), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + CircleAvatar( + radius: 22.0, + backgroundImage: NetworkImage(member.userimage), + backgroundColor: Colors.transparent, + ), + const SizedBox( + width: 10, + ), + Text( + member.username, + style: const TextStyle( + fontWeight: FontWeight.w800, + fontSize: 19, + ), + ), + ], + ), + const SizedBox(height: 10), + Image.network(member.postimage), + const SizedBox(height: 15), + Row( + children: [ + Icon( + member.isLiked + ? FontAwesomeIcons.solidHeart + : FontAwesomeIcons.heart, + color: member.isLiked ? Colors.redAccent : Colors.black, + size: 27, + ), + const SizedBox(width: 10), + const Icon( + FontAwesomeIcons.commentAlt, + size: 27, + ), + const SizedBox(width: 10), + const Icon( + FontAwesomeIcons.paperPlane, + size: 27, + ), + Expanded(child: Container()), + const Icon( + FontAwesomeIcons.bookmark, + size: 27, + ), + ], + ), + const SizedBox(height: 10), + const Text('20 Likes', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 17, + )), + ], + ), + ), + ), + ); +} diff --git a/lib/main.dart b/lib/main.dart index 2c084ed..d8090a1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,255 +1,27 @@ import 'package:flutter/material.dart'; -import 'dart:math' as math; +import 'package:flutter/services.dart'; +import 'screens/teams.dart'; + void main() { + WidgetsFlutterBinding.ensureInitialized(); + SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( + statusBarColor: Colors.transparent, + statusBarIconBrightness: Brightness.light, + )); runApp(const MyApp()); } -class Contact { - String image; - String name; - String mobileNumber; - DateTime date; - bool isIncoming; - - Contact(this.image, this.name, this.mobileNumber, this.date, this.isIncoming); -} - 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'), - ); - } -} - -class MyHomePage extends StatefulWidget { - const MyHomePage({Key? key, required this.title}) : super(key: key); - - final String title; - - @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 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, + theme: ThemeData( + primarySwatch: Colors.deepPurple, ), + home: const Teams(title: 'Teams'), ); } } diff --git a/lib/screens/teams.dart b/lib/screens/teams.dart new file mode 100644 index 0000000..828df78 --- /dev/null +++ b/lib/screens/teams.dart @@ -0,0 +1,71 @@ +import 'package:contacts_01/constant/aboutme.dart'; +import 'package:contacts_01/constant/team_list.dart'; +import 'package:flutter/material.dart'; + + +class Teams extends StatefulWidget { + const Teams({Key? key, required this.title}) : super(key: key); + final String title; + + @override + _TeamsState createState() => _TeamsState(); +} + +class _TeamsState extends State { + int _currentIndex = 0; + static late List _teamList; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBar( + title: Text( + widget.title, + style: const TextStyle( + color: Colors.black87, fontSize: 30, fontWeight: FontWeight.w900), + ), + centerTitle: false, + backgroundColor: Colors.white, + elevation: 0, + ), + body: Center( + child: _teamList[_currentIndex], + ), + bottomNavigationBar: BottomNavigationBar( + elevation: 0, + iconSize: 40, + selectedFontSize: 0, + unselectedFontSize: 0, + type: BottomNavigationBarType.fixed, + currentIndex: _currentIndex, + selectedItemColor: Colors.black87, + onTap: _onNavTap, + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.home_outlined), + activeIcon: Icon(Icons.home), + label: '', + ), + BottomNavigationBarItem( + icon: Icon(Icons.person_outlined), + activeIcon: Icon(Icons.person), + label: '', + ), + ], + ), + ); + } + + _TeamsState() { + _teamList = [ + buildTeamList(), + buildAboutMe(), + ]; + } + void _onNavTap(int index) { + setState(() { + _currentIndex = index; + }); + } +} diff --git a/pubspec.lock b/pubspec.lock index 750761f..95826a3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -74,6 +74,25 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + font_awesome_flutter: + dependency: "direct main" + description: + name: font_awesome_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "9.1.0" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" lints: dependency: transitive description: @@ -102,6 +121,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" sky_engine: dependency: transitive description: flutter @@ -156,6 +182,48 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.12" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" vector_math: dependency: transitive description: @@ -164,4 +232,5 @@ packages: source: hosted version: "2.1.0" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" diff --git a/pubspec.yaml b/pubspec.yaml index 1c93cc7..d25de61 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,6 +34,8 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 + font_awesome_flutter: ^9.1.0 + url_launcher: ^6.0.10 dev_dependencies: flutter_test: