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);
// 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);
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,26 +520,31 @@ class _InteractionScreenState extends State<InteractionScreen> {
style: TextStyle( style: TextStyle(
fontSize: 18.0, fontWeight: FontWeight.normal), fontSize: 18.0, fontWeight: FontWeight.normal),
) )
: Padding( : Expanded(
padding: const EdgeInsets.only(left: 8.0, right: 8.0), child: Padding(
child: SizedBox( padding: const EdgeInsets.only(left: 8.0, right: 8.0),
// width: child: SizedBox(
// isTablet ? 200 : MediaQuery.of(context).size.width, // width:
//height: isTablet ? 50 : 40, // isTablet ? 200 : MediaQuery.of(context).size.width,
width: MediaQuery.of(context).size.width, //height: isTablet ? 50 : 40,
child: InteractionTextField( width: MediaQuery.of(context).size.width,
inputType: sectionItem.input == "number" height: isTablet ? 50 : 40,
? TextInputType.number
: TextInputType.name,
maxchars: int.parse(sectionItem.chars ?? "0"),
controller: sectionItem.controller!,
labelText: sectionItem.name,
onChanged: (val) {
sectionItem.selectedValue = [];
// sectionItem.selectedValue!.clear();
provider.setTextValue(val, sectionItem, multiple); child: InteractionTextField(
}, inputType: sectionItem.input == "number"
? TextInputType.number
: TextInputType.name,
maxchars: int.parse(sectionItem.chars ?? "0"),
controller: sectionItem.controller!,
labelText: sectionItem.name,
onChanged: (val) {
sectionItem.selectedValue = [];
// sectionItem.selectedValue!.clear();
provider.setTextValue(
val, sectionItem, 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,130 +1482,126 @@ 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: [
sectionItem.widget == InteractionWidget.BUTTON && sectionItem.widget == InteractionWidget.BUTTON &&
sectionItem.input == 'add' || sectionItem.input == 'add' ||
sectionItem.input == 'deletebtn' sectionItem.input == 'deletebtn'
? const SizedBox.shrink() ? const SizedBox.shrink()
: Padding( : Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
left: 8.0, right: 8.0), left: 8.0, right: 8.0),
child: FittedBox( child: FittedBox(
fit: BoxFit.scaleDown, fit: BoxFit.scaleDown,
child: Text( child: Text(
'${sectionItem.name}:*', '${sectionItem.name}:*',
style: TextStyle( style: TextStyle(
color: Colors.orange.shade800, color: Colors.orange.shade800,
fontSize: 18), fontSize: 18),
),
), ),
), ),
// const SizedBox( ),
// height: 15, // const SizedBox(
// ), // height: 15,
sectionItem.widget == InteractionWidget.BUTTON // ),
? sectionItem.input == 'chooseFile' sectionItem.widget == InteractionWidget.BUTTON
? Row( ? sectionItem.input == 'chooseFile'
children: [ ? Row(
CustomButton( children: [
backgroundColor: CustomButton(
const Color.fromARGB( backgroundColor:
255, 233, 229, 229), const Color.fromARGB(
onPressed: () async { 255, 233, 229, 229),
sectionItem.selectedValue = []; onPressed: () async {
sectionItem.extension = []; sectionItem.selectedValue = [];
sectionItem.fileName = []; sectionItem.extension = [];
await getEncodedFile( sectionItem.fileName = [];
sectionItem); await getEncodedFile(sectionItem);
setState(() {});
},
width: 120,
height: 40,
fontsize: 12,
textColor: Colors.black,
title: sectionItem.name),
const SizedBox(
width: 5,
),
Text(
sectionItem
.selectedValue!.isNotEmpty
? sectionItem.selectedValue!
.isNotEmpty
? 'File uploaded'
: "Files Uploaded"
: 'No file uploaded',
style: TextStyle(
color: sectionItem
.selectedValue!
.isNotEmpty
? Colors.green
: Colors.red),
),
],
)
: isTablet
? IconButton(
onPressed: () {
provider.deleteMultipleRows(
sectionItem.gid!,
sectionList[i],
sectionName);
setState(() {}); setState(() {});
}, },
icon: const Icon( width: 120,
Icons.cancel, height: 40,
size: 30, fontsize: 12,
color: Color.fromARGB( textColor: Colors.black,
255, 8, 39, 92), title: sectionItem.name),
), const SizedBox(
) width: 5,
: Padding( ),
padding: const EdgeInsets.only( Text(
left: 3.0, top: 5), sectionItem.selectedValue!.isNotEmpty
child: CustomButton( ? sectionItem
backgroundColor: .selectedValue!.isNotEmpty
const Color.fromARGB( ? 'File uploaded'
255, 233, 75, 75), : "Files Uploaded"
onPressed: () { : 'No file uploaded',
provider.deleteMultipleRows( style: TextStyle(
sectionItem.gid!, color: sectionItem
sectionList[i], .selectedValue!.isNotEmpty
sectionName); ? Colors.green
: Colors.red),
),
],
)
: isTablet
? IconButton(
onPressed: () {
provider.deleteMultipleRows(
sectionItem.gid!,
sectionList[i],
sectionName);
setState(() {}); setState(() {});
}, },
// width: 80, icon: const Icon(
// height: 30, Icons.cancel,
size: 30,
color:
Color.fromARGB(255, 8, 39, 92),
),
)
: Padding(
padding: const EdgeInsets.only(
left: 3.0, top: 5),
child: CustomButton(
backgroundColor:
const Color.fromARGB(
255, 233, 75, 75),
onPressed: () {
provider.deleteMultipleRows(
sectionItem.gid!,
sectionList[i],
sectionName);
height: 40, setState(() {});
},
// width: 80,
// height: 30,
// height: height: 40,
// MediaQuery.of(context).size.height *
// 0.2, // height:
fontsize: 12, // MediaQuery.of(context).size.height *
textColor: Colors.white, // 0.2,
title: "Delete"), fontsize: 12,
) textColor: Colors.white,
: returnWidget( title: "Delete"),
sectionItem: sectionItem, )
item: item, : returnWidget(
provider: provider, sectionItem: sectionItem,
list: list, item: item,
gridIndex: i, provider: provider,
listIndex: listIndex, list: list,
widgetData: sectionItem.widget!, gridIndex: i,
multiple: true), listIndex: listIndex,
], widgetData: sectionItem.widget!,
), 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,101 +501,125 @@ 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(
padding: isTablet decoration: BoxDecoration(
? const EdgeInsets.only(left: 22.0) border: Border.all(color: Colors.black),
: const EdgeInsets.only(left: 12.0, right: 12.0), borderRadius: BorderRadius.circular(10),
child: Column( ),
children: [ child: Padding(
for (var i = 0; i < convertedArray.length; i++) padding: isTablet
GridView.builder( ? const EdgeInsets.only(left: 14.0)
physics: const NeverScrollableScrollPhysics(), : const EdgeInsets.only(left: 12.0, right: 12.0),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( child: Column(
crossAxisCount: context.responsive<int>( children: [
1, // default for (var i = 0; i < convertedArray.length; i++)
sm: 1, // small GridView.builder(
md: 1, // medium physics: const NeverScrollableScrollPhysics(),
lg: sectionList.length == 1 ? 1 : 4, // large gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
xl: 5, // extra large screen crossAxisCount: context.responsive<int>(
), 1, // default
mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 2, sm: 1, // small
), md: 2, // medium
shrinkWrap: true, lg: sectionList.length == 1
padding: EdgeInsets.zero, ? 1
// childAspectRatio: sectionList.length == 1 || !isTablet : (sectionList.length >= 1 ? 3 : 3),
// ? orientation == Orientation.landscape // lg: sectionList.length == 1 ? 1 : 3, // large
// ? 10 xl: 3, // extra large screen
// : 4.2
// : 1.8,
itemCount: convertedArray[i].length,
itemBuilder: (context, index) {
// children: List.generate(
// sectionList.length,
// (i) {
// print(sectionList);
// SectionList sectionItem = sectionList[i];
// dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN
// ? sectionItem.value ?? "Select"
// : ' ';
// List<InputClass> list =
// sectionItem.widget == InteractionWidget.DROPDOWN ||
// sectionItem.widget == InteractionWidget.AUTOCOMPLETE ||
// sectionItem.widget == InteractionWidget.MULTISELECT
// ? provider.getData2(sectionItem)
// : [];
// provider.checkboxlist =
// sectionItem.widget == InteractionWidget.CHECKBOX
// ? provider.getData2(sectionItem)
// : [];
SectionList sectionItem = convertedArray[i][index];
dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN
? sectionItem.value ?? "Select"
: ' ';
List<InputClass> list = sectionItem.widget ==
InteractionWidget.DROPDOWN ||
sectionItem.widget == InteractionWidget.AUTOCOMPLETE ||
sectionItem.widget == InteractionWidget.MULTISELECT
? provider.getData2(sectionItem)
: [];
provider.checkboxlist =
sectionItem.widget == InteractionWidget.CHECKBOX
? provider.getData2(sectionItem)
: [];
return SizedBox(
height: MediaQuery.of(context).size.height,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
sectionItem.widget == InteractionWidget.BUTTON &&
sectionItem.param == 'add' ||
sectionItem.param == 'deletebtn'
? const SizedBox.shrink()
: Text(
'${sectionItem.name}:*',
style: TextStyle(
color: Colors.orange.shade800,
fontSize: isTablet ? 18 : 14,
),
),
const SizedBox(
height: 15,
),
returnWidget(
sectionItem: sectionItem,
item: item,
provider: provider,
list: list,
gridIndex: i,
listIndex: listIndex,
widgetData: sectionItem.widget!),
],
), ),
); 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,
padding: EdgeInsets.zero,
// childAspectRatio: sectionList.length == 1 || !isTablet
// ? orientation == Orientation.landscape
// ? 10
// : 4.2
// : 1.8,
itemCount: convertedArray[i].length,
itemBuilder: (context, index) {
// children: List.generate(
// sectionList.length,
// (i) {
// print(sectionList);
// SectionList sectionItem = sectionList[i];
// dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN
// ? sectionItem.value ?? "Select"
// : ' ';
// List<InputClass> list =
// sectionItem.widget == InteractionWidget.DROPDOWN ||
// sectionItem.widget == InteractionWidget.AUTOCOMPLETE ||
// sectionItem.widget == InteractionWidget.MULTISELECT
// ? provider.getData2(sectionItem)
// : [];
// provider.checkboxlist =
// sectionItem.widget == InteractionWidget.CHECKBOX
// ? provider.getData2(sectionItem)
// : [];
SectionList sectionItem = convertedArray[i][index];
dropdownvalue =
sectionItem.widget == InteractionWidget.DROPDOWN
? sectionItem.value ?? "Select"
: ' ';
List<InputClass> list = sectionItem.widget ==
InteractionWidget.DROPDOWN ||
sectionItem.widget ==
InteractionWidget.AUTOCOMPLETE ||
sectionItem.widget == InteractionWidget.MULTISELECT
? provider.getData2(sectionItem)
: [];
provider.checkboxlist =
sectionItem.widget == InteractionWidget.CHECKBOX
? provider.getData2(sectionItem)
: [];
return SizedBox(
height: MediaQuery.of(context).size.height,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
sectionItem.widget == InteractionWidget.BUTTON &&
sectionItem.param == 'add' ||
sectionItem.param == 'deletebtn'
? const SizedBox.shrink()
// ? const SizedBox.shrink()
: Text(
'${sectionItem.name}:*',
style: TextStyle(
color: Colors.orange.shade800,
fontSize: isTablet ? 18 : 14,
),
),
const SizedBox(
height: 15,
),
returnWidget(
sectionItem: sectionItem,
item: item,
provider: provider,
list: list,
gridIndex: i,
listIndex: listIndex,
widgetData: sectionItem.widget!),
],
),
);
},
),
//),
],
),
), ),
); );
} }

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,25 +810,35 @@ 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,
id: saveInteraction.id, id: saveInteraction.id,
updatedTime: DateTime.now().toString(), updatedTime: DateTime.now().toString(),
form: saveInteraction.form, form: saveInteraction.form,
intId: saveInteraction.intId, intId: saveInteraction.intId,
intName: saveInteraction.intName, intName: saveInteraction.intName,
); );
var box = Hive.box<SaveInteraction>('InteractionDataBox'); var box = Hive.box<SaveInteraction>('InteractionDataBox');
if (!box.isOpen) { if (!box.isOpen) {
box = await Hive.openBox<SaveInteraction>('InteractionDataBox'); box = await Hive.openBox<SaveInteraction>('InteractionDataBox');
}
int index =
box.values.toList().indexWhere((element) => element.id == data.id);
box.putAt(index, data);
} else {
_isLoadingView = false;
notifyListeners();
// Handle validation error
print("JSON data is not valid according to the schema.");
} }
int index =
box.values.toList().indexWhere((element) => element.id == data.id);
box.putAt(index, data);
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,35 +146,56 @@ class _RankingState extends State<Ranking> {
// Do something with selectedRowIds // Do something with selectedRowIds
print('Selected Row IDstrndsss: $selectedRowIds'); print('Selected Row IDstrndsss: $selectedRowIds');
for (int i = 0; i < selectedRowIds.length; i++) { if (selectedRowIds.isEmpty) {
print('The id id : ${selectedRowIds[i]}'); 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++) {
print('The id id : ${selectedRowIds[i]}');
print("checking_value_istrends: ${selectedRowIds[i]}"); print("checking_value_istrends: ${selectedRowIds[i]}");
// selectedno.add(selectedRowIds[i]); // selectedno.add(selectedRowIds[i]);
HiveFunctions.addno(selectedRowIds[i]); HiveFunctions.addno(selectedRowIds[i]);
// _contactbox.put(i, selectedRowIds[i]); // _contactbox.put(i, selectedRowIds[i]);
HiveFunctions.createUser({ HiveFunctions.createUser({
"name": "Gerosa,Gino", "name": "Gerosa,Gino",
"org": "Azienda Ospedaliera di Padova", "org": "Azienda Ospedaliera di Padova",
"adrr": "Via Giustiniani 2, Padova, Veneto 35128, Italy", "adrr": "Via Giustiniani 2, Padova, Veneto 35128, Italy",
"phone": "+390498212410X12", "phone": "+390498212410X12",
"Pphone": "+390498212410X12", "Pphone": "+390498212410X12",
"email": "Gerosa,Gino@gmail.com", "email": "Gerosa,Gino@gmail.com",
"affno": "75", "affno": "75",
"eveno": "8", "eveno": "8",
"pubno": "251", "pubno": "251",
"trailno": "1" "trailno": "1"
});
}
showDialog(
context: context,
builder: (_) {
return Alert(data: "User Added Successfully");
}); });
}
showDialog(
context: context,
builder: (_) {
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();
},
);
}); });
}, },
)), )),