diff --git a/lib/views/screens/admin/user_management/UserProfileScreen.dart b/lib/views/screens/admin/user_management/UserProfileScreen.dart index 1af214b..64a7231 100644 --- a/lib/views/screens/admin/user_management/UserProfileScreen.dart +++ b/lib/views/screens/admin/user_management/UserProfileScreen.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:form_builder_file_picker/form_builder_file_picker.dart'; @@ -7,6 +8,8 @@ import 'package:go_router/go_router.dart'; import 'package:intl/intl.dart'; import 'package:rtc_project_fronend/app_router.dart'; import 'package:rtc_project_fronend/constants/dimens.dart'; +import 'package:rtc_project_fronend/generated/l10n.dart'; +import 'package:rtc_project_fronend/views/screens/pdf_generate/pdf_generator.dart'; import 'package:rtc_project_fronend/views/widgets/portal_master_layout/portal_master_layout.dart'; // ignore_for_file: avoid_print, use_build_context_synchronously import 'package:rtc_project_fronend/api_service.dart'; @@ -15,6 +18,55 @@ import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:rtc_project_fronend/theme/theme_extensions/app_button_theme.dart'; import 'package:rtc_project_fronend/utils/app_focus_helper.dart'; import 'package:rtc_project_fronend/views/widgets/card_elements.dart'; +import 'package:toast/toast.dart'; + +bool editusername = false; +bool editemail = false; +bool editfirstname = false; +bool editlastname = false; +bool editphone = false; +bool editfacultyname = false; +bool editrole = false; +bool editfullnamebangla = false; +bool editgender = false; +bool editdob = false; +bool editpositionenglish = false; +bool editpositionbangla = false; +bool editpositionheldsince = false; +bool editdepartmentname = false; +bool editinstituteName = false; +bool editistitutelocation = false; +bool editinstituteemail = false; +bool editsalaryscale = false; +bool editbasicpay = false; +bool editAreaOfExpertise = false; +bool editExperienceInResearch = false; +bool editTeaching = false; +bool editTotalNumberOfCompleteProjects = false; +bool editTotalNumberOfCompletePublications = false; +bool editOngoingProjects = false; +bool editReferencesOfLatestPublications = false; +bool editNid = false; +bool editNidLocation = false; +bool editPresentAddress = false; +bool editPermanentAddress = false; +bool editProfilePicLocation = false; +bool editSignatureLocation = false; +bool editSealLocation = false; +bool editHighestAcademicQualification = false; +bool editHighestAcademicQualificationUniversity = false; +bool editHighestAcademicQualificationCountry = false; +bool editHighestAcademicQualificationYear = false; +bool editStudentID = false; +bool editStudentRegNo = false; +bool editFirstEnrollmentSemester = false; +bool editUndergraduateCGPALevel = false; +bool initialUserDataChange = false; + +Uint8List? _signatureFileBytes; +Uint8List? _profilePicFileBytes; +Uint8List? _sealFileBytes; +Uint8List? _nidFileBytes; class UserProfileScreen extends StatefulWidget { final String userID; @@ -32,75 +84,57 @@ class _UserProfileScreenState extends State { final _formKey = GlobalKey(); final _formData = FormData(); - bool editusername = false; - bool editemail = false; - bool editfirstname = false; - bool editlastname = false; - bool editphone = false; - bool editfacultyname = false; - bool editrole = false; - bool editfullnamebangla = false; - bool editgender = false; - bool editdob = false; - bool editpositionenglish = false; - bool editpositionbangla = false; - bool editpositionheldsince = false; - bool editdepartmentname = false; - bool editinstituteName = false; - bool editistitutelocation = false; - bool editinstituteemail = false; - bool editsalaryscale = false; - bool editbasicpay = false; - bool editAreaOfExpertise = false; - bool editExperienceInResearch = false; - bool editTeaching = false; - bool editTotalNumberOfCompleteProjects = false; - bool editTotalNumberOfCompletePublications = false; - bool editOngoingProjects = false; - bool editReferencesOfLatestPublications = false; - bool editNid = false; - bool editNidLocation = false; - bool editPresentAddress = false; - bool editPermanentAddress = false; - bool editProfilePicLocation = false; - bool editSignatureLocation = false; - bool editSealLocation = false; - bool editHighestAcademicQualification = false; - bool editHighestAcademicQualificationUniversity = false; - bool editHighestAcademicQualificationCountry = false; - bool editHighestAcademicQualificationYear = false; - bool editStudentID = false; - bool editStudentRegNo = false; - bool editFirstEnrollmentSemester = false; - bool editUndergraduateCGPALevel = false; - bool initialUserDataChange = false; - Future? _future; List? _profilePicFiles; List? _signatureFiles; List? _sealFiles; List? _nidFiles; + void _onProfilePicFileSelected(List? files) { setState(() { + editProfilePicLocation = true; // Toggle edit mode + // Save changes + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + // Change pending user data change to true for re-rendering the Save_changes button + initialUserDataChange = true; _profilePicFiles = files != null ? List.from(files) : null; // Update to assign the list of files }); } void _onSignatureFileSelected(List? files) { setState(() { + editSignatureLocation = true; // Toggle edit mode + // Save changes + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + // Change pending user data change to true for re-rendering the Save_changes button + initialUserDataChange = true; _signatureFiles = files != null ? List.from(files) : null; // Update to assign the list of files }); } void _onSealFileSelected(List? files) { setState(() { + editSealLocation = true; // Toggle edit mode + // Save changes + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + // Change pending user data change to true for re-rendering the Save_changes button + initialUserDataChange = true; _sealFiles = files != null ? List.from(files) : null; // Update to assign the list of files }); } void _onNidFileSelected(List? files) { setState(() { + editNidLocation = true; // Toggle edit mode + // Save changes + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + // Change pending user data change to true for re-rendering the Save_changes button + initialUserDataChange = true; _nidFiles = files != null ? List.from(files) : null; // Update to assign the list of files }); } @@ -110,6 +144,7 @@ class _UserProfileScreenState extends State { // try { for (var file in _profilePicFiles!) { final fileBytes = file.bytes!; + _profilePicFileBytes = fileBytes; final fileName = file.name; _formData.profilePicLocation = fileName; @@ -128,6 +163,7 @@ class _UserProfileScreenState extends State { // try { for (var file in _signatureFiles!) { final fileBytes = file.bytes!; + _signatureFileBytes = fileBytes; final fileName = file.name; _formData.signatureLocation = fileName; @@ -146,6 +182,7 @@ class _UserProfileScreenState extends State { // try { for (var file in _sealFiles!) { final fileBytes = file.bytes!; + _sealFileBytes = fileBytes; final fileName = file.name; _formData.sealLocation = fileName; @@ -164,6 +201,7 @@ class _UserProfileScreenState extends State { // try { for (var file in _nidFiles!) { final fileBytes = file.bytes!; + _nidFileBytes = fileBytes; final fileName = file.name; _formData.nidLocation = fileName; @@ -177,6 +215,19 @@ class _UserProfileScreenState extends State { } else {} } + void _clearSelectedFiles() { + setState(() { + _profilePicFiles = null; + _formKey.currentState?.fields['profilePicLocation']?.reset(); + _signatureFiles = null; + _formKey.currentState?.fields['signatureLocation']?.reset(); + _sealFiles = null; + _formKey.currentState?.fields['sealLocation']?.reset(); + _nidFiles = null; + _formKey.currentState?.fields['nidLocation']?.reset(); + }); + } + // Function to map role name to role ID int getRoleId(String roleName) { switch (roleName) { @@ -217,7 +268,7 @@ class _UserProfileScreenState extends State { Future _getDataAsync() async { if (widget.userID.isNotEmpty) { await Future.delayed(const Duration(seconds: 1), () async { - _formData.userID = widget.userID; + _formData.userId = int.parse(widget.userID); int userID = int.parse(widget.userID); final userDetails = await ApiService.getSpecificUser( @@ -239,7 +290,7 @@ class _UserProfileScreenState extends State { dialog.show(); } - _formData.userID = userDetails['user']['UserID'].toString(); + _formData.userId = userDetails['user']['UserID'] ?? 0; _formData.rolename = getRoleName(userDetails['user']['RoleID']); _formData.username = userDetails['user']['Username'] ?? ''; _formData.positionEnglish = userDetails['user']['PositionEnglish'] ?? ''; @@ -281,13 +332,42 @@ class _UserProfileScreenState extends State { _formData.studentRegNo = userDetails['user']['StudentRegNo'] ?? ''; _formData.firstEnrollmentSemester = userDetails['user']['FirstEnrollmentSemester'] ?? ''; _formData.undergraduateCGPALevel = userDetails['user']['UndergraduateCGPALevel'] ?? ''; + + String piSignaturefilePath = _formData.signatureLocation.isNotEmpty + ? await ApiService.downloadFile('signature/download', _formData.signatureLocation) + : await ApiService.downloadFile('signature/download', "defaultsignature.png"); // Check if value is not empty before making the API call + if (piSignaturefilePath.isNotEmpty) { + Uint8List fileBytes = base64Decode(piSignaturefilePath); + _signatureFileBytes = fileBytes; + } + String piSealfilePath = _formData.sealLocation.isNotEmpty + ? await ApiService.downloadFile('seal/download', _formData.sealLocation) + : await ApiService.downloadFile('seal/download', "defaultseal.png"); // Check if value is not empty before making the API call + if (piSealfilePath.isNotEmpty) { + Uint8List fileBytes = base64Decode(piSealfilePath); + _sealFileBytes = fileBytes; + } + String nidfilePath = _formData.nidLocation.isNotEmpty + ? await ApiService.downloadFile('nid/download', _formData.nidLocation) + : await ApiService.downloadFile('nid/download', "defaultnid.png"); // Check if value is not empty before making the API call + if (nidfilePath.isNotEmpty) { + Uint8List fileBytes = base64Decode(nidfilePath); + _nidFileBytes = fileBytes; + } + String profilePicFilePath = _formData.profilePicLocation.isNotEmpty + ? await ApiService.downloadFile('profile-pic/download', _formData.profilePicLocation) + : await ApiService.downloadFile('profile-pic/download', "defaultprofilepic.png"); // Check if value is not empty before making the API call + if (profilePicFilePath.isNotEmpty) { + Uint8List fileBytes = base64Decode(profilePicFilePath); + _profilePicFileBytes = fileBytes; + } }); } return true; } - void _goSaveChanges(BuildContext context) { + Future _goSaveChanges(BuildContext context) async { AppFocusHelper.instance.requestUnfocus(); final dialog = AwesomeDialog( @@ -348,6 +428,7 @@ class _UserProfileScreenState extends State { _uploadProfilePicFiles(); _uploadSignatureFiles(); _uploadSealFiles(); + final responseBody = await ApiService.updateUserDetailsAdminMode(int.parse(widget.userID), updatedUserData); if (responseBody['statuscode'] == 200) { // Handle success @@ -411,9 +492,35 @@ class _UserProfileScreenState extends State { dialog.show(); } + // void _pdfHandleButtonPress() { + // final d = AwesomeDialog( + // context: context, + // dialogType: DialogType.infoReverse, + // title: "Profile PDF Generating.....", + // desc: "Please wait...5 seconds", + // width: kDialogWidth, + // headerAnimationLoop: true, + // ); + // Future.wait([ + // d.show(), + // Future.delayed(const Duration(seconds: 5), () => d.dismiss()), + // generateProfilePDF(_formData, context, _profilePicFileBytes, _nidFileBytes, _sealFileBytes, _signatureFileBytes), + // ]).then((_) { + // d.dismiss(); + // }); + // } + @override Widget build(BuildContext context) { final themeData = Theme.of(context); + final lang = Lang.of(context); + + ToastContext().init(context); + + // Show sticky toast when the page is built + WidgetsBinding.instance.addPostFrameCallback((_) { + Toast.show("After making any picture changes click Save-Changes button below", duration: 10, gravity: Toast.bottom); + }); return PortalMasterLayout( selectedMenuUri: RouteUri.usermanagementoverview, @@ -461,6 +568,12 @@ class _UserProfileScreenState extends State { style: themeData.textTheme.headlineMedium, textAlign: TextAlign.center, ), + ProPicSigSeal( + formData: _formData, + onProfilePicFileSelected: _onProfilePicFileSelected, + onSignatureFileSelected: _onSignatureFileSelected, + onSealFileSelected: _onSealFileSelected, + ), Padding( padding: const EdgeInsets.only(bottom: kDefaultPadding, top: kDefaultPadding), child: Card( @@ -472,1095 +585,50 @@ class _UserProfileScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0, top: kDefaultPadding), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Username :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editusername, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.username, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editusername, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'userName', - decoration: const InputDecoration( - hintText: 'User Name', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.username, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.username = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editusername = !editusername; // Toggle edit mode - if (!editusername) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editusername - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editusername ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + UserName( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Role :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editrole, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.rolename, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editrole, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderDropdown( - name: 'rolename', - decoration: const InputDecoration( - hintText: 'rolename', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - hint: const Text('Select'), - initialValue: _formData.rolename, - validator: FormBuilderValidators.required(), - items: ['Admin', 'Researcher', 'Reviewer', 'Teacher', 'Student'].map((e) => DropdownMenuItem(value: e, child: Text(e))).toList(), - onSaved: (value) => (_formData.rolename = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editrole = !editrole; // Toggle edit mode - if (!editrole) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editrole - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editrole ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + Role( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'First Name :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editfirstname, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.firstName, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editfirstname, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'firstName', - decoration: const InputDecoration( - hintText: 'First Name', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.firstName, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.firstName = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editfirstname = !editfirstname; // Toggle edit mode - if (!editfirstname) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editfirstname - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editfirstname ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + FirstName( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only( - bottom: kDefaultPadding * 2.0, - ), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Last Name :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editlastname, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.lastName, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editlastname, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'lastName', - decoration: const InputDecoration( - hintText: 'Last Name', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.lastName, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.lastName = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editlastname = !editlastname; // Toggle edit mode - if (!editlastname) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editlastname - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editlastname ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + LastName( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'FullName (Bangla) :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editfullnamebangla, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.fullNameBangla, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editfullnamebangla, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'FullNameBangla', - decoration: const InputDecoration( - hintText: 'FullName (Bangla)', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.fullNameBangla, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.fullNameBangla = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editfullnamebangla = !editfullnamebangla; // Toggle edit mode - if (!editfullnamebangla) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editfullnamebangla - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editfullnamebangla ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + FullNameBangla( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Gender :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editgender, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.gender, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editgender, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderDropdown( - name: 'gender', - decoration: const InputDecoration( - hintText: 'gender', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - hint: const Text('Select'), - initialValue: _formData.gender, - validator: FormBuilderValidators.required(), - items: ['Male', 'Female'].map((e) => DropdownMenuItem(value: e, child: Text(e))).toList(), - onSaved: (value) => (_formData.gender = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editgender = !editgender; // Toggle edit mode - if (!editgender) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editgender - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editgender ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + Gender( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Date of Birth :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editdob, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: - _formData.dateOfBirth != null && _formData.dateOfBirth!.isNotEmpty ? DateFormat("MMMM d, yyyy").format(DateTime.parse(_formData.dateOfBirth)) : '', - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editdob, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderDateTimePicker( - name: 'dateOfBirth', - inputType: InputType.date, - decoration: const InputDecoration( - hintText: 'dateOfBirth', - border: OutlineInputBorder(), - ), - // ignore: unnecessary_null_comparison - initialValue: _formData.dateOfBirth != null && _formData.dateOfBirth!.isNotEmpty ? DateTime.parse(_formData.dateOfBirth) : null, - textAlign: TextAlign.center, - format: DateFormat("MMMM d, yyyy"), - validator: FormBuilderValidators.required(), - onSaved: (value) { - if (value != null) { - _formData.dateOfBirth = value.toString(); - } else { - _formData.dateOfBirth = ''; - } - }, - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editdob = !editdob; // Toggle edit mode - if (!editdob) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editdob - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editdob ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + DateOfBirth( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Email :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editemail, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.email, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editemail, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'email', - decoration: const InputDecoration( - hintText: 'Email', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.email, - validator: FormBuilderValidators.compose([ - FormBuilderValidators.required(), - FormBuilderValidators.email(), - ]), - onSaved: (value) => (_formData.email = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editemail = !editemail; // Toggle edit mode - if (!editemail) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editemail - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editemail ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + Email( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Phone :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editphone, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.phone, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editphone, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'phone', - decoration: const InputDecoration( - hintText: 'Phone', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.phone, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.phone = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editphone = !editphone; // Toggle edit mode - if (!editphone) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editphone - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editphone ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + Phone( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), ], ), @@ -1580,1288 +648,55 @@ class _UserProfileScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0, top: kDefaultPadding), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Position (English) :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editpositionenglish, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.positionEnglish, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editpositionenglish, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'positionenglish', - decoration: const InputDecoration( - hintText: 'Position (English)', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.positionEnglish, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.positionEnglish = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editpositionenglish = !editpositionenglish; // Toggle edit mode - if (!editpositionenglish) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editpositionenglish - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editpositionenglish ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + PositionEnglish( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Position (Bangla) :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editpositionbangla, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.positionBangla, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editpositionbangla, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'positionbangla', - decoration: const InputDecoration( - hintText: '(Bangla)', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.positionBangla, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.positionBangla = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editpositionbangla = !editpositionbangla; // Toggle edit mode - if (!editpositionbangla) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editpositionbangla - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editpositionbangla ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + PositionBangla( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Position Held Since :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editpositionheldsince, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.positionHeldSince, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editpositionheldsince, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'positionheldsince', - decoration: const InputDecoration( - hintText: '(Year only)', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.positionHeldSince, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.positionHeldSince = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editpositionheldsince = !editpositionheldsince; // Toggle edit mode - if (!editpositionheldsince) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editpositionheldsince - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editpositionheldsince ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + PositionHeldSince( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only( - bottom: kDefaultPadding * 2.0, - ), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Department Name :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editdepartmentname, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.departmentName, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editdepartmentname, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderDropdown( - name: 'departmentname', - decoration: const InputDecoration( - border: OutlineInputBorder(), - hoverColor: Colors.transparent, - focusColor: Colors.transparent, - hintText: 'Select', - ), - focusColor: Colors.transparent, - validator: FormBuilderValidators.required(), - initialValue: _formData.departmentName, - autovalidateMode: AutovalidateMode.onUserInteraction, - items: [ - '', - 'Department of Computer Science and Information Technology', - 'Department of Computer and Communication Engineering', - 'Department of Electrical and Electronics Engineering', - 'Department of Physics and Mechanical Engineering', - 'Department of Mathematics', - 'Department of Marine Fisheries and Oceanography', - 'Department of Genetics and Animal Breeding', - 'Department of Fisheries Technology', - 'Department of Human Nutrition and Dietetics', - 'Department of Biochemistry and Food Analysis', - 'Department of Environmental Sanitation', - 'Department of Food Microbiology', - 'Department of Food Technology and Engineering', - 'Department of Post Harvest Technology and Marketing', - 'Department of Dairy Science', - 'Department of Animal Products and By-Products Technology', - 'Department of Basic Science', - 'Department of General Animal Science and Animal Nutrition', - 'Department of Microbiology and Public Health', - 'Department of Pathology and Parasitology', - 'Department of Physiology and Pharmacology', - 'Department of Poultry Science', - 'Department of Disaster Risk Management', - 'Department of Law and Land Administration', - 'Department of Anatomy and Histology', - 'Department of Fisheries Biology and Genetics', - 'Department of Aquaculture', - 'Department of Marketing', - 'Department of Management Studies', - 'Department of Language and Communication', - 'Department of Finance and Banking', - 'Department of Economics and Sociology', - 'Department of Agricultural Botany', - 'Department of Accounting and Information Systems', - 'Department of Fisheries Management', - 'Department of Agricultural Chemistry', - 'Department of Disaster Resilience and Engineering', - 'Department of Medicine Surgery and Obstetrics', - 'Department of Agricultural Engineering', - 'Department of Emergency Management', - 'Department of Agricultural Extension and Rural Development', - 'Department of Environmental Science', - 'Department of Geo Information Science and Earth Observation', - 'Department of Agroforestry', - 'Department of Agronomy', - 'Department of Animal Science', - 'Department of Community Health and Hygiene', - 'Department of Biotechnology', - 'Department of Entomology', - 'Department of Genetics and Plant Breeding', - 'Department of Horticulture', - 'Department of Plant Pathology', - 'Department of Soil Science', - 'Department of Statistics', - 'Department of Climate Smart Agricultured', - ].map((e) => DropdownMenuItem(value: e, child: Text(e))).toList(), - onChanged: (value) => (_formData.departmentName = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editdepartmentname = !editdepartmentname; // Toggle edit mode - if (!editdepartmentname) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editdepartmentname - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editdepartmentname ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + DepartmentName( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Faculty Name:', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editfacultyname, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.facultyName, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editfacultyname, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderDropdown( - name: 'facultyName', - decoration: const InputDecoration( - hintText: 'Select', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - hint: const Text('Select'), - initialValue: _formData.facultyName, - validator: FormBuilderValidators.required(), - items: [ - '', - 'Faculty of Agriculture', - 'Faculty of Computer Science and Engineering', - 'Faculty of Business Administration', - 'Faculty of Animal Science and Veterinary Medicine', - 'Faculty of Fisheries', - 'Faculty of Environmental Science and Disaster Management', - 'Faculty of Nutrition and Food Science', - 'Faculty of Law and Land Administration' - ].map((e) => DropdownMenuItem(value: e, child: Text(e))).toList(), - onSaved: (value) => (_formData.facultyName = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editfacultyname = !editfacultyname; // Toggle edit mode - if (!editfacultyname) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editfacultyname - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editfacultyname ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + FacultyName( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Institute Name :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editinstituteName, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.instituteName, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editinstituteName, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderDropdown( - name: 'instituteName', - decoration: const InputDecoration( - border: OutlineInputBorder(), - hoverColor: Colors.transparent, - focusColor: Colors.transparent, - hintText: 'Select', - ), - focusColor: Colors.transparent, - validator: FormBuilderValidators.required(), - initialValue: _formData.instituteName, - autovalidateMode: AutovalidateMode.onUserInteraction, - items: const [ - DropdownMenuItem( - value: '', - child: Text('Select'), - ), - DropdownMenuItem( - value: 'Patuakhali Science & Technology University (PSTU)', - child: Text('Patuakhali Science & Technology University (PSTU)'), - ), - // Add more DropdownMenuItem as needed with unique values - ], - onChanged: (value) => (_formData.instituteName = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editinstituteName = !editinstituteName; // Toggle edit mode - if (!editinstituteName) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editinstituteName - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editinstituteName ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + InstituteName( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Institute Location (Office Address):', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editistitutelocation, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.instituteLocation, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editistitutelocation, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'instituteLocation', - maxLines: null, - decoration: const InputDecoration( - hintText: '(Office Address)', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.instituteLocation, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.instituteLocation = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editistitutelocation = !editistitutelocation; // Toggle edit mode - if (!editistitutelocation) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editistitutelocation - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editistitutelocation ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + InstituteLocation( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Institute Email :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editinstituteemail, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.instituteEmail, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editinstituteemail, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'instituteEmail', - decoration: const InputDecoration( - hintText: '@pstu.ac.bd', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.instituteEmail, - validator: FormBuilderValidators.compose([ - FormBuilderValidators.required(), - FormBuilderValidators.email(), - ]), - onSaved: (value) => (_formData.instituteEmail = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editinstituteemail = !editinstituteemail; // Toggle edit mode - if (!editinstituteemail) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editinstituteemail - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editinstituteemail ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + InstituteEmail( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Salary Scale :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editsalaryscale, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.salaryScale, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editsalaryscale, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'salaryScale', - decoration: const InputDecoration( - hintText: '(Range of Tk.)', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.salaryScale, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.salaryScale = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editsalaryscale = !editsalaryscale; // Toggle edit mode - if (!editsalaryscale) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editsalaryscale - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editsalaryscale ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + SalaryScale( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Basic Pay :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editbasicpay, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.basicPay.toString(), - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editbasicpay, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'basicPay', - decoration: const InputDecoration( - hintText: '(Tk.)', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.basicPay.toString(), - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.basicPay = double.parse(value ?? '0.0')), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editbasicpay = !editbasicpay; // Toggle edit mode - if (!editbasicpay) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editbasicpay - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editbasicpay ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + BasicPay( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), ], ), @@ -2881,841 +716,40 @@ class _UserProfileScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0, top: kDefaultPadding), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Area of Expertise :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editAreaOfExpertise, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.areaOfExpertise, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editAreaOfExpertise, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'areaOfExpertise', - maxLines: null, - decoration: const InputDecoration( - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.areaOfExpertise, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.areaOfExpertise = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editAreaOfExpertise = !editAreaOfExpertise; // Toggle edit mode - if (!editAreaOfExpertise) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editAreaOfExpertise - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editAreaOfExpertise ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + AreaOfExpertise( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Experience in Research :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editExperienceInResearch, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.experienceInResearch.toString(), - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editExperienceInResearch, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'areaOfExpertise', - decoration: const InputDecoration( - hintText: "(No of Years)", - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.experienceInResearch.toString(), - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.experienceInResearch = int.parse(value ?? '0')), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editExperienceInResearch = !editExperienceInResearch; // Toggle edit mode - if (!editExperienceInResearch) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editExperienceInResearch - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editExperienceInResearch ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + ExperienceInResearch( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Teaching Experience:', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editTeaching, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.teaching.toString(), - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editTeaching, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'teachingExperience', - decoration: const InputDecoration( - hintText: "(No of Years)", - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.teaching.toString(), - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.teaching = int.parse(value ?? '0')), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editTeaching = !editTeaching; // Toggle edit mode - if (!editTeaching) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editTeaching - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editTeaching ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + TeachingExperience( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only( - bottom: kDefaultPadding * 2.0, - ), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Total Number of Complete Projects :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editTotalNumberOfCompleteProjects, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.totalNumberOfCompleteProjects.toString(), - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editTotalNumberOfCompleteProjects, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'totalNumberOfCompleteProjects', - decoration: const InputDecoration( - hintText: "(No of Projects)", - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.totalNumberOfCompleteProjects.toString(), - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.totalNumberOfCompleteProjects = int.parse(value ?? '0')), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editTotalNumberOfCompleteProjects = !editTotalNumberOfCompleteProjects; // Toggle edit mode - if (!editTotalNumberOfCompleteProjects) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editTotalNumberOfCompleteProjects - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editTotalNumberOfCompleteProjects ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + TotalNumberOfCompleteProject( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Total Number of Complete Publications:', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editTotalNumberOfCompletePublications, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.totalNumberOfCompletePublications.toString(), - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editTotalNumberOfCompletePublications, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'totalNumberOfCompletePublications', - decoration: const InputDecoration( - hintText: "(No of Publications)", - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.totalNumberOfCompletePublications.toString(), - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.totalNumberOfCompletePublications = int.parse(value ?? '0')), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editTotalNumberOfCompletePublications = !editTotalNumberOfCompletePublications; // Toggle edit mode - if (!editTotalNumberOfCompletePublications) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editTotalNumberOfCompletePublications - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editTotalNumberOfCompletePublications ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + TotalNumberOfCompletePublication( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Ongoing Projects :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editOngoingProjects, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.ongoingProjects.toString(), - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editOngoingProjects, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'ongoingProjects', - decoration: const InputDecoration( - hintText: "(No of Running Projects)", - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.ongoingProjects.toString(), - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.ongoingProjects = int.parse(value ?? '0')), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editOngoingProjects = !editOngoingProjects; // Toggle edit mode - if (!editOngoingProjects) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editOngoingProjects - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editOngoingProjects ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + OngoingProject( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'References of Latest Publications :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editReferencesOfLatestPublications, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.referencesOfLatestPublications, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editReferencesOfLatestPublications, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - maxLines: null, - name: 'referencesOfLatestPublications', - decoration: const InputDecoration( - hintText: 'References', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.referencesOfLatestPublications, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.referencesOfLatestPublications = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editReferencesOfLatestPublications = !editReferencesOfLatestPublications; // Toggle edit mode - if (!editReferencesOfLatestPublications) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editReferencesOfLatestPublications - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editReferencesOfLatestPublications ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + ReferencesOfLatestPubtication( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), ], ), @@ -3735,1481 +769,46 @@ class _UserProfileScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0, top: kDefaultPadding), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Nid No:', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editNid, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.nid, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editNid, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'nid', - decoration: const InputDecoration( - hintText: 'Nid No', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.nid, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.nid = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editNid = !editNid; // Toggle edit mode - if (!editNid) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editNid - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editNid ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + NidNo( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Nid Photo :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editNidLocation, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - alignment: Alignment.center, - padding: const EdgeInsets.only(bottom: kDefaultPadding * 1.5), - child: Stack( - children: [ - FutureBuilder( - future: _formData.nidLocation.isNotEmpty - ? ApiService.downloadFile('nid/download', _formData.nidLocation) - : Future.value(""), // Check if value is not empty before making the API call - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return const CircularProgressIndicator(); - } else if (snapshot.hasError) { - return Text('Error: ${snapshot.error}'); - } else { - return Image.memory( - base64Decode(snapshot.data!), // Convert base64 string to image bytes - fit: BoxFit.cover, // Adjust image to cover the entire space - // width: 120, // Adjust width as needed - height: 50, // Adjust height as needed - ); - } - }, - ), - ], - ), - ), - ], - ), - ), - ), - ), - Visibility( - visible: editNidLocation, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderFilePicker( - name: 'nidphoto', - // allowedExtensions: const ['jpg', 'png', 'pdf', 'jpeg'], - allowMultiple: false, - maxFiles: 1, - type: FileType.any, - previewImages: true, - decoration: const InputDecoration( - hintText: 'nidphoto', - border: OutlineInputBorder(), - ), - selector: const Row( - children: [ - Icon(Icons.file_upload_rounded), - Text('Upload'), - ], - ), - // typeSelectors: [ - // TypeSelector( - // type: FileType.custom, - // allowedExtensions: ['jpg', 'png', 'pdf', 'jpeg'], - // selector: Row( - // children: [ - // Icon(Icons.file_upload), - // Text('Upload'), - // ], - // ), - // ), - // ], - onChanged: _onNidFileSelected, - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editNidLocation = !editNidLocation; // Toggle edit mode - if (!editNidLocation) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editNidLocation - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editNidLocation ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + NidPhoto( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), + onNidFileSelected: _onNidFileSelected, ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Present Address:', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editPresentAddress, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.presentAddress, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editPresentAddress, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'presentAddress', - decoration: const InputDecoration( - hintText: "Present Address", - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.presentAddress, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.presentAddress = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editPresentAddress = !editPresentAddress; // Toggle edit mode - if (!editPresentAddress) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editPresentAddress - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editPresentAddress ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), - ), - Padding( - padding: const EdgeInsets.only( - bottom: kDefaultPadding * 2.0, - ), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Permanent Address:', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editPermanentAddress, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.permanentAddress, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editPermanentAddress, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'permanentAddress', - decoration: const InputDecoration( - hintText: "Permanent Address", - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.permanentAddress, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.permanentAddress = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editPermanentAddress = !editPermanentAddress; // Toggle edit mode - if (!editPermanentAddress) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editPermanentAddress - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editPermanentAddress ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), - ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Profile Picture:', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editProfilePicLocation, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - alignment: Alignment.center, - padding: const EdgeInsets.only(bottom: kDefaultPadding * 1.5), - child: Stack( - children: [ - FutureBuilder( - future: _formData.profilePicLocation.isNotEmpty - ? ApiService.downloadFile('profile-pic/download', _formData.profilePicLocation) - : Future.value(""), // Check if value is not empty before making the API call - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return const CircularProgressIndicator(); - } else if (snapshot.hasError) { - return Text('Error: ${snapshot.error}'); - } else { - return CircleAvatar( - backgroundColor: Colors.white, - backgroundImage: MemoryImage(base64Decode(snapshot.data!)), // Convert base64 string to image bytes - radius: 60.0, - ); - } - }, - ), - ], - ), - ), - ], - ), - ), - ), - ), - Visibility( - visible: editProfilePicLocation, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderFilePicker( - name: 'profilePicLocation', - // allowedExtensions: const ['jpg', 'png', 'pdf', 'jpeg'], - allowMultiple: false, - maxFiles: 1, - type: FileType.any, - previewImages: true, - decoration: const InputDecoration( - hintText: 'profilePicLocation', - border: OutlineInputBorder(), - ), - selector: const Row( - children: [ - Icon(Icons.file_upload_rounded), - Text('Upload'), - ], - ), - // typeSelectors: [ - // TypeSelector( - // type: FileType.custom, - // allowedExtensions: ['jpg', 'png', 'pdf', 'jpeg'], - // selector: Row( - // children: [ - // Icon(Icons.file_upload), - // Text('Upload'), - // ], - // ), - // ), - // ], - onChanged: _onProfilePicFileSelected, - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editProfilePicLocation = !editProfilePicLocation; // Toggle edit mode - if (!editProfilePicLocation) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editProfilePicLocation - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editProfilePicLocation ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), - ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Signature Photo :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editSignatureLocation, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - alignment: Alignment.center, - padding: const EdgeInsets.only(bottom: kDefaultPadding * 1.5), - child: Stack( - children: [ - FutureBuilder( - future: _formData.signatureLocation.isNotEmpty - ? ApiService.downloadFile('signature/download', _formData.signatureLocation) - : Future.value(""), // Check if value is not empty before making the API call - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return const CircularProgressIndicator(); - } else if (snapshot.hasError) { - return Text('Error: ${snapshot.error}'); - } else { - return Image.memory( - base64Decode(snapshot.data!), // Convert base64 string to image bytes - fit: BoxFit.cover, // Adjust image to cover the entire space - // width: 120, // Adjust width as needed - height: 50, // Adjust height as needed - ); - } - }, - ), - ], - ), - ), - ], - ), - ), - ), - ), - Visibility( - visible: editSignatureLocation, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderFilePicker( - name: 'signatureLocation', - // allowedExtensions: const ['jpg', 'png', 'pdf', 'jpeg'], - allowMultiple: false, - maxFiles: 1, - type: FileType.any, - previewImages: true, - decoration: const InputDecoration( - hintText: 'signatureLocation', - border: OutlineInputBorder(), - ), - selector: const Row( - children: [ - Icon(Icons.file_upload_rounded), - Text('Upload'), - ], - ), - // typeSelectors: [ - // TypeSelector( - // type: FileType.custom, - // allowedExtensions: ['jpg', 'png', 'pdf', 'jpeg'], - // selector: Row( - // children: [ - // Icon(Icons.file_upload), - // Text('Upload'), - // ], - // ), - // ), - // ], - onChanged: _onSignatureFileSelected, - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editSignatureLocation = !editSignatureLocation; // Toggle edit mode - if (!editSignatureLocation) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editSignatureLocation - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editSignatureLocation ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + PresentAddress( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Seal Photo :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editSealLocation, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - alignment: Alignment.center, - padding: const EdgeInsets.only(bottom: kDefaultPadding * 1.5), - child: Stack( - children: [ - FutureBuilder( - future: _formData.sealLocation.isNotEmpty - ? ApiService.downloadFile('seal/download', _formData.sealLocation) - : Future.value(""), // Check if value is not empty before making the API call - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return const CircularProgressIndicator(); - } else if (snapshot.hasError) { - return Text('Error: ${snapshot.error}'); - } else { - return Image.memory( - base64Decode(snapshot.data!), // Convert base64 string to image bytes - fit: BoxFit.cover, // Adjust image to cover the entire space - // width: 120, // Adjust width as needed - height: 50, // Adjust height as needed - ); - } - }, - ), - ], - ), - ), - ], - ), - ), - ), - ), - Visibility( - visible: editSealLocation, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderFilePicker( - name: 'sealLocation', - // allowedExtensions: const ['jpg', 'png', 'pdf', 'jpeg'], - allowMultiple: false, - maxFiles: 1, - type: FileType.any, - previewImages: true, - decoration: const InputDecoration( - hintText: 'sealLocation', - border: OutlineInputBorder(), - ), - selector: const Row( - children: [ - Icon(Icons.file_upload_rounded), - Text('Upload'), - ], - ), - // typeSelectors: [ - // TypeSelector( - // type: FileType.custom, - // allowedExtensions: ['jpg', 'png', 'pdf', 'jpeg'], - // selector: Row( - // children: [ - // Icon(Icons.file_upload), - // Text('Upload'), - // ], - // ), - // ), - // ], - onChanged: _onSealFileSelected, - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editSealLocation = !editSealLocation; // Toggle edit mode - if (!editSealLocation) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editSealLocation - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editSealLocation ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + PermanentAddress( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Highest Academic Qualification:', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editHighestAcademicQualification, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.highestAcademicQualification, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editHighestAcademicQualification, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'highestAcademicQualification', - decoration: const InputDecoration( - hintText: "(eg. B.Sc. in Computer Science)", - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.highestAcademicQualification, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.highestAcademicQualification = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editHighestAcademicQualification = !editHighestAcademicQualification; // Toggle edit mode - if (!editHighestAcademicQualification) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editHighestAcademicQualification - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editHighestAcademicQualification ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + HighestAcademicQualification( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Highest Academic Qualification University :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editHighestAcademicQualificationUniversity, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.highestAcademicQualificationUniversity.toString(), - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editHighestAcademicQualificationUniversity, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'highestAcademicQualificationUniversity', - decoration: const InputDecoration( - hintText: "(University Name)", - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.highestAcademicQualificationUniversity, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.highestAcademicQualificationUniversity = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editHighestAcademicQualificationUniversity = !editHighestAcademicQualificationUniversity; // Toggle edit mode - if (!editHighestAcademicQualificationUniversity) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editHighestAcademicQualificationUniversity - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editHighestAcademicQualificationUniversity ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + HighestAcademicQualificationUniversity( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Highest Academic Qualification Country :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editHighestAcademicQualificationCountry, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.highestAcademicQualificationCountry, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editHighestAcademicQualificationCountry, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - maxLines: null, - name: 'highestAcademicQualificationCountry', - decoration: const InputDecoration( - hintText: '(Country Name)', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.highestAcademicQualificationCountry, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.highestAcademicQualificationCountry = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editHighestAcademicQualificationCountry = !editHighestAcademicQualificationCountry; // Toggle edit mode - if (!editHighestAcademicQualificationCountry) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editHighestAcademicQualificationCountry - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editHighestAcademicQualificationCountry ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + HighestAcademicQualificationCountry( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Highest Academic Qualification Year:', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editHighestAcademicQualificationYear, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.highestAcademicQualificationYear.toString(), - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editHighestAcademicQualificationYear, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - maxLines: null, - name: 'highestAcademicQualificationYear', - decoration: const InputDecoration( - hintText: '(Year)', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.highestAcademicQualificationYear.toString(), - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.highestAcademicQualificationYear = int.parse(value ?? '0')), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editHighestAcademicQualificationYear = !editHighestAcademicQualificationYear; // Toggle edit mode - if (!editHighestAcademicQualificationYear) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editHighestAcademicQualificationYear - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editHighestAcademicQualificationYear ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + HighestAcademicQualificationYear( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), ], ), @@ -5229,483 +828,25 @@ class _UserProfileScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0, top: kDefaultPadding), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Student ID :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editStudentID, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.studentID.toString(), - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editStudentID, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'studentID', - decoration: const InputDecoration( - hintText: 'Enter Student ID', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.studentID.toString(), - // validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.studentID = int.parse(value ?? '0')), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editStudentID = !editStudentID; // Toggle edit mode - if (!editStudentID) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editStudentID - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editStudentID ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + StudentID( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Student Reg.No. :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editStudentRegNo, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.studentRegNo, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editStudentRegNo, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'regNo', - decoration: const InputDecoration( - hintText: 'Reg. No.', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.studentRegNo, - // validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.studentRegNo = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editStudentRegNo = !editStudentRegNo; // Toggle edit mode - if (!editStudentRegNo) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editStudentRegNo - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editStudentRegNo ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + StudentRegNo( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'First Enrollment Semester :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editFirstEnrollmentSemester, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.firstEnrollmentSemester, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editFirstEnrollmentSemester, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'firstEnrollmentSemester', - decoration: const InputDecoration( - hintText: '(eg. Semester - 1)', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.firstEnrollmentSemester, - // validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.firstEnrollmentSemester = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editFirstEnrollmentSemester = !editFirstEnrollmentSemester; // Toggle edit mode - if (!editFirstEnrollmentSemester) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editFirstEnrollmentSemester - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editFirstEnrollmentSemester ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + FirstEnrollmentSemester( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), - Padding( - padding: const EdgeInsets.only( - bottom: kDefaultPadding * 2.0, - ), - child: LayoutBuilder( - builder: (context, constraints) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), - child: const Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: 'Undergraduate CGPA Level :', - backgroundColor: Color.fromARGB(255, 74, 89, 96), - titleColor: Color.fromARGB(255, 151, 204, 197), - showDivider: false, - ), - ], - ), - ), - ), - const SizedBox(width: kDefaultPadding), - Visibility( - visible: !editUndergraduateCGPALevel, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CardHeader( - title: _formData.undergraduateCGPALevel, - backgroundColor: const Color.fromARGB(255, 51, 55, 56), - titleColor: const Color.fromARGB(255, 238, 216, 221), - showDivider: false, - ), - ], - ), - ), - ), - ), - Visibility( - visible: editUndergraduateCGPALevel, - child: SizedBox( - width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FormBuilderTextField( - name: 'undergraduateCGPALevel', - decoration: const InputDecoration( - hintText: '(eg. 4.0)', - border: OutlineInputBorder(), - floatingLabelBehavior: FloatingLabelBehavior.always, - ), - initialValue: _formData.undergraduateCGPALevel, - validator: FormBuilderValidators.required(), - onSaved: (value) => (_formData.undergraduateCGPALevel = value ?? ''), - ), - ], - ), - ), - ), - ), - const SizedBox(width: kDefaultPadding), - SizedBox( - width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ElevatedButton( - style: themeData.extension()!.infoOutlined, - onPressed: () { - setState(() { - editUndergraduateCGPALevel = !editUndergraduateCGPALevel; // Toggle edit mode - if (!editUndergraduateCGPALevel) { - // Save changes if transitioning from edit mode to view mode - _formKey.currentState!.validate(); - _formKey.currentState!.save(); - // Change pending user data change to true for re-rendering the Save_changes button - initialUserDataChange = true; - } - }); - }, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), - child: Icon( - editUndergraduateCGPALevel - ? Icons.save_outlined // Change icon based on edit mode - : Icons.mode_edit_outline_outlined, - size: (themeData.textTheme.labelLarge!.fontSize! + 4.0), - ), - ), - Text(editUndergraduateCGPALevel ? "Save" : "Edit"), - ], - ), - ), - const SizedBox(height: kDefaultPadding), - ], - ), - ), - ), - ], - ); - }, - ), + UndergraduateCGPALevel( + formData: _formData, + themeData: themeData, + onDoSave: () => _goSaveChanges(context), ), ], ), @@ -5791,8 +932,6079 @@ class _UserProfileScreenState extends State { } } +class UndergraduateCGPALevel extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const UndergraduateCGPALevel({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _UndergraduateCGPALevelState createState() => _UndergraduateCGPALevelState(); +} + +class _UndergraduateCGPALevelState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only( + bottom: kDefaultPadding * 2.0, + ), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Undergraduate CGPA Level :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editUndergraduateCGPALevel, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.undergraduateCGPALevel, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editUndergraduateCGPALevel, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'undergraduateCGPALevel', + decoration: const InputDecoration( + hintText: '(eg. 4.0)', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.undergraduateCGPALevel, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.undergraduateCGPALevel = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editUndergraduateCGPALevel = !editUndergraduateCGPALevel; // Toggle edit mode + if (!editUndergraduateCGPALevel) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editUndergraduateCGPALevel + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editUndergraduateCGPALevel ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class FirstEnrollmentSemester extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const FirstEnrollmentSemester({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _FirstEnrollmentSemesterState createState() => _FirstEnrollmentSemesterState(); +} + +class _FirstEnrollmentSemesterState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'First Enrollment Semester :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editFirstEnrollmentSemester, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.firstEnrollmentSemester, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editFirstEnrollmentSemester, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'firstEnrollmentSemester', + decoration: const InputDecoration( + hintText: '(eg. Semester - 1)', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.firstEnrollmentSemester, + // validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.firstEnrollmentSemester = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editFirstEnrollmentSemester = !editFirstEnrollmentSemester; // Toggle edit mode + if (!editFirstEnrollmentSemester) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editFirstEnrollmentSemester + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editFirstEnrollmentSemester ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class StudentRegNo extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const StudentRegNo({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _StudentRegNoState createState() => _StudentRegNoState(); +} + +class _StudentRegNoState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Student Reg.No. :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editStudentRegNo, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.studentRegNo, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editStudentRegNo, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'regNo', + decoration: const InputDecoration( + hintText: 'Reg. No.', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.studentRegNo, + // validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.studentRegNo = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editStudentRegNo = !editStudentRegNo; // Toggle edit mode + if (!editStudentRegNo) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editStudentRegNo + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editStudentRegNo ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class StudentID extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const StudentID({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _StudentIDState createState() => _StudentIDState(); +} + +class _StudentIDState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0, top: kDefaultPadding), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Student ID :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editStudentID, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.studentID.toString(), + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editStudentID, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'studentID', + decoration: const InputDecoration( + hintText: 'Enter Student ID', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.studentID.toString(), + // validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.studentID = int.parse(value ?? '0')), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editStudentID = !editStudentID; // Toggle edit mode + if (!editStudentID) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editStudentID + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editStudentID ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class HighestAcademicQualificationYear extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const HighestAcademicQualificationYear({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _HighestAcademicQualificationYearState createState() => _HighestAcademicQualificationYearState(); +} + +class _HighestAcademicQualificationYearState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Highest Academic Qualification Year:', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editHighestAcademicQualificationYear, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.highestAcademicQualificationYear.toString(), + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editHighestAcademicQualificationYear, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + maxLines: null, + name: 'highestAcademicQualificationYear', + decoration: const InputDecoration( + hintText: '(Year)', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.highestAcademicQualificationYear.toString(), + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.highestAcademicQualificationYear = int.parse(value ?? '0')), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editHighestAcademicQualificationYear = !editHighestAcademicQualificationYear; // Toggle edit mode + if (!editHighestAcademicQualificationYear) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editHighestAcademicQualificationYear + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editHighestAcademicQualificationYear ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class HighestAcademicQualificationCountry extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const HighestAcademicQualificationCountry({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _HighestAcademicQualificationCountryState createState() => _HighestAcademicQualificationCountryState(); +} + +class _HighestAcademicQualificationCountryState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Highest Academic Qualification Country :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editHighestAcademicQualificationCountry, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.highestAcademicQualificationCountry, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editHighestAcademicQualificationCountry, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + maxLines: null, + name: 'highestAcademicQualificationCountry', + decoration: const InputDecoration( + hintText: '(Country Name)', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.highestAcademicQualificationCountry, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.highestAcademicQualificationCountry = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editHighestAcademicQualificationCountry = !editHighestAcademicQualificationCountry; // Toggle edit mode + if (!editHighestAcademicQualificationCountry) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editHighestAcademicQualificationCountry + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editHighestAcademicQualificationCountry ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class HighestAcademicQualificationUniversity extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const HighestAcademicQualificationUniversity({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _HighestAcademicQualificationUniversityState createState() => _HighestAcademicQualificationUniversityState(); +} + +class _HighestAcademicQualificationUniversityState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Highest Academic Qualification University :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editHighestAcademicQualificationUniversity, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.highestAcademicQualificationUniversity.toString(), + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editHighestAcademicQualificationUniversity, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'highestAcademicQualificationUniversity', + decoration: const InputDecoration( + hintText: "(University Name)", + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.highestAcademicQualificationUniversity, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.highestAcademicQualificationUniversity = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editHighestAcademicQualificationUniversity = !editHighestAcademicQualificationUniversity; // Toggle edit mode + if (!editHighestAcademicQualificationUniversity) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editHighestAcademicQualificationUniversity + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editHighestAcademicQualificationUniversity ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class HighestAcademicQualification extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const HighestAcademicQualification({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _HighestAcademicQualificationState createState() => _HighestAcademicQualificationState(); +} + +class _HighestAcademicQualificationState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Highest Academic Qualification:', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editHighestAcademicQualification, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.highestAcademicQualification, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editHighestAcademicQualification, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'highestAcademicQualification', + decoration: const InputDecoration( + hintText: "(eg. B.Sc. in Computer Science)", + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.highestAcademicQualification, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.highestAcademicQualification = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editHighestAcademicQualification = !editHighestAcademicQualification; // Toggle edit mode + if (!editHighestAcademicQualification) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editHighestAcademicQualification + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editHighestAcademicQualification ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class PermanentAddress extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const PermanentAddress({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _PermanentAddressState createState() => _PermanentAddressState(); +} + +class _PermanentAddressState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only( + bottom: kDefaultPadding * 2.0, + ), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Permanent Address:', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editPermanentAddress, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.permanentAddress, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editPermanentAddress, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'permanentAddress', + decoration: const InputDecoration( + hintText: "Permanent Address", + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.permanentAddress, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.permanentAddress = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editPermanentAddress = !editPermanentAddress; // Toggle edit mode + if (!editPermanentAddress) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editPermanentAddress + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editPermanentAddress ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class PresentAddress extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const PresentAddress({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _PresentAddressState createState() => _PresentAddressState(); +} + +class _PresentAddressState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Present Address:', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editPresentAddress, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.presentAddress, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editPresentAddress, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'presentAddress', + decoration: const InputDecoration( + hintText: "Present Address", + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.presentAddress, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.presentAddress = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editPresentAddress = !editPresentAddress; // Toggle edit mode + if (!editPresentAddress) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editPresentAddress + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editPresentAddress ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class NidPhoto extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + final Function(List?) onNidFileSelected; + + const NidPhoto({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + required this.onNidFileSelected, + }) : super(key: key); + + @override + _NidPhotoState createState() => _NidPhotoState(); +} + +class _NidPhotoState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Nid Photo :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + alignment: Alignment.center, + padding: const EdgeInsets.only(bottom: kDefaultPadding * 1.5), + child: Stack( + children: [ + FutureBuilder( + future: widget.formData.nidLocation.isNotEmpty + ? ApiService.downloadFile('nid/download', widget.formData.nidLocation) + : ApiService.downloadFile('nid/download', "defaultnid.png"), // Check if value is not empty before making the API call + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const CircularProgressIndicator(); + } else if (snapshot.hasError) { + return Text('Error: ${snapshot.error}'); + } else { + return Image.memory( + base64Decode(snapshot.data!), // Convert base64 string to image bytes + fit: BoxFit.cover, // Adjust image to cover the entire space + // width: 120, // Adjust width as needed + height: 50, // Adjust height as needed + ); + } + }, + ), + ], + ), + ), + ], + ), + ), + ), + SizedBox( + width: ((constraints.maxWidth * 0.31) - (kDefaultPadding * 0.31)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderFilePicker( + name: 'nidLocation', + key: ValueKey(widget.formData.nidLocation), // Add this line + // allowedExtensions: const ['jpg', 'png', 'pdf', 'jpeg'], + allowMultiple: false, + maxFiles: 1, + type: FileType.any, + previewImages: true, + decoration: const InputDecoration( + hintText: 'nidLocation', + border: OutlineInputBorder(), + ), + selector: const Row( + children: [ + Icon(Icons.file_upload_rounded), + Text('Update Nid Photo'), + ], + ), + // typeSelectors: [ + // TypeSelector( + // type: FileType.custom, + // allowedExtensions: ['jpg', 'png', 'pdf', 'jpeg'], + // selector: Row( + // children: [ + // Icon(Icons.file_upload), + // Text('Upload'), + // ], + // ), + // ), + // ], + onChanged: widget.onNidFileSelected, + ), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class NidNo extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const NidNo({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _NidNoState createState() => _NidNoState(); +} + +class _NidNoState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0, top: kDefaultPadding), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Nid No:', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editNid, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.nid, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editNid, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'nid', + decoration: const InputDecoration( + hintText: 'Nid No', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.nid, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.nid = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editNid = !editNid; // Toggle edit mode + if (!editNid) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editNid + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editNid ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class ReferencesOfLatestPubtication extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const ReferencesOfLatestPubtication({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _ReferencesOfLatestPubticationState createState() => _ReferencesOfLatestPubticationState(); +} + +class _ReferencesOfLatestPubticationState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'References of Latest Publications :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editReferencesOfLatestPublications, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.referencesOfLatestPublications, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editReferencesOfLatestPublications, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + maxLines: null, + name: 'referencesOfLatestPublications', + decoration: const InputDecoration( + hintText: 'References', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.referencesOfLatestPublications, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.referencesOfLatestPublications = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editReferencesOfLatestPublications = !editReferencesOfLatestPublications; // Toggle edit mode + if (!editReferencesOfLatestPublications) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editReferencesOfLatestPublications + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editReferencesOfLatestPublications ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class OngoingProject extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const OngoingProject({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _OngoingProjectState createState() => _OngoingProjectState(); +} + +class _OngoingProjectState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Ongoing Projects :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editOngoingProjects, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.ongoingProjects.toString(), + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editOngoingProjects, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'ongoingProjects', + decoration: const InputDecoration( + hintText: "(No of Running Projects)", + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.ongoingProjects.toString(), + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.ongoingProjects = int.parse(value ?? '0')), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editOngoingProjects = !editOngoingProjects; // Toggle edit mode + if (!editOngoingProjects) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editOngoingProjects + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editOngoingProjects ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class TotalNumberOfCompletePublication extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const TotalNumberOfCompletePublication({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _TotalNumberOfCompletePublicationState createState() => _TotalNumberOfCompletePublicationState(); +} + +class _TotalNumberOfCompletePublicationState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Total Number of Complete Publications:', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editTotalNumberOfCompletePublications, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.totalNumberOfCompletePublications.toString(), + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editTotalNumberOfCompletePublications, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'totalNumberOfCompletePublications', + decoration: const InputDecoration( + hintText: "(No of Publications)", + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.totalNumberOfCompletePublications.toString(), + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.totalNumberOfCompletePublications = int.parse(value ?? '0')), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editTotalNumberOfCompletePublications = !editTotalNumberOfCompletePublications; // Toggle edit mode + if (!editTotalNumberOfCompletePublications) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editTotalNumberOfCompletePublications + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editTotalNumberOfCompletePublications ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class TotalNumberOfCompleteProject extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const TotalNumberOfCompleteProject({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _TotalNumberOfCompleteProjectState createState() => _TotalNumberOfCompleteProjectState(); +} + +class _TotalNumberOfCompleteProjectState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only( + bottom: kDefaultPadding * 2.0, + ), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Total Number of Complete Projects :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editTotalNumberOfCompleteProjects, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.totalNumberOfCompleteProjects.toString(), + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editTotalNumberOfCompleteProjects, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'totalNumberOfCompleteProjects', + decoration: const InputDecoration( + hintText: "(No of Projects)", + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.totalNumberOfCompleteProjects.toString(), + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.totalNumberOfCompleteProjects = int.parse(value ?? '0')), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editTotalNumberOfCompleteProjects = !editTotalNumberOfCompleteProjects; // Toggle edit mode + if (!editTotalNumberOfCompleteProjects) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editTotalNumberOfCompleteProjects + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editTotalNumberOfCompleteProjects ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class TeachingExperience extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const TeachingExperience({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _TeachingExperienceState createState() => _TeachingExperienceState(); +} + +class _TeachingExperienceState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Teaching Experience:', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editTeaching, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.teaching.toString(), + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editTeaching, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'teachingExperience', + decoration: const InputDecoration( + hintText: "(No of Years)", + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.teaching.toString(), + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.teaching = int.parse(value ?? '0')), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editTeaching = !editTeaching; // Toggle edit mode + if (!editTeaching) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editTeaching + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editTeaching ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class ExperienceInResearch extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const ExperienceInResearch({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _ExperienceInResearchState createState() => _ExperienceInResearchState(); +} + +class _ExperienceInResearchState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Experience in Research :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editExperienceInResearch, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.experienceInResearch.toString(), + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editExperienceInResearch, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'areaOfExpertise', + decoration: const InputDecoration( + hintText: "(No of Years)", + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.experienceInResearch.toString(), + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.experienceInResearch = int.parse(value ?? '0')), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editExperienceInResearch = !editExperienceInResearch; // Toggle edit mode + if (!editExperienceInResearch) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editExperienceInResearch + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editExperienceInResearch ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class AreaOfExpertise extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const AreaOfExpertise({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _AreaOfExpertiseState createState() => _AreaOfExpertiseState(); +} + +class _AreaOfExpertiseState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0, top: kDefaultPadding), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Area of Expertise :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editAreaOfExpertise, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.areaOfExpertise, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editAreaOfExpertise, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'areaOfExpertise', + maxLines: null, + decoration: const InputDecoration( + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.areaOfExpertise, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.areaOfExpertise = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editAreaOfExpertise = !editAreaOfExpertise; // Toggle edit mode + if (!editAreaOfExpertise) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editAreaOfExpertise + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editAreaOfExpertise ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class BasicPay extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const BasicPay({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _BasicPayState createState() => _BasicPayState(); +} + +class _BasicPayState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Basic Pay :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editbasicpay, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.basicPay.toString(), + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editbasicpay, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'basicPay', + decoration: const InputDecoration( + hintText: '(Tk.)', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.basicPay.toString(), + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.basicPay = double.parse(value ?? '0.0')), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editbasicpay = !editbasicpay; // Toggle edit mode + if (!editbasicpay) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editbasicpay + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editbasicpay ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class SalaryScale extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const SalaryScale({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _SalaryScaleState createState() => _SalaryScaleState(); +} + +class _SalaryScaleState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Salary Scale :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editsalaryscale, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.salaryScale, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editsalaryscale, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'salaryScale', + decoration: const InputDecoration( + hintText: '(Range of Tk.)', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.salaryScale, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.salaryScale = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editsalaryscale = !editsalaryscale; // Toggle edit mode + if (!editsalaryscale) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editsalaryscale + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editsalaryscale ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class InstituteEmail extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const InstituteEmail({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _InstituteEmailState createState() => _InstituteEmailState(); +} + +class _InstituteEmailState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Institute Email :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editinstituteemail, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.instituteEmail, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editinstituteemail, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'instituteEmail', + decoration: const InputDecoration( + hintText: 'example@pstu.ac.bd', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.instituteEmail, + validator: FormBuilderValidators.compose([ + FormBuilderValidators.required(), + FormBuilderValidators.email(), + ]), + onSaved: (value) => (widget.formData.instituteEmail = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editinstituteemail = !editinstituteemail; // Toggle edit mode + if (!editinstituteemail) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editinstituteemail + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editinstituteemail ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class InstituteLocation extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const InstituteLocation({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _InstituteLocationState createState() => _InstituteLocationState(); +} + +class _InstituteLocationState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Institute Location (Office Address):', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editistitutelocation, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.instituteLocation, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editistitutelocation, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'instituteLocation', + maxLines: null, + decoration: const InputDecoration( + hintText: '(Office Address)', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.instituteLocation, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.instituteLocation = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editistitutelocation = !editistitutelocation; // Toggle edit mode + if (!editistitutelocation) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editistitutelocation + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editistitutelocation ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class InstituteName extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const InstituteName({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _InstituteNameState createState() => _InstituteNameState(); +} + +class _InstituteNameState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Institute Name :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editinstituteName, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.instituteName, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editinstituteName, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderDropdown( + name: 'instituteName', + decoration: const InputDecoration( + border: OutlineInputBorder(), + hoverColor: Colors.transparent, + focusColor: Colors.transparent, + hintText: 'Select', + ), + focusColor: Colors.transparent, + validator: FormBuilderValidators.required(), + initialValue: widget.formData.instituteName, + autovalidateMode: AutovalidateMode.onUserInteraction, + items: const [ + DropdownMenuItem( + value: '', + child: Text('Select'), + ), + DropdownMenuItem( + value: 'Patuakhali Science & Technology University (PSTU)', + child: Text('Patuakhali Science & Technology University (PSTU)'), + ), + // Add more DropdownMenuItem as needed with unique values + ], + onChanged: (value) => (widget.formData.instituteName = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editinstituteName = !editinstituteName; // Toggle edit mode + if (!editinstituteName) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + // Change pending user data change to true for re-rendering the Save_changes button + initialUserDataChange = true; + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editinstituteName + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editinstituteName ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class FacultyName extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const FacultyName({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _FacultyNameState createState() => _FacultyNameState(); +} + +class _FacultyNameState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Faculty Name:', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editfacultyname, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.facultyName, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editfacultyname, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderDropdown( + name: 'facultyName', + decoration: const InputDecoration( + hintText: 'Select', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + hint: const Text('Select'), + initialValue: widget.formData.facultyName, + validator: FormBuilderValidators.required(), + items: [ + '', + 'Faculty of Agriculture', + 'Faculty of Computer Science and Engineering', + 'Faculty of Business Administration', + 'Faculty of Animal Science and Veterinary Medicine', + 'Faculty of Fisheries', + 'Faculty of Environmental Science and Disaster Management', + 'Faculty of Nutrition and Food Science', + 'Faculty of Law and Land Administration' + ].map((e) => DropdownMenuItem(value: e, child: Text(e))).toList(), + onSaved: (value) => (widget.formData.facultyName = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editfacultyname = !editfacultyname; // Toggle edit mode + if (!editfacultyname) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editfacultyname + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editfacultyname ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class DepartmentName extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const DepartmentName({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _DepartmentNameState createState() => _DepartmentNameState(); +} + +class _DepartmentNameState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only( + bottom: kDefaultPadding * 2.0, + ), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Department Name :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editdepartmentname, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.departmentName, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editdepartmentname, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderDropdown( + name: 'departmentname', + decoration: const InputDecoration( + border: OutlineInputBorder(), + hoverColor: Colors.transparent, + focusColor: Colors.transparent, + hintText: 'Select', + ), + focusColor: Colors.transparent, + validator: FormBuilderValidators.required(), + initialValue: widget.formData.departmentName, + autovalidateMode: AutovalidateMode.onUserInteraction, + items: [ + '', + 'Department of Computer Science and Information Technology', + 'Department of Computer and Communication Engineering', + 'Department of Electrical and Electronics Engineering', + 'Department of Physics and Mechanical Engineering', + 'Department of Mathematics', + 'Department of Marine Fisheries and Oceanography', + 'Department of Genetics and Animal Breeding', + 'Department of Fisheries Technology', + 'Department of Human Nutrition and Dietetics', + 'Department of Biochemistry and Food Analysis', + 'Department of Environmental Sanitation', + 'Department of Food Microbiology', + 'Department of Food Technology and Engineering', + 'Department of Post Harvest Technology and Marketing', + 'Department of Dairy Science', + 'Department of Animal Products and By-Products Technology', + 'Department of Basic Science', + 'Department of General Animal Science and Animal Nutrition', + 'Department of Microbiology and Public Health', + 'Department of Pathology and Parasitology', + 'Department of Physiology and Pharmacology', + 'Department of Poultry Science', + 'Department of Disaster Risk Management', + 'Department of Law and Land Administration', + 'Department of Anatomy and Histology', + 'Department of Fisheries Biology and Genetics', + 'Department of Aquaculture', + 'Department of Marketing', + 'Department of Management Studies', + 'Department of Language and Communication', + 'Department of Finance and Banking', + 'Department of Economics and Sociology', + 'Department of Agricultural Botany', + 'Department of Accounting and Information Systems', + 'Department of Fisheries Management', + 'Department of Agricultural Chemistry', + 'Department of Disaster Resilience and Engineering', + 'Department of Medicine Surgery and Obstetrics', + 'Department of Agricultural Engineering', + 'Department of Emergency Management', + 'Department of Agricultural Extension and Rural Development', + 'Department of Environmental Science', + 'Department of Geo Information Science and Earth Observation', + 'Department of Agroforestry', + 'Department of Agronomy', + 'Department of Animal Science', + 'Department of Community Health and Hygiene', + 'Department of Biotechnology', + 'Department of Entomology', + 'Department of Genetics and Plant Breeding', + 'Department of Horticulture', + 'Department of Plant Pathology', + 'Department of Soil Science', + 'Department of Statistics', + 'Department of Climate Smart Agricultured', + ].map((e) => DropdownMenuItem(value: e, child: Text(e))).toList(), + onChanged: (value) => (widget.formData.departmentName = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editdepartmentname = !editdepartmentname; // Toggle edit mode + if (!editdepartmentname) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editdepartmentname + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editdepartmentname ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class PositionHeldSince extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const PositionHeldSince({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _PositionHeldSinceState createState() => _PositionHeldSinceState(); +} + +class _PositionHeldSinceState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Position Held Since :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editpositionheldsince, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.positionHeldSince, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editpositionheldsince, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'positionheldsince', + decoration: const InputDecoration( + hintText: '(Year only)', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.positionHeldSince, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.positionHeldSince = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editpositionheldsince = !editpositionheldsince; // Toggle edit mode + if (!editpositionheldsince) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editpositionheldsince + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editpositionheldsince ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class PositionBangla extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const PositionBangla({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _PositionBanglaState createState() => _PositionBanglaState(); +} + +class _PositionBanglaState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Position (Bangla) :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editpositionbangla, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.positionBangla, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editpositionbangla, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'positionbangla', + decoration: const InputDecoration( + hintText: '(Bangla)', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.positionBangla, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.positionBangla = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editpositionbangla = !editpositionbangla; // Toggle edit mode + if (!editpositionbangla) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editpositionbangla + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editpositionbangla ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class PositionEnglish extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const PositionEnglish({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _PositionEnglishState createState() => _PositionEnglishState(); +} + +class _PositionEnglishState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0, top: kDefaultPadding), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Position (English) :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editpositionenglish, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.positionEnglish, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editpositionenglish, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'positionenglish', + decoration: const InputDecoration( + hintText: 'Position (English)', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.positionEnglish, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.positionEnglish = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editpositionenglish = !editpositionenglish; // Toggle edit mode + if (!editpositionenglish) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editpositionenglish + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editpositionenglish ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class Phone extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const Phone({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _PhoneState createState() => _PhoneState(); +} + +class _PhoneState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Phone :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editphone, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.phone, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editphone, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'phone', + decoration: const InputDecoration( + hintText: 'Phone', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.phone, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.phone = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editphone = !editphone; // Toggle edit mode + if (!editphone) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editphone + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editphone ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class Email extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const Email({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _EmailState createState() => _EmailState(); +} + +class _EmailState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Email :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editemail, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.email, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editemail, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'email', + decoration: const InputDecoration( + hintText: 'Email', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.email, + validator: FormBuilderValidators.compose([ + FormBuilderValidators.required(), + FormBuilderValidators.email(), + ]), + onSaved: (value) => (widget.formData.email = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editemail = !editemail; // Toggle edit mode + if (!editemail) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editemail + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editemail ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class DateOfBirth extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const DateOfBirth({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _DateOfBirthState createState() => _DateOfBirthState(); +} + +class _DateOfBirthState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Date of Birth :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editdob, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.dateOfBirth != null && widget.formData.dateOfBirth!.isNotEmpty ? DateFormat("MMMM d, yyyy").format(DateTime.parse(widget.formData.dateOfBirth)) : '', + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editdob, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderDateTimePicker( + name: 'dateOfBirth', + inputType: InputType.date, + decoration: const InputDecoration( + hintText: 'dateOfBirth', + border: OutlineInputBorder(), + ), + // ignore: unnecessary_null_comparison + initialValue: widget.formData.dateOfBirth != null && widget.formData.dateOfBirth!.isNotEmpty ? DateTime.parse(widget.formData.dateOfBirth) : null, + textAlign: TextAlign.center, + format: DateFormat("MMMM d, yyyy"), + validator: FormBuilderValidators.required(), + onSaved: (value) { + if (value != null) { + widget.formData.dateOfBirth = value.toString(); + } else { + widget.formData.dateOfBirth = ''; + } + }, + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editdob = !editdob; // Toggle edit mode + if (!editdob) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editdob + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editdob ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class Gender extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const Gender({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _GenderState createState() => _GenderState(); +} + +class _GenderState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Gender :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editgender, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.gender, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editgender, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderDropdown( + name: 'gender', + decoration: const InputDecoration( + hintText: 'gender', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + hint: const Text('Select'), + initialValue: widget.formData.gender, + validator: FormBuilderValidators.required(), + items: ['Male', 'Female'].map((e) => DropdownMenuItem(value: e, child: Text(e))).toList(), + onSaved: (value) => (widget.formData.gender = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editgender = !editgender; // Toggle edit mode + if (!editgender) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editgender + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editgender ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class FullNameBangla extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const FullNameBangla({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _FullNameBanglaState createState() => _FullNameBanglaState(); +} + +class _FullNameBanglaState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'FullName (Bangla) :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editfullnamebangla, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.fullNameBangla, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editfullnamebangla, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'FullNameBangla', + decoration: const InputDecoration( + hintText: 'FullName (Bangla)', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.fullNameBangla, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.fullNameBangla = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editfullnamebangla = !editfullnamebangla; // Toggle edit mode + if (!editfullnamebangla) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editfullnamebangla + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editfullnamebangla ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class LastName extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const LastName({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _LastNameState createState() => _LastNameState(); +} + +class _LastNameState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only( + bottom: kDefaultPadding * 2.0, + ), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Last Name :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editlastname, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.lastName, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editlastname, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'lastName', + decoration: const InputDecoration( + hintText: 'Last Name', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.lastName, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.lastName = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editlastname = !editlastname; // Toggle edit mode + if (!editlastname) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editlastname + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editlastname ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class FirstName extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const FirstName({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _FirstNameState createState() => _FirstNameState(); +} + +class _FirstNameState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'First Name :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editfirstname, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.firstName, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editfirstname, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'firstName', + decoration: const InputDecoration( + hintText: 'First Name', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.firstName, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.firstName = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editfirstname = !editfirstname; // Toggle edit mode + if (!editfirstname) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editfirstname + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editfirstname ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class Role extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const Role({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _RoleState createState() => _RoleState(); +} + +class _RoleState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Role :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editrole, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.rolename, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editrole, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderDropdown( + name: 'rolename', + decoration: const InputDecoration( + hintText: 'rolename', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + hint: const Text('Select'), + initialValue: widget.formData.rolename, + validator: FormBuilderValidators.required(), + items: ['Admin', 'Researcher', 'Reviewer', 'Teacher', 'Student'].map((e) => DropdownMenuItem(value: e, child: Text(e))).toList(), + onSaved: (value) => (widget.formData.rolename = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editrole = !editrole; // Toggle edit mode + if (!editrole) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editrole + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editrole ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class UserName extends StatefulWidget { + final FormData formData; + final ThemeData themeData; + final Future Function() onDoSave; + + const UserName({ + required this.formData, + Key? key, + required this.themeData, + required this.onDoSave, + }) : super(key: key); + + @override + _UserNameState createState() => _UserNameState(); +} + +class _UserNameState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0, top: kDefaultPadding), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: const Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: 'Username :', + backgroundColor: Color.fromARGB(255, 74, 89, 96), + titleColor: Color.fromARGB(255, 151, 204, 197), + showDivider: false, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + Visibility( + visible: !editusername, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CardHeader( + title: widget.formData.username, + backgroundColor: const Color.fromARGB(255, 51, 55, 56), + titleColor: const Color.fromARGB(255, 238, 216, 221), + showDivider: false, + ), + ], + ), + ), + ), + ), + Visibility( + visible: editusername, + child: SizedBox( + width: ((constraints.maxWidth * 0.55) - (kDefaultPadding * 0.55)), + child: Card( + clipBehavior: Clip.antiAlias, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FormBuilderTextField( + name: 'userName', + decoration: const InputDecoration( + hintText: 'User Name', + border: OutlineInputBorder(), + floatingLabelBehavior: FloatingLabelBehavior.always, + ), + initialValue: widget.formData.username, + validator: FormBuilderValidators.required(), + onSaved: (value) => (widget.formData.username = value ?? ''), + ), + ], + ), + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.10) - (kDefaultPadding * 0.10)), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ElevatedButton( + style: widget.themeData.extension()!.infoOutlined, + onPressed: () { + setState(() { + editusername = !editusername; // Toggle edit mode + if (!editusername) { + // Save changes if transitioning from edit mode to view mode + _formKey.currentState!.validate(); + _formKey.currentState!.save(); + widget.onDoSave(); + } + }); + }, + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(right: kDefaultPadding * 0.5), + child: Icon( + editusername + ? Icons.save_outlined // Change icon based on edit mode + : Icons.mode_edit_outline_outlined, + size: (widget.themeData.textTheme.labelLarge!.fontSize! + 4.0), + ), + ), + Text(editusername ? "Save" : "Edit"), + ], + ), + ), + const SizedBox(height: kDefaultPadding), + ], + ), + ), + ], + ); + }, + ), + ), + ); + } +} + +class ProPicSigSeal extends StatefulWidget { + final FormData formData; + final Function(List?) onProfilePicFileSelected; + final Function(List?) onSealFileSelected; + final Function(List?) onSignatureFileSelected; + + const ProPicSigSeal({required this.formData, required this.onProfilePicFileSelected, required this.onSealFileSelected, required this.onSignatureFileSelected, Key? key}) : super(key: key); + + @override + _ProPicSigSealState createState() => _ProPicSigSealState(); +} + +class _ProPicSigSealState extends State { + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return FormBuilder( + key: _formKey, + autovalidateMode: AutovalidateMode.onUserInteraction, + clearValueOnUnregister: false, + autoFocusOnValidationFailure: true, + onChanged: () { + _formKey.currentState!.save(); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding, top: kDefaultPadding), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: Container( + alignment: Alignment.center, + padding: const EdgeInsets.only(bottom: kDefaultPadding * 1.5), + child: Stack( + children: [ + FutureBuilder( + future: widget.formData.profilePicLocation.isNotEmpty + ? ApiService.downloadFile('profile-pic/download', widget.formData.profilePicLocation) + : ApiService.downloadFile('profile-pic/download', "defaultprofilepic.png"), // Check if value is not empty before making the API call + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const CircularProgressIndicator(); + } else if (snapshot.hasError) { + return Text('Error: ${snapshot.error}'); + } else { + return CircleAvatar( + backgroundColor: Colors.white, + backgroundImage: MemoryImage(base64Decode(snapshot.data!)), // Convert base64 string to image bytes + radius: 60.0, + ); + } + }, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: Container( + alignment: Alignment.center, + padding: const EdgeInsets.only(bottom: kDefaultPadding * 1.5), + child: Stack( + children: [ + FutureBuilder( + future: widget.formData.signatureLocation.isNotEmpty + ? ApiService.downloadFile('signature/download', widget.formData.signatureLocation) + : ApiService.downloadFile('signature/download', "defaultsignature.png"), // Check if value is not empty before making the API call + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const CircularProgressIndicator(); + } else if (snapshot.hasError) { + return Text('Error: ${snapshot.error}'); + } else { + return Image.memory( + base64Decode(snapshot.data!), // Convert base64 string to image bytes + fit: BoxFit.cover, // Adjust image to cover the entire space + // width: 120, // Adjust width as needed + height: 50, // Adjust height as needed + ); + } + }, + ), + ], + ), + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.32) - (kDefaultPadding * 0.32)), + child: Container( + alignment: Alignment.center, + padding: const EdgeInsets.only(bottom: kDefaultPadding * 1.5), + child: Stack( + children: [ + FutureBuilder( + future: widget.formData.sealLocation.isNotEmpty + ? ApiService.downloadFile('seal/download', widget.formData.sealLocation) + : ApiService.downloadFile('seal/download', "defaultseal.png"), // Check if value is not empty before making the API call + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const CircularProgressIndicator(); + } else if (snapshot.hasError) { + return Text('Error: ${snapshot.error}'); + } else { + return Image.memory( + base64Decode(snapshot.data!), // Convert base64 string to image bytes + fit: BoxFit.cover, // Adjust image to cover the entire space + // width: 120, // Adjust width as needed + height: 50, // Adjust height as needed + ); + } + }, + ), + ], + ), + ), + ), + ], + ); + }, + ), + ), + Padding( + padding: const EdgeInsets.only(bottom: kDefaultPadding * 2.0), + child: LayoutBuilder( + builder: (context, constraints) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: FormBuilderFilePicker( + name: 'profilePicLocation', + key: ValueKey(widget.formData.profilePicLocation), // Add this line + allowMultiple: false, + maxFiles: 1, + type: FileType.any, + previewImages: true, + decoration: const InputDecoration( + hintText: 'profilePicLocation', + border: OutlineInputBorder(), + ), + selector: const Row( + children: [ + Icon(Icons.file_upload_rounded), + Text('Update Profile Image'), + ], + ), + onChanged: widget.onProfilePicFileSelected, + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.33) - (kDefaultPadding * 0.33)), + child: FormBuilderFilePicker( + name: 'signatureLocation', + key: ValueKey(widget.formData.signatureLocation), // Add this line + allowMultiple: false, + maxFiles: 1, + type: FileType.any, + previewImages: true, + decoration: const InputDecoration( + hintText: 'signatureLocation', + border: OutlineInputBorder(), + ), + selector: const Row( + children: [ + Icon(Icons.file_upload_rounded), + Text('Update Signature Image'), + ], + ), + onChanged: widget.onSignatureFileSelected, + ), + ), + const SizedBox(width: kDefaultPadding), + SizedBox( + width: ((constraints.maxWidth * 0.32) - (kDefaultPadding * 0.32)), + child: FormBuilderFilePicker( + name: 'sealLocation', + key: ValueKey(widget.formData.sealLocation), // Add this line + allowMultiple: false, + maxFiles: 1, + type: FileType.any, + previewImages: true, + decoration: const InputDecoration( + hintText: 'sealLocation', + border: OutlineInputBorder(), + ), + selector: const Row( + children: [ + Icon(Icons.file_upload_rounded), + Text('Update Seal Image'), + ], + ), + onChanged: widget.onSealFileSelected, + ), + ), + ], + ); + }, + ), + ), + ], + ), + ), + ); + } +} + class FormData { - String userID = ''; + int userId = 0; String roleID = ''; String rolename = '';