diff --git a/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java index f9801fb..e4fefd1 100644 --- a/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java @@ -69,6 +69,15 @@ public class BuilderService { executeDump(true); // ADD OTHER SERVICE +addCustomMenu( "Child","Child", "Transcations"); + + +addCustomMenu( "Testlist","Testlist", "Transcations"); + + +addCustomMenu( "Testss","Testss", "Transcations"); + + System.out.println("dashboard and menu inserted..."); diff --git a/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/ChildController.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/ChildController.java new file mode 100644 index 0000000..d5d40cb --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/ChildController.java @@ -0,0 +1,83 @@ +package com.realnet.basicp1.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.basicp1.Entity.Child; +import com.realnet.basicp1.Services.ChildService ; + + +@RequestMapping(value = "/Child") + @CrossOrigin("*") +@RestController +public class ChildController { + @Autowired + private ChildService Service; + +@Value("${projectPath}") + private String projectPath; + + + + @PostMapping("/Child") + public Child Savedata(@RequestBody Child data) { + Child save = Service.Savedata(data) ; + + System.out.println("data saved..." + save); + + return save; + } +@PutMapping("/Child/{id}") + public Child update(@RequestBody Child data,@PathVariable Integer id ) { + Child update = Service.update(data,id); + System.out.println("data update..." + update); + return update; + } +// get all with pagination + @GetMapping("/Child/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("/Child") + public List getdetails() { + List get = Service.getdetails(); + return get; +} +// get all without authentication + + @GetMapping("/token/Child") + public List getallwioutsec() { + List get = Service.getdetails(); + return get; +} +@GetMapping("/Child/{id}") + public Child getdetailsbyId(@PathVariable Integer id ) { + Child get = Service.getdetailsbyId(id); + return get; + } +@DeleteMapping("/Child/{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/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/TestlistController.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/TestlistController.java new file mode 100644 index 0000000..fd34299 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/TestlistController.java @@ -0,0 +1,99 @@ +package com.realnet.basicp1.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.basicp1.Entity.Testlist; +import com.realnet.basicp1.Services.TestlistService ; + + + + + + +@RequestMapping(value = "/Testlist") + @CrossOrigin("*") +@RestController +public class TestlistController { + @Autowired + private TestlistService Service; + +@Value("${projectPath}") + private String projectPath; + + + + + + + + @PostMapping("/Testlist") + public Testlist Savedata(@RequestBody Testlist data) { + Testlist save = Service.Savedata(data) ; + + + + + + System.out.println("data saved..." + save); + + return save; + } +@PutMapping("/Testlist/{id}") + public Testlist update(@RequestBody Testlist data,@PathVariable Integer id ) { + Testlist update = Service.update(data,id); + System.out.println("data update..." + update); + return update; + } +// get all with pagination + @GetMapping("/Testlist/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("/Testlist") + public List getdetails() { + List get = Service.getdetails(); + return get; +} +// get all without authentication + + @GetMapping("/token/Testlist") + public List getallwioutsec() { + List get = Service.getdetails(); + return get; +} +@GetMapping("/Testlist/{id}") + public Testlist getdetailsbyId(@PathVariable Integer id ) { + Testlist get = Service.getdetailsbyId(id); + return get; + } +@DeleteMapping("/Testlist/{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/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/Testlist_ListFilter1Controller.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/Testlist_ListFilter1Controller.java new file mode 100644 index 0000000..7ce75d3 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/Testlist_ListFilter1Controller.java @@ -0,0 +1,24 @@ +package com.realnet.basicp1.Controllers; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.web.bind.annotation.*; +import com.realnet.basicp1.Entity.Testlist_ListFilter1; +import com.realnet.basicp1.Services.Testlist_ListFilter1Service ; +@RequestMapping(value = "/Testlist_ListFilter1") +@RestController +public class Testlist_ListFilter1Controller { + + @Autowired + private Testlist_ListFilter1Service Service; + + @GetMapping("/Testlist_ListFilter1") + public List getlist() { + List get = Service.getlistbuilder(); + return get; +} + @GetMapping("/Testlist_ListFilter11") + public List getlistwithparam( ) { + List get = Service.getlistbuilderparam( ); + return get; +} +} \ No newline at end of file diff --git a/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/TestssController.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/TestssController.java new file mode 100644 index 0000000..2d6b809 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/TestssController.java @@ -0,0 +1,123 @@ +package com.realnet.basicp1.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.basicp1.Entity.Testss; +import com.realnet.basicp1.Services.TestssService ; + + + + + + + + + + + + +@RequestMapping(value = "/Testss") + @CrossOrigin("*") +@RestController +public class TestssController { + @Autowired + private TestssService Service; + +@Value("${projectPath}") + private String projectPath; + + + + + + + + + + + + + + @PostMapping("/Testss") + public Testss Savedata(@RequestBody Testss data) { + Testss save = Service.Savedata(data) ; + + + + + + + + + + + + System.out.println("data saved..." + save); + + return save; + } +@PutMapping("/Testss/{id}") + public Testss update(@RequestBody Testss data,@PathVariable Integer id ) { + Testss update = Service.update(data,id); + System.out.println("data update..." + update); + return update; + } +// get all with pagination + @GetMapping("/Testss/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("/Testss") + public List getdetails() { + List get = Service.getdetails(); + return get; +} +// get all without authentication + + @GetMapping("/token/Testss") + public List getallwioutsec() { + List get = Service.getdetails(); + return get; +} +@GetMapping("/Testss/{id}") + public Testss getdetailsbyId(@PathVariable Integer id ) { + Testss get = Service.getdetailsbyId(id); + return get; + } +@DeleteMapping("/Testss/{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/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/tokenFree_ChildController.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/tokenFree_ChildController.java new file mode 100644 index 0000000..33b5de6 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/tokenFree_ChildController.java @@ -0,0 +1,83 @@ +package com.realnet.basicp1.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.basicp1.Entity.Child; +import com.realnet.basicp1.Services.ChildService ; + + +@RequestMapping(value = "/token/Child") + @CrossOrigin("*") +@RestController +public class tokenFree_ChildController { + @Autowired + private ChildService Service; + +@Value("${projectPath}") + private String projectPath; + + + + @PostMapping("/Child") + public Child Savedata(@RequestBody Child data) { + Child save = Service.Savedata(data) ; + + System.out.println("data saved..." + save); + + return save; + } +@PutMapping("/Child/{id}") + public Child update(@RequestBody Child data,@PathVariable Integer id ) { + Child update = Service.update(data,id); + System.out.println("data update..." + update); + return update; + } +// get all with pagination + @GetMapping("/Child/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("/Child") + public List getdetails() { + List get = Service.getdetails(); + return get; +} +// get all without authentication + + @GetMapping("/token/Child") + public List getallwioutsec() { + List get = Service.getdetails(); + return get; +} +@GetMapping("/Child/{id}") + public Child getdetailsbyId(@PathVariable Integer id ) { + Child get = Service.getdetailsbyId(id); + return get; + } +@DeleteMapping("/Child/{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/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/tokenFree_TestlistController.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/tokenFree_TestlistController.java new file mode 100644 index 0000000..2a1bd06 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/tokenFree_TestlistController.java @@ -0,0 +1,99 @@ +package com.realnet.basicp1.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.basicp1.Entity.Testlist; +import com.realnet.basicp1.Services.TestlistService ; + + + + + + +@RequestMapping(value = "/token/Testlist") + @CrossOrigin("*") +@RestController +public class tokenFree_TestlistController { + @Autowired + private TestlistService Service; + +@Value("${projectPath}") + private String projectPath; + + + + + + + + @PostMapping("/Testlist") + public Testlist Savedata(@RequestBody Testlist data) { + Testlist save = Service.Savedata(data) ; + + + + + + System.out.println("data saved..." + save); + + return save; + } +@PutMapping("/Testlist/{id}") + public Testlist update(@RequestBody Testlist data,@PathVariable Integer id ) { + Testlist update = Service.update(data,id); + System.out.println("data update..." + update); + return update; + } +// get all with pagination + @GetMapping("/Testlist/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("/Testlist") + public List getdetails() { + List get = Service.getdetails(); + return get; +} +// get all without authentication + + @GetMapping("/token/Testlist") + public List getallwioutsec() { + List get = Service.getdetails(); + return get; +} +@GetMapping("/Testlist/{id}") + public Testlist getdetailsbyId(@PathVariable Integer id ) { + Testlist get = Service.getdetailsbyId(id); + return get; + } +@DeleteMapping("/Testlist/{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/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/tokenFree_Testlist_ListFilter1Controller.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/tokenFree_Testlist_ListFilter1Controller.java new file mode 100644 index 0000000..8a5c566 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/tokenFree_Testlist_ListFilter1Controller.java @@ -0,0 +1,24 @@ +package com.realnet.basicp1.Controllers; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.web.bind.annotation.*; +import com.realnet.basicp1.Entity.Testlist_ListFilter1; +import com.realnet.basicp1.Services.Testlist_ListFilter1Service ; +@RequestMapping(value = "/token/Testlist_ListFilter1") +@RestController +public class tokenFree_Testlist_ListFilter1Controller { + + @Autowired + private Testlist_ListFilter1Service Service; + + @GetMapping("/Testlist_ListFilter1") + public List getlist() { + List get = Service.getlistbuilder(); + return get; +} + @GetMapping("/Testlist_ListFilter11") + public List getlistwithparam( ) { + List get = Service.getlistbuilderparam( ); + return get; +} +} \ No newline at end of file diff --git a/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/tokenFree_TestssController.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/tokenFree_TestssController.java new file mode 100644 index 0000000..82c55c3 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/tokenFree_TestssController.java @@ -0,0 +1,123 @@ +package com.realnet.basicp1.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.basicp1.Entity.Testss; +import com.realnet.basicp1.Services.TestssService ; + + + + + + + + + + + + +@RequestMapping(value = "/token/Testss") + @CrossOrigin("*") +@RestController +public class tokenFree_TestssController { + @Autowired + private TestssService Service; + +@Value("${projectPath}") + private String projectPath; + + + + + + + + + + + + + + @PostMapping("/Testss") + public Testss Savedata(@RequestBody Testss data) { + Testss save = Service.Savedata(data) ; + + + + + + + + + + + + System.out.println("data saved..." + save); + + return save; + } +@PutMapping("/Testss/{id}") + public Testss update(@RequestBody Testss data,@PathVariable Integer id ) { + Testss update = Service.update(data,id); + System.out.println("data update..." + update); + return update; + } +// get all with pagination + @GetMapping("/Testss/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("/Testss") + public List getdetails() { + List get = Service.getdetails(); + return get; +} +// get all without authentication + + @GetMapping("/token/Testss") + public List getallwioutsec() { + List get = Service.getdetails(); + return get; +} +@GetMapping("/Testss/{id}") + public Testss getdetailsbyId(@PathVariable Integer id ) { + Testss get = Service.getdetailsbyId(id); + return get; + } +@DeleteMapping("/Testss/{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/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Child.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Child.java new file mode 100644 index 0000000..4639ecc --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Child.java @@ -0,0 +1,24 @@ +package com.realnet.basicp1.Entity; + import lombok.*; +import com.realnet.WhoColumn.Entity.Extension; + import javax.persistence.*; + import java.time.LocalDateTime; + import java.util.*; + + + @Entity + @Data + public class Child extends Extension { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + +private String name; + + +} diff --git a/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Testlist.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Testlist.java new file mode 100644 index 0000000..4f42e76 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Testlist.java @@ -0,0 +1,33 @@ +package com.realnet.basicp1.Entity; + import lombok.*; +import com.realnet.WhoColumn.Entity.Extension; + import javax.persistence.*; + import java.time.LocalDateTime; + import java.util.*; + + + + + + + @Entity + @Data + public class Testlist extends Extension { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + +private String name; + +@Column(length = 2000) +private String description; + +private boolean active; + + +} diff --git a/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Testlist_ListFilter1.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Testlist_ListFilter1.java new file mode 100644 index 0000000..23f52a9 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Testlist_ListFilter1.java @@ -0,0 +1,14 @@ +package com.realnet.basicp1.Entity; + import lombok.*; + import javax.persistence.*; + import java.time.LocalDateTime; + import java.util.*; + + @Data + public class Testlist_ListFilter1 { + + private Integer id; + + + private String name; +} diff --git a/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Testss.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Testss.java new file mode 100644 index 0000000..3dc6a55 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Testss.java @@ -0,0 +1,60 @@ +package com.realnet.basicp1.Entity; + import lombok.*; +import com.realnet.WhoColumn.Entity.Extension; + import javax.persistence.*; + import java.time.LocalDateTime; + import java.util.*; + + + + +import com.realnet.basicp1.Entity.Child; + + + + + + + + @Entity + @Data + public class Testss extends Extension { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + +private String name; + + + + + +private String bar_code; + + + + +private String qr_code; + + + +@OneToOne( cascade=CascadeType.ALL) + private Child child; + + + + + +private String dependent_dropdown_field; + + + + + + +} diff --git a/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/ChildRepository.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/ChildRepository.java new file mode 100644 index 0000000..8101d37 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/ChildRepository.java @@ -0,0 +1,26 @@ +package com.realnet.basicp1.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.basicp1.Entity.Child; + +@Repository +public interface ChildRepository extends JpaRepository { + +@Query(value = "select * from child where created_by=?1", nativeQuery = true) + List findAll(Long creayedBy); + +@Query(value = "select * from child where created_by=?1", nativeQuery = true) + Page findAll(Pageable page, Long creayedBy); +} \ No newline at end of file diff --git a/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/TestlistRepository.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/TestlistRepository.java new file mode 100644 index 0000000..7fae69c --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/TestlistRepository.java @@ -0,0 +1,30 @@ +package com.realnet.basicp1.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.basicp1.Entity.Testlist; + +@Repository +public interface TestlistRepository extends JpaRepository { + +@Query(value = "select * from testlist where created_by=?1", nativeQuery = true) + List findAll(Long creayedBy); + +@Query(value = "select * from testlist where created_by=?1", nativeQuery = true) + Page findAll(Pageable page, Long creayedBy); +} \ No newline at end of file diff --git a/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/TestssRepository.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/TestssRepository.java new file mode 100644 index 0000000..f52e525 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/TestssRepository.java @@ -0,0 +1,36 @@ +package com.realnet.basicp1.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.basicp1.Entity.Testss; + +@Repository +public interface TestssRepository extends JpaRepository { + +@Query(value = "select * from testss where created_by=?1", nativeQuery = true) + List findAll(Long creayedBy); + +@Query(value = "select * from testss where created_by=?1", nativeQuery = true) + Page findAll(Pageable page, Long creayedBy); +} \ No newline at end of file diff --git a/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/ChildService.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/ChildService.java new file mode 100644 index 0000000..8a991c4 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/ChildService.java @@ -0,0 +1,73 @@ +package com.realnet.basicp1.Services; +import com.realnet.basicp1.Repository.ChildRepository; +import com.realnet.basicp1.Entity.Child +;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 ChildService { +@Autowired +private ChildRepository Repository; + @Autowired + private AppUserServiceImpl userService; +@Autowired + private RealmService realmService; + +public Child Savedata(Child data) { + + + data.setUpdatedBy(getUser().getUserId()); + data.setCreatedBy(getUser().getUserId()); + data.setAccountId(getUser().getAccount().getAccount_id()); +Child 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 Child getdetailsbyId(Integer id) { + return Repository.findById(id).get(); + } + + + public void delete_by_id(Integer id) { + Repository.deleteById(id); +} + + +public Child update(Child data,Integer id) { + Child old = Repository.findById(id).get(); +old.setName(data.getName()); + +final Child test = Repository.save(old); + data.setUpdatedBy(getUser().getUserId()); + return test;} + + + public AppUser getUser() { + AppUser user = userService.getLoggedInUser(); + return user; + + }} diff --git a/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/TestlistService.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/TestlistService.java new file mode 100644 index 0000000..732bd85 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/TestlistService.java @@ -0,0 +1,93 @@ +package com.realnet.basicp1.Services; +import com.realnet.basicp1.Repository.TestlistRepository; +import com.realnet.basicp1.Entity.Testlist +;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 TestlistService { +@Autowired +private TestlistRepository Repository; + @Autowired + private AppUserServiceImpl userService; +@Autowired + private RealmService realmService; + + + + + +public Testlist Savedata(Testlist data) { + + + + + + + data.setUpdatedBy(getUser().getUserId()); + data.setCreatedBy(getUser().getUserId()); + data.setAccountId(getUser().getAccount().getAccount_id()); +Testlist 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 Testlist getdetailsbyId(Integer id) { + return Repository.findById(id).get(); + } + + + public void delete_by_id(Integer id) { + Repository.deleteById(id); +} + + +public Testlist update(Testlist data,Integer id) { + Testlist old = Repository.findById(id).get(); +old.setName(data.getName()); + +old.setDescription(data.getDescription()); + +old.setActive (data.isActive()); + +final Testlist test = Repository.save(old); + data.setUpdatedBy(getUser().getUserId()); + return test;} + + + + + + + public AppUser getUser() { + AppUser user = userService.getLoggedInUser(); + return user; + + }} diff --git a/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/Testlist_ListFilter1Service.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/Testlist_ListFilter1Service.java new file mode 100644 index 0000000..6862d90 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/Testlist_ListFilter1Service.java @@ -0,0 +1,51 @@ +package com.realnet.basicp1.Services; +import java.util.*; +import com.realnet.basicp1.Repository.TestlistRepository; +import com.realnet.basicp1.Entity.Testlist; + +import com.realnet.basicp1.Entity.Testlist_ListFilter1; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Service; + +@Service + public class Testlist_ListFilter1Service { +@Autowired +private TestlistRepository Repository; + + + + + public List getlistbuilder() { + List list= Repository.findAll(); + ArrayList l = new ArrayList<>(); + for (Testlist data : list) { +boolean isactive = data.isActive(); + + if (isactive) {{ +Testlist_ListFilter1 dummy = new Testlist_ListFilter1(); + dummy.setId(data.getId()); + dummy.setName(data.getName()); + l.add(dummy); +}} +} +return l;} + + + + public List getlistbuilderparam( ) { + List list= Repository.findAll(); + ArrayList l = new ArrayList<>(); + for (Testlist data : list) { +boolean isactive = data.isActive(); + + if (isactive) {{ +Testlist_ListFilter1 dummy = new Testlist_ListFilter1(); + dummy.setId(data.getId()); + dummy.setName(data.getName()); + l.add(dummy); +}} +} +return l;} +} \ No newline at end of file diff --git a/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/TestssService.java b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/TestssService.java new file mode 100644 index 0000000..62c2327 --- /dev/null +++ b/testflutter003-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/TestssService.java @@ -0,0 +1,135 @@ +package com.realnet.basicp1.Services; +import com.realnet.basicp1.Repository.TestssRepository; +import com.realnet.basicp1.Entity.Testss +;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 TestssService { +@Autowired +private TestssRepository Repository; + @Autowired + private AppUserServiceImpl userService; +@Autowired + private RealmService realmService; + + + + + + + + + + + +public Testss Savedata(Testss data) { + + + + + + + + + + + + + data.setUpdatedBy(getUser().getUserId()); + data.setCreatedBy(getUser().getUserId()); + data.setAccountId(getUser().getAccount().getAccount_id()); +Testss 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 Testss getdetailsbyId(Integer id) { + return Repository.findById(id).get(); + } + + + public void delete_by_id(Integer id) { + Repository.deleteById(id); +} + + +public Testss update(Testss data,Integer id) { + Testss old = Repository.findById(id).get(); +old.setName(data.getName()); + + + +old.setBar_code(data.getBar_code()); + + + +old.setQr_code(data.getQr_code()); + + + + +old.setChild(data.getChild()); + + + + + +old.setDependent_dropdown_field(data.getDependent_dropdown_field()); + + + + +final Testss test = Repository.save(old); + data.setUpdatedBy(getUser().getUserId()); + return test;} + + + + + + + + + + + + + public AppUser getUser() { + AppUser user = userService.getLoggedInUser(); + return user; + + }} diff --git a/testflutter003-dbs-d/authsec_mysql/mysql/wf_table/wf_table.sql b/testflutter003-dbs-d/authsec_mysql/mysql/wf_table/wf_table.sql new file mode 100755 index 0000000..1500a17 --- /dev/null +++ b/testflutter003-dbs-d/authsec_mysql/mysql/wf_table/wf_table.sql @@ -0,0 +1,6 @@ +CREATE TABLE dbs.Testss(id BIGINT NOT NULL AUTO_INCREMENT, onetoone VARCHAR(400), bar_code VARCHAR(400), qr_code VARCHAR(400), value_list_field VARCHAR(400), datagrid_field VARCHAR(400), name VARCHAR(400), dependent_dropdown_field VARCHAR(400), PRIMARY KEY (id)); + +CREATE TABLE dbs.Testlist(id BIGINT NOT NULL AUTO_INCREMENT, active VARCHAR(400), description VARCHAR(400), name VARCHAR(400), PRIMARY KEY (id)); + +CREATE TABLE dbs.Child(id BIGINT NOT NULL AUTO_INCREMENT, name VARCHAR(400), PRIMARY KEY (id)); + diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/ChildView/Child_api_service.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/ChildView/Child_api_service.dart new file mode 100644 index 0000000..71086be --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/ChildView/Child_api_service.dart @@ -0,0 +1,76 @@ +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 childApiService { + final String baseUrl = ApiConstants.baseUrl; + + final BaseNetworkService _helper = NetworkApiService(); + + + + Future>> getEntities() async { + + try { + final response = await _helper.getGetApiResponse('$baseUrl/Child/Child'); + 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/Child/Child/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/Child/Child', 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/Child/Child/$entityId', + entity); print(entity); + + } catch (e) { + throw Exception('Failed to update entity: $e'); + } + } + + Future deleteEntity( int entityId) async { + try { + await _helper.getDeleteApiResponse('$baseUrl/Child/Child/$entityId'); + } catch (e) { + throw Exception('Failed to delete entity: $e'); + } + } + + +} \ No newline at end of file diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/ChildView/Child_create_entity_screen.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/ChildView/Child_create_entity_screen.dart new file mode 100644 index 0000000..6ce54cb --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/ChildView/Child_create_entity_screen.dart @@ -0,0 +1,155 @@ +// 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 '../Child_viewModel/Child_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 childCreateEntityScreen extends StatefulWidget { + const childCreateEntityScreen({super.key}); + + @override + _childCreateEntityScreenState createState() => _childCreateEntityScreenState(); +} + +class _childCreateEntityScreenState extends State { + +final Map formData = {}; + final _formKey = GlobalKey(); + final TextEditingController nameController = TextEditingController(); + + + @override + void initState() { + super.initState(); + final provider = Provider.of(context, listen: false); + + +} + + + + @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 Child"), + actions: [ + + +], + ), + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16), + child: Form( + key: _formKey, + child: Column( + children: [ + ReusableTextField( + controller: nameController, + + onSaved:(value) => formData['name'] = value , + label:"Enter Name", + // ValidationProperties +), + + SizedBox(height: 16), + + + 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(); + + + + try { + print(formData); + Map createdEntity = await provider.createEntity(formData); + + + + + 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 Child: $e'), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + } + }, + ), + + + ], + ), + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/ChildView/Child_entity_list_screen.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/ChildView/Child_entity_list_screen.dart new file mode 100644 index 0000000..eb0d5a2 --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/ChildView/Child_entity_list_screen.dart @@ -0,0 +1,576 @@ +// ignore_for_file: use_build_context_synchronously +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'Child_create_entity_screen.dart'; +import 'Child_update_entity_screen.dart'; +import '../Child_viewModel/Child_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 child_entity_list_screen extends StatefulWidget { + + + final Map tabEntity; + const child_entity_list_screen({required this.tabEntity, Key? key}) + : super(key: key); static const String routeName = '/entity-list'; + + @override + _child_entity_list_screenState createState() => _child_entity_list_screenState(); +} + +class _child_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 Child: $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.getEntities(widget.tabEntity['id']); + setState(() { + var getentity = widget.tabEntity['gauravt2']; + final fetchedEntities = + (getentity as List).cast>(); + entities.addAll(fetchedEntities); // Add new data to the existing list + filteredEntities = entities.toList(); // Update only filteredEntities + serachEntities = filteredEntities; + currentPage++; + }); + } catch (e) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Error'), + content: Text('Failed to fetch Child 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['name'].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: " Child"), + 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) => ChildViewModelScreen(), + child: childCreateEntityScreen(), + ), + ), + ).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) => ChildViewModelScreen(), + child: childUpdateEntityScreen(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( + "Name : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['name'].toString() ?? 'No Name 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/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/ChildView/Child_update_entity_screen.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/ChildView/Child_update_entity_screen.dart new file mode 100644 index 0000000..4a7aa75 --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/ChildView/Child_update_entity_screen.dart @@ -0,0 +1,143 @@ +// ignore_for_file: use_build_context_synchronously +import 'dart:convert'; +import 'package:provider/provider.dart'; +import '../Child_viewModel/Child_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 childUpdateEntityScreen extends StatefulWidget { + final Map entity; + + + childUpdateEntityScreen({required this.entity}); + + @override + _childUpdateEntityScreenState createState() => _childUpdateEntityScreenState(); +} + +class _childUpdateEntityScreenState extends State { + final _formKey = GlobalKey(); + + + + + @override + void initState() { + super.initState(); + final provider = Provider.of(context, listen: false); + + +} + + + @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 Child"), actions: [ + + + ], +), + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16), + child: Form( + key: _formKey, + child: Column( + children: [ + + ReusableTextField( + + label: "Please Enter Name", + initialValue: widget.entity['name'] ?? '', + + // ValidationProperties + onSaved: (value) => widget.entity['name'] = value, +), + + SizedBox(height: 16), + + + + CustomButton( + height: getVerticalSize(50), + text: "Update", + margin: getMargin(top: 24, bottom: 5), + onTap: () async { + if (_formKey.currentState!.validate()) { + _formKey.currentState!.save(); + + + + 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 Child: $e'), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + } + }, + ), + ], + ), + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/Child_Repo/Child_repo_screen.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/Child_Repo/Child_repo_screen.dart new file mode 100644 index 0000000..cbead7c --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/Child_Repo/Child_repo_screen.dart @@ -0,0 +1,64 @@ +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 ChildRepoScreen { + final String baseUrl = ApiConstants.baseUrl; + final BaseNetworkService _helper = NetworkApiService(); + + Future getEntities() async { + try { + final response = + await _helper.getGetApiResponse('$baseUrl/Child/Child'); + 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/Child/Child/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/Child/Child', 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/Child/Child/$entityId', entity); + print(entity); + } catch (e) { + throw Exception('Failed to update entity: $e'); + } + } + + Future deleteEntity(int entityId) async { + try { + await _helper + .getDeleteApiResponse('$baseUrl/Child/Child/$entityId'); + } catch (e) { + throw Exception('Failed to delete entity: $e'); + } + } + + +} diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/Child_viewModel/Child_view_model_screen.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/Child_viewModel/Child_view_model_screen.dart new file mode 100644 index 0000000..fd513b6 --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Child/Child_viewModel/Child_view_model_screen.dart @@ -0,0 +1,103 @@ +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 '../Child_Repo/Child_repo_screen.dart'; + +class ChildViewModelScreen extends ChangeNotifier{ + final ChildRepoScreen repo = ChildRepoScreen(); + + 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'); + } + } + + +} \ No newline at end of file diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/TestlistView/Testlist_api_service.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/TestlistView/Testlist_api_service.dart new file mode 100644 index 0000000..3e1fa54 --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/TestlistView/Testlist_api_service.dart @@ -0,0 +1,84 @@ +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 testlistApiService { + final String baseUrl = ApiConstants.baseUrl; + + final BaseNetworkService _helper = NetworkApiService(); + + + + Future>> getEntities() async { + + try { + final response = await _helper.getGetApiResponse('$baseUrl/Testlist/Testlist'); + 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/Testlist/Testlist/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/Testlist/Testlist', 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/Testlist/Testlist/$entityId', + entity); print(entity); + + } catch (e) { + throw Exception('Failed to update entity: $e'); + } + } + + Future deleteEntity( int entityId) async { + try { + await _helper.getDeleteApiResponse('$baseUrl/Testlist/Testlist/$entityId'); + } catch (e) { + throw Exception('Failed to delete entity: $e'); + } + } + + + + + + +} \ No newline at end of file diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/TestlistView/Testlist_create_entity_screen.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/TestlistView/Testlist_create_entity_screen.dart new file mode 100644 index 0000000..f886379 --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/TestlistView/Testlist_create_entity_screen.dart @@ -0,0 +1,214 @@ +// 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 '../Testlist_viewModel/Testlist_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 testlistCreateEntityScreen extends StatefulWidget { + const testlistCreateEntityScreen({super.key}); + + @override + _testlistCreateEntityScreenState createState() => _testlistCreateEntityScreenState(); +} + +class _testlistCreateEntityScreenState extends State { + +final Map formData = {}; + final _formKey = GlobalKey(); + final TextEditingController nameController = TextEditingController(); + + + final TextEditingController descriptionController = TextEditingController(); + + +bool _isSwitchedactive = false; +bool active = false; + +void _toggleSwitchactive(bool value) { + setState(() { + _isSwitchedactive = value; + }); +} + + @override + void initState() { + super.initState(); + final provider = Provider.of(context, listen: false); + + + + + + +} + + + + @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 Testlist"), + actions: [ + + + + + + +], + ), + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16), + child: Form( + key: _formKey, + child: Column( + children: [ + ReusableTextField( + controller: nameController, + + onSaved:(value) => formData['name'] = value , + label:"Enter Name", + // ValidationProperties +), + + SizedBox(height: 16), + + +ReusableTextField( + controller: descriptionController, + + onSaved:(value) => formData['description'] = value , + label: "Enter Description", + maxLines: 5, +// ValidationProperties +), + + + SizedBox(height: 16), + + + Switch( + value: _isSwitchedactive, + onChanged: _toggleSwitchactive, + activeColor: Colors.white, + activeTrackColor: Colors.green, + inactiveThumbColor: Colors.white, + inactiveTrackColor: Colors.red, + ), + + 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['active'] = active; + + + + try { + print(formData); + Map createdEntity = await provider.createEntity(formData); + + + + + + + + + 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 Testlist: $e'), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + } + }, + ), + + + + + + + ], + ), + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/TestlistView/Testlist_entity_list_screen.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/TestlistView/Testlist_entity_list_screen.dart new file mode 100644 index 0000000..c7ef044 --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/TestlistView/Testlist_entity_list_screen.dart @@ -0,0 +1,635 @@ +// ignore_for_file: use_build_context_synchronously +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'Testlist_create_entity_screen.dart'; +import 'Testlist_update_entity_screen.dart'; +import '../Testlist_viewModel/Testlist_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 testlist_entity_list_screen extends StatefulWidget { + static const String routeName = '/entity-list'; + + @override + _testlist_entity_list_screenState createState() => _testlist_entity_list_screenState(); +} + +class _testlist_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 Testlist: $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 Testlist 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['name'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['description'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + entity['active'].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: " Testlist"), + 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) => TestlistViewModelScreen(), + child: testlistCreateEntityScreen(), + ), + ), + ).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) => TestlistViewModelScreen(), + child: testlistUpdateEntityScreen(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( + "Name : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['name'].toString() ?? 'No Name Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Description : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['description'].toString() ?? 'No Description Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Active : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['active'].toString() ?? 'No Active 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/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/TestlistView/Testlist_update_entity_screen.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/TestlistView/Testlist_update_entity_screen.dart new file mode 100644 index 0000000..952d13e --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/TestlistView/Testlist_update_entity_screen.dart @@ -0,0 +1,190 @@ +// ignore_for_file: use_build_context_synchronously +import 'dart:convert'; +import 'package:provider/provider.dart'; +import '../Testlist_viewModel/Testlist_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 testlistUpdateEntityScreen extends StatefulWidget { + final Map entity; + + + testlistUpdateEntityScreen({required this.entity}); + + @override + _testlistUpdateEntityScreenState createState() => _testlistUpdateEntityScreenState(); +} + +class _testlistUpdateEntityScreenState extends State { + final _formKey = GlobalKey(); + + + + + + bool isactive = false; + + + @override + void initState() { + super.initState(); + final provider = Provider.of(context, listen: false); + + + + +isactive = widget.entity['active'] ?? false; // Set initial value + +} + + + @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 Testlist"), actions: [ + + + + + + + ], +), + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16), + child: Form( + key: _formKey, + child: Column( + children: [ + + ReusableTextField( + + label: "Please Enter Name", + initialValue: widget.entity['name'] ?? '', + + // ValidationProperties + onSaved: (value) => widget.entity['name'] = value, +), + + SizedBox(height: 16), + + + + ReusableTextField( + initialValue: widget.entity['description'], + onSaved: (value) => widget.entity['description']= value, + label: "Enter Description", + maxLines: 5, + ), + +Row( + children: [ + Switch( + value: isactive, + onChanged: (newValue) { + setState(() { + isactive = newValue; + }); + }, + activeColor: Colors.white, + activeTrackColor: Colors.green, + inactiveThumbColor: Colors.white, + inactiveTrackColor: Colors.red, + ), + const SizedBox(width: 8), + const Text('Active'), + ], +), + + + CustomButton( + height: getVerticalSize(50), + text: "Update", + margin: getMargin(top: 24, bottom: 5), + onTap: () async { + if (_formKey.currentState!.validate()) { + _formKey.currentState!.save(); + + + + +widget.entity['active'] = isactive; + + + 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 Testlist: $e'), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + } + }, + ), + ], + ), + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/Testlist_Repo/Testlist_repo_screen.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/Testlist_Repo/Testlist_repo_screen.dart new file mode 100644 index 0000000..82cbc03 --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/Testlist_Repo/Testlist_repo_screen.dart @@ -0,0 +1,68 @@ +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 TestlistRepoScreen { + final String baseUrl = ApiConstants.baseUrl; + final BaseNetworkService _helper = NetworkApiService(); + + Future getEntities() async { + try { + final response = + await _helper.getGetApiResponse('$baseUrl/Testlist/Testlist'); + 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/Testlist/Testlist/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/Testlist/Testlist', 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/Testlist/Testlist/$entityId', entity); + print(entity); + } catch (e) { + throw Exception('Failed to update entity: $e'); + } + } + + Future deleteEntity(int entityId) async { + try { + await _helper + .getDeleteApiResponse('$baseUrl/Testlist/Testlist/$entityId'); + } catch (e) { + throw Exception('Failed to delete entity: $e'); + } + } + + + + + + +} diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/Testlist_viewModel/Testlist_view_model_screen.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/Testlist_viewModel/Testlist_view_model_screen.dart new file mode 100644 index 0000000..e03919b --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testlist/Testlist_viewModel/Testlist_view_model_screen.dart @@ -0,0 +1,107 @@ +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 '../Testlist_Repo/Testlist_repo_screen.dart'; + +class TestlistViewModelScreen extends ChangeNotifier{ + final TestlistRepoScreen repo = TestlistRepoScreen(); + + 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'); + } + } + + + + + + +} \ No newline at end of file diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/TestssView/Testss_api_service.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/TestssView/Testss_api_service.dart new file mode 100644 index 0000000..b01f31f --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/TestssView/Testss_api_service.dart @@ -0,0 +1,123 @@ +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 testssApiService { + final String baseUrl = ApiConstants.baseUrl; + + final BaseNetworkService _helper = NetworkApiService(); + + + + Future>> getEntities() async { + + try { + final response = await _helper.getGetApiResponse('$baseUrl/Testss/Testss'); + 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/Testss/Testss/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/Testss/Testss', 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/Testss/Testss/$entityId', + entity); print(entity); + + } catch (e) { + throw Exception('Failed to update entity: $e'); + } + } + + Future deleteEntity( int entityId) async { + try { + await _helper.getDeleteApiResponse('$baseUrl/Testss/Testss/$entityId'); + } catch (e) { + throw Exception('Failed to delete entity: $e'); + } + } + + + + + + + + + + + + + + + Future>> getfirstName() async { + try { + final response = await _helper + .getGetApiResponse('$baseUrl/Name_ListFilter1/Name_ListFilter1'); + final entities = (response as List).cast>(); + return entities; + } catch (e) { + throw Exception('Failed to get first dd: $e'); + } + } + Future>> getsecondName(String name) async { + try { + final response = + await _helper.getGetApiResponse('$baseUrl/Name_ListFilter1/Name_ListFilter11/$name'); + final entities = (response as List).cast>(); + return entities; + } catch (e) { + throw Exception('Failed to get first dd: $e'); + } + } + + + + + +} \ No newline at end of file diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/TestssView/Testss_create_entity_screen.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/TestssView/Testss_create_entity_screen.dart new file mode 100644 index 0000000..1a2ec6b --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/TestssView/Testss_create_entity_screen.dart @@ -0,0 +1,765 @@ +// 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 '../Testss_viewModel/Testss_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 testssCreateEntityScreen extends StatefulWidget { + const testssCreateEntityScreen({super.key}); + + @override + _testssCreateEntityScreenState createState() => _testssCreateEntityScreenState(); +} + +class _testssCreateEntityScreenState extends State { + +final Map formData = {}; + final _formKey = GlobalKey(); + final TextEditingController nameController = TextEditingController(); + + + final TextEditingController field_groupController = TextEditingController(); + + + Widget buildFormField(String fieldOption) { + return Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: Card( + elevation: 4, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + child: Padding( + padding: const EdgeInsets.all(12.0), + child: TextFormField( + decoration: InputDecoration( + labelText: fieldOption, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + ), + ), + onSaved: (value) { + if (formData['child'] == null) { + formData['child'] = {}; + } + formData['child'][fieldOption] = value; + }, + ), + ), + ), + ); + } + + late Future>> _value_list_fielddataFuture; // Data from fetchData + + Future>> value_list_fieldfetchData() async { + +final provider = + Provider.of(context, listen: false); + final resp = await provider.getEntities(); + + if (resp != null) { + return resp; + } else { + throw Exception('Failed to load data: '); + } + + } + + + void showvalue_list_fieldDialog(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return SingleChildScrollView( + child: AlertDialog( + title: const Text('Select a record'), + content: FutureBuilder>>( + future: _value_list_fielddataFuture, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError) { + return Center(child: Text('Error: ${snapshot.error}')); + } else if (!snapshot.hasData || snapshot.data!.isEmpty) { + return const Center(child: Text('No data available..')); + } else { +final List columnsToShow = [ + + + + + 'name', + + + ]; + return SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + columnSpacing: 30, + headingRowColor: MaterialStateColor.resolveWith( + (states) => Colors.blue.shade100), + dataRowColor: MaterialStateColor.resolveWith( + (states) => Colors.white), + dividerThickness: 0.5, + columns: columnsToShow + .map( + (key) => DataColumn( + label: Text( + key, + style: const TextStyle( + fontWeight: FontWeight.bold, fontSize: 16), + ), + ), + ) + .toList(), + rows: snapshot.data!.map((item) { + return DataRow( + cells: columnsToShow.map((key) { + return DataCell( + Text( + item[key].toString(), + style: const TextStyle(fontSize: 14), + ), + onTap: () { + setState(() { + + + nameController.text = item['name'] ?? ''; + + + // Add more fields as needed + }); + Navigator.pop(context); + }, + ); + }).toList()); + }).toList(), + ), + ); + } + }, + ), + actions: [ + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ), + ); + }, + ); + } + + + late Future>> _datagrid_fielddataFuture; // Data from fetchData + + Future>> datagrid_fieldfetchData() async { + +final provider = + Provider.of(context, listen: false); + final resp = await provider.getdatagrid_fieldGrid(); + + if (resp != null) { + return resp; + } else { + throw Exception('Failed to load data: '); + } + + } + +// first dropdown + + + + List> dependent_dropdown_fieldItems = []; + var selecteddependent_dropdown_fieldValue = ''; // Use nullable type Future _load + Future _loaddependent_dropdown_fieldItems() async { + try { + final selectTdata = await apiService.getfirstName(); + + print(' dependent_dropdown_field data is : $selectTdata'); + // Handle null or empty dropdownData + if (selectTdata != null && selectTdata.isNotEmpty) { + setState(() { + dependent_dropdown_fieldItems = selectTdata; + }); + } else { + print(' dependent_dropdown_field data is null or empty'); + } + } catch (e) { + print('Failed to load dependent_dropdown_field items: $e'); + } + } + + Widget _buildDropdownDependent_dropdown_field( + String label, + List> options, + String? value, + void Function(String?) onChanged, + void Function(String?) onSaved, + ) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: DropdownButtonFormField( + decoration: InputDecoration( + labelText: label, + labelStyle: TextStyle( + color: Colors.deepPurple, + ), + contentPadding: const EdgeInsets.symmetric(horizontal: 16.0), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide(color: Colors.deepPurple, width: 2), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide(color: Colors.deepPurple, width: 2), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide(color: Colors.deepPurpleAccent, width: 2), + ), + ), + value: value!.isEmpty ? null : value, + items: [ + const DropdownMenuItem( + value: '', + child: Text('Select dependent_dropdown_field'), + ), + ...options.map>( + (item) { + + + return DropdownMenuItem( + value: item['name'].toString(), + child: Text( + item['name'].toString(), + style: const TextStyle(fontSize: 16), + + + ), + ); + }, + ), + ], + onChanged: onChanged, + onSaved: onSaved, + ), + ); + } + +// dependentdropdown + List> nameItems = []; + var selectednameValue = ''; // Use nullable type Future _load + Future _loadnameItems(String fieldName) async { + try { + final selectTdata = await apiService.getsecondName(fieldName); + + print(' name data is : $selectTdata'); + // Handle null or empty dropdownData + if (selectTdata != null && selectTdata.isNotEmpty) { + setState(() { + nameItems = selectTdata; + }); + } else { + print(' name data is null or empty'); + } + } catch (e) { + print('Failed to load name items: $e'); + } + } + + Widget _buildDropdownName( + String label, + List> options, + String? value, + void Function(String?) onChanged, + void Function(String?) onSaved, + ) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: DropdownButtonFormField( + decoration: InputDecoration( + labelText: label, + labelStyle: TextStyle( + color: Colors.deepPurple, + ), + contentPadding: const EdgeInsets.symmetric(horizontal: 16.0), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide(color: Colors.deepPurple, width: 2), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide(color: Colors.deepPurple, width: 2), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide(color: Colors.deepPurpleAccent, width: 2), + ), + ), + value: value!.isEmpty ? null : value, + items: [ + const DropdownMenuItem( + value: '', + child: Text('Select Name'), + ), + ...options.map>( + (item) { + return DropdownMenuItem( + value: item.values.elementAt(1).toString(), + child: Text( + item.values.elementAt(1).toString(), + style: const TextStyle(fontSize: 16), + ), + ); + }, + ), + ], + onChanged: onChanged, + onSaved: onSaved, + ), + ); + } + + + + + @override + void initState() { + super.initState(); + final provider = Provider.of(context, listen: false); + + + + + + + _value_list_fielddataFuture = value_list_fieldfetchData(); // Initialize _dataFuture with the function + + + _datagrid_fielddataFuture = datagrid_fieldfetchData(); // Initialize _dataFuture with the function + + + _loaddependent_dropdown_fieldItems(); + + +} + + + + @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 Testss"), + actions: [ + + + + + + +Padding( + padding: const EdgeInsets.only(right: 10), + child: InkWell( + onTap: () { + showvalue_list_fieldDialog(context); + }, + borderRadius: BorderRadius.circular(12), + child: Container( + padding: const EdgeInsets.all(10), + decoration: BoxDecoration( + gradient: const LinearGradient( + colors: [Colors.deepPurple, Colors.purpleAccent], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.deepPurpleAccent.withOpacity(0.3), + spreadRadius: 2, + blurRadius: 8, + offset: const Offset(0, 3), + ), + ], + ), + child: const Icon( + Icons.grid_on, + color: Colors.white, + size: 28, + ), + ), + ), + ), + + + + + + +], + ), + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16), + child: Form( + key: _formKey, + child: Column( + children: [ + ReusableTextField( + controller: nameController, + + onSaved:(value) => formData['name'] = value , + label:"Enter Name", + // ValidationProperties +), + + SizedBox(height: 16), + + +Container( + padding: EdgeInsets.all(16.0), + decoration: BoxDecoration( + color: Colors.grey[200], + borderRadius: BorderRadius.circular(8.0), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.2), + spreadRadius: 2, + blurRadius: 4, + offset: Offset(0, 2), + ), + ], + ), + child: Column( + children: [ + Text( + "Field Group", + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 16), + + +ReusableTextField( + onSaved:(value) => formData['bar_code'] = value , + label:"Enter Bar_code", + // ValidationProperties +), + + SizedBox(height: 16), + + + +ReusableTextField( + onSaved:(value) => formData['qr_code'] = value , + label:"Enter Qr_code", + // ValidationProperties +), + + SizedBox(height: 16), + + + SizedBox(height: 16), + ], + ), +), +const SizedBox(height: 16), + + +Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox( + height: 20, + child: Text( + 'Child', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + ), + const SizedBox(height: 16), // Add space between elements + + + + buildFormField('name'), + + + + ], + ), + ), + + + + + + + + + Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Select an Dependent_dropdown_field:', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.black), + ), + const SizedBox(height: 12), + _buildDropdownDependent_dropdown_field( + 'Dependent_dropdown_field', + dependent_dropdown_fieldItems, + selecteddependent_dropdown_fieldValue, + (value) { + setState(() { + selecteddependent_dropdown_fieldValue = value!; + _loadnameItems(selecteddependent_dropdown_fieldValue); + }); + }, + (value) { + setState(() { + formData['dependent_dropdown_field'] = + value?.isEmpty ?? true ? 'no value' : value!; + }); + }, + ), + ], + ), + ), + + Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Select an Name:', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.black), + ), + const SizedBox(height: 12), + _buildDropdownName( + 'Name', + nameItems, + selectednameValue, + (value) { + setState(() { + selectednameValue = value!; + }); + }, + (value) { + setState(() { + formData['name_list'] = + value?.isEmpty ?? true ? 'no value' : value!; + }); + }, + ), + ], + ), + ), + + + + + 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(); + + + + + + + + + + + + + + try { + print(formData); + Map createdEntity = await provider.createEntity(formData); + + + + + + + + + + + + + + + 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 Testss: $e'), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + } + }, + ), + + + + + + + + + SizedBox(height: 16), + +FutureBuilder>>( + future: _datagrid_fielddataFuture, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError) { + return Center(child: Text('Error: ${snapshot.error}')); + } else if (!snapshot.hasData || snapshot.data!.isEmpty) { + return const Center(child: Text('No data available..')); + } else { + final keys = snapshot.data!.first.keys.toList(); + + return SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + columnSpacing: 30, + headingRowColor: MaterialStateColor.resolveWith((states) => Colors.blue.shade100), + dataRowColor: MaterialStateColor.resolveWith((states) => Colors.white), + dividerThickness: 0.5, + columns: keys.map( + (key) => DataColumn( + label: Text( + key, + style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16), + ), + ), + ) + .toList(), + rows: snapshot.data!.map((item) { + return DataRow(cells: keys.map((key) { + return DataCell( + Text( + item[key].toString(), + style: const TextStyle(fontSize: 14), + ), + ); + }).toList()); + }).toList(), + ), + ); + } + }, + ), + SizedBox(height: 16), + + + + + ], + ), + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/TestssView/Testss_entity_list_screen.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/TestssView/Testss_entity_list_screen.dart new file mode 100644 index 0000000..e50f0d0 --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/TestssView/Testss_entity_list_screen.dart @@ -0,0 +1,749 @@ +// ignore_for_file: use_build_context_synchronously +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'Testss_create_entity_screen.dart'; +import 'Testss_update_entity_screen.dart'; +import '../Testss_viewModel/Testss_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 testss_entity_list_screen extends StatefulWidget { + static const String routeName = '/entity-list'; + + @override + _testss_entity_list_screenState createState() => _testss_entity_list_screenState(); +} + +class _testss_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 Testss: $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 Testss 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['name'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + + + entity['bar_code'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + + + + entity['qr_code'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + + + + entity['child'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + + + entity['datagrid_field'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + entity['dependent_dropdown_field'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + entity['name_list'].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: " Testss"), + 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) => TestssViewModelScreen(), + child: testssCreateEntityScreen(), + ), + ), + ).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) => TestssViewModelScreen(), + child: testssUpdateEntityScreen(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( + "Name : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['name'].toString() ?? 'No Name Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Bar_code : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['bar_code'].toString() ?? 'No Bar_code Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Qr_code : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['qr_code'].toString() ?? 'No Qr_code Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + + + + + + + + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Dependent Dropdown Field : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['dependent_dropdown_field'].toString() ?? 'No Dependent Dropdown Field Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Name : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['name_list'].toString() ?? 'No Name 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/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/TestssView/Testss_update_entity_screen.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/TestssView/Testss_update_entity_screen.dart new file mode 100644 index 0000000..5c851d2 --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/TestssView/Testss_update_entity_screen.dart @@ -0,0 +1,550 @@ +// ignore_for_file: use_build_context_synchronously +import 'dart:convert'; +import 'package:provider/provider.dart'; +import '../Testss_viewModel/Testss_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 testssUpdateEntityScreen extends StatefulWidget { + final Map entity; + + + testssUpdateEntityScreen({required this.entity}); + + @override + _testssUpdateEntityScreenState createState() => _testssUpdateEntityScreenState(); +} + +class _testssUpdateEntityScreenState extends State { + final _formKey = GlobalKey(); + + + + + +Widget buildFormField(String fieldOption) { + return Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: Card( + elevation: 4, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + child: Padding( + padding: const EdgeInsets.all(12.0), + child: TextFormField( + initialValue: widget.entity['child'] != null && + widget.entity['child'][fieldOption] != null + ? widget.entity['child'][fieldOption] + : '', + decoration: InputDecoration( + labelText: fieldOption, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + ), + ), +onSaved: (value) { + if (widget.entity['child'] == null) { + widget.entity['child'] = {}; + } + widget.entity['child'][fieldOption] = value; + }, + ), + ), + ), + ); + } + + + + + + +// first dropdown + + + + List> dependent_dropdown_fieldItems = []; + var selecteddependent_dropdown_fieldValue = ''; // Use nullable type Future _load + Future _loaddependent_dropdown_fieldItems() async { + try { + final selectTdata = await apiService.getfirstName(); + + print(' dependent_dropdown_field data is : $selectTdata'); + // Handle null or empty dropdownData + if (selectTdata != null && selectTdata.isNotEmpty) { + setState(() { + dependent_dropdown_fieldItems = selectTdata; + }); + } else { + print(' dependent_dropdown_field data is null or empty'); + } + } catch (e) { + print('Failed to load dependent_dropdown_field items: $e'); + } + } + + Widget _buildDropdownDependent_dropdown_field( + String label, + List> options, + String? value, + void Function(String?) onChanged, + void Function(String?) onSaved, + ) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: DropdownButtonFormField( + decoration: InputDecoration( + labelText: label, + labelStyle: TextStyle( + color: Colors.deepPurple, + ), + contentPadding: const EdgeInsets.symmetric(horizontal: 16.0), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide(color: Colors.deepPurple, width: 2), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide(color: Colors.deepPurple, width: 2), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide(color: Colors.deepPurpleAccent, width: 2), + ), + ), + value: value!.isEmpty ? null : value, + items: [ + const DropdownMenuItem( + value: '', + child: Text('Select dependent_dropdown_field'), + ), + ...options.map>( + (item) { + + + return DropdownMenuItem( + value: item['name'].toString(), + child: Text( + item['name'].toString(), + style: const TextStyle(fontSize: 16), + + + ), + ); + }, + ), + ], + onChanged: onChanged, + onSaved: onSaved, + ), + ); + } + +// dependentdropdown + List> nameItems = []; + var selectednameValue = ''; // Use nullable type Future _load + Future _loadnameItems(String fieldName) async { + try { + final selectTdata = await apiService.getsecondName(fieldName); + + print(' name data is : $selectTdata'); + // Handle null or empty dropdownData + if (selectTdata != null && selectTdata.isNotEmpty) { + setState(() { + nameItems = selectTdata; + }); + } else { + print(' name data is null or empty'); + } + } catch (e) { + print('Failed to load name items: $e'); + } + } + + Widget _buildDropdownName( + String label, + List> options, + String? value, + void Function(String?) onChanged, + void Function(String?) onSaved, + ) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: DropdownButtonFormField( + decoration: InputDecoration( + labelText: label, + labelStyle: TextStyle( + color: Colors.deepPurple, + ), + contentPadding: const EdgeInsets.symmetric(horizontal: 16.0), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide(color: Colors.deepPurple, width: 2), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide(color: Colors.deepPurple, width: 2), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8.0), + borderSide: BorderSide(color: Colors.deepPurpleAccent, width: 2), + ), + ), + value: value!.isEmpty ? null : value, + items: [ + const DropdownMenuItem( + value: '', + child: Text('Select Name'), + ), + ...options.map>( + (item) { + return DropdownMenuItem( + value: item.values.elementAt(1).toString(), + child: Text( + item.values.elementAt(1).toString(), + style: const TextStyle(fontSize: 16), + ), + ); + }, + ), + ], + onChanged: onChanged, + onSaved: onSaved, + ), + ); + } + + + + + + @override + void initState() { + super.initState(); + final provider = Provider.of(context, listen: false); + + + + + + + + + + + _loaddependent_dropdown_fieldItems(); + + +} + + + @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 Testss"), actions: [ + + + + + + + + + + + + + ], +), + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16), + child: Form( + key: _formKey, + child: Column( + children: [ + + ReusableTextField( + + label: "Please Enter Name", + initialValue: widget.entity['name'] ?? '', + + // ValidationProperties + onSaved: (value) => widget.entity['name'] = value, +), + + SizedBox(height: 16), + + +Container( + padding: EdgeInsets.all(16.0), + decoration: BoxDecoration( + color: Colors.grey[200], + borderRadius: BorderRadius.circular(8.0), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.2), + spreadRadius: 2, + blurRadius: 4, + offset: Offset(0, 2), + ), + ], + ), + child: Column( + children: [ + Text( + "Field Group", + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 16), + + + + SizedBox(height: 16), + TextFormField( + initialValue: widget.entity['bar_code'], + decoration: InputDecoration( + labelText: 'field_group bar_code', + ), + onChanged: (value) { + setState(() { + widget.entity['bar_code'] = value; + }); + }, + ), + + + + SizedBox(height: 16), + TextFormField( + initialValue: widget.entity['qr_code'], + decoration: InputDecoration( + labelText: 'field_group qr_code', + ), + onChanged: (value) { + setState(() { + widget.entity['qr_code'] = value; + }); + }, + ), + + + SizedBox(height: 16), + ], + ), +), +const SizedBox(height: 16), + + + +Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox( + height: 20, + child: Text( + 'Child', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + ), + const SizedBox(height: 16), // Add space between elements + + + + buildFormField('name'), + + + ], + ), + ), + + + + + + + + + Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Select an Dependent_dropdown_field:', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.black), + ), + const SizedBox(height: 12), + _buildDropdownDependent_dropdown_field( + 'Dependent_dropdown_field', + dependent_dropdown_fieldItems, + selecteddependent_dropdown_fieldValue, + (value) { + setState(() { + selecteddependent_dropdown_fieldValue = value!; + _loadnameItems(selecteddependent_dropdown_fieldValue); + }); + }, + (value) { + setState(() { + widget.entity['dependent_dropdown_field'] = + value?.isEmpty ?? true ? 'no value' : value!; + }); + }, + ), + ], + ), + ), + + Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Select an Name:', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.black), + ), + const SizedBox(height: 12), + _buildDropdownName( + 'Name', + nameItems, + selectednameValue, + (value) { + setState(() { + selectednameValue = value!; + }); + }, + (value) { + setState(() { + widget.entity['name_list'] = + value?.isEmpty ?? true ? 'no value' : value!; + }); + }, + ), + ], + ), + ), + + + + + + CustomButton( + height: getVerticalSize(50), + text: "Update", + margin: getMargin(top: 24, bottom: 5), + onTap: () async { + if (_formKey.currentState!.validate()) { + _formKey.currentState!.save(); + + + + + + + + + + + + + + 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 Testss: $e'), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + } + }, + ), + ], + ), + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/Testss_Repo/Testss_repo_screen.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/Testss_Repo/Testss_repo_screen.dart new file mode 100644 index 0000000..981a267 --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/Testss_Repo/Testss_repo_screen.dart @@ -0,0 +1,82 @@ +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 TestssRepoScreen { + final String baseUrl = ApiConstants.baseUrl; + final BaseNetworkService _helper = NetworkApiService(); + + Future getEntities() async { + try { + final response = + await _helper.getGetApiResponse('$baseUrl/Testss/Testss'); + 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/Testss/Testss/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/Testss/Testss', 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/Testss/Testss/$entityId', entity); + print(entity); + } catch (e) { + throw Exception('Failed to update entity: $e'); + } + } + + Future deleteEntity(int entityId) async { + try { + await _helper + .getDeleteApiResponse('$baseUrl/Testss/Testss/$entityId'); + } catch (e) { + throw Exception('Failed to delete entity: $e'); + } + } + + + + + + + + + Future getdatagrid_fieldGrid() async { + try { + String apiUrl = "$baseUrl/Testlist_ListFilter1/Testlist_ListFilter1"; + final response = await _helper.getGetApiResponse(apiUrl); + return response; + } catch (e) { + throw Exception('Failed to Upload datagrid Field: $e'); + } + } + + + +} diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/Testss_viewModel/Testss_view_model_screen.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/Testss_viewModel/Testss_view_model_screen.dart new file mode 100644 index 0000000..35edaa3 --- /dev/null +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Testss/Testss_viewModel/Testss_view_model_screen.dart @@ -0,0 +1,128 @@ +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 '../Testss_Repo/Testss_repo_screen.dart'; + +class TestssViewModelScreen extends ChangeNotifier{ + final TestssRepoScreen repo = TestssRepoScreen(); + + 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'); + } + } + + + + + + + + + late List> datagrid_fielddataFuture = + []; // Data from fetchData + + Future>> getdatagrid_fieldGrid() async { + + try { + final value = await repo.getdatagrid_fieldGrid(); + datagrid_fielddataFuture = (value as List) + .map((item) => item as Map) + .toList(); + + return datagrid_fielddataFuture; + } catch (e) { + throw Exception('Failed to get all: $e'); + } + } + + + +} \ No newline at end of file diff --git a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/commans/widgets/custome_drawer.dart b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/commans/widgets/custome_drawer.dart index 73fb148..cf338cf 100644 --- a/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/commans/widgets/custome_drawer.dart +++ b/testflutter003-front-f/authsec_flutterNewUi/base_project/lib/commans/widgets/custome_drawer.dart @@ -1,3 +1,9 @@ +import '../../Entity/basicp1/Testlist/TestlistView/Testlist_entity_list_screen.dart'; +import '../../Entity/basicp1/Testlist/Testlist_viewModel/Testlist_view_model_screen.dart'; + +import '../../Entity/basicp1/Testss/TestssView/Testss_entity_list_screen.dart'; +import '../../Entity/basicp1/Testss/Testss_viewModel/Testss_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 +15,113 @@ 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: 'Testlist', + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ChangeNotifierProvider( + create: (context) => TestlistViewModelScreen(), + child: testlist_entity_list_screen(), + ), + ), + ); + }, ), - ], - ), - ); - } + +DrawerItem( +color: AppColors.primary, +icon: Icons.chat_bubble, +title: 'Testss', +onTap: () { +Navigator.push( +context, +MaterialPageRoute( +builder: (context) => ChangeNotifierProvider( +create: (context) => TestssViewModelScreen(), +child: testss_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