From 65f84fc240301d61bf54a4ae5849c4906d929289 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Tue, 26 Jun 2018 12:09:13 +0530 Subject: [PATCH] profile two done --- lib/main.dart | 1 + lib/model/post.dart | 4 +- lib/myapp.dart | 4 +- lib/ui/page/profile/profile_one_page.dart | 52 ++++---- lib/ui/page/profile/profile_two_page.dart | 156 ++++++++++++++++++++++ lib/ui/widgets/common_scaffold.dart | 7 +- lib/utils/uidata.dart | 1 + pubspec.lock | 7 + pubspec.yaml | 1 + 9 files changed, 204 insertions(+), 29 deletions(-) create mode 100644 lib/ui/page/profile/profile_two_page.dart diff --git a/lib/main.dart b/lib/main.dart index 18c999d..e28f5f7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,6 +5,7 @@ import 'package:flutter_uikit/myapp.dart'; void main() { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); + MaterialPageRoute.debugEnableFadingRoutes = true; Injector.configure(Flavor.MOCK); runApp(MyApp()); } diff --git a/lib/model/post.dart b/lib/model/post.dart index a4fa82b..7c77d9c 100644 --- a/lib/model/post.dart +++ b/lib/model/post.dart @@ -7,6 +7,7 @@ class Post { int likesCount; int commentsCount; String postTime; + List photos; Post( {this.personName, @@ -16,5 +17,6 @@ class Post { this.commentsCount, this.likesCount, this.messageImage, - this.postTime}); + this.postTime, + this.photos}); } diff --git a/lib/myapp.dart b/lib/myapp.dart index 69b669b..04de47c 100644 --- a/lib/myapp.dart +++ b/lib/myapp.dart @@ -6,6 +6,7 @@ import 'package:flutter_uikit/ui/page/login/login_page.dart'; import 'package:flutter_uikit/ui/page/notfound/notfound_page.dart'; import 'package:flutter_uikit/ui/page/payment/credit_card_page.dart'; import 'package:flutter_uikit/ui/page/profile/profile_one_page.dart'; +import 'package:flutter_uikit/ui/page/profile/profile_two_page.dart'; import 'package:flutter_uikit/ui/page/settings/settings_one_page.dart'; import 'package:flutter_uikit/ui/page/shopping/product_detail_page.dart'; import 'package:flutter_uikit/ui/page/shopping/shopping_details_page.dart'; @@ -25,13 +26,14 @@ class MyApp extends StatelessWidget { primarySwatch: Colors.amber), debugShowCheckedModeBanner: false, showPerformanceOverlay: false, - home: HomePage(), + home: ProfileTwoPage(), // initialRoute: UIData.notFoundRoute, //routes routes: { UIData.homeRoute: (BuildContext context) => HomePage(), UIData.profileOneRoute: (BuildContext context) => ProfileOnePage(), + UIData.profileTwoRoute: (BuildContext context) => ProfileTwoPage(), UIData.timelineOneRoute: (BuildContext context) => TimelineOnePage(), UIData.timelineTwoRoute: (BuildContext context) => TimelineTwoPage(), UIData.notFoundRoute: (BuildContext context) => NotFoundPage(), diff --git a/lib/ui/page/profile/profile_one_page.dart b/lib/ui/page/profile/profile_one_page.dart index 5371225..9f26e84 100644 --- a/lib/ui/page/profile/profile_one_page.dart +++ b/lib/ui/page/profile/profile_one_page.dart @@ -55,30 +55,7 @@ class ProfileOnePage extends StatelessWidget { ); //column2 - Widget followColumn() => Container( - height: deviceSize.height * 0.13, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - ProfileTile( - title: "1.5K", - subtitle: "Posts", - ), - ProfileTile( - title: "2.5K", - subtitle: "Followers", - ), - ProfileTile( - title: "10K", - subtitle: "Comments", - ), - ProfileTile( - title: "1.2K", - subtitle: "Following", - ) - ], - ), - ); + //column3 Widget descColumn() => Container( height: deviceSize.height * 0.13, @@ -145,7 +122,7 @@ class ProfileOnePage extends StatelessWidget { children: [ profileColumn(), CommonDivider(), - followColumn(), + followColumn(deviceSize), CommonDivider(), descColumn(), CommonDivider(), @@ -169,3 +146,28 @@ class ProfileOnePage extends StatelessWidget { return _scaffold(); } } + +Widget followColumn(Size deviceSize) => Container( + height: deviceSize.height * 0.13, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + ProfileTile( + title: "1.5K", + subtitle: "Posts", + ), + ProfileTile( + title: "2.5K", + subtitle: "Followers", + ), + ProfileTile( + title: "10K", + subtitle: "Comments", + ), + ProfileTile( + title: "1.2K", + subtitle: "Following", + ) + ], + ), + ); diff --git a/lib/ui/page/profile/profile_two_page.dart b/lib/ui/page/profile/profile_two_page.dart new file mode 100644 index 0000000..2ec949b --- /dev/null +++ b/lib/ui/page/profile/profile_two_page.dart @@ -0,0 +1,156 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_uikit/ui/page/profile/profile_one_page.dart'; +import 'package:flutter_uikit/ui/widgets/common_scaffold.dart'; +import 'package:random_pk/random_pk.dart'; + +class ProfileTwoPage extends StatelessWidget { + Size deviceSize; + + Widget profileHeader() => Container( + height: deviceSize.height / 4, + width: double.infinity, + color: Colors.black, + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Card( + color: Colors.black, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50.0), + border: Border.all(width: 2.0, color: Colors.white)), + child: CircleAvatar( + radius: 40.0, + backgroundImage: NetworkImage( + "https://avatars0.githubusercontent.com/u/12619420?s=460&v=4"), + ), + ), + Text( + "Pawan Kumar", + style: TextStyle(color: Colors.white, fontSize: 20.0), + ), + Text( + "Flutter Developer", + style: TextStyle(color: Colors.white), + ) + ], + ), + ), + ), + ); + Widget imagesCard() => Container( + height: deviceSize.height / 6, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical: 5.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + "Photos", + style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18.0), + ), + ), + Expanded( + child: Card( + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: 5, + itemBuilder: (context, i) => Padding( + padding: const EdgeInsets.all(8.0), + child: Image.network( + "https://cdn.pixabay.com/photo/2016/10/31/18/14/ice-1786311_960_720.jpg"), + ), + ), + ), + ), + ], + ), + ), + ); + + Widget profileColumn() => Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + CircleAvatar( + backgroundImage: NetworkImage( + "https://avatars0.githubusercontent.com/u/12619420?s=460&v=4"), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Pawan Kumar posted a photo", + ), + SizedBox( + height: 5.0, + ), + Text( + "25 mins ago", + ) + ], + ), + )) + ], + ), + ); + + Widget postCard() => Container( + width: double.infinity, + height: deviceSize.height / 3, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical: 5.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + "Post", + style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18.0), + ), + ), + profileColumn(), + Expanded( + child: Card( + elevation: 2.0, + child: Image.network( + "https://cdn.pixabay.com/photo/2018/06/12/01/04/road-3469810_960_720.jpg", + fit: BoxFit.cover, + ), + ), + ), + ], + ), + ), + ); + Widget bodyData() => SingleChildScrollView( + child: Column( + children: [ + profileHeader(), + followColumn(deviceSize), + imagesCard(), + postCard(), + ], + ), + ); + + @override + Widget build(BuildContext context) { + deviceSize = MediaQuery.of(context).size; + return CommonScaffold( + appTitle: "Profile", + bodyData: bodyData(), + elevation: 0.0, + ); + } +} diff --git a/lib/ui/widgets/common_scaffold.dart b/lib/ui/widgets/common_scaffold.dart index 583e5c8..f5b2055 100644 --- a/lib/ui/widgets/common_scaffold.dart +++ b/lib/ui/widgets/common_scaffold.dart @@ -14,18 +14,20 @@ class CommonScaffold extends StatelessWidget { final showBottomNav; final floatingIcon; final centerDocked; + final elevation; CommonScaffold( {this.appTitle, this.bodyData, - this.showFAB, + this.showFAB = false, this.showDrawer = false, this.backGroundColor, this.actionFirstIcon = Icons.search, this.scaffoldKey, this.showBottomNav = false, this.centerDocked = false, - this.floatingIcon}); + this.floatingIcon, + this.elevation = 4.0}); Widget myBottomBar() => new BottomAppBar( hasNotch: true, @@ -85,6 +87,7 @@ class CommonScaffold extends StatelessWidget { key: scaffoldKey != null ? scaffoldKey : null, backgroundColor: backGroundColor != null ? backGroundColor : null, appBar: AppBar( + elevation: elevation, backgroundColor: Colors.black, title: Text(appTitle), actions: [ diff --git a/lib/utils/uidata.dart b/lib/utils/uidata.dart index f36a663..4f2d388 100644 --- a/lib/utils/uidata.dart +++ b/lib/utils/uidata.dart @@ -7,6 +7,7 @@ class UIData { //routes static const String homeRoute = "/home"; static const String profileOneRoute = "/View Profile"; + static const String profileTwoRoute = "/Profile 2"; static const String notFoundRoute = "/No Search Result"; static const String timelineOneRoute = "/Feed"; static const String timelineTwoRoute = "/Tweets"; diff --git a/pubspec.lock b/pubspec.lock index 2073646..04ef9cd 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -256,6 +256,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.29.0+1" + random_pk: + dependency: "direct dev" + description: + name: random_pk + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.3" rxdart: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 1ab949e..a849572 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,6 +21,7 @@ dependencies: flutter_masked_text: dev_dependencies: + random_pk: flutter_test: sdk: flutter