build_app
This commit is contained in:
parent
6bf1c33445
commit
e7c542e986
@ -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 adv1ApiService {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse('$baseUrl/Adv1/Adv1');
|
||||
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/Adv1/Adv1/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/Adv1/Adv1', 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/Adv1/Adv1/$entityId',
|
||||
entity); print(entity);
|
||||
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity( int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl/Adv1/Adv1/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,757 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'Adv1_create_entity_screen.dart';
|
||||
import 'Adv1_update_entity_screen.dart';
|
||||
import '../Adv1_viewModel/Adv1_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 adv1_entity_list_screen extends StatefulWidget {
|
||||
static const String routeName = '/entity-list';
|
||||
|
||||
@override
|
||||
_adv1_entity_list_screenState createState() => _adv1_entity_list_screenState();
|
||||
}
|
||||
|
||||
class _adv1_entity_list_screenState extends State<adv1_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<Adv1ViewModelScreen>(context, listen: false);
|
||||
final fetchedEntities = await provider.getEntities();
|
||||
print('withoutpaging data is $fetchedEntities');
|
||||
setState(() {
|
||||
serachEntities = fetchedEntities; // Update only filteredEntities
|
||||
});
|
||||
print('Adv1 entity is .. $serachEntities');
|
||||
} catch (e) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Error'),
|
||||
content: Text('Failed to fetch Adv1: $e'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Future<void> fetchEntities() async {
|
||||
try {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
|
||||
|
||||
|
||||
final provider =
|
||||
Provider.of<Adv1ViewModelScreen>(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 Adv1 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<Adv1ViewModelScreen>(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['ismale'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['idfemale'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['audio_field'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['audio_field2'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['video_field'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['video_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: " Adv1"),
|
||||
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) => Adv1ViewModelScreen(),
|
||||
child: adv1CreateEntityScreen(),
|
||||
),
|
||||
),
|
||||
).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) => Adv1ViewModelScreen(),
|
||||
child: adv1UpdateEntityScreen(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(
|
||||
"ismale : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['ismale'].toString() ?? 'No ismale Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"idfemale : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['idfemale'].toString() ?? 'No idfemale Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Test1 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['test1'].toString() ?? 'No Test1 Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"T1 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['t1'].toString() ?? 'No T1 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,552 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Adv1_viewModel/Adv1_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 adv1UpdateEntityScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
|
||||
adv1UpdateEntityScreen({required this.entity});
|
||||
|
||||
@override
|
||||
_adv1UpdateEntityScreenState createState() => _adv1UpdateEntityScreenState();
|
||||
}
|
||||
|
||||
class _adv1UpdateEntityScreenState extends State<adv1UpdateEntityScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
String? selectedismale;
|
||||
|
||||
|
||||
Future<void> _showismaleSelectionDialog(BuildContext context) async {
|
||||
final result = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SimpleDialog(
|
||||
title: const Text('Select ismale'),
|
||||
children: [
|
||||
|
||||
|
||||
RadioListTile<String>(
|
||||
title: const Text('no'),
|
||||
value: 'no',
|
||||
groupValue: selectedismale,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
selectedismale = value;
|
||||
Navigator.pop(context, value);
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
|
||||
RadioListTile<String>(
|
||||
title: const Text('yes'),
|
||||
value: 'yes',
|
||||
groupValue: selectedismale,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
selectedismale = value;
|
||||
Navigator.pop(context, value);
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (result != null) {
|
||||
setState(() {
|
||||
selectedismale = result;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
String? selectedidfemale;
|
||||
|
||||
|
||||
Future<void> _showidfemaleSelectionDialog(BuildContext context) async {
|
||||
final result = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SimpleDialog(
|
||||
title: const Text('Select idfemale'),
|
||||
children: [
|
||||
|
||||
|
||||
RadioListTile<String>(
|
||||
title: const Text('no'),
|
||||
value: 'no',
|
||||
groupValue: selectedidfemale,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
selectedidfemale = value;
|
||||
Navigator.pop(context, value);
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
|
||||
RadioListTile<String>(
|
||||
title: const Text('yes'),
|
||||
value: 'yes',
|
||||
groupValue: selectedidfemale,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
selectedidfemale = value;
|
||||
Navigator.pop(context, value);
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (result != null) {
|
||||
setState(() {
|
||||
selectedidfemale = result;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool test1cBox = false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool t1cBox = false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final provider = Provider.of<Adv1ViewModelScreen>(context, listen: false);
|
||||
selectedismale = widget.entity['ismale'] ?? ''; // Initialize selected ismale
|
||||
|
||||
selectedidfemale = widget.entity['idfemale'] ?? ''; // Initialize selected idfemale
|
||||
|
||||
|
||||
|
||||
|
||||
test1cBox = widget.entity['test1'] ?? false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
t1cBox = widget.entity['t1'] ?? false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = Provider.of<Adv1ViewModelScreen>(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 Adv1"), actions: [
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"ismale",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.blueGrey[900],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
GestureDetector(
|
||||
onTap: () => _showismaleSelectionDialog(context),
|
||||
child: AbsorbPointer(
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration(
|
||||
hintText: "Enter ismale",
|
||||
border: OutlineInputBorder(),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
|
||||
),
|
||||
controller: TextEditingController(text: selectedismale),
|
||||
onSaved: (value) {
|
||||
widget.entity['ismale'] = value;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"idfemale",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.blueGrey[900],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
GestureDetector(
|
||||
onTap: () => _showidfemaleSelectionDialog(context),
|
||||
child: AbsorbPointer(
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration(
|
||||
hintText: "Enter idfemale",
|
||||
border: OutlineInputBorder(),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
|
||||
),
|
||||
controller: TextEditingController(text: selectedidfemale),
|
||||
onSaved: (value) {
|
||||
widget.entity['idfemale'] = value;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
|
||||
|
||||
|
||||
Checkbox(
|
||||
value: test1cBox,
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
test1cBox = newValue!;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text('Test1'),
|
||||
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
|
||||
|
||||
|
||||
Checkbox(
|
||||
value: t1cBox,
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
t1cBox = newValue!;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text('T1'),
|
||||
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
|
||||
label: "Please Enter audio Field",
|
||||
initialValue: widget.entity['audio_field'] ?? '',
|
||||
|
||||
// ValidationProperties
|
||||
onSaved: (value) => widget.entity['audio_field'] = value,
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
|
||||
label: "Please Enter audio Field2",
|
||||
initialValue: widget.entity['audio_field2'] ?? '',
|
||||
|
||||
// ValidationProperties
|
||||
onSaved: (value) => widget.entity['audio_field2'] = value,
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
|
||||
label: "Please Enter video Field",
|
||||
initialValue: widget.entity['video_field'] ?? '',
|
||||
|
||||
// ValidationProperties
|
||||
onSaved: (value) => widget.entity['video_field'] = value,
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
|
||||
label: "Please Enter video Field2",
|
||||
initialValue: widget.entity['video_field2'] ?? '',
|
||||
|
||||
// ValidationProperties
|
||||
onSaved: (value) => widget.entity['video_field2'] = 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['test1'] = test1cBox;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
widget.entity['t1'] = t1cBox;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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 Adv1: $e'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,158 @@
|
||||
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 Adv1RepoScreen {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
Future<dynamic> getEntities() async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Adv1/Adv1');
|
||||
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/Adv1/Adv1/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/Adv1/Adv1', 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/Adv1/Adv1/$entityId', entity);
|
||||
print(entity);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity(int entityId) async {
|
||||
try {
|
||||
await _helper
|
||||
.getDeleteApiResponse('$baseUrl/Adv1/Adv1/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Future<dynamic> fileupload_fieldUpload(
|
||||
String ref, String refTableNmae, FormData entity) async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae";
|
||||
final response = await _helper.getPostApiResponse(apiUrl, entity);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Upload File: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> fileupload_field2Upload(
|
||||
String ref, String refTableNmae, FormData entity) async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae";
|
||||
final response = await _helper.getPostApiResponse(apiUrl, entity);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Upload File: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> imageupload_fieldUpload(
|
||||
String ref, String refTableNmae, FormData entity) async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae";
|
||||
final response = await _helper.getPostApiResponse(apiUrl, entity);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Upload Imageupload Field: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> imageupload_field2Upload(
|
||||
String ref, String refTableNmae, FormData entity) async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae";
|
||||
final response = await _helper.getPostApiResponse(apiUrl, entity);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Upload Imageupload Field2: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> audio_fieldUpload(
|
||||
String ref, String refTableNmae, FormData entity) async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae";
|
||||
final response = await _helper.getPostApiResponse(apiUrl, entity);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Upload File: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> audio_field2Upload(
|
||||
String ref, String refTableNmae, FormData entity) async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae";
|
||||
final response = await _helper.getPostApiResponse(apiUrl, entity);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Upload File: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> video_fieldUpload(
|
||||
String ref, String refTableNmae, FormData entity) async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae";
|
||||
final response = await _helper.getPostApiResponse(apiUrl, entity);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Upload File: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> video_field2Upload(
|
||||
String ref, String refTableNmae, FormData entity) async {
|
||||
try {
|
||||
String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae";
|
||||
final response = await _helper.getPostApiResponse(apiUrl, entity);
|
||||
return response;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to Upload File: $e');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,543 @@
|
||||
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 '../Adv1_Repo/Adv1_repo_screen.dart';
|
||||
|
||||
class Adv1ViewModelScreen extends ChangeNotifier{
|
||||
final Adv1RepoScreen repo = Adv1RepoScreen();
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Modify the uploadfileupload_fieldimage function
|
||||
Future<void> uploadfileupload_field(String ref, String refTableNmae,
|
||||
String selectedFilePath, Uint8List imageTimageBytes) async {
|
||||
try {
|
||||
|
||||
final Uint8List fileBytes = imageTimageBytes!;
|
||||
final mimeType = fileupload_fieldlookupMimeType(selectedFilePath);
|
||||
|
||||
FormData formData = FormData.fromMap({
|
||||
'file': MultipartFile.fromBytes(
|
||||
fileBytes,
|
||||
filename: selectedFilePath
|
||||
.split('/')
|
||||
.last, // Get the file name from the path
|
||||
contentType: MediaType.parse(mimeType!),
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
await repo.fileupload_fieldUpload(ref, refTableNmae, formData).then((value) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: "File uploaded successfully",
|
||||
toastType: ToastType.success);
|
||||
}).onError(
|
||||
(error, stackTrace) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Failed to upload file", toastType: ToastType.error);
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
print('Error occurred during form submission: $error');
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the lookupMimeType function if needed
|
||||
String fileupload_fieldlookupMimeType(String filePath) {
|
||||
final ext = filePath.split('.').last;
|
||||
switch (ext) {
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
return 'image/jpeg';
|
||||
case 'png':
|
||||
return 'image/png';
|
||||
case 'pdf':
|
||||
return 'application/pdf';
|
||||
// Add more cases for other file types as needed
|
||||
default:
|
||||
return 'application/octet-stream'; // Default MIME type
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Modify the uploadfileupload_field2image function
|
||||
Future<void> uploadfileupload_field2(String ref, String refTableNmae,
|
||||
String selectedFilePath, Uint8List imageTimageBytes) async {
|
||||
try {
|
||||
|
||||
final Uint8List fileBytes = imageTimageBytes!;
|
||||
final mimeType = fileupload_field2lookupMimeType(selectedFilePath);
|
||||
|
||||
FormData formData = FormData.fromMap({
|
||||
'file': MultipartFile.fromBytes(
|
||||
fileBytes,
|
||||
filename: selectedFilePath
|
||||
.split('/')
|
||||
.last, // Get the file name from the path
|
||||
contentType: MediaType.parse(mimeType!),
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
await repo.fileupload_field2Upload(ref, refTableNmae, formData).then((value) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: "File uploaded successfully",
|
||||
toastType: ToastType.success);
|
||||
}).onError(
|
||||
(error, stackTrace) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Failed to upload file", toastType: ToastType.error);
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
print('Error occurred during form submission: $error');
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the lookupMimeType function if needed
|
||||
String fileupload_field2lookupMimeType(String filePath) {
|
||||
final ext = filePath.split('.').last;
|
||||
switch (ext) {
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
return 'image/jpeg';
|
||||
case 'png':
|
||||
return 'image/png';
|
||||
case 'pdf':
|
||||
return 'application/pdf';
|
||||
// Add more cases for other file types as needed
|
||||
default:
|
||||
return 'application/octet-stream'; // Default MIME type
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Modify the uploadimageupload_fieldimage function
|
||||
Future<void> uploadimageupload_field(String ref, String refTableNmae,
|
||||
String selectedFilePath, Uint8List image_timageBytes) async {
|
||||
try {
|
||||
|
||||
final Uint8List fileBytes = image_timageBytes!;
|
||||
final mimeType = imageupload_fieldlookupMimeType(selectedFilePath);
|
||||
|
||||
FormData formData = FormData.fromMap({
|
||||
'file': MultipartFile.fromBytes(
|
||||
fileBytes,
|
||||
filename: selectedFilePath
|
||||
.split('/')
|
||||
.last, // Get the file name from the path
|
||||
contentType: MediaType.parse(mimeType!),
|
||||
),
|
||||
});
|
||||
await repo.imageupload_fieldUpload(ref, refTableNmae, formData).then((value) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: "File uploaded successfully",
|
||||
toastType: ToastType.success);
|
||||
}).onError(
|
||||
(error, stackTrace) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Failed to upload file", toastType: ToastType.error);
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
print('Error occurred during form submission: $error');
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the lookupMimeType function if needed
|
||||
String imageupload_fieldlookupMimeType(String filePath) {
|
||||
final ext = filePath.split('.').last;
|
||||
switch (ext) {
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
return 'image/jpeg';
|
||||
case 'png':
|
||||
return 'image/png';
|
||||
case 'pdf':
|
||||
return 'application/pdf';
|
||||
// Add more cases for other file types as needed
|
||||
default:
|
||||
return 'application/octet-stream'; // Default MIME type
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Modify the uploadimageupload_field2image function
|
||||
Future<void> uploadimageupload_field2(String ref, String refTableNmae,
|
||||
String selectedFilePath, Uint8List image_timageBytes) async {
|
||||
try {
|
||||
|
||||
final Uint8List fileBytes = image_timageBytes!;
|
||||
final mimeType = imageupload_field2lookupMimeType(selectedFilePath);
|
||||
|
||||
FormData formData = FormData.fromMap({
|
||||
'file': MultipartFile.fromBytes(
|
||||
fileBytes,
|
||||
filename: selectedFilePath
|
||||
.split('/')
|
||||
.last, // Get the file name from the path
|
||||
contentType: MediaType.parse(mimeType!),
|
||||
),
|
||||
});
|
||||
await repo.imageupload_field2Upload(ref, refTableNmae, formData).then((value) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: "File uploaded successfully",
|
||||
toastType: ToastType.success);
|
||||
}).onError(
|
||||
(error, stackTrace) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Failed to upload file", toastType: ToastType.error);
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
print('Error occurred during form submission: $error');
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the lookupMimeType function if needed
|
||||
String imageupload_field2lookupMimeType(String filePath) {
|
||||
final ext = filePath.split('.').last;
|
||||
switch (ext) {
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
return 'image/jpeg';
|
||||
case 'png':
|
||||
return 'image/png';
|
||||
case 'pdf':
|
||||
return 'application/pdf';
|
||||
// Add more cases for other file types as needed
|
||||
default:
|
||||
return 'application/octet-stream'; // Default MIME type
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Modify the uploadaudio_fieldimage function
|
||||
Future<void> uploadaudio_field(String ref, String refTableNmae,
|
||||
String selectedFilePath, Uint8List image_timageBytes) async {
|
||||
try {
|
||||
|
||||
final Uint8List fileBytes = image_timageBytes!;
|
||||
final mimeType = audio_fieldlookupMimeType(selectedFilePath);
|
||||
|
||||
FormData formData = FormData.fromMap({
|
||||
'file': MultipartFile.fromBytes(
|
||||
fileBytes,
|
||||
filename: selectedFilePath
|
||||
.split('/')
|
||||
.last, // Get the file name from the path
|
||||
contentType: MediaType.parse(mimeType!),
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
await repo.audio_fieldUpload(ref, refTableNmae, formData).then((value) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: "File uploaded successfully",
|
||||
toastType: ToastType.success);
|
||||
}).onError(
|
||||
(error, stackTrace) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Failed to upload file", toastType: ToastType.error);
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
print('Error occurred during form submission: $error');
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the lookupMimeType function if needed
|
||||
String audio_fieldlookupMimeType(String filePath) {
|
||||
final ext = filePath.split('.').last.toLowerCase();
|
||||
switch (ext) {
|
||||
case 'mp3':
|
||||
return 'audio/mpeg';
|
||||
case 'wav':
|
||||
return 'audio/wav';
|
||||
case 'm4a':
|
||||
return 'audio/mp4';
|
||||
case 'flac':
|
||||
return 'audio/flac';
|
||||
// Add more cases for other audio formats as needed
|
||||
default:
|
||||
return 'application/octet-stream'; // Default MIME type
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Modify the uploadaudio_field2image function
|
||||
Future<void> uploadaudio_field2(String ref, String refTableNmae,
|
||||
String selectedFilePath, Uint8List image_timageBytes) async {
|
||||
try {
|
||||
|
||||
final Uint8List fileBytes = image_timageBytes!;
|
||||
final mimeType = audio_field2lookupMimeType(selectedFilePath);
|
||||
|
||||
FormData formData = FormData.fromMap({
|
||||
'file': MultipartFile.fromBytes(
|
||||
fileBytes,
|
||||
filename: selectedFilePath
|
||||
.split('/')
|
||||
.last, // Get the file name from the path
|
||||
contentType: MediaType.parse(mimeType!),
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
await repo.audio_field2Upload(ref, refTableNmae, formData).then((value) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: "File uploaded successfully",
|
||||
toastType: ToastType.success);
|
||||
}).onError(
|
||||
(error, stackTrace) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Failed to upload file", toastType: ToastType.error);
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
print('Error occurred during form submission: $error');
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the lookupMimeType function if needed
|
||||
String audio_field2lookupMimeType(String filePath) {
|
||||
final ext = filePath.split('.').last.toLowerCase();
|
||||
switch (ext) {
|
||||
case 'mp3':
|
||||
return 'audio/mpeg';
|
||||
case 'wav':
|
||||
return 'audio/wav';
|
||||
case 'm4a':
|
||||
return 'audio/mp4';
|
||||
case 'flac':
|
||||
return 'audio/flac';
|
||||
// Add more cases for other audio formats as needed
|
||||
default:
|
||||
return 'application/octet-stream'; // Default MIME type
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Modify the uploadvideo_fieldimage function
|
||||
Future<void> uploadvideo_field(String ref, String refTableNmae,
|
||||
String selectedFilePath, Uint8List image_timageBytes) async {
|
||||
try {
|
||||
|
||||
final Uint8List fileBytes = image_timageBytes!;
|
||||
final mimeType = video_fieldlookupMimeType(selectedFilePath);
|
||||
|
||||
FormData formData = FormData.fromMap({
|
||||
'file': MultipartFile.fromBytes(
|
||||
fileBytes,
|
||||
filename: selectedFilePath
|
||||
.split('/')
|
||||
.last, // Get the file name from the path
|
||||
contentType: MediaType.parse(mimeType!),
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
|
||||
await repo.video_fieldUpload(ref, refTableNmae, formData).then((value) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: "File uploaded successfully",
|
||||
toastType: ToastType.success);
|
||||
}).onError(
|
||||
(error, stackTrace) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Failed to upload file", toastType: ToastType.error);
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
print('Error occurred during form submission: $error');
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the lookupMimeType function if needed
|
||||
String video_fieldlookupMimeType(String filePath) {
|
||||
final ext = filePath.split('.').last.toLowerCase();
|
||||
switch (ext) {
|
||||
case 'mp4':
|
||||
return 'video/mp4';
|
||||
case 'mov':
|
||||
return 'video/quicktime';
|
||||
case 'avi':
|
||||
return 'video/x-msvideo';
|
||||
case 'wmv':
|
||||
return 'video/x-ms-wmv';
|
||||
case 'flv':
|
||||
return 'video/x-flv';
|
||||
case 'mkv':
|
||||
return 'video/x-matroska';
|
||||
// Add more cases for other file types as needed
|
||||
default:
|
||||
return 'application/octet-stream'; // Default MIME type
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Modify the uploadvideo_field2image function
|
||||
Future<void> uploadvideo_field2(String ref, String refTableNmae,
|
||||
String selectedFilePath, Uint8List image_timageBytes) async {
|
||||
try {
|
||||
|
||||
final Uint8List fileBytes = image_timageBytes!;
|
||||
final mimeType = video_field2lookupMimeType(selectedFilePath);
|
||||
|
||||
FormData formData = FormData.fromMap({
|
||||
'file': MultipartFile.fromBytes(
|
||||
fileBytes,
|
||||
filename: selectedFilePath
|
||||
.split('/')
|
||||
.last, // Get the file name from the path
|
||||
contentType: MediaType.parse(mimeType!),
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
|
||||
await repo.video_field2Upload(ref, refTableNmae, formData).then((value) {
|
||||
ToastMessageUtil.showToast(
|
||||
message: "File uploaded successfully",
|
||||
toastType: ToastType.success);
|
||||
}).onError(
|
||||
(error, stackTrace) {
|
||||
print("error--$error");
|
||||
ToastMessageUtil.showToast(
|
||||
message: "Failed to upload file", toastType: ToastType.error);
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
print('Error occurred during form submission: $error');
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the lookupMimeType function if needed
|
||||
String video_field2lookupMimeType(String filePath) {
|
||||
final ext = filePath.split('.').last.toLowerCase();
|
||||
switch (ext) {
|
||||
case 'mp4':
|
||||
return 'video/mp4';
|
||||
case 'mov':
|
||||
return 'video/quicktime';
|
||||
case 'avi':
|
||||
return 'video/x-msvideo';
|
||||
case 'wmv':
|
||||
return 'video/x-ms-wmv';
|
||||
case 'flv':
|
||||
return 'video/x-flv';
|
||||
case 'mkv':
|
||||
return 'video/x-matroska';
|
||||
// Add more cases for other file types as needed
|
||||
default:
|
||||
return 'application/octet-stream'; // Default MIME type
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -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 dv2ApiService {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>> getEntities() async {
|
||||
|
||||
try {
|
||||
final response = await _helper.getGetApiResponse('$baseUrl/Dv2/Dv2');
|
||||
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/Dv2/Dv2/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/Dv2/Dv2', 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/Dv2/Dv2/$entityId',
|
||||
entity); print(entity);
|
||||
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity( int entityId) async {
|
||||
try {
|
||||
await _helper.getDeleteApiResponse('$baseUrl/Dv2/Dv2/$entityId');
|
||||
} catch (e) {
|
||||
throw Exception('Failed to delete entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,566 @@
|
||||
// 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 '../Dv2_viewModel/Dv2_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 dv2CreateEntityScreen extends StatefulWidget {
|
||||
const dv2CreateEntityScreen({super.key});
|
||||
|
||||
@override
|
||||
_dv2CreateEntityScreenState createState() => _dv2CreateEntityScreenState();
|
||||
}
|
||||
|
||||
class _dv2CreateEntityScreenState extends State<dv2CreateEntityScreen> {
|
||||
|
||||
final Map<String, dynamic> formData = {};
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final TextEditingController addressController = TextEditingController();
|
||||
|
||||
|
||||
final TextEditingController per_addressController = TextEditingController();
|
||||
|
||||
|
||||
String inputValuecurrency = '';
|
||||
String outputValuecurrency = '';
|
||||
|
||||
void _convertCurrency_currency() {
|
||||
String inputText = inputValuecurrency.replaceAll(',', ''); // Remove commas
|
||||
try {
|
||||
double parsedValue = double.parse(inputText); // Parse the value
|
||||
String formattedValue =
|
||||
parsedValue.toStringAsFixed(2); // Format to 2 decimal places
|
||||
setState(() {
|
||||
outputValuecurrency = formattedValue;
|
||||
});
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
outputValuecurrency = "Invalid input";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String inputValuecurrency2 = '';
|
||||
String outputValuecurrency2 = '';
|
||||
|
||||
void _convertCurrency_currency2() {
|
||||
String inputText = inputValuecurrency2.replaceAll(',', ''); // Remove commas
|
||||
try {
|
||||
double parsedValue = double.parse(inputText); // Parse the value
|
||||
String formattedValue =
|
||||
parsedValue.toStringAsFixed(2); // Format to 2 decimal places
|
||||
setState(() {
|
||||
outputValuecurrency2 = formattedValue;
|
||||
});
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
outputValuecurrency2 = "Invalid input";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String inputDataqrcode_field = 'Hello QR!'; // Default data for QR code generation
|
||||
TextEditingController controllerInputqrcode_field = TextEditingController();
|
||||
|
||||
String inputDataqrcode_field2 = 'Hello QR!'; // Default data for QR code generation
|
||||
TextEditingController controllerInputqrcode_field2 = TextEditingController();
|
||||
|
||||
String inputDatabarcode_field = 'Hello BarCode'; // By default barcode
|
||||
TextEditingController controllerInputbarcode_field = TextEditingController();
|
||||
|
||||
String inputDatabarcode_field2 = 'Hello BarCode'; // By default barcode
|
||||
TextEditingController controllerInputbarcode_field2 = TextEditingController();
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final provider = Provider.of<Dv2ViewModelScreen>(context, listen: false);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
controllerInputqrcode_field.text = inputDataqrcode_field;
|
||||
|
||||
controllerInputqrcode_field2.text = inputDataqrcode_field2;
|
||||
|
||||
controllerInputbarcode_field.text = inputDatabarcode_field;
|
||||
|
||||
controllerInputbarcode_field2.text = inputDatabarcode_field2;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = Provider.of<Dv2ViewModelScreen>(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 Dv2"),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[200],
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 4,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Address",
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
onSaved:(value) => formData['name'] = value ,
|
||||
label:"Enter Name",
|
||||
// ValidationProperties
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
onSaved:(value) => formData['last_name'] = value ,
|
||||
label:"Enter Last_name",
|
||||
// ValidationProperties
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
|
||||
Container(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[200],
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 4,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"per address",
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
ReusableTextField(
|
||||
onSaved:(value) => formData['test'] = value ,
|
||||
label:"Enter Test",
|
||||
// ValidationProperties
|
||||
),
|
||||
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
|
||||
TextFormField(
|
||||
keyboardType: TextInputType.number,
|
||||
onChanged: (text) {
|
||||
setState(() {
|
||||
inputValuecurrency = text;
|
||||
});
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
labelText:
|
||||
'Enter Currency Value (with or without commas)',
|
||||
prefixIcon: Icon(Icons.currency_rupee),
|
||||
border: OutlineInputBorder(),
|
||||
|
||||
),
|
||||
onSaved: (value) {
|
||||
_convertCurrency_currency();
|
||||
formData['currency'] = outputValuecurrency;
|
||||
}),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
TextFormField(
|
||||
keyboardType: TextInputType.number,
|
||||
onChanged: (text) {
|
||||
setState(() {
|
||||
inputValuecurrency2 = text;
|
||||
});
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
labelText:
|
||||
'Enter Currency Value (with or without commas)',
|
||||
prefixIcon: Icon(Icons.currency_rupee),
|
||||
border: OutlineInputBorder(),
|
||||
|
||||
),
|
||||
onSaved: (value) {
|
||||
_convertCurrency_currency2();
|
||||
formData['currency2'] = outputValuecurrency2;
|
||||
}),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Generate QR Code',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
QrImageView(
|
||||
data: inputDataqrcode_field,
|
||||
version: QrVersions.auto,
|
||||
size: 200.0,
|
||||
gapless: false,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: controllerInputqrcode_field,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Enter data for QR code',
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
inputDataqrcode_field = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Generate QR Code',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
QrImageView(
|
||||
data: inputDataqrcode_field2,
|
||||
version: QrVersions.auto,
|
||||
size: 200.0,
|
||||
gapless: false,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: controllerInputqrcode_field2,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Enter data for QR code',
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
inputDataqrcode_field2 = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'Generate Barcode',
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (inputDatabarcode_field.isNotEmpty)
|
||||
BarcodeWidget(
|
||||
barcode: Barcode.code128(), // Choose the type of barcode
|
||||
data: inputDatabarcode_field,
|
||||
width: 200,
|
||||
height: 80,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: controllerInputbarcode_field,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Enter data for barcode',
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
inputDatabarcode_field = value;
|
||||
formData['barcode_field'] = inputDatabarcode_field;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
],
|
||||
),
|
||||
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'Generate Barcode',
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (inputDatabarcode_field2.isNotEmpty)
|
||||
BarcodeWidget(
|
||||
barcode: Barcode.code128(), // Choose the type of barcode
|
||||
data: inputDatabarcode_field2,
|
||||
width: 200,
|
||||
height: 80,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: controllerInputbarcode_field2,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Enter data for barcode',
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
inputDatabarcode_field2 = value;
|
||||
formData['barcode_field2'] = inputDatabarcode_field2;
|
||||
});
|
||||
},
|
||||
),
|
||||
const 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 Dv2: $e'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,873 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'Dv2_create_entity_screen.dart';
|
||||
import 'Dv2_update_entity_screen.dart';
|
||||
import '../Dv2_viewModel/Dv2_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 dv2_entity_list_screen extends StatefulWidget {
|
||||
static const String routeName = '/entity-list';
|
||||
|
||||
@override
|
||||
_dv2_entity_list_screenState createState() => _dv2_entity_list_screenState();
|
||||
}
|
||||
|
||||
class _dv2_entity_list_screenState extends State<dv2_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<Dv2ViewModelScreen>(context, listen: false);
|
||||
final fetchedEntities = await provider.getEntities();
|
||||
print('withoutpaging data is $fetchedEntities');
|
||||
setState(() {
|
||||
serachEntities = fetchedEntities; // Update only filteredEntities
|
||||
});
|
||||
print('Dv2 entity is .. $serachEntities');
|
||||
} catch (e) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Error'),
|
||||
content: Text('Failed to fetch Dv2: $e'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Future<void> fetchEntities() async {
|
||||
try {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
|
||||
|
||||
|
||||
final provider =
|
||||
Provider.of<Dv2ViewModelScreen>(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 Dv2 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<Dv2ViewModelScreen>(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['last_name'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['test'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['currency'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['currency2'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['qrcode_field'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['qrcode_field2'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['barcode_field'].toString().toLowerCase().contains(keyword.toLowerCase()) ||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity['barcode_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: " Dv2"),
|
||||
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) => Dv2ViewModelScreen(),
|
||||
child: dv2CreateEntityScreen(),
|
||||
),
|
||||
),
|
||||
).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) => Dv2ViewModelScreen(),
|
||||
child: dv2UpdateEntityScreen(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(
|
||||
"Last_name : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['last_name'].toString() ?? 'No Last_name Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Test : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['test'].toString() ?? 'No Test Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Currency : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['currency'].toString() ?? 'No Currency Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Currency2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['currency2'].toString() ?? 'No Currency2 Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"QRCode Field : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['qrcode_field'].toString() ?? 'No QRCode Field Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"QRCode Field2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['qrcode_field2'].toString() ?? 'No QRCode Field2 Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"BarCode Field : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['barcode_field'].toString() ?? 'No BarCode Field Available',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16Bluegray900,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Padding(
|
||||
padding: getPadding(
|
||||
top: 10,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"BarCode Field2 : ",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.left,
|
||||
style: AppStyle.txtGilroyMedium16,
|
||||
),
|
||||
Text(
|
||||
entity['barcode_field2'].toString() ?? 'No BarCode 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,592 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:convert';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../Dv2_viewModel/Dv2_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 dv2UpdateEntityScreen extends StatefulWidget {
|
||||
final Map<String, dynamic> entity;
|
||||
|
||||
|
||||
dv2UpdateEntityScreen({required this.entity});
|
||||
|
||||
@override
|
||||
_dv2UpdateEntityScreenState createState() => _dv2UpdateEntityScreenState();
|
||||
}
|
||||
|
||||
class _dv2UpdateEntityScreenState extends State<dv2UpdateEntityScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
final TextEditingController _inputcurrencyController = TextEditingController();
|
||||
double editedcurrencyValue = 0.0;
|
||||
|
||||
final TextEditingController _inputcurrency2Controller = TextEditingController();
|
||||
double editedcurrency2Value = 0.0;
|
||||
|
||||
late String inputDataqrcode_field;
|
||||
late TextEditingController controllerInputqrcode_field;
|
||||
|
||||
|
||||
late String inputDataqrcode_field2;
|
||||
late TextEditingController controllerInputqrcode_field2;
|
||||
|
||||
|
||||
late String inputDatabarcode_field; // By default barcode
|
||||
TextEditingController controllerInputbarcode_field = TextEditingController();
|
||||
|
||||
|
||||
late String inputDatabarcode_field2; // By default barcode
|
||||
TextEditingController controllerInputbarcode_field2 = TextEditingController();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final provider = Provider.of<Dv2ViewModelScreen>(context, listen: false);
|
||||
|
||||
|
||||
|
||||
|
||||
// Convert the currency value to double if it's not already
|
||||
if (widget.entity['currency'] is String) {
|
||||
widget.entity['currency'] =
|
||||
double.tryParse(widget.entity['currency']) ?? 0.0;
|
||||
}
|
||||
|
||||
// Initially set the controller text without formatting
|
||||
_inputcurrencyController.text = widget.entity['currency'].toString();
|
||||
editedcurrencyValue = widget.entity['currency'];
|
||||
|
||||
// Convert the currency value to double if it's not already
|
||||
if (widget.entity['currency'] is String) {
|
||||
widget.entity['currency'] =
|
||||
double.tryParse(widget.entity['currency']) ?? 0.0;
|
||||
}
|
||||
|
||||
// Initially set the controller text without formatting
|
||||
_inputcurrency2Controller.text = widget.entity['currency'].toString();
|
||||
editedcurrency2Value = widget.entity['currency'];
|
||||
|
||||
inputDataqrcode_field = widget.entity['qrcode_field'] ?? "Hello";
|
||||
controllerInputqrcode_field = TextEditingController(text: inputDataqrcode_field);
|
||||
|
||||
inputDataqrcode_field2 = widget.entity['qrcode_field2'] ?? "Hello";
|
||||
controllerInputqrcode_field2 = TextEditingController(text: inputDataqrcode_field2);
|
||||
|
||||
inputDatabarcode_field = widget.entity['barcode_field'] ?? "Hello";
|
||||
controllerInputbarcode_field.text = inputDatabarcode_field;
|
||||
|
||||
|
||||
inputDatabarcode_field2 = widget.entity['barcode_field2'] ?? "Hello";
|
||||
controllerInputbarcode_field2.text = inputDatabarcode_field2;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = Provider.of<Dv2ViewModelScreen>(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 Dv2"), actions: [
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[200],
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 4,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Address",
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
|
||||
SizedBox(height: 16),
|
||||
TextFormField(
|
||||
initialValue: widget.entity['name'],
|
||||
decoration: InputDecoration(
|
||||
labelText: 'address name',
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
widget.entity['name'] = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
|
||||
SizedBox(height: 16),
|
||||
TextFormField(
|
||||
initialValue: widget.entity['last_name'],
|
||||
decoration: InputDecoration(
|
||||
labelText: 'address last_name',
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
widget.entity['last_name'] = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
|
||||
|
||||
Container(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[200],
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 4,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"per address",
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
|
||||
|
||||
|
||||
SizedBox(height: 16),
|
||||
TextFormField(
|
||||
initialValue: widget.entity['test'],
|
||||
decoration: InputDecoration(
|
||||
labelText: 'per_address test',
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
widget.entity['test'] = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
|
||||
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextFormField(
|
||||
controller: _inputcurrencyController,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Edit Currency Value',
|
||||
prefixIcon: Icon(Icons.money),
|
||||
border: OutlineInputBorder(),
|
||||
|
||||
),
|
||||
onChanged: (text) {
|
||||
setState(() {
|
||||
try {
|
||||
String currencyString = text;
|
||||
currencyString = currencyString.replaceAll(',', ''); // Remove commas
|
||||
currencyString = currencyString.replaceAll('₹', ''); // Remove currency symbol
|
||||
editedcurrencyValue = double.parse(currencyString);
|
||||
print("Parsed double value: $editedcurrencyValue");
|
||||
} catch (e) {
|
||||
print("Invalid input: $text");
|
||||
editedcurrencyValue = 0.0; // Set to a default value or handle the error accordingly
|
||||
}
|
||||
});
|
||||
},
|
||||
onSaved: (value) {
|
||||
widget.entity['currency'] = editedcurrencyValue;
|
||||
},
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'Edited Currency Value: ${editedcurrencyValue.toStringAsFixed(2)}', // Display formatted currency value
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
// Add other form fields here
|
||||
],
|
||||
),
|
||||
|
||||
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextFormField(
|
||||
controller: _inputcurrency2Controller,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Edit Currency Value',
|
||||
prefixIcon: Icon(Icons.money),
|
||||
border: OutlineInputBorder(),
|
||||
|
||||
),
|
||||
onChanged: (text) {
|
||||
setState(() {
|
||||
try {
|
||||
String currencyString = text;
|
||||
currencyString = currencyString.replaceAll(',', ''); // Remove commas
|
||||
currencyString = currencyString.replaceAll('₹', ''); // Remove currency symbol
|
||||
editedcurrency2Value = double.parse(currencyString);
|
||||
print("Parsed double value: $editedcurrency2Value");
|
||||
} catch (e) {
|
||||
print("Invalid input: $text");
|
||||
editedcurrency2Value = 0.0; // Set to a default value or handle the error accordingly
|
||||
}
|
||||
});
|
||||
},
|
||||
onSaved: (value) {
|
||||
widget.entity['currency2'] = editedcurrency2Value;
|
||||
},
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'Edited Currency Value: ${editedcurrency2Value.toStringAsFixed(2)}', // Display formatted currency value
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
// Add other form fields here
|
||||
],
|
||||
),
|
||||
|
||||
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Generate QR Code',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
QrImageView(
|
||||
data: inputDataqrcode_field,
|
||||
version: QrVersions.auto,
|
||||
size: 200.0,
|
||||
gapless: false,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: controllerInputqrcode_field,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Enter data for QR code',
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
inputDataqrcode_field = value;
|
||||
widget.entity['qrcode_field'] = inputDataqrcode_field;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Generate QR Code',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
QrImageView(
|
||||
data: inputDataqrcode_field2,
|
||||
version: QrVersions.auto,
|
||||
size: 200.0,
|
||||
gapless: false,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: controllerInputqrcode_field2,
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Enter data for QR code',
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
inputDataqrcode_field2 = value;
|
||||
widget.entity['qrcode_field2'] = inputDataqrcode_field2;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'Generate Barcode',
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (inputDatabarcode_field.isNotEmpty)
|
||||
BarcodeWidget(
|
||||
barcode: Barcode.code128(), // Choose the type of barcode
|
||||
data: inputDatabarcode_field,
|
||||
width: 200,
|
||||
height: 80,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: controllerInputbarcode_field,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Enter data for barcode',
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
inputDatabarcode_field = value;
|
||||
widget.entity['barcode_field'] = inputDatabarcode_field;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// ElevatedButton(
|
||||
// onPressed: () {
|
||||
// setState(() {
|
||||
// inputData = controllerInput.text;
|
||||
// });
|
||||
// },
|
||||
// child: const Text('Generate Barcode'),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'Generate Barcode',
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (inputDatabarcode_field2.isNotEmpty)
|
||||
BarcodeWidget(
|
||||
barcode: Barcode.code128(), // Choose the type of barcode
|
||||
data: inputDatabarcode_field2,
|
||||
width: 200,
|
||||
height: 80,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: controllerInputbarcode_field2,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Enter data for barcode',
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
inputDatabarcode_field2 = value;
|
||||
widget.entity['barcode_field2'] = inputDatabarcode_field2;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// ElevatedButton(
|
||||
// onPressed: () {
|
||||
// setState(() {
|
||||
// inputData = controllerInput.text;
|
||||
// });
|
||||
// },
|
||||
// child: const Text('Generate Barcode'),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
const 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 Dv2: $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 Dv2RepoScreen {
|
||||
final String baseUrl = ApiConstants.baseUrl;
|
||||
final BaseNetworkService _helper = NetworkApiService();
|
||||
|
||||
Future<dynamic> getEntities() async {
|
||||
try {
|
||||
final response =
|
||||
await _helper.getGetApiResponse('$baseUrl/Dv2/Dv2');
|
||||
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/Dv2/Dv2/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/Dv2/Dv2', 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/Dv2/Dv2/$entityId', entity);
|
||||
print(entity);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to update entity: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteEntity(int entityId) async {
|
||||
try {
|
||||
await _helper
|
||||
.getDeleteApiResponse('$baseUrl/Dv2/Dv2/$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 '../Dv2_Repo/Dv2_repo_screen.dart';
|
||||
|
||||
class Dv2ViewModelScreen extends ChangeNotifier{
|
||||
final Dv2RepoScreen repo = Dv2RepoScreen();
|
||||
|
||||
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,9 @@
|
||||
import '../../Entity/angulardatatype/Dv2/Dv2View/Dv2_entity_list_screen.dart';
|
||||
import '../../Entity/angulardatatype/Dv2/Dv2_viewModel/Dv2_view_model_screen.dart';
|
||||
|
||||
import '../../Entity/angulardatatype/Adv1/Adv1View/Adv1_entity_list_screen.dart';
|
||||
import '../../Entity/angulardatatype/Adv1/Adv1_viewModel/Adv1_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';
|
||||
@ -70,6 +76,40 @@ class MyCustomDrawer extends StatelessWidget {
|
||||
),
|
||||
|
||||
// NEW MENU
|
||||
DrawerItem(
|
||||
color: AppColors.primary,
|
||||
icon: Icons.chat_bubble,
|
||||
title: 'Dv2',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Dv2ViewModelScreen(),
|
||||
child: dv2_entity_list_screen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
DrawerItem(
|
||||
color: AppColors.primary,
|
||||
icon: Icons.chat_bubble,
|
||||
title: 'Adv1',
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider(
|
||||
create: (context) => Adv1ViewModelScreen(),
|
||||
child: adv1_entity_list_screen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
|
||||
DrawerItem(
|
||||
icon: Icons.logout,
|
||||
|
||||
@ -69,6 +69,12 @@ public class BuilderService {
|
||||
executeDump(true);
|
||||
|
||||
// ADD OTHER SERVICE
|
||||
addCustomMenu( "Dv2", "Transcations");
|
||||
|
||||
|
||||
addCustomMenu( "Adv1", "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.Adv1;
|
||||
import com.realnet.angulardatatype.Services.Adv1Service ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/Adv1")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class Adv1Controller {
|
||||
@Autowired
|
||||
private Adv1Service Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Adv1")
|
||||
public Adv1 Savedata(@RequestBody Adv1 data) {
|
||||
Adv1 save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Adv1/{id}")
|
||||
public Adv1 update(@RequestBody Adv1 data,@PathVariable Integer id ) {
|
||||
Adv1 update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Adv1/getall/page")
|
||||
public Page<Adv1> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Adv1> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Adv1")
|
||||
public List<Adv1> getdetails() {
|
||||
List<Adv1> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Adv1")
|
||||
public List<Adv1> getallwioutsec() {
|
||||
List<Adv1> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Adv1/{id}")
|
||||
public Adv1 getdetailsbyId(@PathVariable Integer id ) {
|
||||
Adv1 get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Adv1/{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.Dv2;
|
||||
import com.realnet.angulardatatype.Services.Dv2Service ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/Dv2")
|
||||
@CrossOrigin("*")
|
||||
@RestController
|
||||
public class Dv2Controller {
|
||||
@Autowired
|
||||
private Dv2Service Service;
|
||||
|
||||
@Value("${projectPath}")
|
||||
private String projectPath;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/Dv2")
|
||||
public Dv2 Savedata(@RequestBody Dv2 data) {
|
||||
Dv2 save = Service.Savedata(data) ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("data saved..." + save);
|
||||
|
||||
return save;
|
||||
}
|
||||
@PutMapping("/Dv2/{id}")
|
||||
public Dv2 update(@RequestBody Dv2 data,@PathVariable Integer id ) {
|
||||
Dv2 update = Service.update(data,id);
|
||||
System.out.println("data update..." + update);
|
||||
return update;
|
||||
}
|
||||
// get all with pagination
|
||||
@GetMapping("/Dv2/getall/page")
|
||||
public Page<Dv2> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size) {
|
||||
Pageable paging = PageRequest.of(page, size);
|
||||
Page<Dv2> get = Service.getAllWithPagination(paging);
|
||||
|
||||
return get;
|
||||
|
||||
}
|
||||
@GetMapping("/Dv2")
|
||||
public List<Dv2> getdetails() {
|
||||
List<Dv2> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
// get all without authentication
|
||||
|
||||
@GetMapping("/token/Dv2")
|
||||
public List<Dv2> getallwioutsec() {
|
||||
List<Dv2> get = Service.getdetails();
|
||||
return get;
|
||||
}
|
||||
@GetMapping("/Dv2/{id}")
|
||||
public Dv2 getdetailsbyId(@PathVariable Integer id ) {
|
||||
Dv2 get = Service.getdetailsbyId(id);
|
||||
return get;
|
||||
}
|
||||
@DeleteMapping("/Dv2/{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,86 @@
|
||||
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 Adv1 extends Extension {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
private String ismale;
|
||||
|
||||
private String idfemale;
|
||||
|
||||
|
||||
|
||||
|
||||
private boolean test1;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private boolean t1;
|
||||
|
||||
|
||||
|
||||
private String fileupload_fieldname;
|
||||
private String fileupload_fieldpath ;
|
||||
|
||||
private String fileupload_field2name;
|
||||
private String fileupload_field2path ;
|
||||
|
||||
private String imageupload_fieldname;
|
||||
private String imageupload_fieldpath ;
|
||||
|
||||
private String imageupload_field2name;
|
||||
private String imageupload_field2path ;
|
||||
|
||||
private String audio_fieldname;
|
||||
private String audio_fieldpath ;
|
||||
|
||||
private String audio_field2name;
|
||||
private String audio_field2path ;
|
||||
|
||||
private String video_fieldname;
|
||||
private String video_fieldpath ;
|
||||
|
||||
private String video_field2name;
|
||||
private String video_field2path ;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
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 Dv2 extends Extension {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
|
||||
|
||||
private String last_name;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private String test;
|
||||
|
||||
|
||||
|
||||
private String currency;
|
||||
|
||||
private String currency2;
|
||||
|
||||
private String qrcode_field;
|
||||
|
||||
private String qrcode_field2;
|
||||
|
||||
private String barcode_field;
|
||||
|
||||
private String barcode_field2;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -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.Adv1;
|
||||
|
||||
@Repository
|
||||
public interface Adv1Repository extends JpaRepository<Adv1, Integer> {
|
||||
|
||||
@Query(value = "select * from adv1 where created_by=?1", nativeQuery = true)
|
||||
List<Adv1> findAll(Long creayedBy);
|
||||
|
||||
@Query(value = "select * from adv1 where created_by=?1", nativeQuery = true)
|
||||
Page<Adv1> 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.Dv2;
|
||||
|
||||
@Repository
|
||||
public interface Dv2Repository extends JpaRepository<Dv2, Integer> {
|
||||
|
||||
@Query(value = "select * from dv2 where created_by=?1", nativeQuery = true)
|
||||
List<Dv2> findAll(Long creayedBy);
|
||||
|
||||
@Query(value = "select * from dv2 where created_by=?1", nativeQuery = true)
|
||||
Page<Dv2> findAll(Pageable page, Long creayedBy);
|
||||
}
|
||||
@ -0,0 +1,195 @@
|
||||
package com.realnet.angulardatatype.Services;
|
||||
import com.realnet.angulardatatype.Repository.Adv1Repository;
|
||||
import com.realnet.angulardatatype.Entity.Adv1
|
||||
;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 Adv1Service {
|
||||
@Autowired
|
||||
private Adv1Repository Repository;
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
@Autowired
|
||||
private RealmService realmService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Adv1 Savedata(Adv1 data) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
data.setCreatedBy(getUser().getUserId());
|
||||
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||
Adv1 save = Repository.save(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
// get all with pagination
|
||||
public Page<Adv1> getAllWithPagination(Pageable page) {
|
||||
return Repository.findAll(page, getUser().getUserId());
|
||||
}
|
||||
public List<Adv1> getdetails() {
|
||||
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||
List<Adv1> all = Repository.findAll(getUser().getUserId());
|
||||
|
||||
return all ; }
|
||||
|
||||
|
||||
public Adv1 getdetailsbyId(Integer id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Integer id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Adv1 update(Adv1 data,Integer id) {
|
||||
Adv1 old = Repository.findById(id).get();
|
||||
old.setIsmale(data.getIsmale());
|
||||
|
||||
old.setIdfemale(data.getIdfemale());
|
||||
|
||||
|
||||
|
||||
old.setTest1(data.isTest1());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
old.setT1(data.isT1());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
final Adv1 test = Repository.save(old);
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
return test;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public AppUser getUser() {
|
||||
AppUser user = userService.getLoggedInUser();
|
||||
return user;
|
||||
|
||||
}}
|
||||
@ -0,0 +1,184 @@
|
||||
package com.realnet.angulardatatype.Services;
|
||||
import com.realnet.angulardatatype.Repository.Dv2Repository;
|
||||
import com.realnet.angulardatatype.Entity.Dv2
|
||||
;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 com.realnet.config.EmailService;
|
||||
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class Dv2Service {
|
||||
@Autowired
|
||||
private Dv2Repository Repository;
|
||||
@Autowired
|
||||
private AppUserServiceImpl userService;
|
||||
@Autowired
|
||||
private RealmService realmService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private EmailService emailServicestatic;
|
||||
|
||||
public Dv2 Savedata(Dv2 data) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
// emailServicestatic.sendEmail( getUser().getEmail(),"Dv2", "test");
|
||||
emailServicestatic.sendEmailViaSetu(getUser().getEmail(),"test","","ganesh");
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
System.out.println("Got error During Mail Send " + e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
data.setCreatedBy(getUser().getUserId());
|
||||
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||
Dv2 save = Repository.save(data);
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
// get all with pagination
|
||||
public Page<Dv2> getAllWithPagination(Pageable page) {
|
||||
return Repository.findAll(page, getUser().getUserId());
|
||||
}
|
||||
public List<Dv2> getdetails() {
|
||||
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||
List<Dv2> all = Repository.findAll(getUser().getUserId());
|
||||
|
||||
return all ; }
|
||||
|
||||
|
||||
public Dv2 getdetailsbyId(Integer id) {
|
||||
return Repository.findById(id).get();
|
||||
}
|
||||
|
||||
|
||||
public void delete_by_id(Integer id) {
|
||||
Repository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Dv2 update(Dv2 data,Integer id) {
|
||||
Dv2 old = Repository.findById(id).get();
|
||||
|
||||
|
||||
old.setName(data.getName());
|
||||
|
||||
|
||||
|
||||
old.setLast_name(data.getLast_name());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
old.setTest(data.getTest());
|
||||
|
||||
|
||||
|
||||
|
||||
old.setCurrency(data.getCurrency());
|
||||
|
||||
old.setCurrency2(data.getCurrency2());
|
||||
|
||||
old.setQrcode_field(data.getQrcode_field());
|
||||
|
||||
old.setQrcode_field2(data.getQrcode_field2());
|
||||
|
||||
old.setBarcode_field(data.getBarcode_field());
|
||||
|
||||
old.setBarcode_field2(data.getBarcode_field2());
|
||||
|
||||
|
||||
|
||||
final Dv2 test = Repository.save(old);
|
||||
data.setUpdatedBy(getUser().getUserId());
|
||||
return test;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public AppUser getUser() {
|
||||
AppUser user = userService.getLoggedInUser();
|
||||
return user;
|
||||
|
||||
}}
|
||||
4
test31march2-testdb-d/authsec_mysql/mysql/wf_table/wf_table.sql
Executable file
4
test31march2-testdb-d/authsec_mysql/mysql/wf_table/wf_table.sql
Executable file
@ -0,0 +1,4 @@
|
||||
CREATE TABLE testdb.Adv1(id BIGINT NOT NULL AUTO_INCREMENT, video_field2 VARCHAR(400), video_field VARCHAR(400), audio_field2 VARCHAR(400), ismale VARCHAR(400), fileupload_field2 VARCHAR(400), fileupload_field VARCHAR(400), imageupload_field VARCHAR(400), audio_field VARCHAR(400), idfemale VARCHAR(400), test1 bit(1), t1 bit(1), imageupload_field2 VARCHAR(400), PRIMARY KEY (id));
|
||||
|
||||
CREATE TABLE testdb.Dv2(id BIGINT NOT NULL AUTO_INCREMENT, qrcode_field2 VARCHAR(400), test VARCHAR(400), currency2 VARCHAR(400), currency VARCHAR(400), qrcode_field VARCHAR(400), name VARCHAR(400), last_name VARCHAR(400), barcode_field2 VARCHAR(400), static VARCHAR(400), barcode_field VARCHAR(400), PRIMARY KEY (id));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user