diff --git a/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java b/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java index 5b4b8cb..8e31f23 100644 --- a/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java +++ b/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java @@ -68,6 +68,9 @@ public class BuilderService { public void callotherService() { // ADD OTHER SERVICE +addCustomMenu( "Test1", "Transcations"); + + executeDump(true, "dump.sql"); diff --git a/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/Test1Controller.java b/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/Test1Controller.java new file mode 100644 index 0000000..c94e4f8 --- /dev/null +++ b/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Controllers/Test1Controller.java @@ -0,0 +1,98 @@ +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.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.beans.factory.annotation.*; +import com.realnet.basicp1.Entity.Test1; +import com.realnet.basicp1.Services.Test1Service ; +@RequestMapping(value = "/Test1") + @CrossOrigin("*") +@RestController +public class Test1Controller { + @Autowired + private Test1Service Service; + +@Value("${projectPath}") + private String projectPath; + + + + + + + + + + + + + + @PostMapping("/Test1") + public Test1 Savedata(@RequestBody Test1 data) { + Test1 save = Service.Savedata(data) ; + + + + + + + + + + + + System.out.println("data saved..." + save); + + return save; + } +@PutMapping("/Test1/{id}") + public Test1 update(@RequestBody Test1 data,@PathVariable Integer id ) { + Test1 update = Service.update(data,id); + System.out.println("data update..." + update); + return update; + } +// get all with pagination + @GetMapping("/Test1/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("/Test1") + public List getdetails() { + List get = Service.getdetails(); + return get; +} +// get all without authentication + + @GetMapping("/token/Test1") + public List getallwioutsec() { + List get = Service.getdetails(); + return get; +} +@GetMapping("/Test1/{id}") + public Test1 getdetailsbyId(@PathVariable Integer id ) { + Test1 get = Service.getdetailsbyId(id); + return get; + } +@DeleteMapping("/Test1/{id}") + public void delete_by_id(@PathVariable Integer id ) { + Service.delete_by_id(id); + + } + +} \ No newline at end of file diff --git a/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Test1.java b/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Test1.java new file mode 100644 index 0000000..5d2e9ea --- /dev/null +++ b/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Entity/Test1.java @@ -0,0 +1,45 @@ +package com.realnet.basicp1.Entity; + import lombok.*; +import com.realnet.WhoColumn.Extension; + import javax.persistence.*; + import java.time.LocalDateTime; + import java.util.*; + + + + + + + + + + + + + + @Entity + @Data + public class Test1 extends Extension { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + +private String dates; + +private String datetimes; + +private String emailid; + +private boolean do_you_like; + +private String link; + +private int prise; + + +} diff --git a/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/Test1Repository.java b/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/Test1Repository.java new file mode 100644 index 0000000..180deb4 --- /dev/null +++ b/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Repository/Test1Repository.java @@ -0,0 +1,27 @@ +package com.realnet.basicp1.Repository; + + +import org.springframework.data.jpa.repository.JpaRepository; + +import org.springframework.stereotype.Repository; +import java.util.*; + + + + + + + + + + + + + + + +import com.realnet.basicp1.Entity.Test1; + +@Repository +public interface Test1Repository extends JpaRepository { +} \ No newline at end of file diff --git a/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/Test1Service.java b/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/Test1Service.java new file mode 100644 index 0000000..299404d --- /dev/null +++ b/prod206flutter-back-b/authsec_springboot/backend/src/main/java/com/realnet/basicp1/Services/Test1Service.java @@ -0,0 +1,100 @@ +package com.realnet.basicp1.Services; +import com.realnet.basicp1.Repository.Test1Repository; +import com.realnet.basicp1.Entity.Test1;import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import com.realnet.SequenceGenerator.Service.SequenceService; +import com.realnet.Notification.Entity.NotificationService; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import com.realnet.users.service1.AppUserServiceImpl; +import com.realnet.users.entity1.AppUser; + + + + + + + + + + + + + import org.springframework.stereotype.Service; + +@Service + public class Test1Service { +@Autowired +private Test1Repository Repository; + @Autowired + private AppUserServiceImpl userService; + + + + + + + + + + + +public Test1 Savedata(Test1 data) { + + + + + + + + + + + + +Test1 save = Repository.save(data); + return save; + } + + +// get all with pagination + public Page getAllWithPagination(Pageable page) { + return Repository.findAll(page); + } +public List getdetails() { + return (List) Repository.findAll(); + } + + +public Test1 getdetailsbyId(Integer id) { + return Repository.findById(id).get(); + } + + + public void delete_by_id(Integer id) { + Repository.deleteById(id); +} + + +public Test1 update(Test1 data,Integer id) { + Test1 old = Repository.findById(id).get(); +old.setDates(data.getDates()); + +old.setDatetimes(data.getDatetimes()); + +old.setEmailid(data.getEmailid()); + +old.setDo_you_like (data.isDo_you_like()); + +old.setLink(data.getLink()); + +old.setPrise(data.getPrise()); + +final Test1 test = Repository.save(old); + return test;} + public AppUser getUser() { + AppUser user = userService.getLoggedInUser(); + return user; + + }} diff --git a/prod206flutter-db-d/authsec_mysql/mysql/wf_table/wf_table.sql b/prod206flutter-db-d/authsec_mysql/mysql/wf_table/wf_table.sql new file mode 100755 index 0000000..e3f9f30 --- /dev/null +++ b/prod206flutter-db-d/authsec_mysql/mysql/wf_table/wf_table.sql @@ -0,0 +1,2 @@ +CREATE TABLE db.Test1(id BIGINT NOT NULL AUTO_INCREMENT, Emailid VARCHAR(400), do_you_like VARCHAR(400), prise VARCHAR(400), Datetimes VARCHAR(400), link VARCHAR(400), Dates Date, PRIMARY KEY (id)); + diff --git a/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Test1/Test1_api_service.dart b/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Test1/Test1_api_service.dart new file mode 100644 index 0000000..184e805 --- /dev/null +++ b/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Test1/Test1_api_service.dart @@ -0,0 +1,100 @@ +import 'package:dio/dio.dart'; +import 'package:http_parser/http_parser.dart'; +import 'dart:typed_data'; +import 'package:image_picker/image_picker.dart'; +import '../../../resources/api_constants.dart'; +import '../../../helpers/api_helper/api_helper.dart'; +import 'dart:convert'; +import 'dart:typed_data'; +class test1ApiService { + final String baseUrl = ApiConstants.baseUrl; + final Dio dio = Dio(); + final ApiHelper _helper = ApiHelper(); + + + Future>> getEntities() async { + + try { + final response = await _helper.get('$baseUrl/Test1/Test1'); + final entities = (response.data as List).cast>(); + return entities; + } catch (e) { + throw Exception('Failed to get all entities: $e'); + } + } +Future>> getAllWithPagination( + String token, int page, int Size) async { + try { + dio.options.headers['Authorization'] = 'Bearer $token'; + final response = await dio + .get('$baseUrl/Test1/Test1/getall/page?page=$page&size=$Size'); + final entities = + (response.data['content'] as List).cast>(); + return entities; + } catch (e) { + throw Exception('Failed to get all without pagination: $e'); + } + } + Future> createEntity( + String token, Map entity) async { + try { + print("in post api$entity"); + dio.options.headers['Authorization'] = 'Bearer $token'; + final response = + await dio.post('$baseUrl/Test1/Test1', data: entity); + + print(entity); + + // Assuming the response is a Map + Map responseData = response.data; + + return responseData; + } catch (e) { + throw Exception('Failed to create entity: $e'); + } + } + + + + + + + + + + + + + + Future updateEntity(String token, int entityId, Map entity) async { + try { + dio.options.headers['Authorization'] = 'Bearer $token'; + await dio.put('$baseUrl/Test1/Test1/$entityId', + data: entity); print(entity); + + } catch (e) { + throw Exception('Failed to update entity: $e'); + } + } + + Future deleteEntity(String token, int entityId) async { + try { + dio.options.headers['Authorization'] = 'Bearer $token'; + await dio.delete('$baseUrl/Test1/Test1/$entityId'); + } catch (e) { + throw Exception('Failed to delete entity: $e'); + } + } + + + + + + + + + + + + +} \ No newline at end of file diff --git a/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Test1/Test1_create_entity_screen.dart b/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Test1/Test1_create_entity_screen.dart new file mode 100644 index 0000000..1297873 --- /dev/null +++ b/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Test1/Test1_create_entity_screen.dart @@ -0,0 +1,354 @@ +// 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 '../../../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:flutter_barcode_scanner/flutter_barcode_scanner.dart'; +import 'package:intl/intl.dart'; + +import 'Test1_api_service.dart'; +import '../../../providers/token_manager.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 'dart:io'; +import '../../../Reuseable/reusable_text_field.dart'; +import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart'; +class test1CreateEntityScreen extends StatefulWidget { + const test1CreateEntityScreen({super.key}); + + @override + _test1CreateEntityScreenState createState() => _test1CreateEntityScreenState(); +} + +class _test1CreateEntityScreenState extends State { + final test1ApiService apiService = test1ApiService(); +final Map formData = {}; + final _formKey = GlobalKey(); +TextEditingController dates = TextEditingController(); + + DateTime selectedDate = DateTime.now(); + Future _selectDate(BuildContext context) async { + final DateTime? picked = await showDatePicker( + context: context, + initialDate: selectedDate, + firstDate: DateTime(2000), + lastDate: DateTime(2101), + ); + if (picked != null && picked != selectedDate) { + setState(() { + selectedDate = picked; + }); + } + } + + + + + bool _isemailidEmailValid = true; + void _validateemailidEmail(String email) { + setState(() { + _isemailidEmailValid = RegExp(r'^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$').hasMatch(email); + }); + } + + +bool _isSwitched = false; +bool do_you_like = false; + +void _toggleSwitch(bool value) { + setState(() { + _isSwitched = value; + }); +} + + bool _isUrlValid = true; + void _validateUrl(String url) { + setState(() { + _isUrlValid = Uri.parse(url).isAbsolute; + }); + } + + + + + @override + void initState() { + super.initState(); + + + + + + + + + + + + +} + + Future performOCR() async { + try { + final ImagePicker _picker = ImagePicker(); + + // Show options for gallery or camera using a dialog + await showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Select Image Source'), + content: SingleChildScrollView( + child: ListBody( + children: [ + GestureDetector( + child: const Text('Gallery'), + onTap: () async { + Navigator.of(context).pop(); + final XFile? image = + await _picker.pickImage(source: ImageSource.gallery); + processImage(image); + }, + ), + const SizedBox(height: 20), + GestureDetector( + child: const Text('Camera'), + onTap: () async { + Navigator.of(context).pop(); + final XFile? image = + await _picker.pickImage(source: ImageSource.camera); + processImage(image); + }, + ), + ], + ), + ), + ); + }, + ); + } catch (e) { + print("OCR Error: $e"); + // Handle OCR errors here + } + } + + + final textRecognizer = TextRecognizer(); + + void processImage(XFile? image) async { + if (image == null) return; // User canceled image picking + + final file = File(image.path); + + final inputImage = InputImage.fromFile(file); + final recognizedText = await textRecognizer.processImage(inputImage); + + StringBuffer extractedTextBuffer = StringBuffer(); + for (TextBlock block in recognizedText.blocks) { + for (TextLine line in block.lines) { + extractedTextBuffer.write(line.text + ' '); + } + } + + textRecognizer.close(); + + String extractedText = extractedTextBuffer.toString().trim(); + + // Now you can process the extracted text as needed + // For example, you can update the corresponding TextFormField with the extracted text + setState(() { + formData['description'] = extractedText; + }); + } + + + @override + Widget build(BuildContext context) { + 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 Test1"), + + + + + + + + + + + +), + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16), + child: Form( + key: _formKey, + child: Column( + children: [ + ReusableDatePickerField( + label:' Dates', controller: dates ), +const SizedBox(height: 16), + + +ReusableTextField( + onSaved:(value) => formData['datetimes'] = value , + label:"Enter Datetimes", + // ValidationProperties +), + + SizedBox(height: 16), + + +ReusableTextField( + onSaved:(value) => formData['emailid'] = value , + label:"Enter Emailid", + // ValidationProperties +), + + SizedBox(height: 16), + + + Switch( + value: _isSwitched, + onChanged: _toggleSwitch, + activeColor: Colors.white, + activeTrackColor: Colors.green, + inactiveThumbColor: Colors.white, + inactiveTrackColor: Colors.red, + ), + + ReusableTextField( + onSaved:(value) => formData['link'] = value , + label: "Enter link", + keyboardType: TextInputType.url, + ), +SizedBox(height: 16), + +ReusableTextField( + onSaved:(value) => formData['prise'] = value , + label: "Enter prise", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))), + ], + // 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(); + + + + + + +formData['do_you_like'] = do_you_like; + + + + + + + + final token = await TokenManager.getToken(); + try { + print(formData); + Map createdEntity = await apiService.createEntity(token!, 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 Test1: $e'), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + } + }, + ), + + + + + + + + + + + + + ], + ), + ), + ), + ), + ); + } +} diff --git a/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Test1/Test1_entity_list_screen.dart b/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Test1/Test1_entity_list_screen.dart new file mode 100644 index 0000000..0c184c3 --- /dev/null +++ b/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Test1/Test1_entity_list_screen.dart @@ -0,0 +1,737 @@ +// ignore_for_file: use_build_context_synchronously +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'Test1_api_service.dart'; +import 'Test1_create_entity_screen.dart'; +import 'Test1_update_entity_screen.dart'; +import '../../../providers/token_manager.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:fluttertoast/fluttertoast.dart'; + +class test1_entity_list_screen extends StatefulWidget { + static const String routeName = '/entity-list'; + + @override + _test1_entity_list_screenState createState() => _test1_entity_list_screenState(); +} + +class _test1_entity_list_screenState extends State { + + final test1ApiService apiService = test1ApiService(); + 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 token = await TokenManager.getToken(); + if (token != null) { + final fetchedEntities = + await apiService.getEntities(); + print('withoutpaging data is $fetchedEntities'); + setState(() { + serachEntities = fetchedEntities; // Update only filteredEntities + }); + print('Test1 entity is .. $serachEntities'); + } + } catch (e) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Error'), + content: Text('Failed to fetch Test1: $e'), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + } +Future fetchEntities() async { + try { + setState(() { + isLoading = true; + }); + + final token = await TokenManager.getToken(); + if (token != null) { + + final fetchedEntities = + await apiService.getAllWithPagination(token, currentPage, pageSize); + print('pagination data is $fetchedEntities'); + setState(() { + entities.addAll(fetchedEntities); // Add new data to the existing list + filteredEntities = entities.toList(); // Update only filteredEntities + currentPage++; + }); + + print(' entity is .. $filteredEntities'); + } + } catch (e) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Error'), + content: Text('Failed to fetch Test1 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 token = await TokenManager.getToken(); + await apiService.deleteEntity(token!, 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['dates'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['datetimes'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['emailid'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + entity['do_you_like'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['link'].toString().toLowerCase().contains(keyword.toLowerCase()) || + + + + + + entity['prise'].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: " Test1"), + 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) => test1CreateEntityScreen(), + ), + ).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) => + test1UpdateEntityScreen(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( + "Dates : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['dates'] ?? 'No Dates Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Datetimes : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['datetimes'] ?? 'No Datetimes Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Emailid : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['emailid'] ?? 'No Emailid Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "do you like : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['do_you_like'].toString() ?? 'No do you like Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "link : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['link'] ?? 'No link Available', + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16Bluegray900, + ), + ], + ), + ), + + + Padding( + padding: getPadding( + top: 10, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "prise : ", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: AppStyle.txtGilroyMedium16, + ), + Text( + entity['prise'].toString() ?? 'No prise 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/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Test1/Test1_update_entity_screen.dart b/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Test1/Test1_update_entity_screen.dart new file mode 100644 index 0000000..b2e2bcb --- /dev/null +++ b/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/Entity/basicp1/Test1/Test1_update_entity_screen.dart @@ -0,0 +1,290 @@ +// ignore_for_file: use_build_context_synchronously +import 'dart:convert'; +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 'Test1_api_service.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 '../../../providers/token_manager.dart'; + +import 'package:flutter/services.dart'; +class test1UpdateEntityScreen extends StatefulWidget { + final Map entity; + + + test1UpdateEntityScreen({required this.entity}); + + @override + _test1UpdateEntityScreenState createState() => _test1UpdateEntityScreenState(); +} + +class _test1UpdateEntityScreenState extends State { + final test1ApiService apiService = test1ApiService(); + final _formKey = GlobalKey(); + +TextEditingController dates = TextEditingController(); +DateTime selectedDate = DateTime.now(); + +Future _selectDate(BuildContext context) async { + final DateTime? picked = await showDatePicker( + context: context, + initialDate: selectedDate, + firstDate: DateTime(2000), + lastDate: DateTime(2101), + ); + print(picked); + if (picked != null && picked != selectedDate) { + setState(() { + selectedDate = picked; + }); + } +} + + + +bool _isemailidEmailValid = true; + +void _validateemailidEmail(String email) { + setState(() { + _isemailidEmailValid = RegExp(r'^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$').hasMatch(email); + }); +} + + bool isdo_you_like = false; + +bool _isUrlValid = true; + +void _validateUrl(String url) { + setState(() { + _isUrlValid = Uri.parse(url).isAbsolute; + }); +} + + + + + @override + void initState() { + super.initState(); + + + + + + +isdo_you_like = widget.entity['do_you_like'] ?? false; // Set initial value + + + + + +} + + + @override + Widget build(BuildContext context) { + 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 Test1"), actions: [ + + + + + + + + + + + + + ], +), + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16), + child: Form( + key: _formKey, + child: Column( + children: [ + ReusableDatePickerField(label: 'Dates', controller: dates, initialDate: widget.entity['dates'],), + + Padding( + padding: getPadding(top: 18), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text("Datetimes", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: + AppStyle.txtGilroyMedium16Bluegray900), + CustomTextFormField( + focusNode: FocusNode(), + hintText: "Please Enter Datetimes", + initialValue: widget.entity['datetimes'], + + // ValidationProperties + onsaved: (value) => widget.entity['datetimes'] = value, + margin: getMargin(top: 7)) + ]), + ), + + ReusableTextField( + initialValue:widget.entity['emailid'] , + onSaved:(value) => widget.entity['emailid'] = value , + label:"Enter Emailid", + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter some text'; + } + return null; + }, + ), + +const SizedBox(height: 16), + +Row( + children: [ + Switch( + value: isdo_you_like, + onChanged: (newValue) { + setState(() { + isdo_you_like = newValue; + }); + }, + activeColor: Colors.white, + activeTrackColor: Colors.green, + inactiveThumbColor: Colors.white, + inactiveTrackColor: Colors.red, + ), + const SizedBox(width: 8), + const Text('do you like'), + ], +), + + ReusableTextField( + initialValue: widget.entity['link'], + onSaved: (value) => widget.entity['link']= value, + label: "Enter link", + keyboardType: TextInputType.url, + ), + + + ReusableTextField( + initialValue: widget.entity['prise'], + onSaved: (value) => widget.entity['prise']= value, + label: "Enter prise", + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))), + ], + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter a number'; + } + return null; + }, + ), + + + CustomButton( + height: getVerticalSize(50), + text: "Update", + margin: getMargin(top: 24, bottom: 5), + onTap: () async { + if (_formKey.currentState!.validate()) { + _formKey.currentState!.save(); + + + + + + +widget.entity['do_you_like'] = isdo_you_like; + + + + + + + final token = await TokenManager.getToken(); + try { + await apiService.updateEntity( + token!, + 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 Test1: $e'), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + } + }, + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/screens/ReuseableWidgets/CustomDrawer.dart b/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/screens/ReuseableWidgets/CustomDrawer.dart index cac5229..ee8a5ae 100644 --- a/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/screens/ReuseableWidgets/CustomDrawer.dart +++ b/prod206flutter-front-f/authsec_flutterNewUi/base_project/lib/screens/ReuseableWidgets/CustomDrawer.dart @@ -1,3 +1,5 @@ +import '../../Entity/basicp1/Test1/Test1_entity_list_screen.dart'; + import 'dart:io'; import 'package:base_project/core/app_export.dart'; import 'package:flutter/material.dart'; @@ -171,6 +173,21 @@ class _CustomDrawerState extends State { SizedBox(height: 18.v), // NEW MENU +_myButton( + context, + "Test1", + () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => test1_entity_list_screen(), + ), + ); + }, + false, + ), + SizedBox(height: 18.v), + _myButton( context, @@ -301,4 +318,4 @@ class _CustomDrawerState extends State { }, ); } -} +} \ No newline at end of file