import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../config/shared_pref_kay.dart'; import '../../config/size_config.dart'; import '../../providers/schedule_provider.dart'; import '../../routes.dart'; import '../../screens/doctor/my_schedule_screen.dart'; import '../../util/dr_app_shared_pref.dart'; import '../../widgets/shared/drawer_item_widget.dart'; import '../../widgets/shared/rounded_container_widget.dart'; import 'app_texts_widget.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); // OWNER : Ibrahim albitar // DATE : 06-04-2020 // DESCRIPTION : Custom App Drawer for app. class AppDrawer extends StatefulWidget { @override _AppDrawerState createState() => _AppDrawerState(); } class _AppDrawerState extends State { bool _isInit = true; DoctorProfileModel doctorProfile; Helpers helpers = new Helpers(); @override void didChangeDependencies() { super.didChangeDependencies(); // if (_isInit) { getDocProfile(); // TODO: Refactor this code to prevent errors in the cosole. // } _isInit = false; } getDocProfile() async { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); // doctorProfile = DoctorProfileModel.fromJson(profile); setState(() { doctorProfile = DoctorProfileModel.fromJson(profile); }); String token = await sharedPref.getString(TOKEN); } @override Widget build(BuildContext context) { // var x = getDocProfile(); return RoundedContainer( child: Container( color: Colors.white, // margin: EdgeInsets.only(top: SizeConfig.heightMultiplier * 2), child: Drawer( child: Column(children: [ Expanded( flex: 4, child: ListView(padding: EdgeInsets.zero, children: [ Container( height: SizeConfig.heightMultiplier * 50, child: InkWell( child: DrawerHeader( child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( child: Image.asset('assets/images/logo.png'), margin: EdgeInsets.only(top: 10, bottom: 15), ), SizedBox( height: 1, child: Container( color: Colors.black26, ), ), SizedBox(height: 15), CircleAvatar( radius: SizeConfig.imageSizeMultiplier * 12, backgroundImage: NetworkImage(doctorProfile.doctorImageURL), backgroundColor: Colors.white, ), Padding( padding: EdgeInsets.only(top: 10), child: AppText( doctorProfile.doctorName, fontWeight: FontWeight.bold, color: Colors.black, fontSize: SizeConfig.textMultiplier * 2, )), AppText( "Director of medical records", //TODO: Make The Dr Title Dynamic and check overflow issue. fontWeight: FontWeight.normal, color: Colors.black87), RaisedButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(18.0), side: BorderSide(color: Colors.red)), child: AppText( TranslationBase.of(context).logout, color: Colors.white, ), onPressed: () async { Navigator.pop(context); await helpers.logout(); }, ), ], ), ), onTap: () { //Navigator.of(context).pushNamed(PROFILE); Navigator.of(context).pushNamed(PROFILE, arguments: { 'title': doctorProfile.doctorName, "doctorProfileall": doctorProfile }); }, ), ), InkWell( child: DrawerItem( TranslationBase.of(context).settings, Icons.settings), onTap: () { Navigator.pop(context); Navigator.of(context).pushNamed(SETTINGS); }, ), InkWell( child: DrawerItem( TranslationBase.of(context).qrReader, DoctorApp.qr_code), onTap: () { Navigator.pop(context); Navigator.of(context).pushNamed(QR_READER); }, ), ]), ), Expanded( flex: 1, child: Column(children: [ Container( // This align moves the children to the bottom child: Align( alignment: FractionalOffset.bottomCenter, child: Container( child: Column( children: [ Text("Powered by"), Image.asset( 'assets/images/cs_logo_container.png', width: SizeConfig.imageSizeMultiplier * 30, ) ], )))) ])) ])), ), width: SizeConfig.realScreenWidth * 0.60, margin: 0, customCornerRaduis: false, // topRight: 30, // bottomRight: 30, backgroundColor: Colors.white, ); } drawerNavigator(context, routeName) { Navigator.of(context).pushNamed(routeName); } }