PaddingIssue

This commit is contained in:
poojakhatawate 2024-06-12 14:59:51 +05:30
parent e13307c953
commit 12542f3534
10 changed files with 702 additions and 320 deletions

View File

@ -1,15 +1,13 @@
import 'package:discover_module/custom_widget/text.dart'; import 'package:discover_module/custom_widget/text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:http_mock_adapter/http_mock_adapter.dart';
class Alert extends StatefulWidget { class Alert extends StatelessWidget {
Alert({super.key, required this.data}); Alert({super.key, required this.data, required this.onPressed});
String? data; String? data;
VoidCallbackAction? oidCallbackAction;
final void Function() onPressed;
@override
State<Alert> createState() => _AlertState();
}
class _AlertState extends State<Alert> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AlertDialog( return AlertDialog(
@ -18,16 +16,10 @@ class _AlertState extends State<Alert> {
txtfont: 22.0, txtfont: 22.0,
), ),
content: Text1( content: Text1(
title: widget.data!, title: data!,
txtfont: 18.0, txtfont: 18.0,
), ),
actions: [ actions: [TextButton(onPressed: onPressed, child: Text("Ok"))],
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text("Cancel"))
],
); );
} }
} }

View File

@ -226,7 +226,12 @@ class _FiltersState extends State<Filters> {
showDialog( showDialog(
context: context, context: context,
builder: (_) { builder: (_) {
return Alert(data: "Please select the Filter"); return Alert(
data: "Please select the Filter",
onPressed: () {
Navigator.of(context).pop();
},
);
}); });
} }
}, },

View File

@ -239,6 +239,17 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
// : 3.8 // : 3.8
// : 2.4, // : 2.4,
// childAspectRatio:
// sectionList.length == 1
// ? orientation ==
// Orientation
// .landscape
// ? 10
// : 4.8
// : isTablet
// ? 3.6
// : 3.0,
childAspectRatio: childAspectRatio:
sectionList.length == 1 sectionList.length == 1
? orientation == ? orientation ==
@ -247,7 +258,7 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
? 10 ? 10
: 4.8 : 4.8
: isTablet : isTablet
? 3.6 ? 2.8
: 3.0, : 3.0,
children: List.generate( children: List.generate(
sectionList.length, sectionList.length,
@ -574,7 +585,18 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
// if (textFieldsValidation(provider).isEmpty) { // if (textFieldsValidation(provider).isEmpty) {
await provider.saveJsonObject(context, await provider.saveJsonObject(context,
widget.saveInteraction.intId, widget.saveInteraction); widget.saveInteraction.intId, widget.saveInteraction);
// showAlertDialog(context, widget.saveInteraction.id);
print("Validation_isss: ${provider.isLoading}");
if (provider.isLoading == false) {
print("Validation_false");
showAlertDialog1(context, "Please fill all the fields");
} else {
showAlertDialog(context, widget.saveInteraction.id); showAlertDialog(context, widget.saveInteraction.id);
print("Validation_True");
}
// } else { // } else {
// _displaySnackBar(textFieldsValidation(provider)); // _displaySnackBar(textFieldsValidation(provider));
// } // }
@ -1228,11 +1250,19 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
// (MediaQuery.of(context).size.height * 0.3) // (MediaQuery.of(context).size.height * 0.3)
// : MediaQuery.of(context).size.width / // : MediaQuery.of(context).size.width /
// (MediaQuery.of(context).size.height * 0.1), // (MediaQuery.of(context).size.height * 0.1),
childAspectRatio: isTablet // childAspectRatio: isTablet
? MediaQuery.of(context).size.width / // ? MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 3) // (MediaQuery.of(context).size.height / 3)
: MediaQuery.of(context).size.width / // : MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height * 0.2), // (MediaQuery.of(context).size.height * 0.2),
childAspectRatio: sectionList.length == 1
? orientation == Orientation.landscape
? 10
: 4.8
: isTablet
? 2.8
: 3.0,
// mainAxisSpacing: // mainAxisSpacing:
// sectionList.length == 1 || !isTablet ? 1 : 3.5, // sectionList.length == 1 || !isTablet ? 1 : 3.5,
// childAspectRatio: sectionList.length == 1 // childAspectRatio: sectionList.length == 1
@ -1388,8 +1418,9 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
setState(() {}); setState(() {});
}, },
width: 80, // width: 80,
height: 30, // height: 30,
height: 40,
fontsize: 12, fontsize: 12,
textColor: Colors.white, textColor: Colors.white,
title: "Delete"), title: "Delete"),
@ -1530,6 +1561,35 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
); );
} }
showAlertDialog1(BuildContext context, String record) {
// set up the buttons
// ViewInteractionProvider provider =
// Provider.of<ViewInteractionProvider>(context, listen: false);
Widget cancelButton = TextButton(
child: const Text("Ok"),
onPressed: () async {
Navigator.of(context).pop();
},
);
// set up the AlertDialog
AlertDialog alert = AlertDialog(
title: const Text(""),
content: Text(record),
actions: [
cancelButton,
],
);
// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
showFilesAlertDialog( showFilesAlertDialog(
BuildContext context, String files, SectionList sectionItem) { BuildContext context, String files, SectionList sectionItem) {
// set up the buttons // set up the buttons

View File

@ -1,6 +1,6 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'dart:js_util'; // import 'dart:js_util';
import 'package:discover_module/constants.dart'; import 'package:discover_module/constants.dart';
import 'package:discover_module/ui_screen/add_event/add_hcp.dart'; import 'package:discover_module/ui_screen/add_event/add_hcp.dart';
@ -182,16 +182,33 @@ class _InteractionScreenState extends State<InteractionScreen> {
child: GridView.count( child: GridView.count(
physics: physics:
const NeverScrollableScrollPhysics(), const NeverScrollableScrollPhysics(),
// crossAxisCount:
// context.responsive<int>(
// 1,
// sm: 1, // small
// md: 1, // medium
// lg: sectionList.length == 1
// ? 1
// : 3, // large
// xl: 3, // extra large screen
// ),
crossAxisCount: crossAxisCount:
context.responsive<int>( context.responsive<int>(
1, 1,
sm: 1, // small sm: 1, // small
md: 1, // medium md: isTablet
? 2
: orientation ==
Orientation.landscape
? 2
: 1, // medium
lg: sectionList.length == 1 lg: sectionList.length == 1
? 1 ? 1
: 3, // large : 3, // large
xl: 3, // extra large screen xl: 3, // extra large screen
), ),
// crossAxisCount: // crossAxisCount:
// orientation == Orientation.portrait // orientation == Orientation.portrait
// ? 1 // ? 1
@ -503,13 +520,16 @@ class _InteractionScreenState extends State<InteractionScreen> {
style: TextStyle( style: TextStyle(
fontSize: 18.0, fontWeight: FontWeight.normal), fontSize: 18.0, fontWeight: FontWeight.normal),
) )
: Padding( : Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0), padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: SizedBox( child: SizedBox(
// width: // width:
// isTablet ? 200 : MediaQuery.of(context).size.width, // isTablet ? 200 : MediaQuery.of(context).size.width,
//height: isTablet ? 50 : 40, //height: isTablet ? 50 : 40,
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
height: isTablet ? 50 : 40,
child: InteractionTextField( child: InteractionTextField(
inputType: sectionItem.input == "number" inputType: sectionItem.input == "number"
? TextInputType.number ? TextInputType.number
@ -521,10 +541,12 @@ class _InteractionScreenState extends State<InteractionScreen> {
sectionItem.selectedValue = []; sectionItem.selectedValue = [];
// sectionItem.selectedValue!.clear(); // sectionItem.selectedValue!.clear();
provider.setTextValue(val, sectionItem, multiple); provider.setTextValue(
val, sectionItem, multiple);
}, },
), ),
), ),
),
); );
case InteractionWidget.DROPDOWN: case InteractionWidget.DROPDOWN:
return customdropdown(sectionItem, provider, list, multiple); return customdropdown(sectionItem, provider, list, multiple);
@ -668,7 +690,7 @@ class _InteractionScreenState extends State<InteractionScreen> {
if (provider.isLoading == false) { if (provider.isLoading == false) {
print("Validation_false"); print("Validation_false");
showAlertDialog(context, "Please fill all the fields"); showAlertDialog1(context, "Please fill all the fields");
} else { } else {
showAlertDialog(context, "Form $record Saved Successfully!"); showAlertDialog(context, "Form $record Saved Successfully!");
print("Validation_True"); print("Validation_True");
@ -1335,22 +1357,14 @@ class _InteractionScreenState extends State<InteractionScreen> {
print("ConvertedArray.leangth: $convertedArray"); print("ConvertedArray.leangth: $convertedArray");
print("ConvertedArray.leangth: ${convertedArray.length}"); print("ConvertedArray.leangth: ${convertedArray.length}");
return return DecoratedBox(
// Container(
// decoration: BoxDecoration(
// border: Border.all(
// width: 0,
// ),
// ),
// child:
DecoratedBox(
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: Colors.black), border: Border.all(color: Colors.black),
borderRadius: BorderRadius.circular(10.0), borderRadius: BorderRadius.circular(10.0),
), ),
child: Padding( child: Padding(
padding: isTablet padding: isTablet
? const EdgeInsets.only(left: 8.0) ? const EdgeInsets.only(left: 14.0)
: const EdgeInsets.only(left: 12.0, right: 12.0), : const EdgeInsets.only(left: 12.0, right: 12.0),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -1358,30 +1372,68 @@ class _InteractionScreenState extends State<InteractionScreen> {
for (var i = 0; i < convertedArray.length; i++) for (var i = 0; i < convertedArray.length; i++)
GridView.builder( GridView.builder(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
// crossAxisCount: context.responsive<int>(
// 1,
// sm: 1, // small
// md: orientation == Orientation.landscape
// ? 1
// : 2, // medium
// lg: sectionList.length == 1
// ? 1
// : (sectionList.length >= 1 ? 3 : 3), // large
// xl: 3, // extra large screen
// ),
// mainAxisSpacing:
// sectionList.length == 1 || !isTablet ? 1 : 2,
// // childAspectRatio: isTablet
// // ? MediaQuery.of(context).size.width /
// // (MediaQuery.of(context).size.height * 0.3)
// // : MediaQuery.of(context).size.width /
// // (MediaQuery.of(context).size.height * 0.1),
// childAspectRatio: isTablet
// ? MediaQuery.of(context).size.width /
// (MediaQuery.of(context).size.height / 3)
// : MediaQuery.of(context).size.width /
// (MediaQuery.of(context).size.height * 0.2),
// ),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: context.responsive<int>( crossAxisCount: context.responsive<int>(
1, 1,
sm: 1, // small sm: 1, // small
md: orientation == Orientation.landscape md: isTablet
? 1 ? 2
: 2, // medium : orientation == Orientation.landscape
lg: sectionList.length == 1 ? 2
? 1 : 1, // medium
: (sectionList.length >= 1 ? 3 : 3), // large lg: sectionList.length == 1 ? 1 : 3, // large
xl: 3, // extra large screen xl: 3, // extra large screen
), ),
mainAxisSpacing: mainAxisSpacing:
sectionList.length == 1 || !isTablet ? 1 : 2, sectionList.length == 1 || !isTablet ? 1 : 1,
// childAspectRatio: isTablet // childAspectRatio: isTablet
// ? MediaQuery.of(context).size.width / // ? MediaQuery.of(context).size.width /
// (MediaQuery.of(context).size.height * 0.3) // (MediaQuery.of(context).size.height * 0.3)
// : MediaQuery.of(context).size.width / // : MediaQuery.of(context).size.width /
// (MediaQuery.of(context).size.height * 0.1), // (MediaQuery.of(context).size.height * 0.1),
childAspectRatio: isTablet
? MediaQuery.of(context).size.width / childAspectRatio: sectionList.length == 1
(MediaQuery.of(context).size.height / 3) ? orientation == Orientation.landscape
: MediaQuery.of(context).size.width / ? 10
(MediaQuery.of(context).size.height * 0.2), : 4.8
: isTablet
? 2.8
: 3.0,
// childAspectRatio: isTablet
// ? MediaQuery.of(context).size.width /
// (MediaQuery.of(context).size.height / 3)
// : orientation == Orientation.landscape
// ? MediaQuery.of(context).size.width /
// (MediaQuery.of(context).size.height * 0.5)
// : MediaQuery.of(context).size.width /
// (MediaQuery.of(context).size.height * 0.1),
), ),
shrinkWrap: true, shrinkWrap: true,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
@ -1430,8 +1482,8 @@ class _InteractionScreenState extends State<InteractionScreen> {
sectionItem.widget == InteractionWidget.CHECKBOX sectionItem.widget == InteractionWidget.CHECKBOX
? provider.getData2(sectionItem) ? provider.getData2(sectionItem)
: []; : [];
return Wrap(children: [ return SizedBox(
Expanded( height: MediaQuery.of(context).size.height,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -1467,8 +1519,7 @@ class _InteractionScreenState extends State<InteractionScreen> {
sectionItem.selectedValue = []; sectionItem.selectedValue = [];
sectionItem.extension = []; sectionItem.extension = [];
sectionItem.fileName = []; sectionItem.fileName = [];
await getEncodedFile( await getEncodedFile(sectionItem);
sectionItem);
setState(() {}); setState(() {});
}, },
@ -1481,17 +1532,15 @@ class _InteractionScreenState extends State<InteractionScreen> {
width: 5, width: 5,
), ),
Text( Text(
sectionItem sectionItem.selectedValue!.isNotEmpty
? sectionItem
.selectedValue!.isNotEmpty .selectedValue!.isNotEmpty
? sectionItem.selectedValue!
.isNotEmpty
? 'File uploaded' ? 'File uploaded'
: "Files Uploaded" : "Files Uploaded"
: 'No file uploaded', : 'No file uploaded',
style: TextStyle( style: TextStyle(
color: sectionItem color: sectionItem
.selectedValue! .selectedValue!.isNotEmpty
.isNotEmpty
? Colors.green ? Colors.green
: Colors.red), : Colors.red),
), ),
@ -1510,8 +1559,8 @@ class _InteractionScreenState extends State<InteractionScreen> {
icon: const Icon( icon: const Icon(
Icons.cancel, Icons.cancel,
size: 30, size: 30,
color: Color.fromARGB( color:
255, 8, 39, 92), Color.fromARGB(255, 8, 39, 92),
), ),
) )
: Padding( : Padding(
@ -1552,8 +1601,7 @@ class _InteractionScreenState extends State<InteractionScreen> {
multiple: true), multiple: true),
], ],
), ),
), );
]);
}) })
], ],
), ),
@ -1684,6 +1732,35 @@ class _InteractionScreenState extends State<InteractionScreen> {
}, },
); );
} }
showAlertDialog1(BuildContext context, String record) {
// set up the buttons
// ViewInteractionProvider provider =
// Provider.of<ViewInteractionProvider>(context, listen: false);
Widget cancelButton = TextButton(
child: const Text("Ok"),
onPressed: () async {
Navigator.of(context).pop();
},
);
// set up the AlertDialog
AlertDialog alert = AlertDialog(
title: const Text(""),
content: Text(record),
actions: [
cancelButton,
],
);
// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
} }

View File

@ -46,7 +46,7 @@ bool get isTablet {
final logicalShortestSide = final logicalShortestSide =
firstView.physicalSize.shortestSide / firstView.devicePixelRatio; firstView.physicalSize.shortestSide / firstView.devicePixelRatio;
// print("size:${logicalShortestSide > 600} tablet "); // print("size:${logicalShortestSide > 600} tablet ");
return logicalShortestSide > 600; return logicalShortestSide > 500;
} }
Future<String> formJsonForSync() async { Future<String> formJsonForSync() async {

View File

@ -144,6 +144,7 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
// ? 10 // ? 10
// : 3.8 // : 3.8
// : 2.8, // : 2.8,
crossAxisCount: crossAxisCount:
context.responsive<int>( context.responsive<int>(
1, 1,
@ -168,6 +169,15 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
: isTablet : isTablet
? 2.8 ? 2.8
: 3.0, : 3.0,
// childAspectRatio:
// sectionList.length == 1
// ? orientation ==
// Orientation.landscape
// ? 10
// : 4.8
// : isTablet
// ? 2.8
// : 3.0,
shrinkWrap: true, shrinkWrap: true,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
children: List.generate( children: List.generate(
@ -491,9 +501,14 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
print("ConvertedArrayEdit.leangth: $convertedArray"); print("ConvertedArrayEdit.leangth: $convertedArray");
print("ConvertedArray.leangth2323: ${convertedArray.length}"); print("ConvertedArray.leangth2323: ${convertedArray.length}");
return Padding( return DecoratedBox(
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
borderRadius: BorderRadius.circular(10),
),
child: Padding(
padding: isTablet padding: isTablet
? const EdgeInsets.only(left: 22.0) ? const EdgeInsets.only(left: 14.0)
: const EdgeInsets.only(left: 12.0, right: 12.0), : const EdgeInsets.only(left: 12.0, right: 12.0),
child: Column( child: Column(
children: [ children: [
@ -504,14 +519,28 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
crossAxisCount: context.responsive<int>( crossAxisCount: context.responsive<int>(
1, // default 1, // default
sm: 1, // small sm: 1, // small
md: 1, // medium md: 2, // medium
lg: sectionList.length == 1 ? 1 : 4, // large lg: sectionList.length == 1
xl: 5, // extra large screen ? 1
: (sectionList.length >= 1 ? 3 : 3),
// lg: sectionList.length == 1 ? 1 : 3, // large
xl: 3, // extra large screen
), ),
mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 2, childAspectRatio: sectionList.length == 1
? orientation == Orientation.landscape
? 10
: 4.8
: isTablet
? 2.8
: 3.0,
mainAxisSpacing:
sectionList.length == 1 || !isTablet ? 1 : 3.5,
// mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 2,
), ),
shrinkWrap: true, shrinkWrap: true,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
// childAspectRatio: sectionList.length == 1 || !isTablet // childAspectRatio: sectionList.length == 1 || !isTablet
// ? orientation == Orientation.landscape // ? orientation == Orientation.landscape
// ? 10 // ? 10
@ -538,12 +567,14 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
// ? provider.getData2(sectionItem) // ? provider.getData2(sectionItem)
// : []; // : [];
SectionList sectionItem = convertedArray[i][index]; SectionList sectionItem = convertedArray[i][index];
dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN dropdownvalue =
sectionItem.widget == InteractionWidget.DROPDOWN
? sectionItem.value ?? "Select" ? sectionItem.value ?? "Select"
: ' '; : ' ';
List<InputClass> list = sectionItem.widget == List<InputClass> list = sectionItem.widget ==
InteractionWidget.DROPDOWN || InteractionWidget.DROPDOWN ||
sectionItem.widget == InteractionWidget.AUTOCOMPLETE || sectionItem.widget ==
InteractionWidget.AUTOCOMPLETE ||
sectionItem.widget == InteractionWidget.MULTISELECT sectionItem.widget == InteractionWidget.MULTISELECT
? provider.getData2(sectionItem) ? provider.getData2(sectionItem)
: []; : [];
@ -561,6 +592,8 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
sectionItem.param == 'add' || sectionItem.param == 'add' ||
sectionItem.param == 'deletebtn' sectionItem.param == 'deletebtn'
? const SizedBox.shrink() ? const SizedBox.shrink()
// ? const SizedBox.shrink()
: Text( : Text(
'${sectionItem.name}:*', '${sectionItem.name}:*',
style: TextStyle( style: TextStyle(
@ -587,6 +620,7 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
//), //),
], ],
), ),
),
); );
} }

View File

@ -45,6 +45,10 @@ class ViewInteractionProvider extends ChangeNotifier {
Hive.box<InteractionConfigData>('InteractionConfigDataBox')); Hive.box<InteractionConfigData>('InteractionConfigDataBox'));
late final InteractionProvider interactionProvider; late final InteractionProvider interactionProvider;
late bool _isLoadingView;
get isLoading => _isLoadingView;
initConfigData() async { initConfigData() async {
intConfigDataList = _hiveprovider.getAllDataFromHive(); intConfigDataList = _hiveprovider.getAllDataFromHive();
notifyListeners(); notifyListeners();
@ -673,6 +677,85 @@ class ViewInteractionProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
// saveJsonObject(BuildContext context, String form,
// SaveInteraction saveInteraction) async {
// for (var res in interactionReponseList) {
// for (var sec in res.sectionList) {
// debugPrint("print ${sec.selectedValue}");
// }
// for (var sec in res.multipleList!) {
// debugPrint("printmultiple ${sec.selectedValue}");
// }
// }
// List<FormFieldData> resultData = interactionReponseList
// .map((e) => FormFieldData(
// multipleList: e.multipleList == null
// ? []
// : e.multipleList!
// .map((mobj) => SectionList(
// depid: mobj.depid,
// id: mobj.id,
// inputList: mobj.inputList,
// isRequired: mobj.isRequired,
// extension: mobj.extension,
// fileName: mobj.fileName,
// name: mobj.name,
// param: mobj.param,
// selectedValue:
// mobj.tempselectedValue ?? mobj.selectedValue,
// widget: mobj.widget,
// gid: mobj.gid,
// input: mobj.input,
// selectedId: mobj.selectedId,
// value: mobj.value))
// .toList(),
// sectionList: e.sectionList
// .map((obj) => SectionList(
// depid: obj.depid,
// id: obj.id,
// inputList: obj.inputList,
// extension: obj.extension,
// fileName: obj.fileName,
// isRequired: obj.isRequired,
// name: obj.name,
// param: obj.param,
// selectedValue: obj.tempselectedValue ?? obj.selectedValue,
// widget: obj.widget,
// controller: obj.controller,
// gid: obj.gid,
// input: obj.input,
// selectedId: obj.selectedId,
// value: obj.value))
// .toList(),
// sectionName: e.sectionName,
// multiple: e.multiple,
// ))
// .toList();
// final data = SaveInteraction(
// save: resultData,
// id: saveInteraction.id,
// updatedTime: DateTime.now().toString(),
// form: saveInteraction.form,
// intId: saveInteraction.intId,
// intName: saveInteraction.intName,
// );
// var box = Hive.box<SaveInteraction>('InteractionDataBox');
// if (!box.isOpen) {
// box = await Hive.openBox<SaveInteraction>('InteractionDataBox');
// }
// int index =
// box.values.toList().indexWhere((element) => element.id == data.id);
// box.putAt(index, data);
// await getRecords(saveInteraction.form!);
// // box.close();
// // await MockApiCall().postFormData(data);
// }
saveJsonObject(BuildContext context, String form, saveJsonObject(BuildContext context, String form,
SaveInteraction saveInteraction) async { SaveInteraction saveInteraction) async {
for (var res in interactionReponseList) { for (var res in interactionReponseList) {
@ -727,6 +810,9 @@ class ViewInteractionProvider extends ChangeNotifier {
multiple: e.multiple, multiple: e.multiple,
)) ))
.toList(); .toList();
if (validateSectionList(resultData)) {
_isLoadingView = true;
notifyListeners();
final data = SaveInteraction( final data = SaveInteraction(
save: resultData, save: resultData,
@ -746,6 +832,13 @@ class ViewInteractionProvider extends ChangeNotifier {
box.values.toList().indexWhere((element) => element.id == data.id); box.values.toList().indexWhere((element) => element.id == data.id);
box.putAt(index, data); box.putAt(index, data);
} else {
_isLoadingView = false;
notifyListeners();
// Handle validation error
print("JSON data is not valid according to the schema.");
}
await getRecords(saveInteraction.form!); await getRecords(saveInteraction.form!);
// box.close(); // box.close();
@ -822,6 +915,97 @@ class ViewInteractionProvider extends ChangeNotifier {
} }
return false; return false;
} }
bool validateSectionList(List<FormFieldData> resultData) {
for (var formData in resultData) {
for (var section in formData.sectionList) {
// print("Section.leangthiss: ${resultData.length}");
// for (int i = 0; i <= resultData.length; i++) {
// SectionList sectionItem = formData.sectionList[i];
// print("Section_isssss1111: ${sectionItem.validation!.isRequired}");
// }
print("Section_isssss: $section");
print("Section_isssss: ${section.widget}");
print("Section_isssss: ${section.selectedId}");
if (section.widget == InteractionWidget.TEXT) {
if (section.controller!.text.isEmpty) {
debugPrint("Iam text and empty");
notifyListeners();
return false;
}
} else if (section.widget == InteractionWidget.AUTOCOMPLETE) {
if (section.selectedValue!.isEmpty) {
debugPrint("Iam AUTOCOMPLETE and empty");
notifyListeners();
return false;
}
} else if (section.widget == InteractionWidget.DROPDOWN) {
if (section.selectedValue!.isEmpty) {
debugPrint("Iam dropdown and empty");
notifyListeners();
return false;
}
} else if (section.widget == InteractionWidget.CHECKBOX) {
if (section.selectedValue!.isEmpty) {
debugPrint("Iam CHECKBOX and empty");
notifyListeners();
return false;
}
}
}
print("Multilist");
for (var msection in formData.multipleList!) {
print("Multilist Enter");
print("Multilist Enterwidget: ${msection.widget}");
if (msection.widget == InteractionWidget.TEXT) {
print("Checkinggg: ${msection.id}");
print("Checkinggg: ${msection.depid}");
print("Checkinggg: ${msection.chars}");
print("Checkinggg: ${msection.selectedId}");
print("Checkinggg: ${msection.selectedValue!}");
if (msection.selectedValue!.isEmpty) {
debugPrint("Iam multi text and empty");
notifyListeners();
return false;
}
} else if (msection.widget == InteractionWidget.AUTOCOMPLETE) {
if (msection.selectedValue!.isEmpty) {
debugPrint("Iam AUTOCOMPLETE and empty");
notifyListeners();
return false;
}
} else if (msection.widget == InteractionWidget.DROPDOWN) {
if (msection.selectedValue!.isEmpty) {
debugPrint("Iam dropdown and empty");
notifyListeners();
return false;
}
} else if (msection.widget == InteractionWidget.CHECKBOX) {
if (msection.selectedValue!.isEmpty) {
debugPrint("Iam CHECKBOX and empty");
notifyListeners();
return false;
}
}
}
}
notifyListeners();
return true;
}
} }

View File

@ -1,9 +1,10 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'dart:js_interop'; // import 'dart:js_interop';
import 'package:discover_module/custom_widget/floating_btn.dart'; import 'package:discover_module/custom_widget/floating_btn.dart';
import 'package:discover_module/custom_widget/show_alert.dart'; import 'package:discover_module/custom_widget/show_alert.dart';
import 'package:discover_module/ui_screen/contacts.dart';
import 'package:discover_module/ui_screen/profile.dart'; import 'package:discover_module/ui_screen/profile.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/foundation.dart' show kIsWeb;
@ -145,6 +146,19 @@ class _RankingState extends State<Ranking> {
// Do something with selectedRowIds // Do something with selectedRowIds
print('Selected Row IDstrndsss: $selectedRowIds'); print('Selected Row IDstrndsss: $selectedRowIds');
if (selectedRowIds.isEmpty) {
showDialog(
context: context,
builder: (_) {
return Alert(
data: "Please Select the user",
onPressed: () {
Navigator.of(context).pop();
print('OK button pressed');
},
);
});
} else {
for (int i = 0; i < selectedRowIds.length; i++) { for (int i = 0; i < selectedRowIds.length; i++) {
print('The id id : ${selectedRowIds[i]}'); print('The id id : ${selectedRowIds[i]}');
@ -172,8 +186,16 @@ class _RankingState extends State<Ranking> {
showDialog( showDialog(
context: context, context: context,
builder: (_) { builder: (_) {
return Alert(data: "User Added Successfully"); return Alert(
data: "User Added Successfully",
onPressed: () {
Navigator.of(context).pop();
// Navigator.push(context,
// MaterialPageRoute(builder: (_) => Contacts()));
},
);
}); });
}
}, },
)), )),
), ),

View File

@ -128,6 +128,9 @@ class RisingStarState extends State<RisingStar> {
builder: (_) { builder: (_) {
return Alert( return Alert(
data: "User Added Successfully", data: "User Added Successfully",
onPressed: () {
Navigator.of(context).pop();
},
); );
}); });
}, },

View File

@ -101,7 +101,12 @@ class _TrendsState extends State<Trends> {
showDialog( showDialog(
context: context, context: context,
builder: (_) { builder: (_) {
return Alert(data: "User Added Successfully"); return Alert(
data: "User Added Successfully",
onPressed: () {
Navigator.of(context).pop();
},
);
}); });
}, },
)), )),