Compare commits

...

3 Commits

6 changed files with 293 additions and 200 deletions

View File

@ -290,14 +290,22 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
sectionItem.input == sectionItem.input ==
'add' 'add'
? const SizedBox.shrink() ? const SizedBox.shrink()
: Text( : Padding(
'${sectionItem.name}:*', padding:
style: TextStyle( const EdgeInsets
color: Colors.orange .only(
.shade800, left: 8.0,
fontSize: isTablet right: 8.0),
? 18 child: Text(
: 12, '${sectionItem.name}:*',
style: TextStyle(
color: Colors
.orange
.shade800,
fontSize: isTablet
? 18
: 12,
),
), ),
), ),
SizedBox( SizedBox(
@ -465,26 +473,24 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
}, },
), ),
) )
: Expanded( : Padding(
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: isTablet ? 200 : MediaQuery.of(context).size.width,
// width: isTablet ? 200 : MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
width: MediaQuery.of(context).size.width,
height: isTablet ? 50 : 40, height: isTablet ? 50 : 40,
child: InteractionTextField( child: InteractionTextField(
maxchars: int.parse(sectionItem.chars ?? "0"), maxchars: int.parse(sectionItem.chars ?? "0"),
controller: sectionItem.controller!, controller: sectionItem.controller!,
inputType: sectionItem.input == "number" inputType: sectionItem.input == "number"
? TextInputType.number ? TextInputType.number
: TextInputType.name, : TextInputType.name,
labelText: sectionItem.name, labelText: sectionItem.name,
onChanged: (val) { onChanged: (val) {
sectionItem.selectedValue = []; sectionItem.selectedValue = [];
provider.setTextValue(val, sectionItem, multiple); provider.setTextValue(val, sectionItem, multiple);
}, },
),
), ),
), ),
); );
@ -647,7 +653,7 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
Widget customdropdown(SectionList sectionItem, Widget customdropdown(SectionList sectionItem,
ViewInteractionProvider provider, List<InputClass> list, bool multiple) { ViewInteractionProvider provider, List<InputClass> list, bool multiple) {
// sectionItem.value = ''; // sectionItem.value = '';
print("%%%%${sectionItem.selectedValue!.last}"); // print("%%%%${sectionItem.selectedValue!.last}");
if (list.isEmpty) { if (list.isEmpty) {
print("###list empty###"); print("###list empty###");
list = []; list = [];
@ -1026,7 +1032,7 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
? provider.getData2(sectionItem) ? provider.getData2(sectionItem)
: []; : [];
return Wrap(children: [ return Wrap(runAlignment: WrapAlignment.spaceEvenly, children: [
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [

View File

@ -282,21 +282,29 @@ class _InteractionScreenState extends State<InteractionScreen> {
sectionItem.input == sectionItem.input ==
'add' 'add'
? const SizedBox.shrink() ? const SizedBox.shrink()
: FittedBox( : Padding(
fit: BoxFit.scaleDown, padding:
child: Text( const EdgeInsets
sectionItem .only(
.validation! left: 8.0,
.isRequired right: 8.0),
? '${sectionItem.name}:*' child: FittedBox(
: '${sectionItem.name}:', fit: BoxFit.scaleDown,
style: TextStyle( child: Text(
color: Colors.orange sectionItem
.shade800, .validation!
fontSize: 18.0, .isRequired
// fontSize: isTablet ? '${sectionItem.name}:*'
// ? 18 : '${sectionItem.name}:',
// : 12, style: TextStyle(
color: Colors
.orange
.shade800,
fontSize: 18.0,
// fontSize: isTablet
// ? 18
// : 12,
),
), ),
), ),
), ),
@ -501,7 +509,7 @@ class _InteractionScreenState extends State<InteractionScreen> {
controller: sectionItem.controller!, controller: sectionItem.controller!,
labelText: sectionItem.name, labelText: sectionItem.name,
onChanged: (val) { onChanged: (val) {
sectionItem.selectedValue = []; sectionItem.selectedValue!.clear();
provider.setTextValue(val, sectionItem, multiple); provider.setTextValue(val, sectionItem, multiple);
}, },
), ),
@ -1051,156 +1059,178 @@ class _InteractionScreenState extends State<InteractionScreen> {
Orientation orientation, Orientation orientation,
FormFieldData item, FormFieldData item,
int listIndex) { int listIndex) {
List<String> items = [];
for (var obj in sectionList) {
items.add(obj.name);
}
Map<String, int> count = {};
for (var i in items) {
count[i] = (count[i] ?? 0) + 1;
}
print(count['delete']);
return Padding( return Padding(
padding: isTablet padding: isTablet
? const EdgeInsets.only(left: 8.0) ? const EdgeInsets.only(left: 8.0)
: const EdgeInsets.only(left: 12.0, right: 12.0), : const EdgeInsets.only(left: 12.0, right: 12.0),
child: GridView.count( child: Card(
physics: const NeverScrollableScrollPhysics(), child: GridView.count(
crossAxisCount: context.responsive<int>( physics: const NeverScrollableScrollPhysics(),
1, // default crossAxisCount: context.responsive<int>(
sm: 1, // small 1, // default
md: 1, // medium sm: 1, // small
lg: sectionList.length == 1 ? 1 : 4, // large md: 2, // medium
xl: 5, // extra large screen lg: sectionList.length == 1 ? 1 : 4, // large
), xl: 5, // extra large screen
mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 2, ),
shrinkWrap: true, mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 2,
padding: EdgeInsets.zero, shrinkWrap: true,
childAspectRatio: sectionList.length == 1 || !isTablet padding: EdgeInsets.zero,
? orientation == Orientation.landscape childAspectRatio: sectionList.length == 1 || !isTablet
? 10 ? orientation == Orientation.landscape
: 4.2 ? 10
: 1.8, : 4.2
children: List.generate( : 3,
sectionList.length, children: List.generate(
(i) { sectionList.length,
print(sectionList); (i) {
SectionList sectionItem = sectionList[i]; print(sectionList);
dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN SectionList sectionItem = sectionList[i];
? sectionItem.value ?? "Select" dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN
: ' '; ? sectionItem.value ?? "Select"
List<InputClass> list = : ' ';
sectionItem.widget == InteractionWidget.DROPDOWN || List<InputClass> list = sectionItem.widget ==
sectionItem.widget == InteractionWidget.AUTOCOMPLETE || InteractionWidget.DROPDOWN ||
sectionItem.widget == InteractionWidget.MULTISELECT sectionItem.widget == InteractionWidget.AUTOCOMPLETE ||
? provider.getData2(sectionItem) sectionItem.widget == InteractionWidget.MULTISELECT
: []; ? provider.getData2(sectionItem)
provider.checkboxlist = : [];
sectionItem.widget == InteractionWidget.CHECKBOX provider.checkboxlist =
? provider.getData2(sectionItem) sectionItem.widget == InteractionWidget.CHECKBOX
: []; ? provider.getData2(sectionItem)
: [];
return Wrap(children: [ return Wrap(runAlignment: WrapAlignment.spaceEvenly, children: [
Column( 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()
: Text( : Text(
'${sectionItem.name}:*', '${sectionItem.name}:*',
style: TextStyle( style: TextStyle(
color: Colors.orange.shade800, color: Colors.orange.shade800,
fontSize: isTablet ? 18 : 14, fontSize: isTablet ? 18 : 14,
),
), ),
), // const SizedBox(
// const SizedBox( // height: 15,
// height: 15, // ),
// ), sectionItem.widget == InteractionWidget.BUTTON
sectionItem.widget == InteractionWidget.BUTTON ? sectionItem.input == 'chooseFile'
? sectionItem.input == 'chooseFile' ? Row(
? Row( children: [
children: [ CustomButton(
CustomButton(
backgroundColor: const Color.fromARGB(
255, 233, 229, 229),
onPressed: () async {
sectionItem.selectedValue = [];
sectionItem.extension = [];
sectionItem.fileName = [];
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(() {});
},
icon: const Icon(
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( backgroundColor: const Color.fromARGB(
255, 233, 75, 75), 255, 233, 229, 229),
onPressed: () { onPressed: () async {
provider.deleteMultipleRows( sectionItem.selectedValue = [];
sectionItem.gid!, sectionItem.extension = [];
sectionList[i], sectionItem.fileName = [];
sectionName); await getEncodedFile(sectionItem);
setState(() {}); setState(() {});
}, },
// width: 80, width: 120,
// height: 30,
height: 40, height: 40,
// height:
// MediaQuery.of(context).size.height *
// 0.2,
fontsize: 12, fontsize: 12,
textColor: Colors.white, textColor: Colors.black,
title: "Delete"), title: sectionItem.name),
) const SizedBox(
: returnWidget( width: 5,
sectionItem: sectionItem, ),
item: item, Text(
provider: provider, sectionItem.selectedValue!.isNotEmpty
list: list, ? sectionItem.selectedValue!.isNotEmpty
gridIndex: i, ? 'File uploaded'
listIndex: listIndex, : "Files Uploaded"
widgetData: sectionItem.widget!, : 'No file uploaded',
multiple: true), style: TextStyle(
], color: sectionItem
), .selectedValue!.isNotEmpty
]); ? Colors.green
}, : Colors.red),
),
],
)
: isTablet
? Row(
children: [
Expanded(
// width: MediaQuery.of(context).size.width,
child: IconButton(
onPressed: () {
provider.deleteMultipleRows(
sectionItem.gid!,
sectionList[i],
sectionName);
setState(() {});
},
icon: const Icon(
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);
setState(() {});
},
// width: 80,
// height: 30,
height: 40,
// height:
// MediaQuery.of(context).size.height *
// 0.2,
fontsize: 12,
textColor: Colors.white,
title: "Delete"),
)
: returnWidget(
sectionItem: sectionItem,
item: item,
provider: provider,
list: list,
gridIndex: i,
listIndex: listIndex,
widgetData: sectionItem.widget!,
multiple: true),
],
),
]);
},
),
), ),
), ),
); );

View File

@ -246,8 +246,8 @@ class InteractionProvider extends ChangeNotifier {
int i = 0; int i = 0;
for (var obj in interactionReponseList) { for (var obj in interactionReponseList) {
if (multiple && obj.multipleList != null) { if (multiple && obj.multipleList != null) {
i = obj.multipleList! i = obj.multipleList!.indexWhere((element) =>
.indexWhere((element) => element.id == sectionItem.id); element.id == sectionItem.id && element.gid == sectionItem.gid);
if (i != -1) { if (i != -1) {
obj.multipleList![i].value = value; obj.multipleList![i].value = value;
obj.multipleList![i].selectedValue!.add(value); obj.multipleList![i].selectedValue!.add(value);
@ -420,7 +420,7 @@ class InteractionProvider extends ChangeNotifier {
List<SectionList> addList = []; List<SectionList> addList = [];
int index = interactionReponseList int index = interactionReponseList
.indexWhere((element) => element.sectionName == sectionName); .indexWhere((element) => element.sectionName == sectionName);
var textEditingController = TextEditingController();
addList = interactionReponseList[index] addList = interactionReponseList[index]
.sectionList .sectionList
.map((e) => SectionList( .map((e) => SectionList(
@ -450,6 +450,17 @@ class InteractionProvider extends ChangeNotifier {
addList.add(delItem); addList.add(delItem);
for (SectionList obj in addList) {
//obj.gid = obj.gid ?? addList.length;
if (obj.widget == InteractionWidget.TEXT) {
// multipletextEditingControllerList.clear();
var textEditingController = TextEditingController();
obj.controller = textEditingController;
multipletextEditingControllerList.add(textEditingController);
}
// newList.add(obj);
}
// if (interactionReponseList[index].multipleList!.isEmpty) { // if (interactionReponseList[index].multipleList!.isEmpty) {
// newList = addList; // newList = addList;
// } else { // } else {
@ -466,13 +477,13 @@ class InteractionProvider extends ChangeNotifier {
if (interactionReponseList[index].multipleList != null) { if (interactionReponseList[index].multipleList != null) {
for (SectionList obj in interactionReponseList[index].multipleList!) { for (SectionList obj in interactionReponseList[index].multipleList!) {
obj.gid = obj.gid ?? interactionReponseList[index].multipleList!.length; obj.gid = obj.gid ?? interactionReponseList[index].multipleList!.length;
if (obj.widget == InteractionWidget.TEXT) { // if (obj.widget == InteractionWidget.TEXT) {
var textEditingController = TextEditingController(); // var textEditingController = TextEditingController();
multipletextEditingControllerList.add(textEditingController); // multipletextEditingControllerList.add(textEditingController);
obj.controller = multipletextEditingControllerList.last; // obj.controller = multipletextEditingControllerList.last;
} // }
// newList.add(obj); //newList.add(obj);
} }
} }
@ -525,6 +536,12 @@ class InteractionProvider extends ChangeNotifier {
Future<String> saveJsonObject(BuildContext context, String form, Future<String> saveJsonObject(BuildContext context, String form,
{bool isEdit = false}) async { {bool isEdit = false}) async {
print("form_data: $form"); print("form_data: $form");
// for (var ob in interactionReponseList) {
// for (var ob2 in ob.multipleList!) {
// debugPrint("!!!!!!!!!!!!In multiple :${ob2.selectedValue}");
// }
// }
List<FormFieldData> resultData = interactionReponseList List<FormFieldData> resultData = interactionReponseList
.map((e) => FormFieldData( .map((e) => FormFieldData(
multipleList: e.multipleList == null multipleList: e.multipleList == null
@ -541,7 +558,7 @@ class InteractionProvider extends ChangeNotifier {
extension: mobj.extension, extension: mobj.extension,
fileName: mobj.fileName, fileName: mobj.fileName,
widget: mobj.widget, widget: mobj.widget,
// controller: mobj.controller, // controller: mobj.controller,
gid: mobj.gid, gid: mobj.gid,
input: mobj.input, input: mobj.input,
selectedId: mobj.selectedId, selectedId: mobj.selectedId,

View File

@ -286,8 +286,10 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
sectionItem.id, sectionItem.selectedValue!.last)); sectionItem.id, sectionItem.selectedValue!.last));
case InteractionWidget.AUTOCOMPLETE: case InteractionWidget.AUTOCOMPLETE:
return Text(provider.getDataValue( return Text(sectionItem.selectedValue!.isNotEmpty
sectionItem.id, sectionItem.selectedValue!.last)); ? provider.getDataValue(
sectionItem.id, sectionItem.selectedValue!.last)
: " ");
case InteractionWidget.MULTISELECT: case InteractionWidget.MULTISELECT:
return Text(sectionItem.selectedValue.toString()); return Text(sectionItem.selectedValue.toString());
@ -320,6 +322,11 @@ class _ViewInteractionScreenState extends State<ViewInteractionScreen> {
? const Text("File Uploaded") ? const Text("File Uploaded")
: const Text(" ") : const Text(" ")
: const Text(" "); : const Text(" ");
case InteractionWidget.DROPDOWN:
return Text(sectionItem.selectedValue!.isNotEmpty
? provider.getDataValue(
sectionItem.id, sectionItem.selectedValue!.last)
: " ");
default: default:
return Text(sectionItem.selectedValue!.isNotEmpty return Text(sectionItem.selectedValue!.isNotEmpty
? provider.getDataValue( ? provider.getDataValue(

View File

@ -140,13 +140,22 @@ class ViewInteractionProvider extends ChangeNotifier {
for (SectionList obj in item.multipleList!) { for (SectionList obj in item.multipleList!) {
obj.gid = obj.gid ?? item.multipleList!.length; obj.gid = obj.gid ?? item.multipleList!.length;
if (obj.widget == InteractionWidget.TEXT) { if (obj.widget == InteractionWidget.TEXT) {
debugPrint("textcontr:${obj.gid}");
debugPrint("textcontr:${obj.selectedValue}");
// debugPrint("textcontr:${obj.controller!.value}");
var textEditingController = TextEditingController(); var textEditingController = TextEditingController();
textEditingController.value = TextEditingValue(
text: obj.selectedValue!.isNotEmpty
? obj.selectedValue!.last ?? ""
: "");
textEditingController.text = obj.selectedValue!.isNotEmpty textEditingController.text = obj.selectedValue!.isNotEmpty
? obj.selectedValue!.last ?? "" ? obj.selectedValue!.last ?? ""
: ""; : "";
multipletextEditingControllerList.add(textEditingController); multipletextEditingControllerList.add(textEditingController);
obj.controller = multipletextEditingControllerList.last; // obj.controller!.value = textEditingController.value;
obj.controller = textEditingController;
// obj.controller = obj.selectedValue.last ?? " "; // obj.controller = obj.selectedValue.last ?? " ";
} }
if (obj.widget == InteractionWidget.DROPDOWN || if (obj.widget == InteractionWidget.DROPDOWN ||
@ -608,6 +617,23 @@ class ViewInteractionProvider extends ChangeNotifier {
// if (interactionReponseList[index].multipleList!.isEmpty) { // if (interactionReponseList[index].multipleList!.isEmpty) {
// newList = addList; // newList = addList;
// } else { // } else {
if (addList.isNotEmpty) {
for (SectionList obj in addList) {
// obj.gid = obj.gid ?? addList.length;
if (obj.widget == InteractionWidget.TEXT) {
var textEditingController = TextEditingController();
multipletextEditingControllerList.add(textEditingController);
obj.controller = multipletextEditingControllerList.last;
obj.controller!.text =
obj.selectedValue != null && obj.selectedValue!.isNotEmpty
? obj.selectedValue!.last
: '';
}
// newList.add(obj);
}
}
if (interactionReponseList[index].multipleList == null) { if (interactionReponseList[index].multipleList == null) {
interactionReponseList[index].multipleList = addList; interactionReponseList[index].multipleList = addList;
} else { } else {
@ -622,10 +648,6 @@ class ViewInteractionProvider extends ChangeNotifier {
for (SectionList obj in interactionReponseList[index].multipleList!) { for (SectionList obj in interactionReponseList[index].multipleList!) {
obj.gid = obj.gid ?? interactionReponseList[index].multipleList!.length; obj.gid = obj.gid ?? interactionReponseList[index].multipleList!.length;
if (obj.widget == InteractionWidget.TEXT) { if (obj.widget == InteractionWidget.TEXT) {
var textEditingController = TextEditingController();
multipletextEditingControllerList.add(textEditingController);
obj.controller = multipletextEditingControllerList.last;
obj.controller!.text = obj.controller!.text =
obj.selectedValue != null && obj.selectedValue!.isNotEmpty obj.selectedValue != null && obj.selectedValue!.isNotEmpty
? obj.selectedValue!.last ? obj.selectedValue!.last
@ -653,6 +675,14 @@ class ViewInteractionProvider extends ChangeNotifier {
saveJsonObject(BuildContext context, String form, saveJsonObject(BuildContext context, String form,
SaveInteraction saveInteraction) async { 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 List<FormFieldData> resultData = interactionReponseList
.map((e) => FormFieldData( .map((e) => FormFieldData(
multipleList: e.multipleList == null multipleList: e.multipleList == null

View File

@ -42,6 +42,9 @@ class InteractionTextField extends StatelessWidget {
onChanged: (value) { onChanged: (value) {
onChanged(value); onChanged(value);
}, },
onSubmitted: (value) {
onChanged(value);
},
inputFormatters: [ inputFormatters: [
inputType == TextInputType.number inputType == TextInputType.number
? FilteringTextInputFormatter.digitsOnly ? FilteringTextInputFormatter.digitsOnly