From 2b9599ddd1c537539cfcf53adc57007880a4c2a2 Mon Sep 17 00:00:00 2001 From: risadmin_prod Date: Sat, 12 Apr 2025 10:59:48 +0000 Subject: [PATCH] build_app --- .../Builders/Services/BuilderService.java | 3 + .../Controllers/Emp_detailsController.java | 299 +++ .../realnet/vpspack/Entity/Emp_details.java | 150 ++ .../Repository/Emp_detailsRepository.java | 80 + .../vpspack/Services/Emp_detailsService.java | 354 +++ .../authsec_mysql/mysql/wf_table/wf_table.sql | 2 + .../Emp_details_api_service.dart | 184 ++ .../Emp_details_create_entity_screen.dart | 1963 +++++++++++++++++ .../Emp_details_entity_list_screen.dart | 1364 ++++++++++++ .../Emp_details_update_entity_screen.dart | 1115 ++++++++++ .../Emp_details_repo_screen.dart | 154 ++ .../Emp_details_view_model_screen.dart | 366 +++ .../lib/commans/widgets/custome_drawer.dart | 156 +- 13 files changed, 6122 insertions(+), 68 deletions(-) create mode 100644 testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Controllers/Emp_detailsController.java create mode 100644 testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Entity/Emp_details.java create mode 100644 testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Repository/Emp_detailsRepository.java create mode 100644 testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Services/Emp_detailsService.java create mode 100755 testingflutter103-db-d/authsec_mysql/mysql/wf_table/wf_table.sql create mode 100644 testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_api_service.dart create mode 100644 testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_create_entity_screen.dart create mode 100644 testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_entity_list_screen.dart create mode 100644 testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_update_entity_screen.dart create mode 100644 testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_details_Repo/Emp_details_repo_screen.dart create mode 100644 testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_details_viewModel/Emp_details_view_model_screen.dart diff --git a/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java b/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java index 11edc5f..1724d70 100644 --- a/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java +++ b/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java @@ -69,6 +69,9 @@ public class BuilderService { executeDump(true); // ADD OTHER SERVICE +addCustomMenu( "Emp_details", "Transcations"); + + System.out.println("dashboard and menu inserted..."); diff --git a/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Controllers/Emp_detailsController.java b/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Controllers/Emp_detailsController.java new file mode 100644 index 0000000..82d3f67 --- /dev/null +++ b/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Controllers/Emp_detailsController.java @@ -0,0 +1,299 @@ +package com.realnet.vpspack.Controllers; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.core.JsonProcessingException; +import org.springframework.web.bind.annotation.CrossOrigin; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.realnet.config.EmailService; +import com.realnet.users.entity1.AppUser; +import com.realnet.users.service1.AppUserServiceImpl; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.data.domain.*; +import com.realnet.fnd.response.EntityResponse; +import org.springframework.http.*; +import org.springframework.beans.factory.annotation.*; +import com.realnet.vpspack.Entity.Emp_details; +import com.realnet.vpspack.Services.Emp_detailsService ; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +@RequestMapping(value = "/Emp_details") + @CrossOrigin("*") +@RestController +public class Emp_detailsController { + @Autowired + private Emp_detailsService Service; + +@Value("${projectPath}") + private String projectPath; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @PostMapping("/Emp_details") + public Emp_details Savedata(@RequestBody Emp_details data) { + Emp_details save = Service.Savedata(data) ; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + System.out.println("data saved..." + save); + + return save; + } +@PutMapping("/Emp_details/{id}") + public Emp_details update(@RequestBody Emp_details data,@PathVariable Integer id ) { + Emp_details update = Service.update(data,id); + System.out.println("data update..." + update); + return update; + } +// get all with pagination + @GetMapping("/Emp_details/getall/page") + public Page getall(@RequestParam(value = "page", required = false) Integer page, + @RequestParam(value = "size", required = false) Integer size) { + Pageable paging = PageRequest.of(page, size); + Page get = Service.getAllWithPagination(paging); + + return get; + + } + @GetMapping("/Emp_details") + public List getdetails() { + List get = Service.getdetails(); + return get; +} +// get all without authentication + + @GetMapping("/token/Emp_details") + public List getallwioutsec() { + List get = Service.getdetails(); + return get; +} +@GetMapping("/Emp_details/{id}") + public Emp_details getdetailsbyId(@PathVariable Integer id ) { + Emp_details get = Service.getdetailsbyId(id); + return get; + } +@DeleteMapping("/Emp_details/{id}") + public ResponseEntity delete_by_id(@PathVariable Integer id ) { + Service.delete_by_id(id); + return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); + + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} \ No newline at end of file diff --git a/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Entity/Emp_details.java b/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Entity/Emp_details.java new file mode 100644 index 0000000..0839801 --- /dev/null +++ b/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Entity/Emp_details.java @@ -0,0 +1,150 @@ +package com.realnet.vpspack.Entity; + import lombok.*; +import com.realnet.WhoColumn.Entity.Extension; + import javax.persistence.*; + import java.time.LocalDateTime; + import java.util.*; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @Entity + @Data + public class Emp_details extends Extension { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + +private String first_name; + +private int numbera; + + private String phone_number; + + +@Column(length = 2000) +private String paragraph_field; + +private String password_field; +@Transient +private String confirmpassword_field; + +@Column(length = 2000) +private String textarea_field; + +private String date_field; + +private String datetime_field; + +private String email_field; + +private boolean toggle_switch; + +private String url_field; + +private int decimal_field; + +private int percentage_field; + +private String recaptcha; + +private String documentsequence; + +private String selectsta; + + private String radios; + + + + +private boolean q; + + + +private boolean b; + + + +private String fileupload_fieldname; +private String fileupload_fieldpath ; + +private String imageupload_fieldname; +private String imageupload_fieldpath ; + +private String audio_fieldname; +private String audio_fieldpath ; + +private String video_fieldname; +private String video_fieldpath ; + +private String survey_form; + +private String currency; + +private String qrcode_field; + +private String barcode_field; + +private int numberb; + +private String calculatedadd; + + +} diff --git a/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Repository/Emp_detailsRepository.java b/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Repository/Emp_detailsRepository.java new file mode 100644 index 0000000..1e23c5c --- /dev/null +++ b/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Repository/Emp_detailsRepository.java @@ -0,0 +1,80 @@ +package com.realnet.vpspack.Repository; + + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import org.springframework.stereotype.Repository; +import java.util.*; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +import com.realnet.vpspack.Entity.Emp_details; + +@Repository +public interface Emp_detailsRepository extends JpaRepository { + +@Query(value = "select * from emp_details where created_by=?1", nativeQuery = true) + List findAll(Long creayedBy); + +@Query(value = "select * from emp_details where created_by=?1", nativeQuery = true) + Page findAll(Pageable page, Long creayedBy); +} \ No newline at end of file diff --git a/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Services/Emp_detailsService.java b/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Services/Emp_detailsService.java new file mode 100644 index 0000000..d5c6e30 --- /dev/null +++ b/testingflutter103-back-b/authsec_springboot/backend/src/main/java/com/realnet/vpspack/Services/Emp_detailsService.java @@ -0,0 +1,354 @@ +package com.realnet.vpspack.Services; +import com.realnet.vpspack.Repository.Emp_detailsRepository; +import com.realnet.vpspack.Entity.Emp_details +;import java.util.*; + +import org.springframework.beans.factory.annotation.Autowired; +import com.realnet.SequenceGenerator.Service.SequenceService; +import org.springframework.data.domain.Page; +import com.realnet.realm.Entity.Realm; +import com.realnet.realm.Services.RealmService; +import org.springframework.data.domain.Pageable; +import org.springframework.http.*; +import com.realnet.users.service1.AppUserServiceImpl; +import com.realnet.users.entity1.AppUser; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + import org.springframework.stereotype.Service; + +@Service + public class Emp_detailsService { +@Autowired +private Emp_detailsRepository Repository; + @Autowired + private AppUserServiceImpl userService; +@Autowired + private RealmService realmService; + + + + + + + + + + + + + + + + + + + + + + + + + + + +@Autowired + private SequenceService documentsequencesequenceService; + + + + + + + + + + + + + + + + + + + + + + + + + + + +public Emp_details Savedata(Emp_details data) { + + + + + + + + + + + + + + + + + + + + + + + + + + + + +data.setDocumentsequence (documentsequencesequenceService.GenerateSequence("aa")); + + + + + + + + + + + + + + + + + + + + + + + + + + + + data.setUpdatedBy(getUser().getUserId()); + data.setCreatedBy(getUser().getUserId()); + data.setAccountId(getUser().getAccount().getAccount_id()); +Emp_details save = Repository.save(data); + return save; + } + + +// get all with pagination + public Page getAllWithPagination(Pageable page) { + return Repository.findAll(page, getUser().getUserId()); + } +public List getdetails() { + List realm = realmService.findByUserId(getUser().getUserId()); +List all = Repository.findAll(getUser().getUserId()); + + return all ; } + + +public Emp_details getdetailsbyId(Integer id) { + return Repository.findById(id).get(); + } + + + public void delete_by_id(Integer id) { + Repository.deleteById(id); +} + + +public Emp_details update(Emp_details data,Integer id) { + Emp_details old = Repository.findById(id).get(); +old.setFirst_name(data.getFirst_name()); + +old.setNumbera(data.getNumbera()); + +old.setPhone_number(data.getPhone_number()); + +old.setParagraph_field(data.getParagraph_field()); + +old.setPassword_field(data.getPassword_field()); + +old.setTextarea_field(data.getTextarea_field()); + +old.setDate_field(data.getDate_field()); + +old.setDatetime_field(data.getDatetime_field()); + +old.setEmail_field(data.getEmail_field()); + +old.setToggle_switch (data.isToggle_switch()); + +old.setUrl_field(data.getUrl_field()); + +old.setDecimal_field(data.getDecimal_field()); + +old.setPercentage_field(data.getPercentage_field()); + +old.setRecaptcha(data.getRecaptcha()); + +old.setDocumentsequence(data.getDocumentsequence()); + +old.setSelectsta(data.getSelectsta()); + +old.setRadios(data.getRadios()); + + + +old.setQ(data.isQ()); + + + +old.setB(data.isB()); + + + + + + + + + + + + + +old.setSurvey_form(data.getSurvey_form()); + +old.setCurrency(data.getCurrency()); + +old.setQrcode_field(data.getQrcode_field()); + +old.setBarcode_field(data.getBarcode_field()); + +old.setNumberb(data.getNumberb()); + +old.setCalculatedadd(data.getCalculatedadd()); + +final Emp_details test = Repository.save(old); + data.setUpdatedBy(getUser().getUserId()); + return test;} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + public AppUser getUser() { + AppUser user = userService.getLoggedInUser(); + return user; + + }} diff --git a/testingflutter103-db-d/authsec_mysql/mysql/wf_table/wf_table.sql b/testingflutter103-db-d/authsec_mysql/mysql/wf_table/wf_table.sql new file mode 100755 index 0000000..b9c2dbe --- /dev/null +++ b/testingflutter103-db-d/authsec_mysql/mysql/wf_table/wf_table.sql @@ -0,0 +1,2 @@ +CREATE TABLE db.Emp_details(id BIGINT NOT NULL AUTO_INCREMENT, video_field VARCHAR(400), b bit(1), qrcode_field VARCHAR(400), datetime_field VARCHAR(400), phone_number VARCHAR(400), radios VARCHAR(400), fileupload_field VARCHAR(400), q bit(1), textarea_field VARCHAR(400), currency VARCHAR(400), recaptcha VARCHAR(400), date_field Date, selectsta VARCHAR(400), barcode_field VARCHAR(400), numberb int, first_name VARCHAR(400), numbera int, toggle_switch VARCHAR(400), percentage_field int, email_field VARCHAR(400), calculatedadd VARCHAR(400), url_field VARCHAR(400), survey_form VARCHAR(400), paragraph_field VARCHAR(400), imageupload_field VARCHAR(400), audio_field VARCHAR(400), password_field VARCHAR(400), decimal_field int, documentsequence VARCHAR(400), PRIMARY KEY (id)); + diff --git a/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_api_service.dart b/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_api_service.dart new file mode 100644 index 0000000..ce6f9aa --- /dev/null +++ b/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_api_service.dart @@ -0,0 +1,184 @@ +import 'dart:typed_data'; +import 'package:dio/dio.dart'; +import 'package:http_parser/http_parser.dart'; +import '../../../../resources/api_constants.dart'; +import '../../../../data/network/base_network_service.dart'; +import '../../../../data/network/network_api_service.dart'; + +class emp_detailsApiService { + final String baseUrl = ApiConstants.baseUrl; + + final BaseNetworkService _helper = NetworkApiService(); + + + + Future>> getEntities() async { + + try { + final response = await _helper.getGetApiResponse('$baseUrl/Emp_details/Emp_details'); + final entities = (response as List).cast>(); + return entities; + } catch (e) { + throw Exception('Failed to get all entities: $e'); + } + } +Future>> getAllWithPagination( + int page, int size) async { + try { + final response = + await _helper.getGetApiResponse('$baseUrl/Emp_details/Emp_details/getall/page?page=$page&size=$size'); + final entities = + (response['content'] as List).cast>(); + return entities; + } catch (e) { + throw Exception('Failed to get all without pagination: $e'); + } + } + Future> createEntity( + Map entity) async { + try { + print("in post api$entity"); + final response = + await _helper.getPostApiResponse('$baseUrl/Emp_details/Emp_details', entity); + + print(entity); + + // Assuming the response is a Map + Map responseData = response; + + return responseData; + } catch (e) { + throw Exception('Failed to create entity: $e'); + } + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Future updateEntity( int entityId, Map entity) async { + try { + await _helper.getPutApiResponse('$baseUrl/Emp_details/Emp_details/$entityId', + entity); print(entity); + + } catch (e) { + throw Exception('Failed to update entity: $e'); + } + } + + Future deleteEntity( int entityId) async { + try { + await _helper.getDeleteApiResponse('$baseUrl/Emp_details/Emp_details/$entityId'); + } catch (e) { + throw Exception('Failed to delete entity: $e'); + } + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} \ No newline at end of file diff --git a/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_create_entity_screen.dart b/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_create_entity_screen.dart new file mode 100644 index 0000000..8fec8fa --- /dev/null +++ b/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_create_entity_screen.dart @@ -0,0 +1,1963 @@ +// ignore_for_file: use_build_context_synchronously +import 'dart:convert'; +import 'package:flutter/material.dart'; +import 'package:file_picker/file_picker.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:provider/provider.dart'; +import '../Emp_details_viewModel/Emp_details_view_model_screen.dart'; +import '../../../../utils/image_constant.dart'; +import '../../../../utils/size_utils.dart'; +import '../../../../theme/app_style.dart'; +import '../../../../widgets/app_bar/appbar_image.dart'; +import '../../../../widgets/app_bar/appbar_title.dart'; +import '../../../../widgets/app_bar/custom_app_bar.dart'; +import '../../../../widgets/custom_button.dart'; +import '../../../../widgets/custom_text_form_field.dart'; +import '../../../../widgets/custom_dropdown_field.dart'; +import 'dart:math'; +import 'package:qr_flutter/qr_flutter.dart'; +import 'package:barcode_widget/barcode_widget.dart'; +import 'package:intl/intl.dart'; + +import 'package:autocomplete_textfield/autocomplete_textfield.dart'; +import 'package:http/http.dart' as http; +import 'package:flutter/services.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import '../../../../Reuseable/reusable_date_picker_field.dart'; +import '../../../../Reuseable/reusable_date_time_picker_field.dart' +;import 'package:multi_select_flutter/multi_select_flutter.dart'; +import 'package:just_audio/just_audio.dart'; +import 'package:video_player/video_player.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:lottie/lottie.dart'; +import '../../../../utils/toast_messages/toast_message_util.dart'; +import 'dart:io'; +import '../../../../Reuseable/reusable_text_field.dart'; +import '../../../../Reuseable/reusable_dropdown_field.dart'; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +class emp_detailsCreateEntityScreen extends StatefulWidget { + const emp_detailsCreateEntityScreen({super.key}); + + @override + _emp_detailsCreateEntityScreenState createState() => _emp_detailsCreateEntityScreenState(); +} + +class _emp_detailsCreateEntityScreenState extends State { + +final Map formData = {}; + final _formKey = GlobalKey(); + final TextEditingController first_nameController = TextEditingController(); + + + final TextEditingController numberaController = TextEditingController(); + + + final TextEditingController phone_numberController = TextEditingController(); + + + final TextEditingController paragraph_fieldController = TextEditingController(); + + + + bool _passwordVisiblepassword_field = false; + bool _isPasswordValidpassword_field = true; + bool _doPasswordsMatchpassword_field = true; + + String _passwordpassword_field = ''; // To store the first password + + void _validatePasswordpassword_field(String password) { + setState(() { + _isPasswordValidpassword_field = password.isNotEmpty; + _passwordpassword_field = password; // Store the password for later comparison + _doPasswordsMatchpassword_field = true; // Reset match flag on new input + }); + } + + void _validateConfirmPasswordpassword_field(String confirmPassword) { + setState(() { + _doPasswordsMatchpassword_field = confirmPassword == _passwordpassword_field; + }); + } + + final TextEditingController textarea_fieldController = TextEditingController(); + + +TextEditingController date_field = TextEditingController(); + + DateTime selectedDatedate_field = DateTime.now(); + Future _selectDatedate_field(BuildContext context) async { + final DateTime? picked = await showDatePicker( + context: context, + initialDate: selectedDatedate_field, + firstDate: DateTime(2000), + lastDate: DateTime(2101), + ); + if (picked != null && picked != selectedDatedate_field) { + setState(() { + selectedDatedate_field = picked; + }); + } + } + + + final TextEditingController datetime_fieldController = TextEditingController(); + + + bool _isemail_fieldEmailValid = true; + void _validateemail_fieldEmail(String email) { + setState(() { + _isemail_fieldEmailValid = RegExp(r'^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$').hasMatch(email); + }); + } + + +bool _isSwitchedtoggle_switch = false; +bool toggle_switch = false; + +void _toggleSwitchtoggle_switch(bool value) { + setState(() { + _isSwitchedtoggle_switch = value; + }); +} + + bool _isUrlValidurl_field = true; + void _validateUrlurl_field(String url) { + setState(() { + _isUrlValidurl_field = Uri.parse(url).isAbsolute; + }); + } + + + final TextEditingController decimal_fieldController = TextEditingController(); + + + final TextEditingController percentage_fieldController = TextEditingController(); + + +late String recaptchacaptcha; + TextEditingController _recaptchaController = TextEditingController(); + final GlobalKey _recaptchascaffoldKey = GlobalKey(); +void generaterecaptchaCaptcha() { + final random = Random(); + const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'; + recaptchacaptcha = String.fromCharCodes(Iterable.generate( + 6, (_) => chars.codeUnitAt(random.nextInt(chars.length)))); + } + + void verifyrecaptchaCaptcha() { + print("Verifying captcha"); + if (_recaptchaController.text.isEmpty) { + print("recaptcha is empty"); + recaptchaSnackbar('Please enter CAPTCHA', success: false); + } else if (_recaptchaController.text != recaptchacaptcha) { + print("captcha is not matching"); + recaptchaSnackbar('CAPTCHA verification failed', success: false); + } else { + print("captcha is verified"); + recaptchaSnackbar('CAPTCHA Verified', success: true); + // Navigate to another screen after verification + // Example navigation to a new screen + // Navigator.push( + // context, + // MaterialPageRoute(builder: (context) => NextScreen()), + // ); + } + } + + void recaptchaSnackbar(String message, {required bool success}) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(message), + backgroundColor: success ? Colors.green : Colors.red, + ), + ); + } + + + + + String? dropdownValueselectsta; + List staticOptionsselectsta = [ + + +'bar_code', + + + +'qr_code', + + +]; + +Widget _buildDropdownselectsta(String label, List options, String? value, void Function(String?) onChanged) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: DropdownButtonFormField( + decoration: InputDecoration(labelText: label, + border: OutlineInputBorder(), +), + value: value, + onChanged: onChanged, + items: options.map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + ), + ); + } + + String? selectedradios; + + Future _showradiosSelectionDialog(BuildContext context) async { + final result = await showDialog( + context: context, + builder: (BuildContext context) { + return SimpleDialog( + title: const Text('Select radios'), + children: [ + + + RadioListTile( + title: const Text('bar_code'), + value: 'bar_code', + groupValue: selectedradios, + onChanged: (value) { + setState(() { + selectedradios = value; + Navigator.pop(context, value); + }); + }, + ), + + + + RadioListTile( + title: const Text('qr_code'), + value: 'qr_code', + groupValue: selectedradios, + onChanged: (value) { + setState(() { + selectedradios = value; + Navigator.pop(context, value); + }); + }, + ), + + + + ], + ); + }, + ); + + if (result != null) { + setState(() { + selectedradios = result; + }); + } + } + + + + + bool qcBox = false; + + + + + bool bcBox = false; + + + + List> selectedfileupload_field = []; + + Future _pickfileupload_field(Map newFile, StateSetter setState) async { + FilePickerResult? result = await FilePicker.platform.pickFiles(); + + if (result != null) { + setState(() { + newFile['fileBytes'] = result.files.first.bytes; + newFile['fileFileName'] = result.files.first.name; + }); + ToastMessageUtil.showToast( + message: "File Uploaded", + toastType: ToastType.success); + } else { + print("No files selected"); + } + } + + Widget _fileupload_fieldbuildUploadRow(Map newFile) { + return StatefulBuilder(builder: (context, setState) { + String? selectedFileName = newFile['fileFileName']; + return Card( + margin: const EdgeInsets.symmetric(vertical: 8.0), + child: ListTile( + leading: Icon(Icons.file_copy, color: Colors.blueAccent), + title: Text(selectedFileName ?? 'No file selected', style: TextStyle(color: Colors.grey[700])), + trailing: ElevatedButton( + onPressed: () => _pickfileupload_field(newFile, setState), + child: const Text('Select File'), + ), + ), + ); + }); + } + + void _addfileupload_fieldUploadRow() { + Map newFile = {}; + setState(() { + selectedfileupload_field.add(newFile); + }); + } + + void _removefileupload_fieldUploadRow(int index) { + setState(() { + selectedfileupload_field.removeAt(index); + }); + } + + Future _uploadfileupload_field(int entityId) async { + // Check if selectedfileupload_field is null or empty + if (selectedfileupload_field == null || selectedfileupload_field.isEmpty) { + print("No files selected for upload."); + return; + } + + final provider = Provider.of(context, listen: false); + + for (var selectedfile in selectedfileupload_field) { + // Ensure selectedfile is not null and has valid data + if (selectedfile == null || + selectedfile['fileFileName'] == null || + selectedfile['fileBytes'] == null) { + print("Skipping a file due to missing data: $selectedfile"); + continue; // Skip this iteration + } + + try { + await provider.uploadfileupload_field( + entityId.toString(), + 'Emp_details', + selectedfile['fileFileName'], + selectedfile['fileBytes'], + ); + print("File uploaded successfully: ${selectedfile['fileFileName']}"); + } catch (e) { + print("Failed to upload file: ${selectedfile['fileFileName']} - Error: $e"); + } + } +} + + + List> selectedimageupload_field = []; + + Future _showimageupload_fieldImage(Map newImage, StateSetter setState) async { + final ImagePicker picker = ImagePicker(); + + // Show a dialog to choose the source + final ImageSource? source = await showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + title: const Text('Select Image Source'), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(ImageSource.camera), + child: const Text('Camera'), + ), + TextButton( + onPressed: () => Navigator.of(context).pop(ImageSource.gallery), + child: const Text('Gallery'), + ), + ], + ), + ); + + if (source != null) { + final XFile? pickedImage = await picker.pickImage(source: source); + + if (pickedImage != null) { + Uint8List imageBytes = await pickedImage.readAsBytes(); + setState(() { + newImage['imageBytes'] = imageBytes; + newImage['imageFileName'] = pickedImage.name; + }); + ToastMessageUtil.showToast( + message: "File Uploaded", + toastType: ToastType.success); + } else { + print("No image selected"); + } + } + } + + Widget _buildUploadRowimageupload_field(Map newImage) { + return StatefulBuilder(builder: (context, setState) { + String? selectedFileName = newImage['imageFileName']; + Uint8List? imageBytes = newImage['imageBytes']; + return Card( + margin: const EdgeInsets.symmetric(vertical: 8.0), + child: ListTile( + leading: imageBytes != null + ? Image.memory(imageBytes, width: 50, height: 50, fit: BoxFit.cover) + : Icon(Icons.image, color: Colors.blueAccent), + title: Text(selectedFileName ?? 'No image selected', style: TextStyle(color: Colors.grey[700])), + trailing: ElevatedButton( + onPressed: () => _showimageupload_fieldImage(newImage, setState), + child: const Text('Select Image'), + ), + ), + ); + }); + } + + void _addUploadRowimageupload_field() { + Map newImage = {}; + setState(() { + selectedimageupload_field.add(newImage); + }); + } + + void _removeUploadRowimageupload_field(int index) { + setState(() { + selectedimageupload_field.removeAt(index); + }); + } + + Future _uploadimageupload_field(int entityId) async { + + // Check if the selectedimageupload_field list is null or empty + if (selectedimageupload_field == null || + selectedimageupload_field.isEmpty) { + print("No images selected for upload."); + return; + } +final provider = + Provider.of(context, listen: false); + for (var selectedImage in selectedimageupload_field) { + if (selectedImage == null || + selectedImage['imageFileName'] == null || + selectedImage['imageBytes'] == null) { + print("Skipping an image due to missing data: $selectedImage"); + continue; // Skip this iteration + } + + try { + + await provider.uploadimageupload_field( + entityId.toString(), + 'Emp_details', + selectedImage['imageFileName'], + selectedImage['imageBytes'], + ); + print("Image uploaded successfully: ${selectedImage['imageFileName']}"); + } catch (e) { + print( + "Failed to upload image: ${selectedImage['imageFileName']} - Error: $e"); + } + } + } + + AudioPlayer _audioPlayeraudio_field = AudioPlayer(); + String? _filePathaudio_field; + String? _fileNameaudio_field; + bool _isPlayingaudio_field = false; + Duration _durationaudio_field = Duration(); + Duration _positionaudio_field = Duration(); + + Future _pickAudioaudio_field() async { + FilePickerResult? result = await FilePicker.platform.pickFiles(type: FileType.audio); + + if (result != null) { + setState(() { + _filePathaudio_field = result.files.single.path; + _fileNameaudio_field = result.files.single.name; + }); + await _audioPlayeraudio_field.setFilePath(_filePathaudio_field!); + _playPauseAudioaudio_field(); + } + } + + void _playPauseAudioaudio_field() { + if (_isPlayingaudio_field) { + _audioPlayeraudio_field.pause(); + } else { + _audioPlayeraudio_field.play(); + } + setState(() { + _isPlayingaudio_field = !_isPlayingaudio_field; + }); + } + void _stopAudioaudio_field() { + _audioPlayeraudio_field.stop(); + setState(() { + _isPlayingaudio_field = false; + _positionaudio_field = Duration(seconds: 0); + }); + } + + void _seekAudioaudio_field(Duration position) { + _audioPlayeraudio_field.seek(position); + } + + Future _uploadaudio_field(int entityId) async { + + try { + // Check if the file path and file name are available + if (_filePathaudio_field == null ) { + print('No file selected for upload.'); + return; + } + // Read the file as bytes + Uint8List fileBytes = await File(_filePathaudio_field!).readAsBytes(); + String fileName = _fileNameaudio_field!; + final provider = Provider.of(context, listen: false); + + await provider.uploadaudio_field( + + + entityId.toString(), + 'Emp_details', + fileName, + fileBytes, + ); + print('Audio uploaded successfully'); + + } catch (error) { + print('Error uploading video: $error'); + } + } + + VideoPlayerController? _controllervideo_field; + final ImagePicker _pickervideo_field = ImagePicker(); + bool _isPlayingvideo_field = false; + bool _isFullScreenvideo_field = false; + bool _showControlsvideo_field = true; + + XFile? pickedFilevideo_field; + + Future _pickVideovideo_field() async { + pickedFilevideo_field = await _pickervideo_field.pickVideo(source: ImageSource.gallery); + + if (pickedFilevideo_field != null) { + _controllervideo_field = VideoPlayerController.file(File(pickedFilevideo_field!.path)) + ..initialize().then((_) { + setState(() {}); + _controllervideo_field!.play(); + _isPlayingvideo_field = true; + }); + } + } + + void _playPauseVideovideo_field() { + if (_controllervideo_field != null && _controllervideo_field!.value.isInitialized) { + setState(() { + if (_controllervideo_field!.value.isPlaying) { + _controllervideo_field!.pause(); + _isPlayingvideo_field = false; + } else { + _controllervideo_field!.play(); + _isPlayingvideo_field = true; + } + }); + } + } + + void _skipForwardvideo_field() { + if (_controllervideo_field != null && _controllervideo_field!.value.isInitialized) { + final position = _controllervideo_field!.value.position; + final duration = _controllervideo_field!.value.duration; + if (position != null && duration != null) { + final newPosition = position + const Duration(seconds: 10); + _controllervideo_field!.seekTo(newPosition > duration ? duration : newPosition); + } + } + } + + void _skipBackwardvideo_field() { + if (_controllervideo_field != null && _controllervideo_field!.value.isInitialized) { + final position = _controllervideo_field!.value.position; + if (position != null) { + final newPosition = position - const Duration(seconds: 10); + _controllervideo_field!.seekTo(newPosition < const Duration(seconds: 0) + ? const Duration(seconds: 0) + : newPosition); + } + } + } + + void _toggleFullScreenvideo_field() { + setState(() { + _isFullScreenvideo_field = !_isFullScreenvideo_field; + }); + } + +Future _uploadvideo_field(int entityId) async { + try { + // Check if a file is selected + if (pickedFilevideo_field == null) { + print('No file selected for upload.'); + return; + } + + // Extract file path and name safely + String filePath = pickedFilevideo_field!.path; + String fileName = pickedFilevideo_field!.name; + + // Ensure file exists before reading + File file = File(filePath); + if (!await file.exists()) { + print('File not found at path: $filePath'); + return; + } + + // Read the file as bytes safely + Uint8List? fileBytes; + try { + fileBytes = await file.readAsBytes(); + } catch (e) { + print('Error reading file: $e'); + return; + } + + // Ensure fileBytes is not empty + if (fileBytes.isEmpty) { + print('File is empty, upload aborted.'); + return; + } + + // Get the provider instance safely + final provider = Provider.of(context, listen: false); + + // Upload the file + await provider.uploadvideo_field( + entityId.toString(), + 'Emp_details', + fileName, + fileBytes, + ); + + print('Video uploaded successfully: $fileName'); + } catch (error) { + print('Error uploading Video: $error'); + } +} + + +var survey_formanswers; + +String inputValuecurrency = ''; +String outputValuecurrency = ''; + +void _convertCurrency_currency() { + String inputText = inputValuecurrency.replaceAll(',', ''); // Remove commas + try { + double parsedValue = double.parse(inputText); // Parse the value + String formattedValue = + parsedValue.toStringAsFixed(2); // Format to 2 decimal places + setState(() { + outputValuecurrency = formattedValue; + }); + } catch (e) { + setState(() { + outputValuecurrency = "Invalid input"; + }); + } +} + + + String inputDataqrcode_field = 'Hello QR!'; // Default data for QR code generation + TextEditingController controllerInputqrcode_field = TextEditingController(); + + String inputDatabarcode_field = 'Hello BarCode'; // By default barcode + TextEditingController controllerInputbarcode_field = TextEditingController(); + + final TextEditingController numberbController = TextEditingController(); + + + + + String calculatedaddOperator = '+'; + String calculatedaddresult = ''; + + final List calculatedaddoperators = ['+', '-', '*', '/']; + + void calculatecalculatedaddResult() { + int calculation; + switch (calculatedaddOperator) { + case '+': + calculation = + + +int.parse(numberaController.text) + + + + + +int.parse(numberbController.text) + + + + +0; + + + break; + case '-': + calculation = + + +int.parse(numberaController.text) - + + + +int.parse(numberbController.text) - + + +0; + break; + case '*': + calculation = + + +int.parse(numberaController.text) * + + + +int.parse(numberbController.text) * + + +1; + break; + case '/': + if ( + + +int.parse(numberaController.text)== 0 || + + + +int.parse(numberbController.text)== 0 || + + + + +1 != 1) { + calculatedaddresult = 'Division by zero error'; + return; + } + calculation = ( + + +int.parse(numberaController.text) / + + + +int.parse(numberbController.text) / + + + +1).toInt(); + break; + default: + calculation = 0; + } + setState(() { + calculatedaddresult = 'Result: $calculation'; + }); + } + + @override + void initState() { + super.initState(); + final provider = Provider.of(context, listen: false); + + + + + + + + + + + + + + + + + + + + + + + + + + + generaterecaptchaCaptcha(); + + + + + + + + + + + + + +_audioPlayeraudio_field.durationStream.listen((Duration? d) { + setState(() { + _durationaudio_field = d ?? Duration.zero; + }); + }); + + + _audioPlayeraudio_field.positionStream.listen((Duration p) { + setState(() { + _positionaudio_field = p; + }); + }); + + _audioPlayeraudio_field.playerStateStream.listen((PlayerState state) { + if (state.processingState == ProcessingState.completed) { + setState(() { + _isPlayingaudio_field = false; + _positionaudio_field = Duration(seconds: 0); + }); + } + }); + + + + + + + +controllerInputqrcode_field.text = inputDataqrcode_field; + + controllerInputbarcode_field.text = inputDatabarcode_field; + + + + + +} + + + + @override + Widget build(BuildContext context) { + final provider = Provider.of(context, listen: false); + return Scaffold( + appBar: CustomAppBar( + height: getVerticalSize(49), + leadingWidth: 40, + leading: AppbarImage( + height: getSize(24), + width: getSize(24), + svgPath: ImageConstant.imgArrowleftBlueGray900, + margin: getMargin(left: 16, top: 12, bottom: 13), + onTap: () { + Navigator.pop(context); + }), + centerTitle: true, + title: AppbarTitle(text: "Create Emp_details"), + actions: [ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +], + ), + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16), + child: Form( + key: _formKey, + child: Column( + children: [ + ReusableTextField( + controller: first_nameController, + + onSaved:(value) => formData['first_name'] = value , + label:"Enter First name", + // ValidationProperties +), + + SizedBox(height: 16), + + +ReusableTextField( + controller: numberaController, + + onSaved:(value) => formData['numbera'] = value , + label: "Enter Numbera", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))), + ], + // ValidationProperties +), + +SizedBox(height: 16), + +ReusableTextField( + onSaved:(value) => formData['phone_number'] = value , + label: "Enter Phone Number", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, +LengthLimitingTextInputFormatter( + 10), // Limit input to 10 digits + ], + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter Phone Number'; + } + if (value.length != 10) { + return 'Phone number must be exactly 10 digits'; + } + return null; + }, + ), + +ReusableTextField( + controller: paragraph_fieldController, + + onSaved:(value) => formData['paragraph_field'] = value , + label: "Enter Paragraph Field", + maxLines: 5, + + ), + +TextFormField( + obscureText: !_passwordVisiblepassword_field, + decoration: InputDecoration( + labelText: 'Password Field', + suffixIcon: IconButton( + icon: Icon( + _passwordVisiblepassword_field + ? Icons.visibility + : Icons.visibility_off, + ), + onPressed: () { + setState(() { + _passwordVisiblepassword_field = !_passwordVisiblepassword_field; + }); + }, + ), + errorText: + _isPasswordValidpassword_field ? null : 'Please enter a password', + border: OutlineInputBorder(), + ), + onSaved: (value) => formData['password_field'] = value, + onChanged: _validatePasswordpassword_field, + ), + const SizedBox(height: 16), + TextFormField( + obscureText: !_passwordVisiblepassword_field, + decoration: InputDecoration( + labelText: 'Confirm Password Field', + suffixIcon: IconButton( + icon: Icon( + _passwordVisiblepassword_field + ? Icons.visibility + : Icons.visibility_off, + ), + onPressed: () { + setState(() { + _passwordVisiblepassword_field = !_passwordVisiblepassword_field; + }); + }, + ), + errorText: + _doPasswordsMatchpassword_field ? null : 'Passwords do not match', + border: OutlineInputBorder(), + ), + onChanged: _validateConfirmPasswordpassword_field, + ), + +ReusableTextField( + controller: textarea_fieldController, + + onSaved:(value) => formData['textarea_field'] = value , + label: "Enter Textarea Field", + maxLines: 5, +// ValidationProperties +), + + + SizedBox(height: 16), + + +ReusableDatePickerField( + label:' Date Field', controller: date_field +, + onSaved: (value) => formData['date_field'] = value,), +const SizedBox(height: 16), + + +ReusableTextField( + controller: datetime_fieldController, + + onSaved:(value) => formData['datetime_field'] = value , + label:"Enter Datetime Field", + // ValidationProperties +), + + SizedBox(height: 16), + + + +Padding( + padding: getPadding(top: 19), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text("Email Field", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900), + CustomTextFormField( + hintText: "Enter Email Field", + errorText: _isemail_fieldEmailValid ? null : 'Please enter a valid email', + +onsaved: (value) => formData['email_field'] = value, + onChanged: (value) { + _validateemail_fieldEmail(value); + }, + margin: getMargin(top: 6)) + ])), + + Switch( + value: _isSwitchedtoggle_switch, + onChanged: _toggleSwitchtoggle_switch, + activeColor: Colors.white, + activeTrackColor: Colors.green, + inactiveThumbColor: Colors.white, + inactiveTrackColor: Colors.red, + ), + + +Padding( + padding: getPadding(top: 19), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text("Url Field", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900), + CustomTextFormField( + hintText: "Enter Url Field", + errorText: _isUrlValidurl_field ? null : 'Please enter a valid URL', + keyboardType: TextInputType.url, + + + onsaved: (value) => formData['url_field'] = value, + onChanged: _validateUrlurl_field, + + margin: getMargin(top: 6)) + ])), +SizedBox(height: 16), + +ReusableTextField( + controller: decimal_fieldController, + + onSaved:(value) => formData['decimal_field'] = value , + label: "Enter Decimal Field", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))), + ], + // ValidationProperties +), + +SizedBox(height: 16), + +ReusableTextField( + controller: percentage_fieldController, + + onSaved:(value) => formData['percentage_field'] = value , + label: "Enter Percentage Field", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))), + ], + // ValidationProperties +), + +SizedBox(height: 16), + +Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Enter the following CAPTCHA:', + style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + ), + SizedBox(height: 16), + Container( + decoration: BoxDecoration( + color: Colors.grey[300], + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.3), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(0, 3), + ), + ], + ), + padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + recaptchacaptcha, + style: TextStyle( + fontSize: 28, + fontWeight: FontWeight.bold, + color: Colors.blue, + letterSpacing: 4, + fontFamily: 'Roboto', + decoration: TextDecoration.none, + ), + ), + IconButton( + icon: Icon(Icons.refresh), + onPressed: () { + setState(() { + generaterecaptchaCaptcha(); + }); + }, + ), + ], + ), + ), + SizedBox(height: 24), + TextFormField( + controller: _recaptchaController, + decoration: InputDecoration( + labelText: 'Enter CAPTCHA', + border: OutlineInputBorder(), + ), + ), + SizedBox(height: 24), + ElevatedButton( + onPressed: verifyrecaptchaCaptcha, + child: Text('Verify CAPTCHA'), + ), + ], + ), + ), + + + + _buildDropdownselectsta('selectsta', staticOptionsselectsta, dropdownValueselectsta, (value) { + setState(() { + dropdownValueselectsta = value; + formData['selectsta'] = dropdownValueselectsta; + + }); + }), + const SizedBox(height: 16), + + +Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Radios", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Colors.blueGrey[900], + ), + ), + const SizedBox(height: 6), + GestureDetector( + onTap: () => _showradiosSelectionDialog(context), + child: AbsorbPointer( + child: TextFormField( + decoration: InputDecoration( + hintText: "Enter Radios", + border: OutlineInputBorder(), + contentPadding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0), + ), + controller: TextEditingController(text: selectedradios), + onSaved: (value) { + formData['radios'] = value; + }, + ), + ), + ), + const SizedBox(height: 16), + + ], + ), + ), + + Row( + children: [ + + + + Checkbox( + value: qcBox, + onChanged: (newValue) { + setState(() { + qcBox = newValue!; + }); + }, + ), + const SizedBox(width: 8), + Text('Q'), + + + + + Checkbox( + value: bcBox, + onChanged: (newValue) { + setState(() { + bcBox = newValue!; + }); + }, + ), + const SizedBox(width: 8), + Text('B'), + + + ], + ), + SizedBox(height: 16), + + SizedBox( + height: MediaQuery.of(context).size.height*0.5, +child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + children: [ + Expanded( + child: ListView.builder( + itemCount: selectedfileupload_field.length, + itemBuilder: (context, index) { + return Stack( + children: [ + _fileupload_fieldbuildUploadRow(selectedfileupload_field[index]), + Positioned( + right: 8, + top: 8, + child: IconButton( + icon: const Icon(Icons.remove_circle, color: Colors.redAccent), + onPressed: () { + _removefileupload_fieldUploadRow(index); + }, + ), + ), + ], + ); + }, + ), + ), + const SizedBox(height: 16), + ElevatedButton.icon( + icon: const Icon(Icons.add), + label: const Text('Add File Upload Row'), + onPressed: _addfileupload_fieldUploadRow, + style: ElevatedButton.styleFrom( + foregroundColor: Colors.white, backgroundColor: Colors.blueAccent, + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12), + textStyle: const TextStyle(fontSize: 16), + ), + ), + const SizedBox(height: 16), + + ], + ), + ),), + const SizedBox(height: 16), + + SizedBox( + height: MediaQuery.of(context).size.height*0.5, +child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + children: [ + Expanded( + child: ListView.builder( + itemCount: selectedimageupload_field.length, + itemBuilder: (context, index) { + return Stack( + children: [ + _buildUploadRowimageupload_field(selectedimageupload_field[index]), + Positioned( + right: 8, + top: 8, + child: IconButton( + icon: const Icon(Icons.remove_circle, color: Colors.redAccent), + onPressed: () { + _removeUploadRowimageupload_field(index); + }, + ), + ), + ], + ); + }, + ), + ), + const SizedBox(height: 16), + ElevatedButton.icon( + icon: const Icon(Icons.add), + label: const Text('Add Image Upload Row'), + onPressed: _addUploadRowimageupload_field, + style: ElevatedButton.styleFrom( + foregroundColor: Colors.white, + backgroundColor: Colors.blueAccent, + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12), + textStyle: const TextStyle(fontSize: 16), + ), + ), + const SizedBox(height: 16), + + ], + ), + ), + ), + + const SizedBox(height: 16), + + Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + children: [ + if (_fileNameaudio_field != null) + Text( + _fileNameaudio_field!, + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + ), + if (_filePathaudio_field != null) + Slider( + value: _positionaudio_field.inSeconds.toDouble(), + min: 0.0, + max: _durationaudio_field.inSeconds.toDouble(), + onChanged: (double value) { + setState(() { + _seekAudioaudio_field(Duration(seconds: value.toInt())); + }); + }, + ), + if (_filePathaudio_field != null) + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton( + icon: Icon(Icons.skip_previous), + onPressed: () { + final newPosition = _positionaudio_field - Duration(seconds: 10); + _seekAudioaudio_field(newPosition < Duration(seconds: 0) ? Duration(seconds: 0) : newPosition); + }, + ), + IconButton( + icon: Icon(_isPlayingaudio_field ? Icons.pause : Icons.play_arrow), + onPressed: _playPauseAudioaudio_field, + ), + IconButton( + icon: Icon(Icons.skip_next), + onPressed: () { + final newPosition = _positionaudio_field + Duration(seconds: 10); + _seekAudioaudio_field(newPosition > _durationaudio_field ? _durationaudio_field : newPosition); + }, + ), + IconButton( + icon: Icon(Icons.stop), + onPressed: _stopAudioaudio_field, + ), + ], + ), + const SizedBox(height: 20), + ElevatedButton.icon( + icon: Icon(Icons.audiotrack), + label: Text('Pick Audio'), + onPressed: _pickAudioaudio_field, + ), + ], + ), + ), + +Column( + children: [ + Center( + child: _controllervideo_field == null + ? const Text('No video selected') + : _controllervideo_field!.value.isInitialized + ? GestureDetector( + onTap: () { + setState(() { + _showControlsvideo_field = !_showControlsvideo_field; + }); + }, + child: Stack( + alignment: Alignment.center, + children: [ + AspectRatio( + aspectRatio: 16 / 9, + child: VideoPlayer(_controllervideo_field!), + ), + if (_showControlsvideo_field) + Positioned( + bottom: 0, + left: 0, + right: 0, + child: Container( + color: Colors.black54, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + IconButton( + icon: const Icon(Icons.replay_10, color: Colors.white), + onPressed: _skipBackwardvideo_field, + ), + IconButton( + icon: Icon( + _isPlayingvideo_field ? Icons.pause : Icons.play_arrow, + color: Colors.white, + ), + onPressed: _playPauseVideovideo_field, + ), + IconButton( + icon: const Icon(Icons.forward_10, color: Colors.white), + onPressed: _skipForwardvideo_field, + ), + IconButton( + icon: Icon( + _isFullScreenvideo_field ? Icons.fullscreen_exit : Icons.fullscreen, + color: Colors.white, + ), + onPressed: _toggleFullScreenvideo_field, + ), + ], + ), + ), + ), + ], + ), + ) + : const CircularProgressIndicator(), + ), + const SizedBox(height: 20), + ElevatedButton( + onPressed: _pickVideovideo_field, + child: Row( + mainAxisSize: MainAxisSize.min, + children: const [ + Icon(Icons.video_library), + SizedBox(width: 8), + Text('Pick Video'), + ], + ), + ), + ], + ), + + ElevatedButton( + onPressed: () async { + // survey_formanswers = await Navigator.push( + // context, + // MaterialPageRoute( + // builder: (context) => survey_form_form_screen(), + // ), + // ); + }, + child: const Text('${survey_form}')), + + TextFormField( + keyboardType: TextInputType.number, + onChanged: (text) { + setState(() { + inputValuecurrency = text; + }); + }, + decoration: const InputDecoration( + labelText: + 'Enter Currency Value (with or without commas)', + prefixIcon: Icon(Icons.currency_rupee), + border: OutlineInputBorder(), + + ), + onSaved: (value) { + _convertCurrency_currency(); + formData['currency'] = outputValuecurrency; + }), + const SizedBox(height: 16), + + Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Generate QR Code', + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + ), + const SizedBox(height: 16), + QrImageView( + data: inputDataqrcode_field, + version: QrVersions.auto, + size: 200.0, + gapless: false, + ), + const SizedBox(height: 16), + TextField( + controller: controllerInputqrcode_field, + decoration: InputDecoration( + border: OutlineInputBorder(), + labelText: 'Enter data for QR code', + ), + onChanged: (value) { + setState(() { + inputDataqrcode_field = value; + }); + }, + ), + ], + ), + ), + + + Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Text( + 'Generate Barcode', + style: TextStyle(fontSize: 18), + ), + const SizedBox(height: 16), + if (inputDatabarcode_field.isNotEmpty) + BarcodeWidget( + barcode: Barcode.code128(), // Choose the type of barcode + data: inputDatabarcode_field, + width: 200, + height: 80, + ), + const SizedBox(height: 16), + TextField( + controller: controllerInputbarcode_field, + decoration: const InputDecoration( + border: OutlineInputBorder(), + labelText: 'Enter data for barcode', + ), + onChanged: (value) { + setState(() { + inputDatabarcode_field = value; + formData['barcode_field'] = inputDatabarcode_field; + }); + }, + ), + const SizedBox(height: 16), + + ], + ), + +ReusableTextField( + controller: numberbController, + + onSaved:(value) => formData['numberb'] = value , + label: "Enter Numberb", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))), + ], + // ValidationProperties +), + +SizedBox(height: 16), + + + const SizedBox(height: 8.0), + DropdownButtonFormField( + value: calculatedaddOperator, + items: calculatedaddoperators.map((String operator) { + return DropdownMenuItem( + value: operator, + child: Text(operator), + ); + }).toList(), + onChanged: (value) { + setState(() { + calculatedaddOperator = value!; + print(calculatedaddOperator.toString()); + print("value-- $value"); + }); + }, + decoration: const InputDecoration(labelText: 'Operator'), + ), + const SizedBox(height: 20.0), + ElevatedButton( + onPressed: () { + if (_formKey.currentState!.validate()) { + _formKey.currentState?.save(); // Save the form fields + + } + calculatecalculatedaddResult(); + setState(() { + + }); + }, + child: const Text('Calculate'), + ), + const SizedBox(height: 20.0), + Text(calculatedaddresult,style: TextStyle(color: Colors.black),), + + const SizedBox(width: 8), + CustomButton( + height: getVerticalSize(50), + text: "Submit", + margin: getMargin(top: 24, bottom: 5), + onTap: () async { + if (_formKey.currentState!.validate()) { + _formKey.currentState!.save(); + + + + + + + + + + + + + + + + + + +formData['toggle_switch'] = toggle_switch; + + + + + + + + + + + + + + + + + + + formData['q'] = qcBox; + + + + formData['b'] = bcBox; + + + + + + + + + + + + + + + + + + + + + + + + + try { + print(formData); + Map createdEntity = await provider.createEntity(formData); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + await _uploadfileupload_field(createdEntity['id']); + + + await _uploadimageupload_field(createdEntity['id']); + + + await _uploadaudio_field(createdEntity['id']); + + + await _uploadvideo_field(createdEntity['id']); + + + + + + + + + + + + + + + + + Navigator.pop(context); + } catch (e) { + // ignore: use_build_context_synchronously + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Error'), + content: Text('Failed to create Emp_details: $e'), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + } + }, + ), + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ], + ), + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_entity_list_screen.dart b/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_entity_list_screen.dart new file mode 100644 index 0000000..2f9d906 --- /dev/null +++ b/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_entity_list_screen.dart @@ -0,0 +1,1364 @@ +// ignore_for_file: use_build_context_synchronously +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'Emp_details_create_entity_screen.dart'; +import 'Emp_details_update_entity_screen.dart'; +import '../Emp_details_viewModel/Emp_details_view_model_screen.dart'; +import 'package:flutter/services.dart'; +import 'package:speech_to_text/speech_to_text.dart' as stt; +import '../../../../theme/app_style.dart'; +import '../../../../utils/size_utils.dart'; +import '../../../../widgets/custom_icon_button.dart'; +import '../../../../utils/image_constant.dart'; +import '../../../../widgets/app_bar/appbar_image.dart'; +import '../../../../widgets/app_bar/appbar_title.dart'; +import '../../../../widgets/app_bar/custom_app_bar.dart'; +import '../../../../theme/app_decoration.dart'; +import 'package:multi_select_flutter/multi_select_flutter.dart'; +import '../../../../Reuseable/reusable_text_field.dart'; +import 'package:provider/provider.dart'; +import '../../../../utils/toast_messages/toast_message_util.dart'; +import 'package:fluttertoast/fluttertoast.dart'; + +class emp_details_entity_list_screen extends StatefulWidget { + static const String routeName = '/entity-list'; + + @override + _emp_details_entity_list_screenState createState() => _emp_details_entity_list_screenState(); +} + +class _emp_details_entity_list_screenState extends State { + List> entities = []; + List> filteredEntities = []; + List> serachEntities = []; + + bool showCardView = true; // Add this variable to control the view mode + TextEditingController searchController = TextEditingController(); + late stt.SpeechToText _speech; + + bool isLoading = false; // Add this variable to track loading state + int currentPage = 0; + int pageSize = 10; // Adjust this based on your backend API + + final ScrollController _scrollController = ScrollController(); + @override + void initState() { + _speech = stt.SpeechToText(); + super.initState(); + fetchEntities(); + _scrollController.addListener(_scrollListener); + fetchwithoutpaging(); + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Future fetchwithoutpaging() async { + try { + final provider = + Provider.of(context, listen: false); + final fetchedEntities = await provider.getEntities(); + setState(() { + serachEntities = fetchedEntities; // Update only filteredEntities + }); + } catch (e) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Error'), + content: Text('Failed to fetch Emp_details: $e'), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + } +Future fetchEntities() async { + try { + setState(() { + isLoading = true; + }); + + + + final provider = + Provider.of(context, listen: false); + final fetchedEntities = + await provider.getAllWithPagination(currentPage, pageSize); + setState(() { + entities.addAll(fetchedEntities); // Add new data to the existing list + filteredEntities = entities.toList(); // Update only filteredEntities + currentPage++; + }); + + } catch (e) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Error'), + content: Text('Failed to fetch Emp_details data: $e'), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } finally { + setState(() { + isLoading = false; + }); + } + } + + void _scrollListener() { + if (_scrollController.position.pixels == + _scrollController.position.maxScrollExtent) { + fetchEntities(); + } + } + + Future deleteEntity(Map entity) async { + try { + final provider = + Provider.of(context, listen: false); + + await provider.deleteEntity(entity['id']);; + setState(() { + entities.remove(entity); + }); + } catch (e) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Error'), + content: Text('Failed to delete entity: $e'), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + } + + void _searchEntities(String keyword) { + setState(() { + filteredEntities = serachEntities + .where((entity) => + + + + entity['first_name'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['numbera'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['phone_number'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['paragraph_field'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['password_field'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['textarea_field'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['date_field'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['datetime_field'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['email_field'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + entity['toggle_switch'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['url_field'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['decimal_field'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['percentage_field'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + + + entity['documentsequence'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['selectsta'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['radios'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + + + + + + + entity['audio_field'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['video_field'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['survey_form'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['currency'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['qrcode_field'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['barcode_field'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['numberb'].toString().toLowerCase().contains(keyword.toLowerCase()) + + + + + ).toList(); + }); + } + + void _startListening() async { + if (!_speech.isListening) { + bool available = await _speech.initialize( + onStatus: (status) { + print('Speech recognition status: $status'); + }, + onError: (error) { + print('Speech recognition error: $error'); + }, + ); + + if (available) { + _speech.listen( + onResult: (result) { + if (result.finalResult) { + searchController.text = result.recognizedWords; + _searchEntities(result.recognizedWords); + } + }, + ); + } + } + } + + void _stopListening() { + if (_speech.isListening) { + _speech.stop(); + } + } + + @override + void dispose() { + _speech.cancel(); + super.dispose(); + } + +onTapArrowleft1(BuildContext context) { + Navigator.pop(context); + } + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + appBar: CustomAppBar( + height: getVerticalSize(49), + leadingWidth: 40, + leading: AppbarImage( + height: getSize(24), + width: getSize(24), + svgPath: ImageConstant.imgArrowleft, + margin: getMargin(left: 16, top: 12, bottom: 13), + onTap: () { + onTapArrowleft1(context); + }), + centerTitle: true, + title: AppbarTitle(text: " Emp_details"), + actions: [ + Row( + children: [ + Switch( + activeColor: Colors.greenAccent, + inactiveThumbColor: Colors.white, + value: showCardView, + onChanged: (value) { + setState(() { + showCardView = value; + }); + }, + ), + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ], + ), ], + ), + body: RefreshIndicator( + onRefresh: () async { + currentPage = 1; + entities.clear(); + await fetchEntities(); + }, + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: TextField( + controller: searchController, + onChanged: (value) { + _searchEntities(value); + }, + decoration: InputDecoration( + hintText: 'Search...', + contentPadding: const EdgeInsets.symmetric(horizontal: 16.0), + filled: true, + fillColor: Colors.grey[200], + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide.none, + ), + suffixIcon: IconButton( + icon: const Icon(Icons.mic), + onPressed: () { + _startListening(); + }, + ), + ), + ), + ), + Expanded( + child: ListView.builder( + itemCount: filteredEntities.length + (isLoading ? 1 : 0), + itemBuilder: (BuildContext context, int index) { + if (index < filteredEntities.length) { + final entity = filteredEntities[index]; + return _buildListItem(entity); + } else { + // Display the loading indicator at the bottom when new data is loading + return const Padding( + padding: EdgeInsets.all(8.0), + child: Center( + child: CircularProgressIndicator(), + ), + ); + } + }, + controller: _scrollController, + ), + ), + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ChangeNotifierProvider( + create: (context) => Emp_detailsViewModelScreen(), + child: emp_detailsCreateEntityScreen(), + ), + ), + ).then((_) { + fetchEntities(); + }); + }, + child: const Icon(Icons.add), + ), + )); + } + + Widget _buildListItem(Map entity) { + return showCardView ? _buildCardView(entity) : _buildNormalView(entity); + } + + + // Function to build card view for a list item + Widget _buildCardView(Map entity) { + return Card( + elevation: 2, + margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), + child: _buildNormalView(entity)) + ; } + + // Function to build normal view for a list item + + // Function to build normal view for a list item + + Widget _buildNormalView(Map entity) { + final values = entity.values.elementAt(21) ?? 'Authsec'; + + return SizedBox( + width: double.maxFinite, + child: Container( + padding: getPadding( + left: 16, + top: 5, + right: 5, + bottom: 17, + ), + decoration: AppDecoration.outlineGray70011.copyWith( + borderRadius: BorderRadiusStyle.roundedBorder6, + color: Colors.grey[100]), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: getPadding( + //right: 13, + ), + child: Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.30, + margin: getMargin( + left: 8, + top: 3, + bottom: 1, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + entity['id'].toString(), + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGreenSemiBold16, + ), + ], + ), + ), + const Spacer(), + PopupMenuButton( + icon: const Icon( + Icons.more_vert, + color: Colors.black, + size: 16, + ), + itemBuilder: (BuildContext context) { + return [ + PopupMenuItem( + value: 'edit', + child: Row( + children: [ + const Icon( + Icons.edit, + size: 16, // Adjust the icon size as needed + ), + const SizedBox(width: 8), + Text( + 'Edit', + style: AppStyle + .txtGilroySemiBold16, // Adjust the text size as needed + ), + ], + ), + ), + PopupMenuItem( + value: 'delete', + child: Row( + children: [ + const Icon( + Icons.delete, + size: 16, // Adjust the icon size as needed + ), + const SizedBox(width: 8), + Text( + 'Delete', + style: AppStyle + .txtGilroySemiBold16, // Adjust the text size as needed + ), + ], + ), + ), + ]; + }, + onSelected: (String value) { + if (value == 'edit') { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ChangeNotifierProvider( + create: (context) => Emp_detailsViewModelScreen(), + child: emp_detailsUpdateEntityScreen(entity: entity), + ), + ), + ).then((_) { + fetchEntities(); + }); + } else if (value == 'delete') { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Confirm Deletion'), + content: const Text( + 'Are you sure you want to delete?'), + actions: [ + TextButton( + child: const Text('Cancel'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + child: const Text('Delete'), + onPressed: () { + Navigator.of(context).pop(); + deleteEntity(entity) + .then((value) => {fetchEntities()}); + }, + ), + ], + ); + }, + ); + } + }, + ), + ], + ), + ), + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "First name : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['first_name'].toString() ?? 'No First name Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Numbera : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['numbera'].toString() ?? 'No Numbera Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Phone Number : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['phone_number'].toString() ?? 'No Phone Number Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Paragraph Field : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['paragraph_field'].toString() ?? 'No Paragraph Field Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Password Field : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['password_field'].toString() ?? 'No Password Field Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Textarea Field : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['textarea_field'].toString() ?? 'No Textarea Field Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Date Field : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['date_field'].toString() ?? 'No Date Field Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Datetime Field : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['datetime_field'].toString() ?? 'No Datetime Field Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Email Field : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['email_field'].toString() ?? 'No Email Field Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "toggle switch : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['toggle_switch'].toString() ?? 'No toggle switch Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Url Field : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['url_field'].toString() ?? 'No Url Field Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Decimal Field : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['decimal_field'].toString() ?? 'No Decimal Field Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Percentage Field : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['percentage_field'].toString() ?? 'No Percentage Field Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "documentsequence : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['documentsequence'].toString() ?? 'No documentsequence Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "selectsta : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['selectsta'].toString() ?? 'No selectsta Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Radios : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['radios'].toString() ?? 'No Radios Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Q : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['q'].toString() ?? 'No Q Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "B : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['b'].toString() ?? 'No B Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + + + + + + + + + + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Survey Form : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['survey_form'].toString() ?? 'No Survey Form Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Currency : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['currency'].toString() ?? 'No Currency Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "QRCode Field : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['qrcode_field'].toString() ?? 'No QRCode Field Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "BarCode Field : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['barcode_field'].toString() ?? 'No BarCode Field Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Numberb : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['numberb'].toString() ?? 'No Numberb Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + + + ], + ), + ), + ); + } + + Widget _buildLeadingIcon(String title) { + return CircleAvatar( + backgroundColor: Colors.blue, + child: Text( + title.isNotEmpty ? title[0].toUpperCase() : 'NA', + style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + ); + } + + void _showAdditionalFieldsDialog( + BuildContext context, + Map entity, + ) { + final dateFormat = DateFormat('yyyy-MM-dd HH:mm:ss'); + + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Additional Fields'), + content: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'Created At: ${_formatTimestamp(entity['createdAt'], dateFormat)}'), + Text('Created By: ${entity['createdBy'] ?? 'N/A'}'), + Text('Updated By: ${entity['updatedBy'] ?? 'N/A'}'), + Text( + 'Updated At: ${_formatTimestamp(entity['updatedAt'], dateFormat)}'), + Text('Account ID: ${entity['accountId'] ?? 'N/A'}'), + ], + ), + actions: [ + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + + String _formatTimestamp(dynamic timestamp, DateFormat dateFormat) { + if (timestamp is int) { + final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp); + return dateFormat.format(dateTime); + } else if (timestamp is String) { + return timestamp; + } else { + return 'N/A'; + } + } +} + \ No newline at end of file diff --git a/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_update_entity_screen.dart b/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_update_entity_screen.dart new file mode 100644 index 0000000..fdf1cec --- /dev/null +++ b/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_update_entity_screen.dart @@ -0,0 +1,1115 @@ +// ignore_for_file: use_build_context_synchronously +import 'dart:convert'; +import 'package:provider/provider.dart'; +import '../Emp_details_viewModel/Emp_details_view_model_screen.dart'; +import '../../../../utils/image_constant.dart'; +import '../../../../utils/size_utils.dart'; +import '../../../../theme/app_style.dart'; +import '../../../../widgets/app_bar/appbar_image.dart'; +import '../../../../widgets/app_bar/appbar_title.dart'; +import '../../../../widgets/app_bar/custom_app_bar.dart'; +import 'package:barcode_widget/barcode_widget.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import '../../../../widgets/custom_button.dart'; +import '../../../../widgets/custom_text_form_field.dart'; +import 'package:flutter/material.dart'; +import 'package:autocomplete_textfield/autocomplete_textfield.dart'; +import 'package:qr_flutter/qr_flutter.dart'; +import 'package:intl/intl.dart'; + +import 'dart:math'; +import '../../../../Reuseable/reusable_text_field.dart'; +import '../../../../Reuseable/reusable_date_picker_field.dart'; +import '../../../../Reuseable/reusable_date_time_picker_field.dart'; +import '../../../../Reuseable/reusable_dropdown_field.dart'; +import 'package:flutter/services.dart'; +class emp_detailsUpdateEntityScreen extends StatefulWidget { + final Map entity; + + + emp_detailsUpdateEntityScreen({required this.entity}); + + @override + _emp_detailsUpdateEntityScreenState createState() => _emp_detailsUpdateEntityScreenState(); +} + +class _emp_detailsUpdateEntityScreenState extends State { + final _formKey = GlobalKey(); + + + + + + + + + + + bool _passwordVisiblepassword_field = false; + bool _isPasswordValidpassword_field = true; + bool _doPasswordsMatchpassword_field = true; + + String _passwordpassword_field = ''; // To store the first password + + void _validatePasswordpassword_field(String password) { + setState(() { + _isPasswordValidpassword_field = password.isNotEmpty; + _passwordpassword_field = password; // Store the password for later comparison + _doPasswordsMatchpassword_field = true; // Reset match flag on new input + }); + } + + void _validateConfirmPasswordpassword_field(String confirmPassword) { + setState(() { + _doPasswordsMatchpassword_field = confirmPassword == _passwordpassword_field; + }); + } + + + +TextEditingController date_field = TextEditingController(); +DateTime selectedDatedate_field = DateTime.now(); + +Future _selectDatedate_field(BuildContext context) async { + final DateTime? picked = await showDatePicker( + context: context, + initialDate: selectedDatedate_field, + firstDate: DateTime(2000), + lastDate: DateTime(2101), + ); + print(picked); + if (picked != null && picked != selectedDatedate_field) { + setState(() { + selectedDatedate_field = picked; + }); + } +} + + + +bool _isemail_fieldEmailValid = true; + +void _validateemail_fieldEmail(String email) { + setState(() { + _isemail_fieldEmailValid = RegExp(r'^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$').hasMatch(email); + }); +} + + bool istoggle_switch = false; + +bool _isUrlValidurl_field = true; + +void _validateUrlurl_field(String url) { + setState(() { + _isUrlValidurl_field= Uri.parse(url).isAbsolute; + }); +} + + + + + + + + + + + var selectedselectsta; // Initialize with the default value \n); + List selectstaList = [ + + + 'bar_code', + + + + + 'qr_code', + + + + ]; + +Widget _buildDropdownselectsta(String label, List options, String? value, void Function(String?) onChanged) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: DropdownButtonFormField( + decoration: InputDecoration(labelText: label, + border: OutlineInputBorder(), +), + value: value, + onChanged: onChanged, + items: options.map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + ), + ); + } + + String? selectedradios; + + + Future _showradiosSelectionDialog(BuildContext context) async { + final result = await showDialog( + context: context, + builder: (BuildContext context) { + return SimpleDialog( + title: const Text('Select radios'), + children: [ + + + RadioListTile( + title: const Text('bar_code'), + value: 'bar_code', + groupValue: selectedradios, + onChanged: (value) { + setState(() { + selectedradios = value; + Navigator.pop(context, value); + }); + }, + ), + + + + RadioListTile( + title: const Text('qr_code'), + value: 'qr_code', + groupValue: selectedradios, + onChanged: (value) { + setState(() { + selectedradios = value; + Navigator.pop(context, value); + }); + }, + ), + + + + ], + ); + }, + ); + + if (result != null) { + setState(() { + selectedradios = result; + }); + } + } + + + + + bool qcBox = false; + + + + + bool bcBox = false; + + + + + + + + + + + + + +final TextEditingController _inputcurrencyController = TextEditingController(); +double editedcurrencyValue = 0.0; + +late String inputDataqrcode_field; + late TextEditingController controllerInputqrcode_field; + + + late String inputDatabarcode_field; // By default barcode + TextEditingController controllerInputbarcode_field = TextEditingController(); + + + + + + + + @override + void initState() { + super.initState(); + final provider = Provider.of(context, listen: false); + + + + + + + + + + + + + + + + + + +istoggle_switch = widget.entity['toggle_switch'] ?? false; // Set initial value + + + + + + + + + + + + selectedselectsta = widget.entity['selectsta'] ?? selectstaList[0] ; // Initialize with the default value + +selectedradios = widget.entity['radios'] ?? ''; // Initialize selected radios + + + + +qcBox = widget.entity['q'] ?? false; + + + +bcBox = widget.entity['b'] ?? false; + + + + + + + + + + + + + + // Convert the currency value to double if it's not already + if (widget.entity['currency'] is String) { + widget.entity['currency'] = + double.tryParse(widget.entity['currency']) ?? 0.0; + } + + // Initially set the controller text without formatting + _inputcurrencyController.text = widget.entity['currency'].toString(); + editedcurrencyValue = widget.entity['currency']; + + inputDataqrcode_field = widget.entity['qrcode_field'] ?? "Hello"; + controllerInputqrcode_field = TextEditingController(text: inputDataqrcode_field); + + inputDatabarcode_field = widget.entity['barcode_field'] ?? "Hello"; + controllerInputbarcode_field.text = inputDatabarcode_field; + + + + + + +} + + + @override + Widget build(BuildContext context) { + final provider = Provider.of(context, listen: false); + return Scaffold( + appBar: CustomAppBar( + height: getVerticalSize(49), + leadingWidth: 40, + leading: AppbarImage( + height: getSize(24), + width: getSize(24), + svgPath: ImageConstant.imgArrowleftBlueGray900, + margin: getMargin(left: 16, top: 12, bottom: 13), + onTap: () { + Navigator.pop(context); + }), + centerTitle: true, + title: AppbarTitle(text: "Update Emp_details"), actions: [ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ], +), + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16), + child: Form( + key: _formKey, + child: Column( + children: [ + + ReusableTextField( + + label: "Please Enter First name", + initialValue: widget.entity['first_name'] ?? '', + + // ValidationProperties + onSaved: (value) => widget.entity['first_name'] = value, +), + + SizedBox(height: 16), + + + ReusableTextField( + initialValue: widget.entity['numbera'].toString(), + onSaved: (value) => widget.entity['numbera']= value, + label: "Enter Numbera", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))), + ], + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter a number'; + } + return null; + }, + ), + +ReusableTextField( + initialValue: widget.entity['phone_number'], + onSaved: (value) => widget.entity['phone_number'] = value, + label: "Enter Phone Number", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + LengthLimitingTextInputFormatter( + 10), // Limit input to 10 digits + ], + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter Phone Number'; + } + if (value.length != 10) { + return 'Phone number must be exactly 10 digits'; + } + return null; + }, + ), + + // }), + ReusableTextField( + initialValue: widget.entity['paragraph_field'], + onSaved: (value) => widget.entity['paragraph_field']= value, + label: "Enter Paragraph Field", + maxLines: 5, + ), + +TextFormField( + initialValue: widget.entity['password_field'], + + obscureText: !_passwordVisiblepassword_field, + decoration: InputDecoration( + labelText: 'Password Field', + suffixIcon: IconButton( + icon: Icon( + _passwordVisiblepassword_field + ? Icons.visibility + : Icons.visibility_off, + ), + onPressed: () { + setState(() { + _passwordVisiblepassword_field = !_passwordVisiblepassword_field; + }); + }, + ), + errorText: + _isPasswordValidpassword_field ? null : 'Please enter a password', + border: OutlineInputBorder(), + ), + onSaved: (value) => widget.entity['password_field'] = value, + onChanged: _validatePasswordpassword_field, + ), + const SizedBox(height: 16), + TextFormField( + obscureText: !_passwordVisiblepassword_field, + decoration: InputDecoration( + labelText: 'Confirm Password Field', + suffixIcon: IconButton( + icon: Icon( + _passwordVisiblepassword_field + ? Icons.visibility + : Icons.visibility_off, + ), + onPressed: () { + setState(() { + _passwordVisiblepassword_field = !_passwordVisiblepassword_field; + }); + }, + ), + errorText: + _doPasswordsMatchpassword_field ? null : 'Passwords do not match', + border: OutlineInputBorder(), + ), + onChanged: _validateConfirmPasswordpassword_field, + ), + + + + + + ReusableTextField( + initialValue: widget.entity['textarea_field'], + onSaved: (value) => widget.entity['textarea_field']= value, + label: "Enter Textarea Field", + maxLines: 5, + ), + + ReusableDatePickerField(label: 'Date Field', controller: date_field, initialDate: widget.entity['date_field'], + onSaved: (value) => widget.entity['date_field'] = value,), + + + + ReusableTextField( + + label: "Please Enter Datetime Field", + initialValue: widget.entity['datetime_field'] ?? '', + + // ValidationProperties + onSaved: (value) => widget.entity['datetime_field'] = value, +), + + SizedBox(height: 16), + + + Padding( + padding: getPadding(top: 19), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text("Email Field", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle + .txtGilroyMedium16Bluegray900), + CustomTextFormField( + hintText: "Enter Email Field", + initialValue: widget.entity['email_field'], + keyboardType: TextInputType.url, + errorText: _isemail_fieldEmailValid ? null : 'Please enter a valid URL', + onChanged: _validateemail_fieldEmail, + + + + // ValidationProperties + + onsaved: (value) { + widget.entity['email_field'] = value; + }, + margin: getMargin(top: 6)) + ])), + +SizedBox(height: 16), + +Row( + children: [ + Switch( + value: istoggle_switch, + onChanged: (newValue) { + setState(() { + istoggle_switch = newValue; + }); + }, + activeColor: Colors.white, + activeTrackColor: Colors.green, + inactiveThumbColor: Colors.white, + inactiveTrackColor: Colors.red, + ), + const SizedBox(width: 8), + const Text('toggle switch'), + ], +), + + Padding( + padding: getPadding(top: 19), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text("Url Field", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle + .txtGilroyMedium16Bluegray900), + CustomTextFormField( + hintText: "Enter Url Field", + initialValue: widget.entity['url_field'], + keyboardType: TextInputType.url, + errorText: _isUrlValidurl_field ? null : 'Please enter a valid URL', + onChanged: _validateUrlurl_field, + + + + // ValidationProperties + + onsaved: (value) { + widget.entity['url_field'] = value; + }, + margin: getMargin(top: 6)) + ])), + +SizedBox(height: 16), + + ReusableTextField( + initialValue: widget.entity['decimal_field'].toString(), + onSaved: (value) => widget.entity['decimal_field']= value, + label: "Enter Decimal Field", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))), + ], + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter a number'; + } + return null; + }, + ), + + ReusableTextField( + initialValue: widget.entity['percentage_field'].toString(), + onSaved: (value) => widget.entity['percentage_field']= value, + label: "Enter Percentage Field", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))), + ], + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter a number'; + } + return null; + }, + ), + + + ReusableTextField( + + label: "Please Enter recaptcha", + initialValue: widget.entity['recaptcha'] ?? '', + + // ValidationProperties + onSaved: (value) => widget.entity['recaptcha'] = value, +), + + SizedBox(height: 16), + + + + ReusableTextField( + + label: "Please Enter documentsequence", + initialValue: widget.entity['documentsequence'] ?? '', + + // ValidationProperties + onSaved: (value) => widget.entity['documentsequence'] = value, +), + + SizedBox(height: 16), + + + + + _buildDropdownselectsta( + 'selectsta', + selectstaList, + selectedselectsta, + (value) { + setState(() { + selectedselectsta = value; + widget.entity['selectsta'] = value; // Save selected value to entity + }); + }, + ), + + +Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Radios", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Colors.blueGrey[900], + ), + ), + const SizedBox(height: 6), + GestureDetector( + onTap: () => _showradiosSelectionDialog(context), + child: AbsorbPointer( + child: TextFormField( + decoration: InputDecoration( + hintText: "Enter Radios", + border: OutlineInputBorder(), + contentPadding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0), + ), + controller: TextEditingController(text: selectedradios), + onSaved: (value) { + widget.entity['radios'] = value; + }, + ), + ), + ), + const SizedBox(height: 16), + + ], + ), + ), + + Row( + children: [ + + + + Checkbox( + value: qcBox, + onChanged: (newValue) { + setState(() { + qcBox = newValue!; + }); + }, + ), + const SizedBox(width: 8), + Text('Q'), + + + + + Checkbox( + value: bcBox, + onChanged: (newValue) { + setState(() { + bcBox = newValue!; + }); + }, + ), + const SizedBox(width: 8), + Text('B'), + + + + ], + ), + SizedBox(height: 16), + + + + + + + ReusableTextField( + + label: "Please Enter audio Field", + initialValue: widget.entity['audio_field'] ?? '', + + // ValidationProperties + onSaved: (value) => widget.entity['audio_field'] = value, +), + + SizedBox(height: 16), + + + + ReusableTextField( + + label: "Please Enter video Field", + initialValue: widget.entity['video_field'] ?? '', + + // ValidationProperties + onSaved: (value) => widget.entity['video_field'] = value, +), + + SizedBox(height: 16), + + + + ReusableTextField( + + label: "Please Enter Survey Form", + initialValue: widget.entity['survey_form'] ?? '', + + // ValidationProperties + onSaved: (value) => widget.entity['survey_form'] = value, +), + + SizedBox(height: 16), + + +Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextFormField( + controller: _inputcurrencyController, + keyboardType: TextInputType.number, + decoration: const InputDecoration( + labelText: 'Edit Currency Value', + prefixIcon: Icon(Icons.money), + border: OutlineInputBorder(), + + ), + onChanged: (text) { + setState(() { + try { + String currencyString = text; + currencyString = currencyString.replaceAll(',', ''); // Remove commas + currencyString = currencyString.replaceAll('₹', ''); // Remove currency symbol + editedcurrencyValue = double.parse(currencyString); + print("Parsed double value: $editedcurrencyValue"); + } catch (e) { + print("Invalid input: $text"); + editedcurrencyValue = 0.0; // Set to a default value or handle the error accordingly + } + }); + }, + onSaved: (value) { + widget.entity['currency'] = editedcurrencyValue; + }, + ), + SizedBox(height: 16), + Text( + 'Edited Currency Value: ${editedcurrencyValue.toStringAsFixed(2)}', // Display formatted currency value + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 16), + // Add other form fields here + ], +), + + +Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'Generate QR Code', + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + ), + const SizedBox(height: 16), + QrImageView( + data: inputDataqrcode_field, + version: QrVersions.auto, + size: 200.0, + gapless: false, + ), + const SizedBox(height: 16), + TextField( + controller: controllerInputqrcode_field, + decoration: InputDecoration( + border: OutlineInputBorder(), + labelText: 'Enter data for QR code', + ), + onChanged: (value) { + setState(() { + inputDataqrcode_field = value; + widget.entity['qrcode_field'] = inputDataqrcode_field; + }); + }, + ), + ], + ), + + Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Text( + 'Generate Barcode', + style: TextStyle(fontSize: 18), + ), + const SizedBox(height: 16), + if (inputDatabarcode_field.isNotEmpty) + BarcodeWidget( + barcode: Barcode.code128(), // Choose the type of barcode + data: inputDatabarcode_field, + width: 200, + height: 80, + ), + const SizedBox(height: 16), + TextField( + controller: controllerInputbarcode_field, + decoration: const InputDecoration( + border: OutlineInputBorder(), + labelText: 'Enter data for barcode', + ), + onChanged: (value) { + setState(() { + inputDatabarcode_field = value; + widget.entity['barcode_field'] = inputDatabarcode_field; + }); + }, + ), + const SizedBox(height: 16), + // ElevatedButton( + // onPressed: () { + // setState(() { + // inputData = controllerInput.text; + // }); + // }, + // child: const Text('Generate Barcode'), + // ), + ], + ), + const SizedBox(height: 16), + + ReusableTextField( + initialValue: widget.entity['numberb'].toString(), + onSaved: (value) => widget.entity['numberb']= value, + label: "Enter Numberb", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))), + ], + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter a number'; + } + return null; + }, + ), + + + + + CustomButton( + height: getVerticalSize(50), + text: "Update", + margin: getMargin(top: 24, bottom: 5), + onTap: () async { + if (_formKey.currentState!.validate()) { + _formKey.currentState!.save(); + + + + + + + + + + + + + + + + + + +widget.entity['toggle_switch'] = istoggle_switch; + + + + + + + + + + + + + + + + + + + + widget.entity['q'] = qcBox; + + + + + widget.entity['b'] = bcBox; + + + + + + + + + + + + + + + + + + + + + + + + + try { + await provider.updateEntity( + widget.entity[ + 'id'], // Assuming 'id' is the key in your entity map + widget.entity); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Navigator.pop(context); + } catch (e) { + // ignore: use_build_context_synchronously + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Error'), + content: + Text('Failed to update Emp_details: $e'), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + } + }, + ), + ], + ), + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_details_Repo/Emp_details_repo_screen.dart b/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_details_Repo/Emp_details_repo_screen.dart new file mode 100644 index 0000000..9b1b99a --- /dev/null +++ b/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_details_Repo/Emp_details_repo_screen.dart @@ -0,0 +1,154 @@ +import 'package:dio/dio.dart'; +import '../../../../data/network/base_network_service.dart'; +import '../../../../data/network/network_api_service.dart'; +import '../../../../resources/api_constants.dart'; + +class Emp_detailsRepoScreen { + final String baseUrl = ApiConstants.baseUrl; + final BaseNetworkService _helper = NetworkApiService(); + + Future getEntities() async { + try { + final response = + await _helper.getGetApiResponse('$baseUrl/Emp_details/Emp_details'); + return response; + } catch (e) { + throw Exception('Failed to get all entities: $e'); + } + } + + Future getAllWithPagination(int page, int size) async { + try { + final response = await _helper.getGetApiResponse( + '$baseUrl/Emp_details/Emp_details/getall/page?page=$page&size=$size'); + return response; + } catch (e) { + throw Exception('Failed to get all without pagination: $e'); + } + } + + Future createEntity(Map entity) async { + try { + print("in post api$entity"); + final response = await _helper.getPostApiResponse( + '$baseUrl/Emp_details/Emp_details', entity); + + print(entity); + + return response; + } catch (e) { + throw Exception('Failed to create entity: $e'); + } + } + + Future updateEntity(int entityId, Map entity) async { + try { + await _helper.getPutApiResponse( + '$baseUrl/Emp_details/Emp_details/$entityId', entity); + print(entity); + } catch (e) { + throw Exception('Failed to update entity: $e'); + } + } + + Future deleteEntity(int entityId) async { + try { + await _helper + .getDeleteApiResponse('$baseUrl/Emp_details/Emp_details/$entityId'); + } catch (e) { + throw Exception('Failed to delete entity: $e'); + } + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Future fileupload_fieldUpload( + String ref, String refTableNmae, FormData entity) async { + try { + String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae"; + final response = await _helper.getPostApiResponse(apiUrl, entity); + return response; + } catch (e) { + throw Exception('Failed to Upload File: $e'); + } + } + + Future imageupload_fieldUpload( + String ref, String refTableNmae, FormData entity) async { + try { + String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae"; + final response = await _helper.getPostApiResponse(apiUrl, entity); + return response; + } catch (e) { + throw Exception('Failed to Upload Imageupload Field: $e'); + } + } + + Future audio_fieldUpload( + String ref, String refTableNmae, FormData entity) async { + try { + String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae"; + final response = await _helper.getPostApiResponse(apiUrl, entity); + return response; + } catch (e) { + throw Exception('Failed to Upload File: $e'); + } + } + + Future video_fieldUpload( + String ref, String refTableNmae, FormData entity) async { + try { + String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae"; + final response = await _helper.getPostApiResponse(apiUrl, entity); + return response; + } catch (e) { + throw Exception('Failed to Upload File: $e'); + } + } + + + + + + + + + + + + + +} diff --git a/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_details_viewModel/Emp_details_view_model_screen.dart b/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_details_viewModel/Emp_details_view_model_screen.dart new file mode 100644 index 0000000..938e668 --- /dev/null +++ b/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/Entity/vpspack/Emp_details/Emp_details_viewModel/Emp_details_view_model_screen.dart @@ -0,0 +1,366 @@ +import 'dart:typed_data'; +import 'package:dio/dio.dart'; +import 'package:http_parser/http_parser.dart'; +import '../../../../utils/toast_messages/toast_message_util.dart'; +import 'package:flutter/material.dart'; +import '../Emp_details_Repo/Emp_details_repo_screen.dart'; + +class Emp_detailsViewModelScreen extends ChangeNotifier{ + final Emp_detailsRepoScreen repo = Emp_detailsRepoScreen(); + + Future>> getEntities() async { + try { + final response = await repo.getEntities(); + final entities = (response as List).cast>(); + return entities; + } catch (e) { + throw Exception('Failed to get all entities: $e'); + } + } + + + Future>> getAllWithPagination( + int page, int size) async { + try { + final response = + await repo.getAllWithPagination(page, size); // ✅ Use await + + print('with pagination res - $response'); + + // ✅ Ensure response is a Map + if (response is! Map) { + throw Exception('Unexpected response format: $response'); + } + + // ✅ Extract 'content' and ensure it's a list + final entities = (response['content'] as List) + .cast>() // ✅ Ensure list of maps + .toList(); + return entities; + } catch (e) { + print(e); + throw Exception('Failed to get all without pagination :- $e'); + } + } + + + Future> createEntity(Map entity) async { + try { + print("in post api - $entity"); + // Wait for API response + final responseData = + await repo.createEntity(entity) as Map; + print('after value - $responseData'); + ToastMessageUtil.showToast( + message: "Added Successfully", toastType: ToastType.success); + + return responseData; // Return the data AFTER it is received + } catch (error) { + print("error--$error"); + ToastMessageUtil.showToast( + message: "Got Error", toastType: ToastType.error); + + throw Exception( + 'Failed to Create Entity: $error'); // Properly rethrow the error + } + } + Future updateEntity(int entityId, Map entity) async { + try { + repo.updateEntity(entityId, entity).then((value) { + ToastMessageUtil.showToast( + message: "Updated Successfully", toastType: ToastType.success); + }).onError( + (error, stackTrace) { + print("error--$error"); + ToastMessageUtil.showToast( + message: "Got Error", toastType: ToastType.error); + }, + ); + print(entity); + } catch (e) { + throw Exception('Failed to update entity: $e'); + } + } + + Future deleteEntity(int entityId) async { + try { + repo.deleteEntity(entityId).then((value) { + ToastMessageUtil.showToast( + message: "Deleted Successfully", toastType: ToastType.success); + }).onError( + (error, stackTrace) { + print("error--$error"); + ToastMessageUtil.showToast( + message: "Got Error", toastType: ToastType.error); + }, + ); + } catch (e) { + throw Exception('Failed to delete entity: $e'); + } + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// Modify the uploadfileupload_fieldimage function + Future uploadfileupload_field(String ref, String refTableNmae, + String selectedFilePath, Uint8List imageTimageBytes) async { + try { + + final Uint8List fileBytes = imageTimageBytes!; + final mimeType = fileupload_fieldlookupMimeType(selectedFilePath); + + FormData formData = FormData.fromMap({ + 'file': MultipartFile.fromBytes( + fileBytes, + filename: selectedFilePath + .split('/') + .last, // Get the file name from the path + contentType: MediaType.parse(mimeType!), + ), + }); + + + await repo.fileupload_fieldUpload(ref, refTableNmae, formData).then((value) { + ToastMessageUtil.showToast( + message: "File uploaded successfully", + toastType: ToastType.success); + }).onError( + (error, stackTrace) { + print("error--$error"); + ToastMessageUtil.showToast( + message: "Failed to upload file", toastType: ToastType.error); + }, + ); + } catch (error) { + print('Error occurred during form submission: $error'); + } + } + +// Modify the lookupMimeType function if needed + String fileupload_fieldlookupMimeType(String filePath) { + final ext = filePath.split('.').last; + switch (ext) { + case 'jpg': + case 'jpeg': + return 'image/jpeg'; + case 'png': + return 'image/png'; + case 'pdf': + return 'application/pdf'; + // Add more cases for other file types as needed + default: + return 'application/octet-stream'; // Default MIME type + } + } + + +// Modify the uploadimageupload_fieldimage function + Future uploadimageupload_field(String ref, String refTableNmae, + String selectedFilePath, Uint8List image_timageBytes) async { + try { + + final Uint8List fileBytes = image_timageBytes!; + final mimeType = imageupload_fieldlookupMimeType(selectedFilePath); + + FormData formData = FormData.fromMap({ + 'file': MultipartFile.fromBytes( + fileBytes, + filename: selectedFilePath + .split('/') + .last, // Get the file name from the path + contentType: MediaType.parse(mimeType!), + ), + }); +await repo.imageupload_fieldUpload(ref, refTableNmae, formData).then((value) { + ToastMessageUtil.showToast( + message: "File uploaded successfully", + toastType: ToastType.success); + }).onError( + (error, stackTrace) { + print("error--$error"); + ToastMessageUtil.showToast( + message: "Failed to upload file", toastType: ToastType.error); + }, + ); + } catch (error) { + print('Error occurred during form submission: $error'); + } + } + +// Modify the lookupMimeType function if needed + String imageupload_fieldlookupMimeType(String filePath) { + final ext = filePath.split('.').last; + switch (ext) { + case 'jpg': + case 'jpeg': + return 'image/jpeg'; + case 'png': + return 'image/png'; + case 'pdf': + return 'application/pdf'; + // Add more cases for other file types as needed + default: + return 'application/octet-stream'; // Default MIME type + } + } + + +// Modify the uploadaudio_fieldimage function + Future uploadaudio_field(String ref, String refTableNmae, + String selectedFilePath, Uint8List image_timageBytes) async { + try { + + final Uint8List fileBytes = image_timageBytes!; + final mimeType = audio_fieldlookupMimeType(selectedFilePath); + + FormData formData = FormData.fromMap({ + 'file': MultipartFile.fromBytes( + fileBytes, + filename: selectedFilePath + .split('/') + .last, // Get the file name from the path + contentType: MediaType.parse(mimeType!), + ), + }); + + + await repo.audio_fieldUpload(ref, refTableNmae, formData).then((value) { + ToastMessageUtil.showToast( + message: "File uploaded successfully", + toastType: ToastType.success); + }).onError( + (error, stackTrace) { + print("error--$error"); + ToastMessageUtil.showToast( + message: "Failed to upload file", toastType: ToastType.error); + }, + ); + } catch (error) { + print('Error occurred during form submission: $error'); + } + } + +// Modify the lookupMimeType function if needed + String audio_fieldlookupMimeType(String filePath) { + final ext = filePath.split('.').last.toLowerCase(); + switch (ext) { + case 'mp3': + return 'audio/mpeg'; + case 'wav': + return 'audio/wav'; + case 'm4a': + return 'audio/mp4'; + case 'flac': + return 'audio/flac'; + // Add more cases for other audio formats as needed + default: + return 'application/octet-stream'; // Default MIME type + } +} + + +// Modify the uploadvideo_fieldimage function + Future uploadvideo_field(String ref, String refTableNmae, + String selectedFilePath, Uint8List image_timageBytes) async { + try { + + final Uint8List fileBytes = image_timageBytes!; + final mimeType = video_fieldlookupMimeType(selectedFilePath); + + FormData formData = FormData.fromMap({ + 'file': MultipartFile.fromBytes( + fileBytes, + filename: selectedFilePath + .split('/') + .last, // Get the file name from the path + contentType: MediaType.parse(mimeType!), + ), + }); + + + + await repo.video_fieldUpload(ref, refTableNmae, formData).then((value) { + ToastMessageUtil.showToast( + message: "File uploaded successfully", + toastType: ToastType.success); + }).onError( + (error, stackTrace) { + print("error--$error"); + ToastMessageUtil.showToast( + message: "Failed to upload file", toastType: ToastType.error); + }, + ); + } catch (error) { + print('Error occurred during form submission: $error'); + } + } + +// Modify the lookupMimeType function if needed + String video_fieldlookupMimeType(String filePath) { + final ext = filePath.split('.').last.toLowerCase(); + switch (ext) { + case 'mp4': + return 'video/mp4'; + case 'mov': + return 'video/quicktime'; + case 'avi': + return 'video/x-msvideo'; + case 'wmv': + return 'video/x-ms-wmv'; + case 'flv': + return 'video/x-flv'; + case 'mkv': + return 'video/x-matroska'; + // Add more cases for other file types as needed + default: + return 'application/octet-stream'; // Default MIME type + } + } + + + + + + + + + + + + + +} \ No newline at end of file diff --git a/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/commans/widgets/custome_drawer.dart b/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/commans/widgets/custome_drawer.dart index 73fb148..16cedb3 100644 --- a/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/commans/widgets/custome_drawer.dart +++ b/testingflutter103-front-f/authsec_flutterNewUi/base_project/lib/commans/widgets/custome_drawer.dart @@ -1,3 +1,6 @@ +import '../../Entity/vpspack/Emp_details/Emp_detailsView/Emp_details_entity_list_screen.dart'; +import '../../Entity/vpspack/Emp_details/Emp_details_viewModel/Emp_details_view_model_screen.dart'; + import 'package:base_project/utils/image_constant.dart'; import 'package:base_project/commans/widgets/custome_drawe_item.dart'; import 'package:base_project/resources/app_colors.dart'; @@ -9,79 +12,96 @@ import 'package:flutter_svg/svg.dart'; import 'package:provider/provider.dart'; class MyCustomDrawer extends StatelessWidget { - const MyCustomDrawer({super.key}); +const MyCustomDrawer({super.key}); - @override - Widget build(BuildContext context) { - final email = UserManager().email; - final userName = UserManager().userName; - final provider = Provider.of(context, listen: false); - return Drawer( - child: ListView( - padding: EdgeInsets.zero, - children: [ - UserAccountsDrawerHeader( - decoration: const BoxDecoration( - color: AppColors.primary, - ), - currentAccountPicture: CircleAvatar( - radius: 60, - backgroundColor: AppColors.primary.withOpacity(0.3), - backgroundImage: provider.profileImageBytes != null - ? MemoryImage(provider.profileImageBytes!) - : null, - child: provider.profileImageBytes != null - ? null // Use backgroundImage for the actual image, so child should be null - : SvgPicture.asset( - ImageConstant.userProfileImg, // Placeholder SVG asset +@override +Widget build(BuildContext context) { +final email = UserManager().email; +final userName = UserManager().userName; +final provider = Provider.of(context, listen: false); +return Drawer( +child: ListView( +padding: EdgeInsets.zero, +children: [ +UserAccountsDrawerHeader( +decoration: const BoxDecoration( +color: AppColors.primary, +), +currentAccountPicture: CircleAvatar( +radius: 60, +backgroundColor: AppColors.primary.withOpacity(0.3), +backgroundImage: provider.profileImageBytes != null +? MemoryImage(provider.profileImageBytes!) +: null, +child: provider.profileImageBytes != null +? null // Use backgroundImage for the actual image, so child should be null +: SvgPicture.asset( +ImageConstant.userProfileImg, // Placeholder SVG asset // AppImages.userProfileImg, // Placeholder SVG asset - width: 60, // Adjust to fit the CircleAvatar - height: 60, - ), - ), - accountName: Text("Hello, $userName"), - accountEmail: Text(email.toString()), - ), - DrawerItem( - color: AppColors.primary, - icon: Icons.person, - title: 'Profile', - onTap: () { - Navigator.pushNamed(context, RouteNames.profileView); - }, - ), - DrawerItem( - color: AppColors.primary, - icon: Icons.system_security_update, - title: 'System Parameters', - onTap: () { +width: 60, // Adjust to fit the CircleAvatar +height: 60, +), +), +accountName: Text("Hello, $userName"), +accountEmail: Text(email.toString()), +), +DrawerItem( +color: AppColors.primary, +icon: Icons.person, +title: 'Profile', +onTap: () { +Navigator.pushNamed(context, RouteNames.profileView); +}, +), +DrawerItem( +color: AppColors.primary, +icon: Icons.system_security_update, +title: 'System Parameters', +onTap: () { // Add navigation or other logic here - Navigator.pushNamed(context, RouteNames.systemParamsView); - }, - ), - DrawerItem( - color: AppColors.primary, - icon: Icons.password, - title: 'change password', - onTap: () { - Navigator.pushNamed(context, RouteNames.changePasswordView); - }, - ), +Navigator.pushNamed(context, RouteNames.systemParamsView); +}, +), +DrawerItem( +color: AppColors.primary, +icon: Icons.password, +title: 'change password', +onTap: () { +Navigator.pushNamed(context, RouteNames.changePasswordView); +}, +), // NEW MENU - - DrawerItem( - icon: Icons.logout, - color: Colors.red, - title: 'Logout', - onTap: () async { - await UserManager().clearUser(); - Navigator.pushReplacementNamed(context, RouteNames.splashView); - }, +DrawerItem( + color: AppColors.primary, + icon: Icons.chat_bubble, + title: 'Emp_details', + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ChangeNotifierProvider( + create: (context) => Emp_detailsViewModelScreen(), + child: emp_details_entity_list_screen(), + ), + ), + ); + }, ), - ], - ), - ); - } + + +DrawerItem( +icon: Icons.logout, +color: Colors.red, +title: 'Logout', +onTap: () async { +await UserManager().clearUser(); +Navigator.pushReplacementNamed(context, RouteNames.splashView); +}, +), +], +), +); } +} \ No newline at end of file