Compare commits

..

3 Commits

6 changed files with 293 additions and 200 deletions

View File

@ -290,16 +290,24 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
sectionItem.input ==
'add'
? const SizedBox.shrink()
: Text(
: Padding(
padding:
const EdgeInsets
.only(
left: 8.0,
right: 8.0),
child: Text(
'${sectionItem.name}:*',
style: TextStyle(
color: Colors.orange
color: Colors
.orange
.shade800,
fontSize: isTablet
? 18
: 12,
),
),
),
SizedBox(
height: isTablet ? 15 : 5,
),
@ -465,8 +473,7 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
},
),
)
: Expanded(
child: Padding(
: Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: SizedBox(
// width: isTablet ? 200 : MediaQuery.of(context).size.width,
@ -486,7 +493,6 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
},
),
),
),
);
case InteractionWidget.DROPDOWN:
return customdropdown(sectionItem, provider, list, multiple);
@ -647,7 +653,7 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
Widget customdropdown(SectionList sectionItem,
ViewInteractionProvider provider, List<InputClass> list, bool multiple) {
// sectionItem.value = '';
print("%%%%${sectionItem.selectedValue!.last}");
// print("%%%%${sectionItem.selectedValue!.last}");
if (list.isEmpty) {
print("###list empty###");
list = [];
@ -1026,7 +1032,7 @@ class _EditInteractionScreenState extends State<EditInteractionScreen> {
? provider.getData2(sectionItem)
: [];
return Wrap(children: [
return Wrap(runAlignment: WrapAlignment.spaceEvenly, children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [

View File

@ -282,7 +282,13 @@ class _InteractionScreenState extends State<InteractionScreen> {
sectionItem.input ==
'add'
? const SizedBox.shrink()
: FittedBox(
: Padding(
padding:
const EdgeInsets
.only(
left: 8.0,
right: 8.0),
child: FittedBox(
fit: BoxFit.scaleDown,
child: Text(
sectionItem
@ -291,7 +297,8 @@ class _InteractionScreenState extends State<InteractionScreen> {
? '${sectionItem.name}:*'
: '${sectionItem.name}:',
style: TextStyle(
color: Colors.orange
color: Colors
.orange
.shade800,
fontSize: 18.0,
// fontSize: isTablet
@ -300,6 +307,7 @@ class _InteractionScreenState extends State<InteractionScreen> {
),
),
),
),
// SizedBox(
// height: isTablet ? 15 : 5,
// ),
@ -501,7 +509,7 @@ class _InteractionScreenState extends State<InteractionScreen> {
controller: sectionItem.controller!,
labelText: sectionItem.name,
onChanged: (val) {
sectionItem.selectedValue = [];
sectionItem.selectedValue!.clear();
provider.setTextValue(val, sectionItem, multiple);
},
),
@ -1051,16 +1059,29 @@ class _InteractionScreenState extends State<InteractionScreen> {
Orientation orientation,
FormFieldData item,
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(
padding: isTablet
? const EdgeInsets.only(left: 8.0)
: const EdgeInsets.only(left: 12.0, right: 12.0),
child: Card(
child: GridView.count(
physics: const NeverScrollableScrollPhysics(),
crossAxisCount: context.responsive<int>(
1, // default
sm: 1, // small
md: 1, // medium
md: 2, // medium
lg: sectionList.length == 1 ? 1 : 4, // large
xl: 5, // extra large screen
),
@ -1071,7 +1092,7 @@ class _InteractionScreenState extends State<InteractionScreen> {
? orientation == Orientation.landscape
? 10
: 4.2
: 1.8,
: 3,
children: List.generate(
sectionList.length,
(i) {
@ -1080,8 +1101,8 @@ class _InteractionScreenState extends State<InteractionScreen> {
dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN
? sectionItem.value ?? "Select"
: ' ';
List<InputClass> list =
sectionItem.widget == InteractionWidget.DROPDOWN ||
List<InputClass> list = sectionItem.widget ==
InteractionWidget.DROPDOWN ||
sectionItem.widget == InteractionWidget.AUTOCOMPLETE ||
sectionItem.widget == InteractionWidget.MULTISELECT
? provider.getData2(sectionItem)
@ -1091,7 +1112,7 @@ class _InteractionScreenState extends State<InteractionScreen> {
? provider.getData2(sectionItem)
: [];
return Wrap(children: [
return Wrap(runAlignment: WrapAlignment.spaceEvenly, children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -1139,15 +1160,19 @@ class _InteractionScreenState extends State<InteractionScreen> {
: "Files Uploaded"
: 'No file uploaded',
style: TextStyle(
color:
sectionItem.selectedValue!.isNotEmpty
color: sectionItem
.selectedValue!.isNotEmpty
? Colors.green
: Colors.red),
),
],
)
: isTablet
? IconButton(
? Row(
children: [
Expanded(
// width: MediaQuery.of(context).size.width,
child: IconButton(
onPressed: () {
provider.deleteMultipleRows(
sectionItem.gid!,
@ -1159,12 +1184,16 @@ class _InteractionScreenState extends State<InteractionScreen> {
icon: const Icon(
Icons.cancel,
size: 30,
color: Color.fromARGB(255, 8, 39, 92),
color:
Color.fromARGB(255, 8, 39, 92),
),
),
),
],
)
: Padding(
padding:
const EdgeInsets.only(left: 3.0, top: 5),
padding: const EdgeInsets.only(
left: 3.0, top: 5),
child: CustomButton(
backgroundColor: const Color.fromARGB(
255, 233, 75, 75),
@ -1203,6 +1232,7 @@ class _InteractionScreenState extends State<InteractionScreen> {
},
),
),
),
);
}

View File

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

View File

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

View File

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

View File

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