diff --git a/lib/controllers/doctor _controller.dart b/lib/controllers/doctor_controller.dart similarity index 100% rename from lib/controllers/doctor _controller.dart rename to lib/controllers/doctor_controller.dart diff --git a/lib/data/models/doctor.dart b/lib/data/models/doctor.dart index a075ace..abd6234 100644 --- a/lib/data/models/doctor.dart +++ b/lib/data/models/doctor.dart @@ -52,7 +52,7 @@ class Profile { String? lastName; List qualifications; - var profileDescription; + String? profileDescription; Profile({ this.title, diff --git a/lib/data/services/doctor_profile_service.dart b/lib/data/services/doctor_profile_service.dart index 8349f78..9ba3a88 100644 --- a/lib/data/services/doctor_profile_service.dart +++ b/lib/data/services/doctor_profile_service.dart @@ -3,7 +3,7 @@ import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:telemednet/data/models/doctor.dart'; -import '../../controllers/doctor _controller.dart'; +import '../../controllers/doctor_controller.dart'; class DoctorProfileService { static final String doctorProfileCollectionName = diff --git a/lib/routes.dart b/lib/routes.dart index 0c9acc5..84aa8a2 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -1,7 +1,7 @@ import 'package:firebase_ui_auth/firebase_ui_auth.dart'; import 'package:flutter/material.dart'; import 'package:telemednet/screens/authentication/launch_screen.dart'; -import 'package:telemednet/screens/doctor_screens/Doctor_profile_screen.dart'; +import 'package:telemednet/screens/doctor_screens/doctor_profile_screen.dart'; import 'package:telemednet/controller/patient_controller.dart'; import 'package:telemednet/screens/doctor_screens/achivements.dart'; import 'package:telemednet/screens/doctor_screens/address_screen.dart'; @@ -16,7 +16,7 @@ import 'package:telemednet/screens/patientScreens/registrationScreens/patient_ad import 'package:telemednet/screens/patientScreens/registrationScreens/patient_family_members_screen.dart'; import 'package:telemednet/screens/patientScreens/registrationScreens/patient_registration_screen.dart'; -import 'controllers/doctor _controller.dart'; +import 'controllers/doctor_controller.dart'; import 'screens/patientScreens/patient_landing_screen.dart'; import 'screens/patientScreens/registrationScreens/family_members_edit_screen.dart'; @@ -30,7 +30,7 @@ final Map routes = { // var user = ModalRoute.of(context)!.settings.arguments as TelemedUser?; // return UserProfileScreen(user: user); // }, - RouteNames.profileUpload: (context) => ProfileUploadPage(), + RouteNames.profileUpload: (context) => const ProfileUploadPage(), RouteNames.patientLandingScreen: (context) => const PatientLandingScreen(), RouteNames.patientDashboardScreen: (context) => const PatientDashboardScreen(), diff --git a/lib/screens/doctor_screens/Doctor_profile_screen.dart b/lib/screens/doctor_screens/Doctor_profile_screen.dart index ba044d7..74b0ee6 100644 --- a/lib/screens/doctor_screens/Doctor_profile_screen.dart +++ b/lib/screens/doctor_screens/Doctor_profile_screen.dart @@ -3,14 +3,16 @@ import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; import 'package:telemednet/route_names.dart'; import 'package:telemednet/screens/doctor_screens/address_screen.dart'; -import '../../controllers/doctor _controller.dart'; +import '../../controllers/doctor_controller.dart'; class ProfileUploadPage extends StatefulWidget { + const ProfileUploadPage({super.key}); + @override - _ProfileUploadPageState createState() => _ProfileUploadPageState(); + ProfileUploadPageState createState() => ProfileUploadPageState(); } -class _ProfileUploadPageState extends State { +class ProfileUploadPageState extends State { final DoctorController _controller = DoctorController(); final _titleController = TextEditingController(); final _surnameController = TextEditingController(); @@ -56,7 +58,7 @@ class _ProfileUploadPageState extends State { }); } - bool _validateAndProceed() { + bool validateAndProceed() { _controller.profileController.updateTitle(_titleController.text); _controller.profileController.updateSurName(_surnameController.text); _controller.profileController.updateLastName(_firstnameController.text); @@ -69,10 +71,10 @@ class _ProfileUploadPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Doctor Profile'), + title: const Text('Doctor Profile'), ), body: SingleChildScrollView( - padding: EdgeInsets.all(16.0), + padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -83,11 +85,11 @@ class _ProfileUploadPageState extends State { radius: 60, backgroundImage: _image != null ? FileImage(_image!) : null, child: - _image == null ? Icon(Icons.camera_alt, size: 50) : null, + _image == null ? const Icon(Icons.camera_alt, size: 50) : null, ), ), ), - SizedBox(height: 24), + const SizedBox(height: 24), _buildTextField( 'Title', 'Mr, Ms..', @@ -112,42 +114,42 @@ class _ProfileUploadPageState extends State { _middlenameController, (value) => _controller.profileController.updateMiddleName(value), ), - SizedBox(height: 16), - Text( + const SizedBox(height: 16), + const Text( 'Qualifications', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), ), - SizedBox(height: 8), + const SizedBox(height: 8), Row( children: [ Expanded( child: TextField( controller: _qualificationController, - decoration: InputDecoration( + decoration: const InputDecoration( hintText: 'Add Qualification', border: OutlineInputBorder(), ), ), ), - SizedBox(width: 8), + const SizedBox(width: 8), ElevatedButton( onPressed: _addQualification, - child: Icon(Icons.add), style: ElevatedButton.styleFrom( - shape: CircleBorder(), - padding: EdgeInsets.all(12), + shape: const CircleBorder(), + padding: const EdgeInsets.all(12), ), + child: const Icon(Icons.add), ), ], ), - SizedBox(height: 16), + const SizedBox(height: 16), Wrap( spacing: 8, runSpacing: 8, children: _controller.profileController.model.qualifications .map((qual) => Chip( label: Text(qual), - deleteIcon: Icon(Icons.close), + deleteIcon: const Icon(Icons.close), onDeleted: () => _removeQualification(qual), )) .toList(), @@ -191,7 +193,7 @@ class _ProfileUploadPageState extends State { decoration: InputDecoration( labelText: label, hintText: hint, - border: OutlineInputBorder(), + border: const OutlineInputBorder(), ), onChanged: onChanged, ), diff --git a/lib/screens/doctor_screens/achivements.dart b/lib/screens/doctor_screens/achivements.dart index eee0f2c..1ee00e1 100644 --- a/lib/screens/doctor_screens/achivements.dart +++ b/lib/screens/doctor_screens/achivements.dart @@ -1,14 +1,14 @@ import 'package:flutter/material.dart'; -import '../../controllers/doctor _controller.dart'; +import '../../controllers/doctor_controller.dart'; import '../../route_names.dart'; class AchievementsScreen extends StatefulWidget { final DoctorController controller; const AchievementsScreen({ - Key? key, + super.key, required this.controller, - }) : super(key: key); + }); @override State createState() => _AchievementsScreenState(); @@ -146,11 +146,11 @@ class _AchievementsScreenState extends State { body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.all(16.0), + const Padding( + padding: EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: const [ + children: [ Text( 'Add Your Achievements', style: TextStyle( diff --git a/lib/screens/doctor_screens/address_screen.dart b/lib/screens/doctor_screens/address_screen.dart index 77f838e..0bb6629 100644 --- a/lib/screens/doctor_screens/address_screen.dart +++ b/lib/screens/doctor_screens/address_screen.dart @@ -1,14 +1,13 @@ import 'package:flutter/material.dart'; import 'package:telemednet/screens/doctor_screens/profile_description_screen.dart'; import '../../common/custom_style.dart'; -import '../../controllers/doctor _controller.dart'; +import '../../controllers/doctor_controller.dart'; import '../../route_names.dart'; class DoctorAddressScreen extends StatefulWidget { final DoctorController controller; - const DoctorAddressScreen({Key? key, required this.controller}) - : super(key: key); + const DoctorAddressScreen({super.key, required this.controller}); @override State createState() => _DoctorAddressScreenState(); @@ -51,7 +50,7 @@ class _DoctorAddressScreenState extends State { super.dispose(); } - bool _validateAndProceed() { + bool validateAndProceed() { // Update the address model addressController.updateFloorBuilding(_floorBuildingController.text); addressController.updateStreet(_streetController.text); diff --git a/lib/screens/doctor_screens/digital_signature.dart b/lib/screens/doctor_screens/digital_signature.dart index 8b53805..185152d 100644 --- a/lib/screens/doctor_screens/digital_signature.dart +++ b/lib/screens/doctor_screens/digital_signature.dart @@ -1,278 +1,7 @@ -// // import 'package:flutter/material.dart'; -// // import 'dart:io'; -// // import 'package:image_picker/image_picker.dart'; -// // import '../../controllers/doctor _controller.dart'; - -// // class DigitalSignatureScreen extends StatefulWidget { -// // final DoctorController controller; - -// // const DigitalSignatureScreen({ -// // Key? key, -// // required this.controller, -// // }) : super(key: key); - -// // @override -// // State createState() => _DigitalSignatureScreenState(); -// // } - -// // class _DigitalSignatureScreenState extends State { -// // File? _signatureFile; -// // final ImagePicker _picker = ImagePicker(); - -// // Future _pickImage() async { -// // try { -// // final XFile? image = await _picker.pickImage(source: ImageSource.gallery); -// // if (image != null) { -// // setState(() { -// // _signatureFile = File(image.path); -// // }); -// // widget.controller.updateDigitalSignature(image.path); -// // } -// // } catch (e) { -// // debugPrint('Error picking image: $e'); -// // } -// // } - -// // @override -// // Widget build(BuildContext context) { -// // return Scaffold( -// // appBar: AppBar( -// // title: const Text( -// // 'Digital Signature', -// // style: TextStyle( -// // fontSize: 24, -// // fontWeight: FontWeight.bold, -// // ), -// // ), -// // actions: [ -// // TextButton( -// // onPressed: () { -// // Navigator.pop(context); -// // }, -// // child: const Text( -// // 'Skip', -// // style: TextStyle( -// // color: Color(0xFF5BC0DE), -// // fontSize: 16, -// // ), -// // ), -// // ), -// // ], -// // ), -// // body: Column( -// // crossAxisAlignment: CrossAxisAlignment.center, -// // children: [ -// // const SizedBox(height: 20), -// // Center( -// // child: SizedBox( -// // width: 605, -// // height: 205, -// // child: Container( -// // decoration: BoxDecoration( -// // border: Border.all(color: Colors.grey.shade300), -// // borderRadius: BorderRadius.circular(12), -// // ), -// // child: Stack( -// // children: [ -// // if (_signatureFile != null) -// // ClipRRect( -// // borderRadius: BorderRadius.circular(12), -// // child: Image.file( -// // _signatureFile!, -// // width: 605, -// // height: 205, -// // fit: BoxFit.contain, -// // ), -// // ), -// // Positioned( -// // right: 16, -// // bottom: 16, -// // child: ElevatedButton.icon( -// // onPressed: _pickImage, -// // icon: const Icon(Icons.upload), -// // label: const Text('Upload'), -// // style: ElevatedButton.styleFrom( -// // backgroundColor: Colors.white, -// // foregroundColor: Colors.black, -// // shape: RoundedRectangleBorder( -// // borderRadius: BorderRadius.circular(20), -// // ), -// // ), -// // ), -// // ), -// // ], -// // ), -// // ), -// // ), -// // ), -// // const Spacer(), -// // Padding( -// // padding: const EdgeInsets.all(16), -// // child: ElevatedButton( -// // onPressed: () { -// // if (widget.controller.validateProfile()) { -// // Navigator.pop(context); -// // } -// // }, -// // style: ElevatedButton.styleFrom( -// // backgroundColor: const Color(0xFF5BC0DE), -// // shape: const CircleBorder(), -// // padding: const EdgeInsets.all(24), -// // ), -// // child: const Icon( -// // Icons.arrow_forward_ios, -// // color: Colors.white, -// // ), -// // ), -// // ), -// // ], -// // ), -// // ); -// // } -// // } -// import 'package:flutter/material.dart'; -// import 'dart:io'; -// import 'package:image_picker/image_picker.dart'; -// import '../../controllers/doctor _controller.dart'; - -// class DigitalSignatureScreen extends StatefulWidget { -// final DoctorController controller; - -// const DigitalSignatureScreen({ -// Key? key, -// required this.controller, -// }) : super(key: key); - -// @override -// State createState() => _DigitalSignatureScreenState(); -// } - -// class _DigitalSignatureScreenState extends State { -// File? _signatureFile; -// final ImagePicker _picker = ImagePicker(); - -// Future _pickImage() async { -// try { -// final XFile? image = await _picker.pickImage(source: ImageSource.gallery); -// if (image != null) { -// setState(() { -// _signatureFile = File(image.path); -// }); -// widget.controller.updateDigitalSignature(image.path); -// } -// } catch (e) { -// debugPrint('Error picking image: $e'); -// } -// } - -// @override -// Widget build(BuildContext context) { -// return Scaffold( -// appBar: AppBar( -// title: const Text( -// 'Digital Signature', -// style: TextStyle( -// fontSize: 24, -// fontWeight: FontWeight.bold, -// ), -// ), -// actions: [ -// TextButton( -// onPressed: () { -// Navigator.pop(context); -// }, -// child: const Text( -// 'Save and Skip', -// style: TextStyle( -// color: Color(0xFF5BC0DE), -// fontSize: 16, -// ), -// ), -// ), -// ], -// ), -// body: Column( -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// const SizedBox(height: 20), -// Center( -// child: SizedBox( -// width: 605, -// height: 205, -// child: Container( -// decoration: BoxDecoration( -// border: Border.all(color: Colors.grey.shade300), -// borderRadius: BorderRadius.circular(12), -// ), -// child: Stack( -// children: [ -// if (_signatureFile != null) -// ClipRRect( -// borderRadius: BorderRadius.circular(12), -// child: Image.file( -// _signatureFile!, -// width: 605, -// height: 205, -// fit: BoxFit.contain, -// ), -// ), -// if (_signatureFile == null) -// Center( -// child: Text( -// 'No signature uploaded', -// style: TextStyle( -// color: Colors.grey.shade400, -// fontSize: 16, -// ), -// ), -// ), -// ], -// ), -// ), -// ), -// ), -// const SizedBox(height: 20), -// ElevatedButton.icon( -// onPressed: _pickImage, -// icon: const Icon(Icons.upload), -// label: const Text('Upload Signature'), -// style: ElevatedButton.styleFrom( -// backgroundColor: const Color(0xFF5BC0DE), -// foregroundColor: Colors.white, -// shape: RoundedRectangleBorder( -// borderRadius: BorderRadius.circular(8), -// ), -// ), -// ), -// const Spacer(), -// Padding( -// padding: const EdgeInsets.all(16), -// child: ElevatedButton( -// onPressed: () { -// if (widget.controller.validateProfile()) { -// Navigator.pop(context); -// } -// }, -// style: ElevatedButton.styleFrom( -// backgroundColor: const Color(0xFF5BC0DE), -// shape: const CircleBorder(), -// padding: const EdgeInsets.all(24), -// ), -// child: const Icon( -// Icons.arrow_forward_ios, -// color: Colors.white, -// ), -// ), -// ), -// ], -// ), -// ); -// } -// } import 'package:flutter/material.dart'; import 'dart:io'; import 'package:image_picker/image_picker.dart'; -import '../../controllers/doctor _controller.dart'; +import '../../controllers/doctor_controller.dart'; import '../../data/services/doctor_profile_service.dart'; import '../../route_names.dart'; @@ -280,9 +9,9 @@ class DigitalSignatureScreen extends StatefulWidget { final DoctorController controller; const DigitalSignatureScreen({ - Key? key, + super.key, required this.controller, - }) : super(key: key); + }); @override State createState() => _DigitalSignatureScreenState(); @@ -307,20 +36,22 @@ class _DigitalSignatureScreenState extends State { } Future _saveProfile() async { - // Directly save the doctor profile without validation bool success = await DoctorProfileService.saveDoctorProfile(widget.controller); - - if (success) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('Doctor profile saved successfully!')), - ); - Navigator.of(context).pushNamed(RouteNames.doctorAddressScreen); - } else { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Failed to save profile. Please try again.')), - ); + if (mounted) { + setState(() { + if (success) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Doctor profile saved successfully!')), + ); + Navigator.of(context).pushNamed(RouteNames.doctorAddressScreen); + } else { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Failed to save profile. Please try again.')), + ); + } + }); } } diff --git a/lib/screens/doctor_screens/experience_screen.dart b/lib/screens/doctor_screens/experience_screen.dart index caed6d4..f13ade1 100644 --- a/lib/screens/doctor_screens/experience_screen.dart +++ b/lib/screens/doctor_screens/experience_screen.dart @@ -1,18 +1,17 @@ import 'package:flutter/material.dart'; -import '../../controllers/doctor _controller.dart'; +import '../../controllers/doctor_controller.dart'; import '../../route_names.dart'; class ExperienceScreen extends StatefulWidget { final DoctorController controller; - const ExperienceScreen({Key? key, required this.controller}) - : super(key: key); + const ExperienceScreen({super.key, required this.controller}); @override - _ExperienceScreenState createState() => _ExperienceScreenState(); + ExperienceScreenState createState() => ExperienceScreenState(); } -class _ExperienceScreenState extends State { +class ExperienceScreenState extends State { String? _selectedExperience; final _licenseController = TextEditingController(); late final DoctorController _controller; diff --git a/lib/screens/doctor_screens/profile_description_screen.dart b/lib/screens/doctor_screens/profile_description_screen.dart index e624316..0487846 100644 --- a/lib/screens/doctor_screens/profile_description_screen.dart +++ b/lib/screens/doctor_screens/profile_description_screen.dart @@ -1,21 +1,21 @@ import 'package:flutter/material.dart'; -import '../../controllers/doctor _controller.dart'; +import '../../controllers/doctor_controller.dart'; import '../../route_names.dart'; class ProfileDescriptionScreen extends StatefulWidget { final DoctorController controller; const ProfileDescriptionScreen({ - Key? key, + super.key, required this.controller, - }) : super(key: key); + }); @override - _ProfileDescriptionScreenState createState() => - _ProfileDescriptionScreenState(); + ProfileDescriptionScreenState createState() => + ProfileDescriptionScreenState(); } -class _ProfileDescriptionScreenState extends State { +class ProfileDescriptionScreenState extends State { final _descriptionController = TextEditingController(); late final DoctorController _controller; bool _isEditing = false; @@ -78,7 +78,7 @@ class _ProfileDescriptionScreenState extends State { ); } - bool _validateAndProceed() { + bool validateAndProceed() { if (!_validateDescription()) { return false; } diff --git a/lib/screens/doctor_screens/specialities_selection.dart b/lib/screens/doctor_screens/specialities_selection.dart index 396a556..6101744 100644 --- a/lib/screens/doctor_screens/specialities_selection.dart +++ b/lib/screens/doctor_screens/specialities_selection.dart @@ -1,14 +1,14 @@ import 'package:flutter/material.dart'; -import '../../controllers/doctor _controller.dart'; +import '../../controllers/doctor_controller.dart'; import '../../route_names.dart'; class SpecialitiesScreen extends StatefulWidget { final DoctorController controller; const SpecialitiesScreen({ - Key? key, + super.key, required this.controller, - }) : super(key: key); + }); @override State createState() => _SpecialitiesScreenState(); @@ -164,11 +164,11 @@ class _SpecialitiesScreenState extends State { ), body: Column( children: [ - Padding( - padding: const EdgeInsets.all(16.0), + const Padding( + padding: EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: const [ + children: [ Text( 'Select Your Specialization', style: TextStyle( diff --git a/lib/screens/patientDashboard/patient_dashboard_screen.dart b/lib/screens/patientDashboard/patient_dashboard_screen.dart index 1995665..8f97cc9 100644 --- a/lib/screens/patientDashboard/patient_dashboard_screen.dart +++ b/lib/screens/patientDashboard/patient_dashboard_screen.dart @@ -79,11 +79,11 @@ class _PatientDashboardScreenState extends State { const SizedBox(height: 16), ElevatedButton( onPressed: () {}, - child: const Text('Consultation >'), style: ElevatedButton.styleFrom( backgroundColor: Colors.white, foregroundColor: Colors.black, ), + child: const Text('Consultation >'), ), ], ), diff --git a/lib/screens/patientDashboard/registrationScreens/patient_family_members_screen.dart b/lib/screens/patientDashboard/registrationScreens/patient_family_members_screen.dart index d8117eb..28d86b2 100644 --- a/lib/screens/patientDashboard/registrationScreens/patient_family_members_screen.dart +++ b/lib/screens/patientDashboard/registrationScreens/patient_family_members_screen.dart @@ -38,13 +38,13 @@ class _PatientFamilyMembersScreenState Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Family members'), + title: const Text('Family members'), actions: [ TextButton( onPressed: () { // Handle 'Done' action }, - child: Text('Done', style: TextStyle(color: Colors.blue)), + child: const Text('Done', style: TextStyle(color: Colors.blue)), ), ], ), @@ -60,8 +60,8 @@ class _PatientFamilyMembersScreenState ), floatingActionButton: FloatingActionButton( onPressed: _addFamilyMember, - child: Icon(Icons.add), backgroundColor: Colors.blue, + child: const Icon(Icons.add), ), ); } @@ -117,30 +117,30 @@ class FamilyMemberCard extends StatelessWidget { @override Widget build(BuildContext context) { return Card( - margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8), + margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), child: Padding( - padding: EdgeInsets.all(16), + padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Name: ${familyMember.name}', - style: TextStyle(fontWeight: FontWeight.bold)), - SizedBox(height: 4), + style: const TextStyle(fontWeight: FontWeight.bold)), + const SizedBox(height: 4), Text('Gender: ${familyMember.gender}'), - SizedBox(height: 4), + const SizedBox(height: 4), Text('Date of Birth: ${familyMember.dateOfBirth}'), - SizedBox(height: 4), + const SizedBox(height: 4), Text('Relation: ${familyMember.relation}'), - SizedBox(height: 8), + const SizedBox(height: 8), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ IconButton( - icon: Icon(Icons.edit, color: Colors.blue), + icon: const Icon(Icons.edit, color: Colors.blue), onPressed: onEdit, ), IconButton( - icon: Icon(Icons.delete, color: Colors.red), + icon: const Icon(Icons.delete, color: Colors.red), onPressed: onDelete, ), ], diff --git a/lib/screens/patientScreens/registrationScreens/patient_adress_screen.dart b/lib/screens/patientScreens/registrationScreens/patient_adress_screen.dart index fde2d63..a7a9c5a 100644 --- a/lib/screens/patientScreens/registrationScreens/patient_adress_screen.dart +++ b/lib/screens/patientScreens/registrationScreens/patient_adress_screen.dart @@ -22,7 +22,7 @@ class _PatientAddressScreenState extends State { String? state; String? city; String? addressType; - Map _errors = {}; + final Map _errors = {}; bool _hasErrors = false; @override