build_app
This commit is contained in:
parent
9b1f3ce9ec
commit
eb55b27a2a
@ -0,0 +1,120 @@
|
||||
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 basicp1ApiService {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse('$baseUrl/Basicp1/Basicp1');
|
||||
final entities = (response as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
Future<List<Map<String, dynamic>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Basicp1/Basicp1/getall/page?page=$page&size=$size');
|
||||
final entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
Future<Map<String, dynamic>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl/Basicp1/Basicp1', entity);
|
||||
|
||||
print(entity);
|
||||
|
||||
// Assuming the response is a Map<String, dynamic>
|
||||
Map<String, dynamic> responseData = response;
|
||||
|
||||
return responseData;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<void> updateEntity( int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
await _helper.getPutApiResponse('$baseUrl/Basicp1/Basicp1/$entityId',
|
||||
entity); print(entity);
|
||||
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity( int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl/Basicp1/Basicp1/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,518 @@
|
||||
// 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 '../Basicp1_viewModel/Basicp1_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 basicp1CreateEntityScreen extends StatefulWidget {
|
||||
const basicp1CreateEntityScreen({super.key});
|
||||
|
||||
@override
|
||||
_basicp1CreateEntityScreenState createState() => _basicp1CreateEntityScreenState();
|
||||
}
|
||||
|
||||
class _basicp1CreateEntityScreenState extends State<basicp1CreateEntityScreen> {
|
||||
|
||||
final Map<String, dynamic> formData = {};
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
|
||||
|
||||
final TextEditingController name2Controller = TextEditingController();
|
||||
|
||||
|
||||
final TextEditingController number1Controller = TextEditingController();
|
||||
|
||||
|
||||
final TextEditingController number2Controller = TextEditingController();
|
||||
|
||||
|
||||
final TextEditingController phone_numberController = TextEditingController();
|
||||
|
||||
|
||||
final TextEditingController phone_number2Controller = TextEditingController();
|
||||
|
||||
|
||||
final TextEditingController paragraph_fieldController = TextEditingController();
|
||||
|
||||
|
||||
final TextEditingController paragraph_field2Controller = TextEditingController();
|
||||
|
||||
|
||||
|
||||
bool _passwordVisiblepassword_field = false;
|
||||
bool _isPasswordValidpassword_field = true;
|
||||
bool _doPasswordsMatchpassword_field = true;
|
||||
|
||||
String _passwordpassword_field = ''; // To store the first password
|
||||
|
||||
void _validatePasswordpassword_field(String password) {
|
||||
setState(() {
|
||||
_isPasswordValidpassword_field = password.isNotEmpty;
|
||||
_passwordpassword_field = password; // Store the password for later comparison
|
||||
_doPasswordsMatchpassword_field = true; // Reset match flag on new input
|
||||
});
|
||||
}
|
||||
|
||||
void _validateConfirmPasswordpassword_field(String confirmPassword) {
|
||||
setState(() {
|
||||
_doPasswordsMatchpassword_field = confirmPassword == _passwordpassword_field;
|
||||
});
|
||||
}
|
||||
|
||||
final TextEditingController textareaController = TextEditingController();
|
||||
|
||||
|
||||
final TextEditingController textarea_fieldController = TextEditingController();
|
||||
|
||||
|
||||
final TextEditingController textarea_field2Controller = TextEditingController();
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final provider = Provider.of<Basicp1ViewModelScreen>(context, listen: false);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = Provider.of<Basicp1ViewModelScreen>(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 Basicp1"),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
),
|
||||
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: name2Controller,
|
||||
|
||||
onSaved:(value) => formData['name2'] = value ,
|
||||
label:"Enter name2",
|
||||
// ValidationProperties
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
controller: number1Controller,
|
||||
|
||||
onSaved:(value) => formData['number1'] = value ,
|
||||
label: "Enter number1",
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))),
|
||||
],
|
||||
// ValidationProperties
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
ReusableTextField(
|
||||
controller: number2Controller,
|
||||
|
||||
onSaved:(value) => formData['number2'] = value ,
|
||||
label: "Enter number2",
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))),
|
||||
],
|
||||
// ValidationProperties
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
ReusableTextField(
|
||||
onSaved:(value) => formData['phone_number'] = value ,
|
||||
label: "Enter Phone Number",
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
LengthLimitingTextInputFormatter(
|
||||
10), // Limit input to 10 digits
|
||||
],
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Phone Number';
|
||||
}
|
||||
if (value.length != 10) {
|
||||
return 'Phone number must be exactly 10 digits';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
ReusableTextField(
|
||||
onSaved:(value) => formData['phone_number2'] = value ,
|
||||
label: "Enter Phone Number2",
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
LengthLimitingTextInputFormatter(
|
||||
10), // Limit input to 10 digits
|
||||
],
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Phone Number2';
|
||||
}
|
||||
if (value.length != 10) {
|
||||
return 'Phone number must be exactly 10 digits';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
ReusableTextField(
|
||||
controller: paragraph_fieldController,
|
||||
|
||||
onSaved:(value) => formData['paragraph_field'] = value ,
|
||||
label: "Enter Paragraph Field",
|
||||
maxLines: 5,
|
||||
|
||||
),
|
||||
|
||||
ReusableTextField(
|
||||
controller: paragraph_field2Controller,
|
||||
|
||||
onSaved:(value) => formData['paragraph_field2'] = value ,
|
||||
label: "Enter Paragraph Field2",
|
||||
maxLines: 5,
|
||||
|
||||
),
|
||||
|
||||
TextFormField(
|
||||
obscureText: !_passwordVisiblepassword_field,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Password Field',
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_passwordVisiblepassword_field
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_passwordVisiblepassword_field = !_passwordVisiblepassword_field;
|
||||
});
|
||||
},
|
||||
),
|
||||
errorText:
|
||||
_isPasswordValidpassword_field ? null : 'Please enter a password',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
onSaved: (value) => formData['password_field'] = value,
|
||||
onChanged: _validatePasswordpassword_field,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
obscureText: !_passwordVisiblepassword_field,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Confirm Password Field',
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_passwordVisiblepassword_field
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_passwordVisiblepassword_field = !_passwordVisiblepassword_field;
|
||||
});
|
||||
},
|
||||
),
|
||||
errorText:
|
||||
_doPasswordsMatchpassword_field ? null : 'Passwords do not match',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
onChanged: _validateConfirmPasswordpassword_field,
|
||||
),
|
||||
|
||||
ReusableTextField(
|
||||
controller: textareaController,
|
||||
|
||||
onSaved:(value) => formData['textarea'] = value ,
|
||||
label: "Enter Textarea",
|
||||
maxLines: 5,
|
||||
// ValidationProperties
|
||||
),
|
||||
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
controller: textarea_fieldController,
|
||||
|
||||
onSaved:(value) => formData['textarea_field'] = value ,
|
||||
label: "Enter Textarea Field",
|
||||
maxLines: 5,
|
||||
// ValidationProperties
|
||||
),
|
||||
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
controller: textarea_field2Controller,
|
||||
|
||||
onSaved:(value) => formData['textarea_field2'] = value ,
|
||||
label: "Enter Textarea Field2",
|
||||
maxLines: 5,
|
||||
// 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<String, dynamic> 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 Basicp1: $e'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,947 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'Basicp1_create_entity_screen.dart';
|
||||
import 'Basicp1_update_entity_screen.dart';
|
||||
import '../Basicp1_viewModel/Basicp1_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 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
class basicp1_entity_list_screen extends StatefulWidget {
|
||||
static const String routeName = '/entity-list';
|
||||
|
||||
@override
|
||||
_basicp1_entity_list_screenState createState() => _basicp1_entity_list_screenState();
|
||||
}
|
||||
|
||||
class _basicp1_entity_list_screenState extends State<basicp1_entity_list_screen> {
|
||||
List<Map<String, dynamic>> entities = [];
|
||||
List<Map<String, dynamic>> filteredEntities = [];
|
||||
List<Map<String, dynamic>> 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<void> fetchwithoutpaging() async {
|
||||
try {
|
||||
final provider =
|
||||
Provider.of<Basicp1ViewModelScreen>(context, listen: false);
|
||||
final fetchedEntities = await provider.getEntities();
|
||||
print('withoutpaging data is $fetchedEntities');
|
||||
setState(() {
|
||||
serachEntities = fetchedEntities; // Update only filteredEntities
|
||||
});
|
||||
print('Basicp1 entity is .. $serachEntities');
|
||||
} catch (e) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Error'),
|
||||
content: Text('Failed to fetch Basicp1: $e'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Future<void> fetchEntities() async {
|
||||
try {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
|
||||
|
||||
|
||||
final provider =
|
||||
Provider.of<Basicp1ViewModelScreen>(context, listen: false);
|
||||
final fetchedEntities =
|
||||
await provider.getAllWithPagination(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 Basicp1 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<void> deleteEntity(Map<String, dynamic> entity) async {
|
||||
try {
|
||||
final provider =
|
||||
Provider.of<Basicp1ViewModelScreen>(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['name2'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['number1'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['number2'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['phone_number'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['phone_number2'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['paragraph_field'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['paragraph_field2'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['password_field'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['textarea'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['textarea_field'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['textarea_field2'].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: " Basicp1"),
|
||||
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) => Basicp1ViewModelScreen(),
|
||||
child: basicp1CreateEntityScreen(),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
fetchEntities();
|
||||
});
|
||||
},
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
Widget _buildListItem(Map<String, dynamic> entity) {
|
||||
return showCardView ? _buildCardView(entity) : _buildNormalView(entity);
|
||||
}
|
||||
|
||||
|
||||
// Function to build card view for a list item
|
||||
Widget _buildCardView(Map<String, dynamic> 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<String, dynamic> 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<String>(
|
||||
icon: const Icon(
|
||||
Icons.more_vert,
|
||||
color: Colors.black,
|
||||
size: 16,
|
||||
),
|
||||
itemBuilder: (BuildContext context) {
|
||||
return [
|
||||
PopupMenuItem<String>(
|
||||
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<String>(
|
||||
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) => Basicp1ViewModelScreen(),
|
||||
child: basicp1UpdateEntityScreen(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(
|
||||
"name2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['name2'].toString() ?? 'No name2 Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"number1 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['number1'].toString() ?? 'No number1 Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"number2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['number2'].toString() ?? 'No number2 Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Phone Number : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['phone_number'].toString() ?? 'No Phone Number Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Phone Number2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['phone_number2'].toString() ?? 'No Phone Number2 Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Paragraph Field : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['paragraph_field'].toString() ?? 'No Paragraph Field Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Paragraph Field2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['paragraph_field2'].toString() ?? 'No Paragraph Field2 Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Password Field : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['password_field'].toString() ?? 'No Password Field Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Textarea : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['textarea'].toString() ?? 'No Textarea Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Textarea Field : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['textarea_field'].toString() ?? 'No Textarea Field Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Textarea Field2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['textarea_field2'].toString() ?? 'No Textarea Field2 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<String, dynamic> 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';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,451 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Basicp1_viewModel/Basicp1_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 basicp1UpdateEntityScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
|
||||
basicp1UpdateEntityScreen({required this.entity});
|
||||
|
||||
@override
|
||||
_basicp1UpdateEntityScreenState createState() => _basicp1UpdateEntityScreenState();
|
||||
}
|
||||
|
||||
class _basicp1UpdateEntityScreenState extends State<basicp1UpdateEntityScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool _passwordVisiblepassword_field = false;
|
||||
bool _isPasswordValidpassword_field = true;
|
||||
bool _doPasswordsMatchpassword_field = true;
|
||||
|
||||
String _passwordpassword_field = ''; // To store the first password
|
||||
|
||||
void _validatePasswordpassword_field(String password) {
|
||||
setState(() {
|
||||
_isPasswordValidpassword_field = password.isNotEmpty;
|
||||
_passwordpassword_field = password; // Store the password for later comparison
|
||||
_doPasswordsMatchpassword_field = true; // Reset match flag on new input
|
||||
});
|
||||
}
|
||||
|
||||
void _validateConfirmPasswordpassword_field(String confirmPassword) {
|
||||
setState(() {
|
||||
_doPasswordsMatchpassword_field = confirmPassword == _passwordpassword_field;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final provider = Provider.of<Basicp1ViewModelScreen>(context, listen: false);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = Provider.of<Basicp1ViewModelScreen>(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 Basicp1"), 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(
|
||||
|
||||
label: "Please Enter name2",
|
||||
initialValue: widget.entity['name2'] ?? '',
|
||||
|
||||
// ValidationProperties
|
||||
onSaved: (value) => widget.entity['name2'] = value,
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
initialValue: widget.entity['number1'].toString(),
|
||||
onSaved: (value) => widget.entity['number1']= value,
|
||||
label: "Enter number1",
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))),
|
||||
],
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter a number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
ReusableTextField(
|
||||
initialValue: widget.entity['number2'].toString(),
|
||||
onSaved: (value) => widget.entity['number2']= value,
|
||||
label: "Enter number2",
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))),
|
||||
],
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter a number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
ReusableTextField(
|
||||
initialValue: widget.entity['phone_number'],
|
||||
onSaved: (value) => widget.entity['phone_number'] = value,
|
||||
label: "Enter Phone Number",
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
LengthLimitingTextInputFormatter(
|
||||
10), // Limit input to 10 digits
|
||||
],
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Phone Number';
|
||||
}
|
||||
if (value.length != 10) {
|
||||
return 'Phone number must be exactly 10 digits';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
ReusableTextField(
|
||||
initialValue: widget.entity['phone_number2'],
|
||||
onSaved: (value) => widget.entity['phone_number2'] = value,
|
||||
label: "Enter Phone Number2",
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
LengthLimitingTextInputFormatter(
|
||||
10), // Limit input to 10 digits
|
||||
],
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter Phone Number2';
|
||||
}
|
||||
if (value.length != 10) {
|
||||
return 'Phone number must be exactly 10 digits';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
// }),
|
||||
ReusableTextField(
|
||||
initialValue: widget.entity['paragraph_field'],
|
||||
onSaved: (value) => widget.entity['paragraph_field']= value,
|
||||
label: "Enter Paragraph Field",
|
||||
maxLines: 5,
|
||||
),
|
||||
|
||||
// }),
|
||||
ReusableTextField(
|
||||
initialValue: widget.entity['paragraph_field2'],
|
||||
onSaved: (value) => widget.entity['paragraph_field2']= value,
|
||||
label: "Enter Paragraph Field2",
|
||||
maxLines: 5,
|
||||
),
|
||||
|
||||
TextFormField(
|
||||
initialValue: widget.entity['password_field'],
|
||||
|
||||
obscureText: !_passwordVisiblepassword_field,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Password Field',
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_passwordVisiblepassword_field
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_passwordVisiblepassword_field = !_passwordVisiblepassword_field;
|
||||
});
|
||||
},
|
||||
),
|
||||
errorText:
|
||||
_isPasswordValidpassword_field ? null : 'Please enter a password',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
onSaved: (value) => widget.entity['password_field'] = value,
|
||||
onChanged: _validatePasswordpassword_field,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
obscureText: !_passwordVisiblepassword_field,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Confirm Password Field',
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_passwordVisiblepassword_field
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_passwordVisiblepassword_field = !_passwordVisiblepassword_field;
|
||||
});
|
||||
},
|
||||
),
|
||||
errorText:
|
||||
_doPasswordsMatchpassword_field ? null : 'Passwords do not match',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
onChanged: _validateConfirmPasswordpassword_field,
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
initialValue: widget.entity['textarea'],
|
||||
onSaved: (value) => widget.entity['textarea']= value,
|
||||
label: "Enter Textarea",
|
||||
maxLines: 5,
|
||||
),
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
initialValue: widget.entity['textarea_field'],
|
||||
onSaved: (value) => widget.entity['textarea_field']= value,
|
||||
label: "Enter Textarea Field",
|
||||
maxLines: 5,
|
||||
),
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
initialValue: widget.entity['textarea_field2'],
|
||||
onSaved: (value) => widget.entity['textarea_field2']= value,
|
||||
label: "Enter Textarea Field2",
|
||||
maxLines: 5,
|
||||
),
|
||||
|
||||
|
||||
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 Basicp1: $e'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
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 Basicp1RepoScreen {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
Future<dynamic> getEntities() async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Basicp1/Basicp1');
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> getAllWithPagination(int page, int size) async {
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse(
|
||||
'$baseUrl/Basicp1/Basicp1/getall/page?page=$page&size=$size');
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> createEntity(Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response = await _helper.getPostApiResponse(
|
||||
'$baseUrl/Basicp1/Basicp1', entity);
|
||||
|
||||
print(entity);
|
||||
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateEntity(int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
await _helper.getPutApiResponse(
|
||||
'$baseUrl/Basicp1/Basicp1/$entityId', entity);
|
||||
print(entity);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity(int entityId) async {
|
||||
try {
|
||||
await _helper
|
||||
.getDeleteApiResponse('$baseUrl/Basicp1/Basicp1/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,125 @@
|
||||
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 '../Basicp1_Repo/Basicp1_repo_screen.dart';
|
||||
|
||||
class Basicp1ViewModelScreen extends ChangeNotifier{
|
||||
final Basicp1RepoScreen repo = Basicp1RepoScreen();
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
try {
|
||||
final response = await repo.getEntities();
|
||||
final entities = (response as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response =
|
||||
await repo.getAllWithPagination(page, size); // ✅ Use await
|
||||
|
||||
print('res - $response');
|
||||
|
||||
// ✅ Ensure response is a Map<String, dynamic>
|
||||
if (response is! Map<String, dynamic>) {
|
||||
throw Exception('Unexpected response format: $response');
|
||||
}
|
||||
|
||||
// ✅ Extract 'content' and ensure it's a list
|
||||
final entities = (response['content'] as List)
|
||||
.cast<Map<String, dynamic>>() // ✅ Ensure list of maps
|
||||
.toList();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
throw Exception('Failed to get all without pagination :- $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<Map<String, dynamic>> createEntity(Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api - $entity");
|
||||
// Wait for API response
|
||||
final responseData =
|
||||
await repo.createEntity(entity) as Map<String, dynamic>;
|
||||
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<void> updateEntity(int entityId, Map<String, dynamic> 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<void> 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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
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 basicp2ApiService {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse('$baseUrl/Basicp2/Basicp2');
|
||||
final entities = (response as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
Future<List<Map<String, dynamic>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Basicp2/Basicp2/getall/page?page=$page&size=$size');
|
||||
final entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
Future<Map<String, dynamic>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl/Basicp2/Basicp2', entity);
|
||||
|
||||
print(entity);
|
||||
|
||||
// Assuming the response is a Map<String, dynamic>
|
||||
Map<String, dynamic> responseData = response;
|
||||
|
||||
return responseData;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<void> updateEntity( int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
await _helper.getPutApiResponse('$baseUrl/Basicp2/Basicp2/$entityId',
|
||||
entity); print(entity);
|
||||
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity( int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl/Basicp2/Basicp2/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,458 @@
|
||||
// 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 '../Basicp2_viewModel/Basicp2_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 basicp2CreateEntityScreen extends StatefulWidget {
|
||||
const basicp2CreateEntityScreen({super.key});
|
||||
|
||||
@override
|
||||
_basicp2CreateEntityScreenState createState() => _basicp2CreateEntityScreenState();
|
||||
}
|
||||
|
||||
class _basicp2CreateEntityScreenState extends State<basicp2CreateEntityScreen> {
|
||||
|
||||
final Map<String, dynamic> formData = {};
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final TextEditingController aboutController = TextEditingController();
|
||||
|
||||
|
||||
final TextEditingController textarea2Controller = TextEditingController();
|
||||
|
||||
|
||||
TextEditingController date_field = TextEditingController();
|
||||
|
||||
DateTime selectedDatedate_field = DateTime.now();
|
||||
Future<void> _selectDatedate_field(BuildContext context) async {
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: selectedDatedate_field,
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2101),
|
||||
);
|
||||
if (picked != null && picked != selectedDatedate_field) {
|
||||
setState(() {
|
||||
selectedDatedate_field = picked;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TextEditingController date_field2 = TextEditingController();
|
||||
|
||||
DateTime selectedDatedate_field2 = DateTime.now();
|
||||
Future<void> _selectDatedate_field2(BuildContext context) async {
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: selectedDatedate_field2,
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2101),
|
||||
);
|
||||
if (picked != null && picked != selectedDatedate_field2) {
|
||||
setState(() {
|
||||
selectedDatedate_field2 = picked;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TextEditingController datetime_field = TextEditingController();
|
||||
|
||||
DateTime selectedDateTimedatetime_field = DateTime.now();
|
||||
Future<void> _selectDateTimedatetime_field(BuildContext context) async {
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: selectedDateTimedatetime_field,
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2101),
|
||||
);
|
||||
|
||||
if (picked != null) {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.fromDateTime(selectedDateTimedatetime_field),
|
||||
);
|
||||
print(pickedTime);
|
||||
if (pickedTime != null) {
|
||||
setState(() {
|
||||
selectedDateTimedatetime_field = DateTime(
|
||||
picked.year,
|
||||
picked.month,
|
||||
picked.day,
|
||||
pickedTime.hour,
|
||||
pickedTime.minute,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TextEditingController datetime_field2 = TextEditingController();
|
||||
|
||||
DateTime selectedDateTimedatetime_field2 = DateTime.now();
|
||||
Future<void> _selectDateTimedatetime_field2(BuildContext context) async {
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: selectedDateTimedatetime_field2,
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2101),
|
||||
);
|
||||
|
||||
if (picked != null) {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.fromDateTime(selectedDateTimedatetime_field2),
|
||||
);
|
||||
print(pickedTime);
|
||||
if (pickedTime != null) {
|
||||
setState(() {
|
||||
selectedDateTimedatetime_field2 = DateTime(
|
||||
picked.year,
|
||||
picked.month,
|
||||
picked.day,
|
||||
pickedTime.hour,
|
||||
pickedTime.minute,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool _isemail_fieldEmailValid = true;
|
||||
void _validateemail_fieldEmail(String email) {
|
||||
setState(() {
|
||||
_isemail_fieldEmailValid = RegExp(r'^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$').hasMatch(email);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
bool _isemail_field2EmailValid = true;
|
||||
void _validateemail_field2Email(String email) {
|
||||
setState(() {
|
||||
_isemail_field2EmailValid = RegExp(r'^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$').hasMatch(email);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final provider = Provider.of<Basicp2ViewModelScreen>(context, listen: false);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = Provider.of<Basicp2ViewModelScreen>(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 Basicp2"),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
ReusableTextField(
|
||||
controller: aboutController,
|
||||
|
||||
onSaved:(value) => formData['about'] = value ,
|
||||
label: "Enter about",
|
||||
maxLines: 5,
|
||||
// ValidationProperties
|
||||
),
|
||||
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
controller: textarea2Controller,
|
||||
|
||||
onSaved:(value) => formData['textarea2'] = value ,
|
||||
label: "Enter Textarea2",
|
||||
maxLines: 5,
|
||||
// ValidationProperties
|
||||
),
|
||||
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
ReusableDatePickerField(
|
||||
label:' Date Field', controller: date_field
|
||||
,
|
||||
onSaved: (value) => formData['date_field'] = value,),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
|
||||
ReusableDatePickerField(
|
||||
label:' Date Field2', controller: date_field2
|
||||
,
|
||||
onSaved: (value) => formData['date_field2'] = value,),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
|
||||
ReusableDateTimePickerField(label: 'Datetime Field', controller: datetime_field,
|
||||
onSaved: (value) => formData['datetime_field'] = value,
|
||||
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
|
||||
ReusableDateTimePickerField(label: 'Datetime Field2', controller: datetime_field2,
|
||||
onSaved: (value) => formData['datetime_field2'] = value,
|
||||
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Email Field",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900),
|
||||
CustomTextFormField(
|
||||
hintText: "Enter Email Field",
|
||||
errorText: _isemail_fieldEmailValid ? null : 'Please enter a valid email',
|
||||
|
||||
onsaved: (value) => formData['email_field'] = value,
|
||||
onChanged: (value) {
|
||||
_validateemail_fieldEmail(value);
|
||||
},
|
||||
margin: getMargin(top: 6))
|
||||
])),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Email Field2",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900),
|
||||
CustomTextFormField(
|
||||
hintText: "Enter Email Field2",
|
||||
errorText: _isemail_field2EmailValid ? null : 'Please enter a valid email',
|
||||
|
||||
onsaved: (value) => formData['email_field2'] = value,
|
||||
onChanged: (value) {
|
||||
_validateemail_field2Email(value);
|
||||
},
|
||||
margin: getMargin(top: 6))
|
||||
])),
|
||||
|
||||
|
||||
|
||||
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<String, dynamic> 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 Basicp2: $e'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,819 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'Basicp2_create_entity_screen.dart';
|
||||
import 'Basicp2_update_entity_screen.dart';
|
||||
import '../Basicp2_viewModel/Basicp2_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 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
class basicp2_entity_list_screen extends StatefulWidget {
|
||||
static const String routeName = '/entity-list';
|
||||
|
||||
@override
|
||||
_basicp2_entity_list_screenState createState() => _basicp2_entity_list_screenState();
|
||||
}
|
||||
|
||||
class _basicp2_entity_list_screenState extends State<basicp2_entity_list_screen> {
|
||||
List<Map<String, dynamic>> entities = [];
|
||||
List<Map<String, dynamic>> filteredEntities = [];
|
||||
List<Map<String, dynamic>> 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<void> fetchwithoutpaging() async {
|
||||
try {
|
||||
final provider =
|
||||
Provider.of<Basicp2ViewModelScreen>(context, listen: false);
|
||||
final fetchedEntities = await provider.getEntities();
|
||||
print('withoutpaging data is $fetchedEntities');
|
||||
setState(() {
|
||||
serachEntities = fetchedEntities; // Update only filteredEntities
|
||||
});
|
||||
print('Basicp2 entity is .. $serachEntities');
|
||||
} catch (e) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Error'),
|
||||
content: Text('Failed to fetch Basicp2: $e'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Future<void> fetchEntities() async {
|
||||
try {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
|
||||
|
||||
|
||||
final provider =
|
||||
Provider.of<Basicp2ViewModelScreen>(context, listen: false);
|
||||
final fetchedEntities =
|
||||
await provider.getAllWithPagination(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 Basicp2 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<void> deleteEntity(Map<String, dynamic> entity) async {
|
||||
try {
|
||||
final provider =
|
||||
Provider.of<Basicp2ViewModelScreen>(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['about'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['textarea2'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['date_field'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['date_field2'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['datetime_field'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['datetime_field2'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['email_field'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['email_field2'].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: " Basicp2"),
|
||||
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) => Basicp2ViewModelScreen(),
|
||||
child: basicp2CreateEntityScreen(),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
fetchEntities();
|
||||
});
|
||||
},
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
Widget _buildListItem(Map<String, dynamic> entity) {
|
||||
return showCardView ? _buildCardView(entity) : _buildNormalView(entity);
|
||||
}
|
||||
|
||||
|
||||
// Function to build card view for a list item
|
||||
Widget _buildCardView(Map<String, dynamic> 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<String, dynamic> 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<String>(
|
||||
icon: const Icon(
|
||||
Icons.more_vert,
|
||||
color: Colors.black,
|
||||
size: 16,
|
||||
),
|
||||
itemBuilder: (BuildContext context) {
|
||||
return [
|
||||
PopupMenuItem<String>(
|
||||
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<String>(
|
||||
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) => Basicp2ViewModelScreen(),
|
||||
child: basicp2UpdateEntityScreen(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(
|
||||
"about : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['about'].toString() ?? 'No about Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Textarea2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['textarea2'].toString() ?? 'No Textarea2 Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Date Field : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['date_field'].toString() ?? 'No Date Field Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Date Field2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['date_field2'].toString() ?? 'No Date Field2 Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Datetime Field : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['datetime_field'].toString() ?? 'No Datetime Field Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Datetime Field2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['datetime_field2'].toString() ?? 'No Datetime Field2 Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Email Field : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['email_field'].toString() ?? 'No Email Field Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Email Field2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['email_field2'].toString() ?? 'No Email Field2 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<String, dynamic> 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';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,404 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Basicp2_viewModel/Basicp2_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 basicp2UpdateEntityScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
|
||||
basicp2UpdateEntityScreen({required this.entity});
|
||||
|
||||
@override
|
||||
_basicp2UpdateEntityScreenState createState() => _basicp2UpdateEntityScreenState();
|
||||
}
|
||||
|
||||
class _basicp2UpdateEntityScreenState extends State<basicp2UpdateEntityScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TextEditingController date_field = TextEditingController();
|
||||
DateTime selectedDatedate_field = DateTime.now();
|
||||
|
||||
Future<void> _selectDatedate_field(BuildContext context) async {
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: selectedDatedate_field,
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2101),
|
||||
);
|
||||
print(picked);
|
||||
if (picked != null && picked != selectedDatedate_field) {
|
||||
setState(() {
|
||||
selectedDatedate_field = picked;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
TextEditingController date_field2 = TextEditingController();
|
||||
DateTime selectedDatedate_field2 = DateTime.now();
|
||||
|
||||
Future<void> _selectDatedate_field2(BuildContext context) async {
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: selectedDatedate_field2,
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2101),
|
||||
);
|
||||
print(picked);
|
||||
if (picked != null && picked != selectedDatedate_field2) {
|
||||
setState(() {
|
||||
selectedDatedate_field2 = picked;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
DateTime selectedDateTimedatetime_field = DateTime.now();
|
||||
TextEditingController datetime_field = TextEditingController();
|
||||
Future<void> _selectDateTimedatetime_field(BuildContext context) async {
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: selectedDateTimedatetime_field,
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2101),
|
||||
);
|
||||
|
||||
if (picked != null) {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.fromDateTime(selectedDateTimedatetime_field),
|
||||
);
|
||||
print(pickedTime);
|
||||
if (pickedTime != null) {
|
||||
setState(() {
|
||||
selectedDateTimedatetime_field = DateTime(
|
||||
picked.year,
|
||||
picked.month,
|
||||
picked.day,
|
||||
pickedTime.hour,
|
||||
pickedTime.minute,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DateTime selectedDateTimedatetime_field2 = DateTime.now();
|
||||
TextEditingController datetime_field2 = TextEditingController();
|
||||
Future<void> _selectDateTimedatetime_field2(BuildContext context) async {
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: selectedDateTimedatetime_field2,
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2101),
|
||||
);
|
||||
|
||||
if (picked != null) {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.fromDateTime(selectedDateTimedatetime_field2),
|
||||
);
|
||||
print(pickedTime);
|
||||
if (pickedTime != null) {
|
||||
setState(() {
|
||||
selectedDateTimedatetime_field2 = DateTime(
|
||||
picked.year,
|
||||
picked.month,
|
||||
picked.day,
|
||||
pickedTime.hour,
|
||||
pickedTime.minute,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool _isemail_fieldEmailValid = true;
|
||||
|
||||
void _validateemail_fieldEmail(String email) {
|
||||
setState(() {
|
||||
_isemail_fieldEmailValid = RegExp(r'^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$').hasMatch(email);
|
||||
});
|
||||
}
|
||||
|
||||
bool _isemail_field2EmailValid = true;
|
||||
|
||||
void _validateemail_field2Email(String email) {
|
||||
setState(() {
|
||||
_isemail_field2EmailValid = RegExp(r'^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$').hasMatch(email);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final provider = Provider.of<Basicp2ViewModelScreen>(context, listen: false);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = Provider.of<Basicp2ViewModelScreen>(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 Basicp2"), actions: [
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
ReusableTextField(
|
||||
initialValue: widget.entity['about'],
|
||||
onSaved: (value) => widget.entity['about']= value,
|
||||
label: "Enter about",
|
||||
maxLines: 5,
|
||||
),
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
initialValue: widget.entity['textarea2'],
|
||||
onSaved: (value) => widget.entity['textarea2']= value,
|
||||
label: "Enter Textarea2",
|
||||
maxLines: 5,
|
||||
),
|
||||
|
||||
ReusableDatePickerField(label: 'Date Field', controller: date_field, initialDate: widget.entity['date_field'],
|
||||
onSaved: (value) => widget.entity['date_field'] = value,),
|
||||
|
||||
|
||||
ReusableDatePickerField(label: 'Date Field2', controller: date_field2, initialDate: widget.entity['date_field2'],
|
||||
onSaved: (value) => widget.entity['date_field2'] = value,),
|
||||
|
||||
|
||||
ReusableDateTimePickerField(label:'Datetime Field', controller: datetime_field, initialDateTime:widget.entity['datetime_field'] ,
|
||||
onSaved: (value) => widget.entity['datetime_field'] = value,),
|
||||
|
||||
|
||||
ReusableDateTimePickerField(label:'Datetime Field2', controller: datetime_field2, initialDateTime:widget.entity['datetime_field2'] ,
|
||||
onSaved: (value) => widget.entity['datetime_field2'] = value,),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Email Field",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle
|
||||
.txtGilroyMedium16Bluegray900),
|
||||
CustomTextFormField(
|
||||
hintText: "Enter Email Field",
|
||||
initialValue: widget.entity['email_field'],
|
||||
keyboardType: TextInputType.url,
|
||||
errorText: _isemail_fieldEmailValid ? null : 'Please enter a valid URL',
|
||||
onChanged: _validateemail_fieldEmail,
|
||||
|
||||
|
||||
|
||||
// ValidationProperties
|
||||
|
||||
onsaved: (value) {
|
||||
widget.entity['email_field'] = value;
|
||||
},
|
||||
margin: getMargin(top: 6))
|
||||
])),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Email Field2",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle
|
||||
.txtGilroyMedium16Bluegray900),
|
||||
CustomTextFormField(
|
||||
hintText: "Enter Email Field2",
|
||||
initialValue: widget.entity['email_field2'],
|
||||
keyboardType: TextInputType.url,
|
||||
errorText: _isemail_field2EmailValid ? null : 'Please enter a valid URL',
|
||||
onChanged: _validateemail_field2Email,
|
||||
|
||||
|
||||
|
||||
// ValidationProperties
|
||||
|
||||
onsaved: (value) {
|
||||
widget.entity['email_field2'] = value;
|
||||
},
|
||||
margin: getMargin(top: 6))
|
||||
])),
|
||||
|
||||
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 Basicp2: $e'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
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 Basicp2RepoScreen {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
Future<dynamic> getEntities() async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Basicp2/Basicp2');
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> getAllWithPagination(int page, int size) async {
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse(
|
||||
'$baseUrl/Basicp2/Basicp2/getall/page?page=$page&size=$size');
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> createEntity(Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response = await _helper.getPostApiResponse(
|
||||
'$baseUrl/Basicp2/Basicp2', entity);
|
||||
|
||||
print(entity);
|
||||
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateEntity(int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
await _helper.getPutApiResponse(
|
||||
'$baseUrl/Basicp2/Basicp2/$entityId', entity);
|
||||
print(entity);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity(int entityId) async {
|
||||
try {
|
||||
await _helper
|
||||
.getDeleteApiResponse('$baseUrl/Basicp2/Basicp2/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,119 @@
|
||||
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 '../Basicp2_Repo/Basicp2_repo_screen.dart';
|
||||
|
||||
class Basicp2ViewModelScreen extends ChangeNotifier{
|
||||
final Basicp2RepoScreen repo = Basicp2RepoScreen();
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
try {
|
||||
final response = await repo.getEntities();
|
||||
final entities = (response as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response =
|
||||
await repo.getAllWithPagination(page, size); // ✅ Use await
|
||||
|
||||
print('res - $response');
|
||||
|
||||
// ✅ Ensure response is a Map<String, dynamic>
|
||||
if (response is! Map<String, dynamic>) {
|
||||
throw Exception('Unexpected response format: $response');
|
||||
}
|
||||
|
||||
// ✅ Extract 'content' and ensure it's a list
|
||||
final entities = (response['content'] as List)
|
||||
.cast<Map<String, dynamic>>() // ✅ Ensure list of maps
|
||||
.toList();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
throw Exception('Failed to get all without pagination :- $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<Map<String, dynamic>> createEntity(Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api - $entity");
|
||||
// Wait for API response
|
||||
final responseData =
|
||||
await repo.createEntity(entity) as Map<String, dynamic>;
|
||||
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<void> updateEntity(int entityId, Map<String, dynamic> 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<void> 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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,116 @@
|
||||
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 basicp3ApiService {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse('$baseUrl/Basicp3/Basicp3');
|
||||
final entities = (response as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
Future<List<Map<String, dynamic>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Basicp3/Basicp3/getall/page?page=$page&size=$size');
|
||||
final entities =
|
||||
(response['content'] as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
Future<Map<String, dynamic>> createEntity(
|
||||
Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response =
|
||||
await _helper.getPostApiResponse('$baseUrl/Basicp3/Basicp3', entity);
|
||||
|
||||
print(entity);
|
||||
|
||||
// Assuming the response is a Map<String, dynamic>
|
||||
Map<String, dynamic> responseData = response;
|
||||
|
||||
return responseData;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<void> updateEntity( int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
await _helper.getPutApiResponse('$baseUrl/Basicp3/Basicp3/$entityId',
|
||||
entity); print(entity);
|
||||
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity( int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl/Basicp3/Basicp3/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,662 @@
|
||||
// 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 '../Basicp3_viewModel/Basicp3_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 basicp3CreateEntityScreen extends StatefulWidget {
|
||||
const basicp3CreateEntityScreen({super.key});
|
||||
|
||||
@override
|
||||
_basicp3CreateEntityScreenState createState() => _basicp3CreateEntityScreenState();
|
||||
}
|
||||
|
||||
class _basicp3CreateEntityScreenState extends State<basicp3CreateEntityScreen> {
|
||||
|
||||
final Map<String, dynamic> formData = {};
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
bool _isSwitchedtoggle_switch = false;
|
||||
bool toggle_switch = false;
|
||||
|
||||
void _toggleSwitchtoggle_switch(bool value) {
|
||||
setState(() {
|
||||
_isSwitchedtoggle_switch = value;
|
||||
});
|
||||
}
|
||||
|
||||
bool _isSwitchedtoggle_switch2 = false;
|
||||
bool toggle_switch2 = false;
|
||||
|
||||
void _toggleSwitchtoggle_switch2(bool value) {
|
||||
setState(() {
|
||||
_isSwitchedtoggle_switch2 = value;
|
||||
});
|
||||
}
|
||||
|
||||
bool _isUrlValidurl_field = true;
|
||||
void _validateUrlurl_field(String url) {
|
||||
setState(() {
|
||||
_isUrlValidurl_field = Uri.parse(url).isAbsolute;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
bool _isUrlValidurl_field2 = true;
|
||||
void _validateUrlurl_field2(String url) {
|
||||
setState(() {
|
||||
_isUrlValidurl_field2 = Uri.parse(url).isAbsolute;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
final TextEditingController decimal_fieldController = TextEditingController();
|
||||
|
||||
|
||||
final TextEditingController decimal_field2Controller = TextEditingController();
|
||||
|
||||
|
||||
final TextEditingController percentage_fieldController = TextEditingController();
|
||||
|
||||
|
||||
final TextEditingController percentage_field2Controller = TextEditingController();
|
||||
|
||||
|
||||
|
||||
|
||||
late String recaptchacaptcha;
|
||||
TextEditingController _recaptchaController = TextEditingController();
|
||||
final GlobalKey<ScaffoldMessengerState> _recaptchascaffoldKey = GlobalKey<ScaffoldMessengerState>();
|
||||
void generaterecaptchaCaptcha() {
|
||||
final random = Random();
|
||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
|
||||
recaptchacaptcha = String.fromCharCodes(Iterable.generate(
|
||||
6, (_) => chars.codeUnitAt(random.nextInt(chars.length))));
|
||||
}
|
||||
|
||||
void verifyrecaptchaCaptcha() {
|
||||
print("Verifying captcha");
|
||||
if (_recaptchaController.text.isEmpty) {
|
||||
print("recaptcha is empty");
|
||||
recaptchaSnackbar('Please enter CAPTCHA', success: false);
|
||||
} else if (_recaptchaController.text != recaptchacaptcha) {
|
||||
print("captcha is not matching");
|
||||
recaptchaSnackbar('CAPTCHA verification failed', success: false);
|
||||
} else {
|
||||
print("captcha is verified");
|
||||
recaptchaSnackbar('CAPTCHA Verified', success: true);
|
||||
// Navigate to another screen after verification
|
||||
// Example navigation to a new screen
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(builder: (context) => NextScreen()),
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
void recaptchaSnackbar(String message, {required bool success}) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
backgroundColor: success ? Colors.green : Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
late String recaptcha2captcha;
|
||||
TextEditingController _recaptcha2Controller = TextEditingController();
|
||||
final GlobalKey<ScaffoldMessengerState> _recaptcha2scaffoldKey = GlobalKey<ScaffoldMessengerState>();
|
||||
void generaterecaptcha2Captcha() {
|
||||
final random = Random();
|
||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
|
||||
recaptcha2captcha = String.fromCharCodes(Iterable.generate(
|
||||
6, (_) => chars.codeUnitAt(random.nextInt(chars.length))));
|
||||
}
|
||||
|
||||
void verifyrecaptcha2Captcha() {
|
||||
print("Verifying captcha");
|
||||
if (_recaptcha2Controller.text.isEmpty) {
|
||||
print("recaptcha2 is empty");
|
||||
recaptcha2Snackbar('Please enter CAPTCHA', success: false);
|
||||
} else if (_recaptcha2Controller.text != recaptcha2captcha) {
|
||||
print("captcha is not matching");
|
||||
recaptcha2Snackbar('CAPTCHA verification failed', success: false);
|
||||
} else {
|
||||
print("captcha is verified");
|
||||
recaptcha2Snackbar('CAPTCHA Verified', success: true);
|
||||
// Navigate to another screen after verification
|
||||
// Example navigation to a new screen
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(builder: (context) => NextScreen()),
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
void recaptcha2Snackbar(String message, {required bool success}) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
backgroundColor: success ? Colors.green : Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final provider = Provider.of<Basicp3ViewModelScreen>(context, listen: false);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
generaterecaptchaCaptcha();
|
||||
|
||||
generaterecaptcha2Captcha();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = Provider.of<Basicp3ViewModelScreen>(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 Basicp3"),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
Switch(
|
||||
value: _isSwitchedtoggle_switch,
|
||||
onChanged: _toggleSwitchtoggle_switch,
|
||||
activeColor: Colors.white,
|
||||
activeTrackColor: Colors.green,
|
||||
inactiveThumbColor: Colors.white,
|
||||
inactiveTrackColor: Colors.red,
|
||||
),
|
||||
|
||||
Switch(
|
||||
value: _isSwitchedtoggle_switch2,
|
||||
onChanged: _toggleSwitchtoggle_switch2,
|
||||
activeColor: Colors.white,
|
||||
activeTrackColor: Colors.green,
|
||||
inactiveThumbColor: Colors.white,
|
||||
inactiveTrackColor: Colors.red,
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Url Field",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900),
|
||||
CustomTextFormField(
|
||||
hintText: "Enter Url Field",
|
||||
errorText: _isUrlValidurl_field ? null : 'Please enter a valid URL',
|
||||
keyboardType: TextInputType.url,
|
||||
|
||||
|
||||
onsaved: (value) => formData['url_field'] = value,
|
||||
onChanged: _validateUrlurl_field,
|
||||
|
||||
margin: getMargin(top: 6))
|
||||
])),
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Url Field2",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900),
|
||||
CustomTextFormField(
|
||||
hintText: "Enter Url Field2",
|
||||
errorText: _isUrlValidurl_field2 ? null : 'Please enter a valid URL',
|
||||
keyboardType: TextInputType.url,
|
||||
|
||||
|
||||
onsaved: (value) => formData['url_field2'] = value,
|
||||
onChanged: _validateUrlurl_field2,
|
||||
|
||||
margin: getMargin(top: 6))
|
||||
])),
|
||||
SizedBox(height: 16),
|
||||
|
||||
ReusableTextField(
|
||||
onSaved:(value) => formData['decimal_field'] = value ,
|
||||
label: "Enter Decimal Field",
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d*')),
|
||||
],
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter a decimal number';
|
||||
}
|
||||
final decimalRegExp = RegExp(r'^\d*\.?\d*$');
|
||||
if (!decimalRegExp.hasMatch(value)) {
|
||||
return 'Please enter a valid decimal number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
onSaved:(value) => formData['decimal_field2'] = value ,
|
||||
label: "Enter Decimal Field2",
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d*')),
|
||||
],
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter a decimal number';
|
||||
}
|
||||
final decimalRegExp = RegExp(r'^\d*\.?\d*$');
|
||||
if (!decimalRegExp.hasMatch(value)) {
|
||||
return 'Please enter a valid decimal number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
controller: percentage_fieldController,
|
||||
|
||||
onSaved:(value) => formData['percentage_field'] = value ,
|
||||
label: "Enter Percentage Field",
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))),
|
||||
],
|
||||
// ValidationProperties
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
ReusableTextField(
|
||||
controller: percentage_field2Controller,
|
||||
|
||||
onSaved:(value) => formData['percentage_field2'] = value ,
|
||||
label: "Enter Percentage Field2",
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))),
|
||||
],
|
||||
// ValidationProperties
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Enter the following CAPTCHA:',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
recaptchacaptcha,
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue,
|
||||
letterSpacing: 4,
|
||||
fontFamily: 'Roboto',
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.refresh),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
generaterecaptchaCaptcha();
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 24),
|
||||
TextFormField(
|
||||
controller: _recaptchaController,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Enter CAPTCHA',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 24),
|
||||
ElevatedButton(
|
||||
onPressed: verifyrecaptchaCaptcha,
|
||||
child: Text('Verify CAPTCHA'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Enter the following CAPTCHA:',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
recaptcha2captcha,
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue,
|
||||
letterSpacing: 4,
|
||||
fontFamily: 'Roboto',
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.refresh),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
generaterecaptcha2Captcha();
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 24),
|
||||
TextFormField(
|
||||
controller: _recaptcha2Controller,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Enter CAPTCHA',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 24),
|
||||
ElevatedButton(
|
||||
onPressed: verifyrecaptcha2Captcha,
|
||||
child: Text('Verify CAPTCHA'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(width: 8),
|
||||
CustomButton(
|
||||
height: getVerticalSize(50),
|
||||
text: "Submit",
|
||||
margin: getMargin(top: 24, bottom: 5),
|
||||
onTap: () async {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
_formKey.currentState!.save();
|
||||
formData['toggle_switch'] = toggle_switch;
|
||||
|
||||
|
||||
formData['toggle_switch2'] = toggle_switch2;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
print(formData);
|
||||
Map<String, dynamic> 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 Basicp3: $e'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,857 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'Basicp3_create_entity_screen.dart';
|
||||
import 'Basicp3_update_entity_screen.dart';
|
||||
import '../Basicp3_viewModel/Basicp3_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 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
class basicp3_entity_list_screen extends StatefulWidget {
|
||||
static const String routeName = '/entity-list';
|
||||
|
||||
@override
|
||||
_basicp3_entity_list_screenState createState() => _basicp3_entity_list_screenState();
|
||||
}
|
||||
|
||||
class _basicp3_entity_list_screenState extends State<basicp3_entity_list_screen> {
|
||||
List<Map<String, dynamic>> entities = [];
|
||||
List<Map<String, dynamic>> filteredEntities = [];
|
||||
List<Map<String, dynamic>> 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<void> fetchwithoutpaging() async {
|
||||
try {
|
||||
final provider =
|
||||
Provider.of<Basicp3ViewModelScreen>(context, listen: false);
|
||||
final fetchedEntities = await provider.getEntities();
|
||||
print('withoutpaging data is $fetchedEntities');
|
||||
setState(() {
|
||||
serachEntities = fetchedEntities; // Update only filteredEntities
|
||||
});
|
||||
print('Basicp3 entity is .. $serachEntities');
|
||||
} catch (e) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Error'),
|
||||
content: Text('Failed to fetch Basicp3: $e'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Future<void> fetchEntities() async {
|
||||
try {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
|
||||
|
||||
|
||||
final provider =
|
||||
Provider.of<Basicp3ViewModelScreen>(context, listen: false);
|
||||
final fetchedEntities =
|
||||
await provider.getAllWithPagination(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 Basicp3 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<void> deleteEntity(Map<String, dynamic> entity) async {
|
||||
try {
|
||||
final provider =
|
||||
Provider.of<Basicp3ViewModelScreen>(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['toggle_switch'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
entity['toggle_switch2'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['url_field'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['url_field2'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['decimal_field'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['decimal_field2'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['percentage_field'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['percentage_field2'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['documentsequenc'].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: " Basicp3"),
|
||||
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) => Basicp3ViewModelScreen(),
|
||||
child: basicp3CreateEntityScreen(),
|
||||
),
|
||||
),
|
||||
).then((_) {
|
||||
fetchEntities();
|
||||
});
|
||||
},
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
Widget _buildListItem(Map<String, dynamic> entity) {
|
||||
return showCardView ? _buildCardView(entity) : _buildNormalView(entity);
|
||||
}
|
||||
|
||||
|
||||
// Function to build card view for a list item
|
||||
Widget _buildCardView(Map<String, dynamic> 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<String, dynamic> 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<String>(
|
||||
icon: const Icon(
|
||||
Icons.more_vert,
|
||||
color: Colors.black,
|
||||
size: 16,
|
||||
),
|
||||
itemBuilder: (BuildContext context) {
|
||||
return [
|
||||
PopupMenuItem<String>(
|
||||
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<String>(
|
||||
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) => Basicp3ViewModelScreen(),
|
||||
child: basicp3UpdateEntityScreen(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(
|
||||
"Toggle Switch : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['toggle_switch'].toString() ?? 'No Toggle Switch Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Toggle Switch2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['toggle_switch2'].toString() ?? 'No Toggle Switch2 Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Url Field : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['url_field'].toString() ?? 'No Url Field Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Url Field2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['url_field2'].toString() ?? 'No Url Field2 Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Decimal Field : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['decimal_field'].toString() ?? 'No Decimal Field Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Decimal Field2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['decimal_field2'].toString() ?? 'No Decimal Field2 Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Percentage Field : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['percentage_field'].toString() ?? 'No Percentage Field Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Percentage Field2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['percentage_field2'].toString() ?? 'No Percentage Field2 Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"documentsequenc : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['documentsequenc'].toString() ?? 'No documentsequenc 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<String, dynamic> 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';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,451 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Basicp3_viewModel/Basicp3_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 basicp3UpdateEntityScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
|
||||
basicp3UpdateEntityScreen({required this.entity});
|
||||
|
||||
@override
|
||||
_basicp3UpdateEntityScreenState createState() => _basicp3UpdateEntityScreenState();
|
||||
}
|
||||
|
||||
class _basicp3UpdateEntityScreenState extends State<basicp3UpdateEntityScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
bool istoggle_switch = false;
|
||||
|
||||
bool istoggle_switch2 = false;
|
||||
|
||||
bool _isUrlValidurl_field = true;
|
||||
|
||||
void _validateUrlurl_field(String url) {
|
||||
setState(() {
|
||||
_isUrlValidurl_field= Uri.parse(url).isAbsolute;
|
||||
});
|
||||
}
|
||||
|
||||
bool _isUrlValidurl_field2 = true;
|
||||
|
||||
void _validateUrlurl_field2(String url) {
|
||||
setState(() {
|
||||
_isUrlValidurl_field2= Uri.parse(url).isAbsolute;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final provider = Provider.of<Basicp3ViewModelScreen>(context, listen: false);
|
||||
istoggle_switch = widget.entity['toggle_switch'] ?? false; // Set initial value
|
||||
|
||||
istoggle_switch2 = widget.entity['toggle_switch2'] ?? false; // Set initial value
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = Provider.of<Basicp3ViewModelScreen>(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 Basicp3"), actions: [
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Switch(
|
||||
value: istoggle_switch,
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
istoggle_switch = newValue;
|
||||
});
|
||||
},
|
||||
activeColor: Colors.white,
|
||||
activeTrackColor: Colors.green,
|
||||
inactiveThumbColor: Colors.white,
|
||||
inactiveTrackColor: Colors.red,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text('Toggle Switch'),
|
||||
],
|
||||
),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
Switch(
|
||||
value: istoggle_switch2,
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
istoggle_switch2 = newValue;
|
||||
});
|
||||
},
|
||||
activeColor: Colors.white,
|
||||
activeTrackColor: Colors.green,
|
||||
inactiveThumbColor: Colors.white,
|
||||
inactiveTrackColor: Colors.red,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text('Toggle Switch2'),
|
||||
],
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Url Field",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle
|
||||
.txtGilroyMedium16Bluegray900),
|
||||
CustomTextFormField(
|
||||
hintText: "Enter Url Field",
|
||||
initialValue: widget.entity['url_field'],
|
||||
keyboardType: TextInputType.url,
|
||||
errorText: _isUrlValidurl_field ? null : 'Please enter a valid URL',
|
||||
onChanged: _validateUrlurl_field,
|
||||
|
||||
|
||||
|
||||
// ValidationProperties
|
||||
|
||||
onsaved: (value) {
|
||||
widget.entity['url_field'] = value;
|
||||
},
|
||||
margin: getMargin(top: 6))
|
||||
])),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
Padding(
|
||||
padding: getPadding(top: 19),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Url Field2",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle
|
||||
.txtGilroyMedium16Bluegray900),
|
||||
CustomTextFormField(
|
||||
hintText: "Enter Url Field2",
|
||||
initialValue: widget.entity['url_field2'],
|
||||
keyboardType: TextInputType.url,
|
||||
errorText: _isUrlValidurl_field2 ? null : 'Please enter a valid URL',
|
||||
onChanged: _validateUrlurl_field2,
|
||||
|
||||
|
||||
|
||||
// ValidationProperties
|
||||
|
||||
onsaved: (value) {
|
||||
widget.entity['url_field2'] = value;
|
||||
},
|
||||
margin: getMargin(top: 6))
|
||||
])),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
ReusableTextField(
|
||||
initialValue: widget.entity['decimal_field'],
|
||||
onSaved: (value) => widget.entity['decimal_field'] = value,
|
||||
label: "Enter Decimal Field",
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d*')),
|
||||
],
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter a decimal number';
|
||||
}
|
||||
final decimalRegExp = RegExp(r'^\d*\.?\d*$');
|
||||
if (!decimalRegExp.hasMatch(value)) {
|
||||
return 'Please enter a valid decimal number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
ReusableTextField(
|
||||
initialValue: widget.entity['decimal_field2'],
|
||||
onSaved: (value) => widget.entity['decimal_field2'] = value,
|
||||
label: "Enter Decimal Field2",
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d*')),
|
||||
],
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter a decimal number';
|
||||
}
|
||||
final decimalRegExp = RegExp(r'^\d*\.?\d*$');
|
||||
if (!decimalRegExp.hasMatch(value)) {
|
||||
return 'Please enter a valid decimal number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
ReusableTextField(
|
||||
initialValue: widget.entity['percentage_field'].toString(),
|
||||
onSaved: (value) => widget.entity['percentage_field']= value,
|
||||
label: "Enter Percentage Field",
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))),
|
||||
],
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter a number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
ReusableTextField(
|
||||
initialValue: widget.entity['percentage_field2'].toString(),
|
||||
onSaved: (value) => widget.entity['percentage_field2']= value,
|
||||
label: "Enter Percentage Field2",
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow((RegExp(r'[0-9]'))),
|
||||
],
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter a number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
|
||||
label: "Please Enter documentsequenc",
|
||||
initialValue: widget.entity['documentsequenc'] ?? '',
|
||||
|
||||
// ValidationProperties
|
||||
onSaved: (value) => widget.entity['documentsequenc'] = value,
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
|
||||
label: "Please Enter recaptcha",
|
||||
initialValue: widget.entity['recaptcha'] ?? '',
|
||||
|
||||
// ValidationProperties
|
||||
onSaved: (value) => widget.entity['recaptcha'] = value,
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
|
||||
label: "Please Enter recaptcha2",
|
||||
initialValue: widget.entity['recaptcha2'] ?? '',
|
||||
|
||||
// ValidationProperties
|
||||
onSaved: (value) => widget.entity['recaptcha2'] = 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();
|
||||
widget.entity['toggle_switch'] = istoggle_switch;
|
||||
|
||||
widget.entity['toggle_switch2'] = istoggle_switch2;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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 Basicp3: $e'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
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 Basicp3RepoScreen {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
Future<dynamic> getEntities() async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Basicp3/Basicp3');
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> getAllWithPagination(int page, int size) async {
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse(
|
||||
'$baseUrl/Basicp3/Basicp3/getall/page?page=$page&size=$size');
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all without pagination: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> createEntity(Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api$entity");
|
||||
final response = await _helper.getPostApiResponse(
|
||||
'$baseUrl/Basicp3/Basicp3', entity);
|
||||
|
||||
print(entity);
|
||||
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to create entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateEntity(int entityId, Map<String, dynamic> entity) async {
|
||||
try {
|
||||
await _helper.getPutApiResponse(
|
||||
'$baseUrl/Basicp3/Basicp3/$entityId', entity);
|
||||
print(entity);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity(int entityId) async {
|
||||
try {
|
||||
await _helper
|
||||
.getDeleteApiResponse('$baseUrl/Basicp3/Basicp3/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,123 @@
|
||||
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 '../Basicp3_Repo/Basicp3_repo_screen.dart';
|
||||
|
||||
class Basicp3ViewModelScreen extends ChangeNotifier{
|
||||
final Basicp3RepoScreen repo = Basicp3RepoScreen();
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
try {
|
||||
final response = await repo.getEntities();
|
||||
final entities = (response as List).cast<Map<String, dynamic>>();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to get all entities: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getAllWithPagination(
|
||||
int page, int size) async {
|
||||
try {
|
||||
final response =
|
||||
await repo.getAllWithPagination(page, size); // ✅ Use await
|
||||
|
||||
print('res - $response');
|
||||
|
||||
// ✅ Ensure response is a Map<String, dynamic>
|
||||
if (response is! Map<String, dynamic>) {
|
||||
throw Exception('Unexpected response format: $response');
|
||||
}
|
||||
|
||||
// ✅ Extract 'content' and ensure it's a list
|
||||
final entities = (response['content'] as List)
|
||||
.cast<Map<String, dynamic>>() // ✅ Ensure list of maps
|
||||
.toList();
|
||||
return entities;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
throw Exception('Failed to get all without pagination :- $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<Map<String, dynamic>> createEntity(Map<String, dynamic> entity) async {
|
||||
try {
|
||||
print("in post api - $entity");
|
||||
// Wait for API response
|
||||
final responseData =
|
||||
await repo.createEntity(entity) as Map<String, dynamic>;
|
||||
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<void> updateEntity(int entityId, Map<String, dynamic> 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<void> 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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,3 +1,12 @@
|
||||
import '../../Entity/angulardatatype/Basicp3/Basicp3View/Basicp3_entity_list_screen.dart';
|
||||
import '../../Entity/angulardatatype/Basicp3/Basicp3_viewModel/Basicp3_view_model_screen.dart';
|
||||
|
||||
import '../../Entity/angulardatatype/Basicp2/Basicp2View/Basicp2_entity_list_screen.dart';
|
||||
import '../../Entity/angulardatatype/Basicp2/Basicp2_viewModel/Basicp2_view_model_screen.dart';
|
||||
|
||||
import '../../Entity/angulardatatype/Basicp1/Basicp1View/Basicp1_entity_list_screen.dart';
|
||||
import '../../Entity/angulardatatype/Basicp1/Basicp1_viewModel/Basicp1_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 +18,130 @@ 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<ProfileViewModel>(context, listen: false);
|
||||
return Drawer(
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children: <Widget>[
|
||||
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<ProfileViewModel>(context, listen: false);
|
||||
return Drawer(
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children: <Widget>[
|
||||
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: 'Basicp3',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Basicp3ViewModelScreen(),
|
||||
child: basicp3_entity_list_screen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
DrawerItem(
|
||||
color: AppColors.primary,
|
||||
icon: Icons.chat_bubble,
|
||||
title: 'Basicp2',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Basicp2ViewModelScreen(),
|
||||
child: basicp2_entity_list_screen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
DrawerItem(
|
||||
color: AppColors.primary,
|
||||
icon: Icons.chat_bubble,
|
||||
title: 'Basicp1',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Basicp1ViewModelScreen(),
|
||||
child: basicp1_entity_list_screen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
DrawerItem(
|
||||
icon: Icons.logout,
|
||||
color: Colors.red,
|
||||
title: 'Logout',
|
||||
onTap: () async {
|
||||
await UserManager().clearUser();
|
||||
Navigator.pushReplacementNamed(context, RouteNames.splashView);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -69,6 +69,15 @@ public class BuilderService {
|
||||
executeDump(true);
|
||||
|
||||
// ADD OTHER SERVICE
|
||||
addCustomMenu( "Basicp3", "Transcations");
|
||||
|
||||
|
||||
addCustomMenu( "Basicp2", "Transcations");
|
||||
|
||||
|
||||
addCustomMenu( "Basicp1", "Transcations");
|
||||
|
||||
|
||||
|
||||
System.out.println("dashboard and menu inserted...");
|
||||
|
||||
|
||||
@ -0,0 +1,171 @@
|
||||
package com.realnet.angulardatatype.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.angulardatatype.Entity.Basicp1;
|
||||
import com.realnet.angulardatatype.Services.Basicp1Service ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/Basicp1")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class Basicp1Controller {
|
||||
@Autowired
|
||||
private Basicp1Service Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Basicp1")
|
||||
public Basicp1 Savedata(@RequestBody Basicp1 data) {
|
||||
Basicp1 save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Basicp1/{id}")
|
||||
public Basicp1 update(@RequestBody Basicp1 data,@PathVariable Integer id ) {
|
||||
Basicp1 update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Basicp1/getall/page")
|
||||
public Page<Basicp1> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Basicp1> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Basicp1")
|
||||
public List<Basicp1> getdetails() {
|
||||
List<Basicp1> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Basicp1")
|
||||
public List<Basicp1> getallwioutsec() {
|
||||
List<Basicp1> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Basicp1/{id}")
|
||||
public Basicp1 getdetailsbyId(@PathVariable Integer id ) {
|
||||
Basicp1 get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Basicp1/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,147 @@
|
||||
package com.realnet.angulardatatype.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.angulardatatype.Entity.Basicp2;
|
||||
import com.realnet.angulardatatype.Services.Basicp2Service ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/Basicp2")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class Basicp2Controller {
|
||||
@Autowired
|
||||
private Basicp2Service Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Basicp2")
|
||||
public Basicp2 Savedata(@RequestBody Basicp2 data) {
|
||||
Basicp2 save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Basicp2/{id}")
|
||||
public Basicp2 update(@RequestBody Basicp2 data,@PathVariable Integer id ) {
|
||||
Basicp2 update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Basicp2/getall/page")
|
||||
public Page<Basicp2> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Basicp2> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Basicp2")
|
||||
public List<Basicp2> getdetails() {
|
||||
List<Basicp2> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Basicp2")
|
||||
public List<Basicp2> getallwioutsec() {
|
||||
List<Basicp2> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Basicp2/{id}")
|
||||
public Basicp2 getdetailsbyId(@PathVariable Integer id ) {
|
||||
Basicp2 get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Basicp2/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,163 @@
|
||||
package com.realnet.angulardatatype.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.angulardatatype.Entity.Basicp3;
|
||||
import com.realnet.angulardatatype.Services.Basicp3Service ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/Basicp3")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class Basicp3Controller {
|
||||
@Autowired
|
||||
private Basicp3Service Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Basicp3")
|
||||
public Basicp3 Savedata(@RequestBody Basicp3 data) {
|
||||
Basicp3 save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Basicp3/{id}")
|
||||
public Basicp3 update(@RequestBody Basicp3 data,@PathVariable Integer id ) {
|
||||
Basicp3 update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Basicp3/getall/page")
|
||||
public Page<Basicp3> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Basicp3> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Basicp3")
|
||||
public List<Basicp3> getdetails() {
|
||||
List<Basicp3> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Basicp3")
|
||||
public List<Basicp3> getallwioutsec() {
|
||||
List<Basicp3> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Basicp3/{id}")
|
||||
public Basicp3 getdetailsbyId(@PathVariable Integer id ) {
|
||||
Basicp3 get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Basicp3/{id}")
|
||||
public ResponseEntity<?> delete_by_id(@PathVariable Integer id ) {
|
||||
Service.delete_by_id(id);
|
||||
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
package com.realnet.angulardatatype.Entity;
|
||||
import lombok.*;
|
||||
import com.realnet.WhoColumn.Entity.Extension;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Basicp1 extends Extension {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String name2;
|
||||
|
||||
private int number1;
|
||||
|
||||
private int number2;
|
||||
|
||||
private String phone_number;
|
||||
|
||||
private String phone_number2;
|
||||
|
||||
|
||||
@Column(length = 2000)
|
||||
private String paragraph_field;
|
||||
|
||||
|
||||
@Column(length = 2000)
|
||||
private String paragraph_field2;
|
||||
|
||||
private String password_field;
|
||||
@Transient
|
||||
private String confirmpassword_field;
|
||||
|
||||
@Column(length = 2000)
|
||||
private String textarea;
|
||||
|
||||
@Column(length = 2000)
|
||||
private String textarea_field;
|
||||
|
||||
@Column(length = 2000)
|
||||
private String textarea_field2;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
package com.realnet.angulardatatype.Entity;
|
||||
import lombok.*;
|
||||
import com.realnet.WhoColumn.Entity.Extension;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Basicp2 extends Extension {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(length = 2000)
|
||||
private String about;
|
||||
|
||||
@Column(length = 2000)
|
||||
private String textarea2;
|
||||
|
||||
private String date_field;
|
||||
|
||||
private String date_field2;
|
||||
|
||||
private String datetime_field;
|
||||
|
||||
private String datetime_field2;
|
||||
|
||||
private String email_field;
|
||||
|
||||
private String email_field2;
|
||||
|
||||
private Long user_id;
|
||||
private String user_name;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package com.realnet.angulardatatype.Entity;
|
||||
import lombok.*;
|
||||
import com.realnet.WhoColumn.Entity.Extension;
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Basicp3 extends Extension {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
private boolean toggle_switch;
|
||||
|
||||
private boolean toggle_switch2;
|
||||
|
||||
private String url_field;
|
||||
|
||||
private String url_field2;
|
||||
|
||||
private double decimal_field;
|
||||
|
||||
private double decimal_field2;
|
||||
|
||||
private int percentage_field;
|
||||
|
||||
private int percentage_field2;
|
||||
|
||||
private String documentsequenc;
|
||||
|
||||
private String recaptcha;
|
||||
|
||||
private String recaptcha2;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package com.realnet.angulardatatype.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.angulardatatype.Entity.Basicp1;
|
||||
|
||||
@Repository
|
||||
public interface Basicp1Repository extends JpaRepository<Basicp1, Integer> {
|
||||
|
||||
@Query(value = "select * from basicp1 where created_by=?1", nativeQuery = true)
|
||||
List<Basicp1> findAll(Long creayedBy);
|
||||
|
||||
@Query(value = "select * from basicp1 where created_by=?1", nativeQuery = true)
|
||||
Page<Basicp1> findAll(Pageable page, Long creayedBy);
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.realnet.angulardatatype.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.angulardatatype.Entity.Basicp2;
|
||||
|
||||
@Repository
|
||||
public interface Basicp2Repository extends JpaRepository<Basicp2, Integer> {
|
||||
|
||||
@Query(value = "select * from basicp2 where created_by=?1", nativeQuery = true)
|
||||
List<Basicp2> findAll(Long creayedBy);
|
||||
|
||||
@Query(value = "select * from basicp2 where created_by=?1", nativeQuery = true)
|
||||
Page<Basicp2> findAll(Pageable page, Long creayedBy);
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package com.realnet.angulardatatype.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.angulardatatype.Entity.Basicp3;
|
||||
|
||||
@Repository
|
||||
public interface Basicp3Repository extends JpaRepository<Basicp3, Integer> {
|
||||
|
||||
@Query(value = "select * from basicp3 where created_by=?1", nativeQuery = true)
|
||||
List<Basicp3> findAll(Long creayedBy);
|
||||
|
||||
@Query(value = "select * from basicp3 where created_by=?1", nativeQuery = true)
|
||||
Page<Basicp3> findAll(Pageable page, Long creayedBy);
|
||||
}
|
||||
@ -0,0 +1,183 @@
|
||||
package com.realnet.angulardatatype.Services;
|
||||
import com.realnet.angulardatatype.Repository.Basicp1Repository;
|
||||
import com.realnet.angulardatatype.Entity.Basicp1
|
||||
;import java.util.*;
|
||||
|
||||
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 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 Basicp1Service {
|
||||
@Autowired
|
||||
private Basicp1Repository Repository;
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
@Autowired
|
||||
private RealmService realmService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Basicp1 Savedata(Basicp1 data) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
data.setCreatedBy(getUser().getUserId());
|
||||
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||
Basicp1 save = Repository.save(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
// get all with pagination
|
||||
public Page<Basicp1> getAllWithPagination(Pageable page) {
|
||||
return Repository.findAll(page, getUser().getUserId());
|
||||
}
|
||||
public List<Basicp1> getdetails() {
|
||||
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||
List<Basicp1> all = Repository.findAll(getUser().getUserId());
|
||||
|
||||
return all ; }
|
||||
|
||||
|
||||
public Basicp1 getdetailsbyId(Integer id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Integer id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Basicp1 update(Basicp1 data,Integer id) {
|
||||
Basicp1 old = Repository.findById(id).get();
|
||||
old.setName(data.getName());
|
||||
|
||||
old.setName2(data.getName2());
|
||||
|
||||
old.setNumber1(data.getNumber1());
|
||||
|
||||
old.setNumber2(data.getNumber2());
|
||||
|
||||
old.setPhone_number(data.getPhone_number());
|
||||
|
||||
old.setPhone_number2(data.getPhone_number2());
|
||||
|
||||
old.setParagraph_field(data.getParagraph_field());
|
||||
|
||||
old.setParagraph_field2(data.getParagraph_field2());
|
||||
|
||||
old.setPassword_field(data.getPassword_field());
|
||||
|
||||
old.setTextarea(data.getTextarea());
|
||||
|
||||
old.setTextarea_field(data.getTextarea_field());
|
||||
|
||||
old.setTextarea_field2(data.getTextarea_field2());
|
||||
|
||||
final Basicp1 test = Repository.save(old);
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
return test;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public AppUser getUser() {
|
||||
AppUser user = userService.getLoggedInUser();
|
||||
return user;
|
||||
|
||||
}}
|
||||
@ -0,0 +1,154 @@
|
||||
package com.realnet.angulardatatype.Services;
|
||||
import com.realnet.angulardatatype.Repository.Basicp2Repository;
|
||||
import com.realnet.angulardatatype.Entity.Basicp2
|
||||
;import java.util.*;
|
||||
|
||||
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 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 Basicp2Service {
|
||||
@Autowired
|
||||
private Basicp2Repository Repository;
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
@Autowired
|
||||
private RealmService realmService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Basicp2 Savedata(Basicp2 data) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data.setUser_id(getUser().getUserId());
|
||||
data.setUser_name(getUser().getFullName());
|
||||
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
data.setCreatedBy(getUser().getUserId());
|
||||
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||
Basicp2 save = Repository.save(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
// get all with pagination
|
||||
public Page<Basicp2> getAllWithPagination(Pageable page) {
|
||||
return Repository.findAll(page, getUser().getUserId());
|
||||
}
|
||||
public List<Basicp2> getdetails() {
|
||||
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||
List<Basicp2> all = Repository.findAll(getUser().getUserId());
|
||||
|
||||
return all ; }
|
||||
|
||||
|
||||
public Basicp2 getdetailsbyId(Integer id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Integer id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Basicp2 update(Basicp2 data,Integer id) {
|
||||
Basicp2 old = Repository.findById(id).get();
|
||||
old.setAbout(data.getAbout());
|
||||
|
||||
old.setTextarea2(data.getTextarea2());
|
||||
|
||||
old.setDate_field(data.getDate_field());
|
||||
|
||||
old.setDate_field2(data.getDate_field2());
|
||||
|
||||
old.setDatetime_field(data.getDatetime_field());
|
||||
|
||||
old.setDatetime_field2(data.getDatetime_field2());
|
||||
|
||||
old.setEmail_field(data.getEmail_field());
|
||||
|
||||
old.setEmail_field2(data.getEmail_field2());
|
||||
|
||||
|
||||
|
||||
final Basicp2 test = Repository.save(old);
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
return test;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public AppUser getUser() {
|
||||
AppUser user = userService.getLoggedInUser();
|
||||
return user;
|
||||
|
||||
}}
|
||||
@ -0,0 +1,174 @@
|
||||
package com.realnet.angulardatatype.Services;
|
||||
import com.realnet.angulardatatype.Repository.Basicp3Repository;
|
||||
import com.realnet.angulardatatype.Entity.Basicp3
|
||||
;import java.util.*;
|
||||
|
||||
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 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 Basicp3Service {
|
||||
@Autowired
|
||||
private Basicp3Repository Repository;
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
@Autowired
|
||||
private RealmService realmService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private SequenceService documentsequencsequenceService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Basicp3 Savedata(Basicp3 data) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data.setDocumentsequenc (documentsequencsequenceService.GenerateSequence("ff"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
data.setCreatedBy(getUser().getUserId());
|
||||
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||
Basicp3 save = Repository.save(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
// get all with pagination
|
||||
public Page<Basicp3> getAllWithPagination(Pageable page) {
|
||||
return Repository.findAll(page, getUser().getUserId());
|
||||
}
|
||||
public List<Basicp3> getdetails() {
|
||||
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||
List<Basicp3> all = Repository.findAll(getUser().getUserId());
|
||||
|
||||
return all ; }
|
||||
|
||||
|
||||
public Basicp3 getdetailsbyId(Integer id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Integer id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Basicp3 update(Basicp3 data,Integer id) {
|
||||
Basicp3 old = Repository.findById(id).get();
|
||||
old.setToggle_switch (data.isToggle_switch());
|
||||
|
||||
old.setToggle_switch2 (data.isToggle_switch2());
|
||||
|
||||
old.setUrl_field(data.getUrl_field());
|
||||
|
||||
old.setUrl_field2(data.getUrl_field2());
|
||||
|
||||
old.setDecimal_field(data.getDecimal_field());
|
||||
|
||||
old.setDecimal_field2(data.getDecimal_field2());
|
||||
|
||||
old.setPercentage_field(data.getPercentage_field());
|
||||
|
||||
old.setPercentage_field2(data.getPercentage_field2());
|
||||
|
||||
old.setDocumentsequenc(data.getDocumentsequenc());
|
||||
|
||||
old.setRecaptcha(data.getRecaptcha());
|
||||
|
||||
old.setRecaptcha2(data.getRecaptcha2());
|
||||
|
||||
final Basicp3 test = Repository.save(old);
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
return test;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public AppUser getUser() {
|
||||
AppUser user = userService.getLoggedInUser();
|
||||
return user;
|
||||
|
||||
}}
|
||||
6
test31march-testdb-d/authsec_mysql/mysql/wf_table/wf_table.sql
Executable file
6
test31march-testdb-d/authsec_mysql/mysql/wf_table/wf_table.sql
Executable file
@ -0,0 +1,6 @@
|
||||
CREATE TABLE testdb.Basicp1(id BIGINT NOT NULL AUTO_INCREMENT, textarea_field VARCHAR(400), paragraph_field VARCHAR(400), textarea VARCHAR(400), paragraph_field2 VARCHAR(400), phone_number2 VARCHAR(400), name VARCHAR(400), number1 int, phone_number VARCHAR(400), number2 int, name2 VARCHAR(400), password_field VARCHAR(400), textarea_field2 VARCHAR(400), PRIMARY KEY (id));
|
||||
|
||||
CREATE TABLE testdb.Basicp2(id BIGINT NOT NULL AUTO_INCREMENT, datetime_field2 VARCHAR(400), about VARCHAR(400), datetime_field VARCHAR(400), userid_field VARCHAR(400), email_field2 VARCHAR(400), date_field Date, email_field VARCHAR(400), textarea2 VARCHAR(400), date_field2 Date, PRIMARY KEY (id));
|
||||
|
||||
CREATE TABLE testdb.Basicp3(id BIGINT NOT NULL AUTO_INCREMENT, toggle_switch2 VARCHAR(400), decimal_field2 double, documentsequenc VARCHAR(400), toggle_switch VARCHAR(400), recaptcha VARCHAR(400), percentage_field int, percentage_field2 int, url_field VARCHAR(400), url_field2 VARCHAR(400), decimal_field double, recaptcha2 VARCHAR(400), PRIMARY KEY (id));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user