From 8c83166c4098e8b0ec797895f5d7e8e467cabc4c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 15 Apr 2020 18:13:01 +0300 Subject: [PATCH] profile screen and extentions class --- lib/screens/profile_screen.dart | 63 ++++++++++++++++++++++ lib/util/extenstions.dart | 8 +++ lib/widgets/shared/app_texts_widget.dart | 37 +++++++------ lib/widgets/shared/drawer_item_widget.dart | 32 ++++++++--- pubspec.yaml | 2 +- 5 files changed, 118 insertions(+), 24 deletions(-) create mode 100644 lib/screens/profile_screen.dart create mode 100644 lib/util/extenstions.dart diff --git a/lib/screens/profile_screen.dart b/lib/screens/profile_screen.dart new file mode 100644 index 00000000..b346e341 --- /dev/null +++ b/lib/screens/profile_screen.dart @@ -0,0 +1,63 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/drawer_item_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; +import 'package:flutter/material.dart'; + +class ProfileScreen extends StatefulWidget { + ProfileScreen({Key key, this.title}) : super(key: key); + + final String title; + + @override + _ProfileScreenState createState() => _ProfileScreenState(); +} + +class _ProfileScreenState extends State { + @override + Widget build(BuildContext context) { + return AppScaffold( + appBarTitle:'Profile', + body:ListView( + padding: EdgeInsets.zero, + children: [ + Container( + height: SizeConfig.heightMultiplier * 30, + child: DrawerHeader( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + CircleAvatar( + radius: SizeConfig.imageSizeMultiplier * 12, + backgroundImage: NetworkImage( + "https://p.kindpng.com/picc/s/404-4042774_profile-photo-circle-circle-profile-picture-png-transparent.png"), + backgroundColor: Colors.transparent, + ), + Padding( + padding: EdgeInsets.only(top: 10), + child: AppText( + "Dr. Chris evans", + fontWeight: FontWeight.bold, + + fontSize: SizeConfig.textMultiplier * 3, + )), + AppText("Director of medical records",) + ], + ), + ), + ), + RoundedContainer(child: ListView(children: [ + DrawerItem("Gender", Icons.person_pin, color: Colors.black, subTitle: "Male",), + DrawerItem("Clinic", Icons.build, color: Colors.black, subTitle: "Neurology Clinic",), + DrawerItem("Hospital", Icons.local_hospital, color: Colors.black, subTitle: "Al-Takkassussi",), + DrawerItem("Speciality", Icons.crop_square, color: Colors.black, subTitle: "being great",), + ],), + width: SizeConfig.screenWidth*0.70, + height: SizeConfig.screenHeight*0.40, + ), + + ] + )); + } +} \ No newline at end of file diff --git a/lib/util/extenstions.dart b/lib/util/extenstions.dart new file mode 100644 index 00000000..26e49670 --- /dev/null +++ b/lib/util/extenstions.dart @@ -0,0 +1,8 @@ +extension Extension on Object { + bool isNullOrEmpty() => this == null || this == ''; + + bool isNullEmptyOrFalse() => this == null || this == '' || !this; + + bool isNullEmptyZeroOrFalse() => + this == null || this == '' || !this || this == 0; +} diff --git a/lib/widgets/shared/app_texts_widget.dart b/lib/widgets/shared/app_texts_widget.dart index 835323f3..07c82d17 100644 --- a/lib/widgets/shared/app_texts_widget.dart +++ b/lib/widgets/shared/app_texts_widget.dart @@ -1,6 +1,8 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import '../../util/extenstions.dart'; + // OWNER : Ibrahim albitar // DATE : 12-04-2020 @@ -17,6 +19,7 @@ class AppText extends StatefulWidget { final double marginRight; final double marginBottom; final double marginLeft; + final bool visibility; AppText(this.data, {this.color = Colors.black, @@ -27,7 +30,8 @@ class AppText extends StatefulWidget { this.marginTop = 0, this.marginRight = 0, this.marginBottom = 0, - this.marginLeft = 0,}); + this.marginLeft = 0, + this.visibility = true}); @override _AppTextState createState() => _AppTextState(); @@ -37,20 +41,23 @@ class _AppTextState extends State { @override Widget build(BuildContext context) { - return Container( - margin: widget.margin != null ? EdgeInsets.all(widget.margin) : EdgeInsets.only( - top: widget.marginTop, - right: widget.marginRight, - bottom: widget.marginBottom, - left: widget.marginLeft - ), - child: Text( - widget.data, - style: TextStyle( - color: widget.color, - fontWeight: widget.fontWeight, - fontSize: widget.fontSize ?? (SizeConfig.textMultiplier * 2), - fontFamily: widget.fontFamily), + return Visibility( + visible: widget.visibility, + child: Container( + margin: widget.margin != null ? EdgeInsets.all(widget.margin) : EdgeInsets.only( + top: widget.marginTop, + right: widget.marginRight, + bottom: widget.marginBottom, + left: widget.marginLeft + ), + child: Text( + widget.data, + style: TextStyle( + color: widget.color, + fontWeight: widget.fontWeight, + fontSize: widget.fontSize ?? (SizeConfig.textMultiplier * 2), + fontFamily: widget.fontFamily), + ), ), ); } diff --git a/lib/widgets/shared/drawer_item_widget.dart b/lib/widgets/shared/drawer_item_widget.dart index fdf035be..a52d8812 100644 --- a/lib/widgets/shared/drawer_item_widget.dart +++ b/lib/widgets/shared/drawer_item_widget.dart @@ -2,6 +2,7 @@ import 'dart:ui'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:flutter/material.dart'; +import '../../util/extenstions.dart'; import '../shared/app_texts_widget.dart'; @@ -12,9 +13,12 @@ import '../shared/app_texts_widget.dart'; class DrawerItem extends StatefulWidget { final String title; + final String subTitle; final IconData icon; + final Color color; - DrawerItem(this.title, this.icon); + + DrawerItem(this.title, this.icon,{this.color, this.subTitle = ''}); @override _DrawerItemState createState() => _DrawerItemState(); @@ -30,15 +34,27 @@ class _DrawerItemState extends State { children: [ Icon( widget.icon, - color: Colors.white, + color: widget.color??Colors.white, size: SizeConfig.imageSizeMultiplier * 7, ), - AppText( - widget.title, - color: Colors.white, - fontWeight: FontWeight.bold, - margin: 10, - fontSize: SizeConfig.textMultiplier * 2.5, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + widget.title, + color: widget.color??Colors.white, + fontWeight: FontWeight.bold, + margin: 5, + fontSize: SizeConfig.textMultiplier * 2.5, + ), + AppText( + widget.subTitle, + visibility: !widget.subTitle.isNullOrEmpty(), + color: widget.color??Colors.white, + marginLeft: 5, + fontSize: SizeConfig.textMultiplier * 2.5, + ), + ], ), ], )); diff --git a/pubspec.yaml b/pubspec.yaml index 7b87b081..6dd80a4f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,7 +14,7 @@ description: A new Flutter project. version: 1.0.0+1 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.6.0 <3.0.0" dependencies: flutter: