diff --git a/lib/main.dart b/lib/main.dart index aac79b4..5994f0a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -49,6 +49,8 @@ Future main() async { var box = await Hive.openBox('mycontact'); var box1 = await Hive.openBox('myfilter'); + await Hive.openBox('checkvalue'); + runApp(MultiProvider( providers: [ ChangeNotifierProvider(create: (_) => InteractionProvider()), @@ -173,3 +175,62 @@ class _MyHomePageState extends State { ); } } + + + + +// import 'package:flutter/material.dart'; + +// class MyGridView extends StatefulWidget { +// @override +// _MyGridViewState createState() => _MyGridViewState(); +// } + +// class _MyGridViewState extends State { +// List> sections = [["Item 1", "Item 2", "Item 3"]]; + +// @override +// Widget build(BuildContext context) { +// return Scaffold( +// appBar: AppBar( +// title: Text('GridView Example'), +// ), +// body: Column( +// children: [ +// Expanded( +// child: ListView.builder( +// itemCount: sections.length, +// itemBuilder: (context, index) { +// return GridView.count( +// shrinkWrap: true, +// crossAxisCount: 2, +// children: sections[index].map((item) { +// return Card( +// child: Center( +// child: Text(item), +// ), +// ); +// }).toList(), +// ); +// }, +// ), +// ), +// ElevatedButton( +// onPressed: () { +// setState(() { +// sections.add(["Item 1", "Item 2", "Item 3"]); +// }); +// }, +// child: Icon(Icons.add), +// ), +// ], +// ), +// ); +// } +// } + +// void main() { +// runApp(MaterialApp( +// home: MyGridView(), +// )); +// } diff --git a/lib/ui_screen/contacts.dart b/lib/ui_screen/contacts.dart index e2ae872..343784b 100644 --- a/lib/ui_screen/contacts.dart +++ b/lib/ui_screen/contacts.dart @@ -29,118 +29,122 @@ class _ContactsState extends State { print( "Data_newww: ${HiveFunctions.getAllUsers()} ,${HiveFunctions.getAllUsers().length} "); - return Scaffold( - // appBar: AppBar( - // title: const Text('Contacts'), - // ), - body: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment - .center, // Align children to start and end of the row + return SafeArea( + child: Scaffold( + // appBar: AppBar( + // title: const Text('Contacts'), + // ), + body: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment + .center, // Align children to start and end of the row - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.only(left: 45.0), - child: Text( - _switchValue ? "My Contacts" : "All Contacts", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 20.0, - fontWeight: FontWeight.w500, - fontStyle: FontStyle.normal, - color: _switchValue ? Colors.black : Colors.black), + children: [ + Expanded( + child: Padding( + padding: const EdgeInsets.only(left: 45.0), + child: Text( + _switchValue ? "My Contacts" : "All Contacts", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 20.0, + fontWeight: FontWeight.w500, + fontStyle: FontStyle.normal, + color: _switchValue ? Colors.black : Colors.black), + ), ), ), - ), - // Expanded( - Row( - // Adjust alignment as needed - mainAxisSize: MainAxisSize.min, - children: [ - _switchValue - ? const Text( - 'All', - style: TextStyle( - fontSize: 12, - decoration: TextDecoration.lineThrough, - decorationThickness: 0.85, - ), - // TODO: implement dispose - ) - : const Text('All', - style: TextStyle( - fontSize: 12, - )), - CupertinoSwitch( - activeColor: Color.fromARGB(255, 0, 71, 132), - value: _switchValue, - onChanged: (value) { - setState(() { - print("Switch_value_is : $value"); - _switchValue = value; - }); - }, - ), - Padding( - padding: const EdgeInsets.only(right: 8.0), - child: !_switchValue + // Expanded( + Row( + // Adjust alignment as needed + mainAxisSize: MainAxisSize.min, + children: [ + _switchValue ? const Text( - 'My', + 'All', style: TextStyle( fontSize: 12, decoration: TextDecoration.lineThrough, decorationThickness: 0.85, ), + // TODO: implement dispose ) - : const Text('My', + : const Text('All', style: TextStyle( fontSize: 12, )), - ) - ], - ), - // ), - ]), - Expanded( - child: ListView.builder( - itemCount: HiveFunctions.getAllUsers().length, - itemBuilder: (BuildContext context, int index) { - var data = HiveFunctions.getAllUsers()[index]; + CupertinoSwitch( + activeColor: Color.fromARGB(255, 0, 71, 132), + value: _switchValue, + onChanged: (value) { + setState(() { + print("Switch_value_is : $value"); + _switchValue = value; + }); + }, + ), + Padding( + padding: const EdgeInsets.only(right: 8.0), + child: !_switchValue + ? const Text( + 'My', + style: TextStyle( + fontSize: 12, + decoration: TextDecoration.lineThrough, + decorationThickness: 0.85, + ), + ) + : const Text('My', + style: TextStyle( + fontSize: 12, + )), + ) + ], + ), + // ), + ]), + Expanded( + child: ListView.builder( + itemCount: HiveFunctions.getAllUsers().length, + itemBuilder: (BuildContext context, int index) { + var data = HiveFunctions.getAllUsers()[index]; - print("dataaaa_isss:$data"); + print("dataaaa_isss:$data"); - return Column( - children: [ - ListTile( - onTap: () { - Navigator.push(context, - MaterialPageRoute(builder: (context) => Profile())); - }, - // title: Text(_contactbox.values.toString()), - leading: ProfilePicture( - name: data["name"], - radius: 20, - fontsize: 12, + return Column( + children: [ + ListTile( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => Profile())); + }, + // title: Text(_contactbox.values.toString()), + leading: ProfilePicture( + name: data["name"], + radius: 20, + fontsize: 12, + ), + title: Text( + data["name"], + style: const TextStyle( + fontSize: 18.0, fontWeight: FontWeight.bold), + ), + subtitle: const Text( + "Added by Pooja.K", + style: TextStyle( + fontSize: 14.0, fontWeight: FontWeight.normal), + ), ), - title: Text( - data["name"], - style: const TextStyle( - fontSize: 18.0, fontWeight: FontWeight.bold), - ), - subtitle: const Text( - "Added by Pooja.K", - style: TextStyle( - fontSize: 14.0, fontWeight: FontWeight.normal), - ), - ), - ], - ); - }, + ], + ); + }, + ), ), - ), - ], + ], + ), ), ); } diff --git a/lib/ui_screen/interactionform/edit_interaction_screen.dart b/lib/ui_screen/interactionform/edit_interaction_screen.dart index 62fcbe3..80211e1 100644 --- a/lib/ui_screen/interactionform/edit_interaction_screen.dart +++ b/lib/ui_screen/interactionform/edit_interaction_screen.dart @@ -98,267 +98,276 @@ class _EditInteractionScreenState extends State { return Consumer( builder: (BuildContext context, provider, Widget? child) { // print("build context"); - // print("${provider.interactionReponseList}"); + // print("Providerr_is: ${provider.multipletextEditingControllerList}"); return GestureDetector( onTap: () { FocusScope.of(context).requestFocus(FocusNode()); }, child: OrientationBuilder(builder: (context, orientation) { - return Scaffold( - //resizeToAvoidBottomInset: false, - appBar: AppBar( - title: Text( - widget.saveInteraction.id, - style: TextStyle( - fontSize: isTablet ? 22 : 14, color: Colors.white), - ), - // backgroundColor: const Color(0xFF2b9af3), - automaticallyImplyLeading: false, - actions: [saveActions(provider)], - leading: InkWell( - onTap: () async { - await provider.disposeValues().then((value) { - Navigator.pop(context); - }); - }, - child: const Icon( - Icons.arrow_back_ios, - color: Colors.white, + return SafeArea( + child: Scaffold( + //resizeToAvoidBottomInset: false, + appBar: AppBar( + title: Text( + widget.saveInteraction.id, + style: TextStyle( + fontSize: isTablet ? 22 : 14, color: Colors.white), ), - ), - ), - body: Column( - children: [ - Expanded( - child: ListView.builder( - itemCount: provider.interactionReponseList.length, - padding: EdgeInsets.zero, - cacheExtent: double.parse( - provider.interactionReponseList.length.toString()), - itemBuilder: (context, index) { - var item = provider.interactionReponseList[index]; - sectionList = item.sectionList; - return Card( - child: ExpansionTile( - maintainState: true, - // backgroundColor: Colors.white, - // collapsedBackgroundColor: Color(0xFF2b9af3), - initiallyExpanded: true, - title: Stack( - alignment: AlignmentDirectional.center, - children: [ - Container( - // height: double.infinity, - width: double.infinity, - padding: const EdgeInsets.all(8.0), - decoration: BoxDecoration( - // color: Color(0xFF2b9af3), - color: Constants.k2color), - child: Text( - item.sectionName, - style: const TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 18.0), - )), - item.multiple - ? Align( - alignment: Alignment.centerRight, - child: IconButton( - onPressed: () { - provider.getSectionItem( - item.sectionName); - // print("index is $listIndex"); - setState(() { - // for (var item - }); - }, - icon: const Icon( - Icons.add_circle_outline, - size: 30, - color: Colors.white, - ), - ), - ) - : const SizedBox.shrink() - ]), - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - const SizedBox( - height: 20, - ), - - Padding( - padding: isTablet - ? const EdgeInsets.only(left: 14.0) - : const EdgeInsets.only( - left: 12.0, right: 12.0), - child: GridView.count( - physics: - const NeverScrollableScrollPhysics(), - // crossAxisCount: - // context.responsive( - // 1, - // sm: 1, // small - // md: 1, // medium - // lg: sectionList.length == 1 - // ? 1 - // : 4, // large - // xl: 3, // extra large screen - // ), - crossAxisCount: - context.responsive( - 1, - sm: 1, // small - md: 2, // medium - lg: sectionList.length == 1 - ? 1 - : 3, // large - xl: 3, // extra large screen - ), - mainAxisSpacing: - sectionList.length == 1 || - !isTablet - ? 1 - : 3.5, - shrinkWrap: true, - padding: EdgeInsets.zero, - // childAspectRatio: - // sectionList.length == 1 || - // !isTablet - // ? orientation == - // Orientation.landscape - // ? 10 - // : 3.8 - // : 2.4, - - childAspectRatio: - sectionList.length == 1 - ? orientation == - Orientation.landscape - ? 10 - : 4.8 - : isTablet - ? 3.6 - : 3.0, - 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) - : []; - - return Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - sectionItem.widget == - InteractionWidget - .BUTTON && - sectionItem.input == - 'add' - ? const SizedBox.shrink() - : Padding( - padding: - const EdgeInsets - .only( - left: 8.0, - right: 8.0), - child: Text( - '${sectionItem.name}:*', - style: TextStyle( - color: Colors - .orange - .shade800, - fontSize: isTablet - ? 18 - : 12, - ), - ), - ), - SizedBox( - height: isTablet ? 15 : 5, - ), - returnWidget( - sectionItem: sectionItem, - item: item, - provider: provider, - list: list, - gridIndex: i, - listIndex: index, - widgetData: - sectionItem.widget!, - multiple: false), - // SizedBox( - // height: isTablet ? 15 : 5, - // ), - ], - ); - }, - ), - ), - ), - SizedBox( - height: isTablet ? 15 : 5, - ), - item.multiple - ? gridViewWidget( - provider, - item.sectionName, - item.multipleList ?? [], - orientation, - item, - index) - : const SizedBox.shrink(), - provider.interactionReponseList.length == - index - 1 - ? saveActions(provider) - : const SizedBox.shrink() - //const Spacer(), - ], - ), - ), - ]), - ); - }, + // backgroundColor: const Color(0xFF2b9af3), + automaticallyImplyLeading: false, + actions: [saveActions(provider)], + leading: InkWell( + onTap: () async { + await provider.disposeValues().then((value) { + Navigator.pop(context); + }); + }, + child: const Icon( + Icons.arrow_back_ios, + color: Colors.white, ), ), - // const Spacer(), - // saveActions(provider), - ], - )); + ), + body: Column( + children: [ + Expanded( + child: ListView.builder( + itemCount: provider.interactionReponseList.length, + padding: EdgeInsets.zero, + cacheExtent: double.parse( + provider.interactionReponseList.length.toString()), + itemBuilder: (context, index) { + var item = provider.interactionReponseList[index]; + sectionList = item.sectionList; + return Card( + child: ExpansionTile( + maintainState: true, + // backgroundColor: Colors.white, + // collapsedBackgroundColor: Color(0xFF2b9af3), + initiallyExpanded: true, + title: Stack( + alignment: AlignmentDirectional.center, + children: [ + Container( + // height: double.infinity, + width: double.infinity, + padding: const EdgeInsets.all(8.0), + decoration: BoxDecoration( + // color: Color(0xFF2b9af3), + color: Constants.k2color), + child: Text( + item.sectionName, + style: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18.0), + )), + item.multiple + ? Align( + alignment: Alignment.centerRight, + child: IconButton( + onPressed: () { + provider.getSectionItem( + item.sectionName); + // print("index is $listIndex"); + setState(() { + // for (var item + }); + }, + icon: const Icon( + Icons.add_circle_outline, + size: 30, + color: Colors.white, + ), + ), + ) + : const SizedBox.shrink() + ]), + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + const SizedBox( + height: 20, + ), + + Padding( + padding: isTablet + ? const EdgeInsets.only( + left: 14.0) + : const EdgeInsets.only( + left: 12.0, right: 12.0), + child: GridView.count( + physics: + const NeverScrollableScrollPhysics(), + // crossAxisCount: + // context.responsive( + // 1, + // sm: 1, // small + // md: 1, // medium + // lg: sectionList.length == 1 + // ? 1 + // : 4, // large + // xl: 3, // extra large screen + // ), + crossAxisCount: + context.responsive( + 1, + sm: 1, // small + md: 2, // medium + lg: sectionList.length == 1 + ? 1 + : 3, // large + xl: 3, // extra large screen + ), + mainAxisSpacing: + sectionList.length == 1 || + !isTablet + ? 1 + : 3.5, + shrinkWrap: true, + padding: EdgeInsets.zero, + // childAspectRatio: + // sectionList.length == 1 || + // !isTablet + // ? orientation == + // Orientation.landscape + // ? 10 + // : 3.8 + // : 2.4, + + childAspectRatio: + sectionList.length == 1 + ? orientation == + Orientation + .landscape + ? 10 + : 4.8 + : isTablet + ? 3.6 + : 3.0, + 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) + : []; + + return Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + sectionItem.widget == + InteractionWidget + .BUTTON && + sectionItem.input == + 'add' + ? const SizedBox + .shrink() + : Padding( + padding: + const EdgeInsets + .only( + left: 8.0, + right: 8.0), + child: Text( + '${sectionItem.name}:*', + style: TextStyle( + color: Colors + .orange + .shade800, + fontSize: + isTablet + ? 18 + : 12, + ), + ), + ), + SizedBox( + height: isTablet ? 15 : 5, + ), + returnWidget( + sectionItem: + sectionItem, + item: item, + provider: provider, + list: list, + gridIndex: i, + listIndex: index, + widgetData: + sectionItem.widget!, + multiple: false), + // SizedBox( + // height: isTablet ? 15 : 5, + // ), + ], + ); + }, + ), + ), + ), + SizedBox( + height: isTablet ? 15 : 5, + ), + item.multiple + ? gridViewWidget( + provider, + item.sectionName, + item.multipleList ?? [], + orientation, + item, + index) + : const SizedBox.shrink(), + provider.interactionReponseList + .length == + index - 1 + ? saveActions(provider) + : const SizedBox.shrink() + //const Spacer(), + ], + ), + ), + ]), + ); + }, + ), + ), + // const Spacer(), + // saveActions(provider), + ], + )), + ); }), ); }); @@ -389,6 +398,7 @@ class _EditInteractionScreenState extends State { return customMultiselectDropdown(sectionItem, provider, list, multiple); case InteractionWidget.RADIO: + print("Radiiooooo"); return (sectionItem.inputList!.length >= 5) ? customdropdown( sectionItem, provider, sectionItem.inputList!, multiple) @@ -556,22 +566,27 @@ class _EditInteractionScreenState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - CustomButton( - backgroundColor: Colors.green.shade900, - onPressed: () async { - // if (textFieldsValidation(provider).isEmpty) { - await provider.saveJsonObject(context, - widget.saveInteraction.intId, widget.saveInteraction); - showAlertDialog(context, widget.saveInteraction.id); - // } else { - // _displaySnackBar(textFieldsValidation(provider)); - // } - }, - textColor: Colors.white, - title: "Update", - height: 40, - width: isTablet ? 120 : 80, - fontsize: isTablet ? 15 : 12, + Padding( + padding: const EdgeInsets.all(4.0), + child: CustomButton( + backgroundColor: Colors.green.shade500, + onPressed: () async { + // if (textFieldsValidation(provider).isEmpty) { + await provider.saveJsonObject(context, + widget.saveInteraction.intId, widget.saveInteraction); + showAlertDialog(context, widget.saveInteraction.id); + // } else { + // _displaySnackBar(textFieldsValidation(provider)); + // } + }, + textColor: Colors.white, + title: "Update", + // height: 40, + // width: isTablet ? 120 : 80, + height: MediaQuery.of(context).size.height * 0.2, + + fontsize: isTablet ? 16 : 12, + ), ), SizedBox( width: isTablet ? 20 : 2, @@ -655,7 +670,8 @@ class _EditInteractionScreenState extends State { Widget customdropdown(SectionList sectionItem, ViewInteractionProvider provider, List list, bool multiple) { // sectionItem.value = ''; - print("%%%%${sectionItem.selectedValue!.last}"); + // print("%%%%${sectionItem.selectedValue!.last}"); + print("ItemList_is: $list"); if (list.isEmpty) { print("###list empty###"); list = []; @@ -987,6 +1003,168 @@ class _EditInteractionScreenState extends State { ); } + // Widget gridViewWidget( + // ViewInteractionProvider provider, + // String sectionName, + // List sectionList, + // Orientation orientation, + // FormFieldData item, + // int listIndex) { + // print("SectionListtt:isss: $sectionList"); + // return Padding( + // padding: isTablet + // ? const EdgeInsets.only(left: 8.0) + // : const EdgeInsets.only(left: 12.0, right: 12.0), + // child: GridView.count( + // physics: const NeverScrollableScrollPhysics(), + // crossAxisCount: context.responsive( + // 1, // default + // sm: 1, // small + // md: 1, // medium + // lg: sectionList.length == 1 ? 1 : 4, // large + // xl: 5, // extra large screen + // ), + // 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, + // children: List.generate( + // sectionList.length, + // (i) { + // // print(sectionList); + // SectionList sectionItem = sectionList[i]; + // dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN + // ? sectionItem.value ?? "Select" + // : ' '; + // List 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 Wrap(children: [ + // 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, + // ), + // sectionItem.widget == InteractionWidget.BUTTON + // ? sectionItem.input == 'chooseFile' + // ? Row( + // children: [ + // CustomButton( + // backgroundColor: const Color.fromARGB( + // 255, 233, 229, 229), + // onPressed: () async { + // if (sectionItem + // .selectedValue!.isNotEmpty) { + // showFilesAlertDialog( + // context, + // sectionItem.fileName!.join(','), + // sectionItem); + // } else { + // 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 + // ? 'File 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( + // 255, 233, 75, 75), + // onPressed: () { + // provider.deleteMultipleRows( + // sectionItem.gid!, + // sectionList[i], + // sectionName); + + // setState(() {}); + // }, + // width: 80, + // height: 30, + // 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), + // ], + // ), + // ]); + // }, + // ), + // ), + // ); + // } + Widget gridViewWidget( ViewInteractionProvider provider, String sectionName, @@ -994,155 +1172,242 @@ class _EditInteractionScreenState extends State { Orientation orientation, FormFieldData item, int listIndex) { - return Padding( - padding: isTablet - ? const EdgeInsets.only(left: 8.0) - : const EdgeInsets.only(left: 12.0, right: 12.0), - child: GridView.count( - physics: const NeverScrollableScrollPhysics(), - crossAxisCount: context.responsive( - 1, // default - sm: 1, // small - md: 1, // medium - lg: sectionList.length == 1 ? 1 : 4, // large - xl: 5, // extra large screen - ), - 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, - children: List.generate( - sectionList.length, - (i) { - // print(sectionList); - SectionList sectionItem = sectionList[i]; - dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN - ? sectionItem.value ?? "Select" - : ' '; - List 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) - : []; + print("SectionListtt:isss: $sectionList"); - return Wrap(children: [ - 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, + List pooja = sectionList; + + print("Pooja: $pooja"); + + List> convertedArray = []; + print("Provider Length: ${item.sectionList.length}"); + + for (int i = 0; i < sectionList.length; i += item.sectionList.length + 1) { + print("Section List11111: $sectionList"); + print("item.sectionList.length List11111: ${item.sectionList.length}"); + + convertedArray + .add(sectionList.sublist(i, i + item.sectionList.length + 1)); + } + print("ConvertedArrayEditMulti.leangth: $convertedArray"); + print("ConvertedArray.leangth: ${convertedArray.length}"); + return DecoratedBox( + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(10.0), + ), + child: Padding( + padding: isTablet + ? const EdgeInsets.only(left: 14.0) + : const EdgeInsets.only(left: 12.0, right: 12.0), + child: Column( + children: [ + for (var i = 0; i < convertedArray.length; i++) + GridView.builder( + physics: const NeverScrollableScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + // crossAxisCount: context.responsive( + // 1, // default + // sm: 1, // small + // md: 1, // medium + // lg: sectionList.length == 1 ? 1 : 4, // large + // xl: 5, // extra large screen + // ), + crossAxisCount: context.responsive( + 1, + sm: 1, // small + md: 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), + // mainAxisSpacing: + // sectionList.length == 1 || !isTablet ? 1 : 3.5, + // childAspectRatio: sectionList.length == 1 + // ? orientation == Orientation.landscape + // ? 10 + // : 4.8 + // : isTablet + // ? 2.8 + // : 3.0, ), - sectionItem.widget == InteractionWidget.BUTTON - ? sectionItem.input == 'chooseFile' - ? Row( - children: [ - CustomButton( - backgroundColor: const Color.fromARGB( - 255, 233, 229, 229), - onPressed: () async { - if (sectionItem - .selectedValue!.isNotEmpty) { - showFilesAlertDialog( - context, - sectionItem.fileName!.join(','), - sectionItem); - } else { - 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 - ? 'File uploaded' - : 'No file uploaded', - style: TextStyle( - color: - sectionItem.selectedValue!.isNotEmpty - ? Colors.green - : Colors.red), - ), - ], - ) - : isTablet - ? IconButton( - onPressed: () { - provider.deleteMultipleRows( - sectionItem.gid!, - sectionList[i], - sectionName); + shrinkWrap: true, + padding: EdgeInsets.zero, - setState(() {}); - }, - icon: const Icon( - Icons.cancel, - size: 30, - color: Color.fromARGB(255, 8, 39, 92), - ), - ) + // 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 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 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() : 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); + padding: const EdgeInsets.only( + left: 8.0, right: 8.0), + child: Text( + '${sectionItem.name}:*', + style: TextStyle( + color: Colors.orange.shade800, + fontSize: isTablet ? 18 : 14, + ), + ), + ), + const SizedBox( + height: 15, + ), + sectionItem.widget == InteractionWidget.BUTTON + ? sectionItem.input == 'chooseFile' + ? Row( + children: [ + CustomButton( + backgroundColor: + const Color.fromARGB( + 255, 233, 229, 229), + onPressed: () async { + if (sectionItem + .selectedValue!.isNotEmpty) { + showFilesAlertDialog( + context, + sectionItem.fileName! + .join(','), + sectionItem); + } else { + 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 + ? 'File 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(() {}); - }, - width: 80, - height: 30, - 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), - ], - ), - ]); - }, + 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, + 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), + ], + ), + ); + }), + ], ), ), ); diff --git a/lib/ui_screen/interactionform/interaction_screen.dart b/lib/ui_screen/interactionform/interaction_screen.dart index 2ea1517..c8e7bff 100644 --- a/lib/ui_screen/interactionform/interaction_screen.dart +++ b/lib/ui_screen/interactionform/interaction_screen.dart @@ -1,5 +1,6 @@ import 'dart:convert'; import 'dart:io'; +import 'dart:js_util'; import 'package:discover_module/constants.dart'; import 'package:discover_module/ui_screen/add_event/add_hcp.dart'; @@ -10,6 +11,7 @@ import 'package:discover_module/ui_screen/interactionform/widget/custombutton.da import 'package:discover_module/ui_screen/interactionform/widget/customrangeslider.dart'; import 'package:discover_module/ui_screen/interactionform/widget/interatciontextfield.dart'; import 'package:discover_module/ui_screen/interactionform/widget/responsive_ext.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; @@ -67,313 +69,320 @@ class _InteractionScreenState extends State { FocusScope.of(context).requestFocus(FocusNode()); }, child: OrientationBuilder(builder: (context, orientation) { - return Scaffold( - //resizeToAvoidBottomInset: false, - appBar: AppBar( - title: const FittedBox( - fit: BoxFit.scaleDown, - child: Text( - 'Record New Interaction', - style: TextStyle( - // fontSize: isTablet ? 22 : 14, color: Colors.white - // fontSize: 20, - color: Colors.white), + return SafeArea( + child: Scaffold( + //resizeToAvoidBottomInset: false, + appBar: AppBar( + title: const FittedBox( + fit: BoxFit.scaleDown, + child: Text( + 'Record New Interaction', + style: TextStyle( + // fontSize: isTablet ? 22 : 14, color: Colors.white + // fontSize: 20, + color: Colors.white), + ), + ), + // backgroundColor: const Color(0xFF2b9af3), + automaticallyImplyLeading: false, + actions: [saveActions(provider)], + leading: InkWell( + onTap: () { + Navigator.pop(context); + }, + child: const Icon( + Icons.arrow_back_ios, + color: Colors.white, + ), ), ), - // backgroundColor: const Color(0xFF2b9af3), - automaticallyImplyLeading: false, - actions: [saveActions(provider)], - leading: InkWell( - onTap: () { - Navigator.pop(context); - }, - child: const Icon( - Icons.arrow_back_ios, - color: Colors.white, - ), - ), - ), - body: Column( - children: [ - Expanded( - child: ListView.builder( - itemCount: provider.interactionReponseList.length, - padding: EdgeInsets.zero, - cacheExtent: double.parse( - provider.interactionReponseList.length.toString()), - itemBuilder: (context, index) { - var item = provider.interactionReponseList[index]; - sectionList = item.sectionList; - return ExpansionTile( - maintainState: true, - // backgroundColor: Colors.white, - // collapsedBackgroundColor: Color(0xFF2b9af3), - initiallyExpanded: true, - title: Stack( - alignment: AlignmentDirectional.center, - children: [ - Container( - // height: double.infinity, - width: double.infinity, - padding: const EdgeInsets.all(8.0), - decoration: BoxDecoration( - // color: Color(0xFF2b9af3), - color: Constants.k2color, - ), - child: Text( - item.sectionName, - style: const TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - // fontSize: isTablet ? 18 : 14 - ), - )), - item.multiple - ? Align( - alignment: Alignment.centerRight, - child: IconButton( - onPressed: () { - if (item.sectionName == "HCP") { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - Addhcp())); - - provider.getSectionItem( - item.sectionName); - // print("index is $listIndex"); - setState(() { - // for (var item - }); - } else { - provider.getSectionItem( - item.sectionName); - // print("index is $listIndex"); - setState(() { - // for (var item - }); - } - }, - icon: const Icon( - Icons.add_circle_outline, - size: 30, - color: Colors.white, - ), - ), - ) - : const SizedBox.shrink() - ]), - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, + body: Column( + children: [ + Expanded( + child: ListView.builder( + itemCount: provider.interactionReponseList.length, + padding: EdgeInsets.zero, + cacheExtent: double.parse( + provider.interactionReponseList.length.toString()), + itemBuilder: (context, index) { + var item = provider.interactionReponseList[index]; + sectionList = item.sectionList; + return ExpansionTile( + maintainState: true, + // backgroundColor: Colors.white, + // collapsedBackgroundColor: Color(0xFF2b9af3), + initiallyExpanded: true, + title: Stack( + alignment: AlignmentDirectional.center, children: [ - // const SizedBox( - // height: 20, - // ), - - Padding( - padding: isTablet - ? const EdgeInsets.only(left: 14.0) - : const EdgeInsets.only( - left: 12.0, right: 12.0), - child: GridView.count( - physics: - const NeverScrollableScrollPhysics(), - crossAxisCount: context.responsive( - 1, - sm: 1, // small - md: 2, // medium - lg: sectionList.length == 1 - ? 1 - : 3, // large - xl: 3, // extra large screen + Container( + // height: double.infinity, + width: double.infinity, + padding: const EdgeInsets.all(8.0), + decoration: BoxDecoration( + // color: Color(0xFF2b9af3), + color: Constants.k2color, ), - // crossAxisCount: - // orientation == Orientation.portrait - // ? 1 - // : 3, - // crossAxisCount: (MediaQuery.of(context) - // .orientation == - // Orientation.landscape) - // ? 3 - // : 1, + child: Text( + item.sectionName, + style: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + // fontSize: isTablet ? 18 : 14 + ), + )), + item.multiple + ? Align( + alignment: Alignment.centerRight, + child: IconButton( + onPressed: () { + if (item.sectionName == "HCP") { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + Addhcp())); - mainAxisSpacing: - sectionList.length == 1 || !isTablet + provider.getSectionItem( + item.sectionName, + ); + // print("index is $listIndex"); + setState(() { + // for (var item + }); + } else { + provider.getSectionItem( + item.sectionName, + ); + // print("index is $listIndex"); + setState(() {}); + } + }, + icon: const Icon( + Icons.add_circle_outline, + size: 30, + color: Colors.white, + ), + ), + ) + : const SizedBox.shrink() + ]), + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Padding( + padding: isTablet + ? const EdgeInsets.only(left: 14.0) + : const EdgeInsets.only( + left: 12.0, right: 12.0), + child: GridView.count( + physics: + const NeverScrollableScrollPhysics(), + crossAxisCount: + context.responsive( + 1, + sm: 1, // small + md: 1, // medium + lg: sectionList.length == 1 ? 1 - : 3.5, - // mainAxisSpacing: - // orientation == Orientation.portrait - // ? 1 - // : 3, - shrinkWrap: true, - padding: EdgeInsets.zero, - // childAspectRatio: MediaQuery.of(context) - // .size - // .aspectRatio * - // 0.10, - // childAspectRatio: - // sectionList.length == 1 - // ? orientation == - // Orientation.landscape - // ? 10 - // : 3.8 - // : 2.4, - // childAspectRatio: - // sectionList.length == 1 - // ? orientation == - // Orientation.landscape - // ? 10 - // : 3.8 - // : isTablet - // ? 2.8 - // : 3.8, + : 3, // large + xl: 3, // extra large screen + ), + // crossAxisCount: + // orientation == Orientation.portrait + // ? 1 + // : 3, + // crossAxisCount: (MediaQuery.of(context) + // .orientation == + // Orientation.landscape) + // ? 3 + // : 1, - childAspectRatio: - sectionList.length == 1 - ? orientation == - Orientation.landscape - ? 10 - : 4.8 - : isTablet - ? 2.8 - : 3.0, - // /:2.4, - // childAspectRatio: 3.8, + mainAxisSpacing: + sectionList.length == 1 || + !isTablet + ? 1 + : 3.5, + // mainAxisSpacing: + // orientation == Orientation.portrait + // ? 1 + // : 3, + shrinkWrap: true, + padding: EdgeInsets.zero, + // childAspectRatio: MediaQuery.of(context) + // .size + // .aspectRatio * + // 0.10, + // childAspectRatio: + // sectionList.length == 1 + // ? orientation == + // Orientation.landscape + // ? 10 + // : 3.8 + // : 2.4, + // childAspectRatio: + // sectionList.length == 1 + // ? orientation == + // Orientation.landscape + // ? 10 + // : 3.8 + // : isTablet + // ? 2.8 + // : 3.8, - children: List.generate( - sectionList.length, - (i) { - SectionList sectionItem = - sectionList[i]; - dropdownvalue = sectionItem - .widget == - InteractionWidget.DROPDOWN - ? sectionItem.value ?? "Select" - : ' '; - List 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) - : []; + childAspectRatio: + sectionList.length == 1 + ? orientation == + Orientation.landscape + ? 10 + : 4.8 + : isTablet + ? 2.8 + : 3.0, + // /:2.4, + // childAspectRatio: 3.8, - return Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - sectionItem.widget == - InteractionWidget - .BUTTON && - sectionItem.input == - 'add' - ? const SizedBox.shrink() - : Padding( - padding: - const EdgeInsets - .only( - left: 8.0, - right: 8.0), - child: FittedBox( - fit: BoxFit.scaleDown, - child: Text( - sectionItem - .validation! - .isRequired - ? '${sectionItem.name}:*' - : '${sectionItem.name}:', - style: TextStyle( - color: Colors - .orange - .shade800, - fontSize: 18.0, - // fontSize: isTablet - // ? 18 - // : 12, + children: List.generate( + sectionList.length, + (i) { + 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) + : []; + + return Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + sectionItem.widget == + InteractionWidget + .BUTTON && + sectionItem.input == + 'add' + ? const SizedBox.shrink() + : Padding( + padding: + const EdgeInsets + .only( + left: 8.0, + right: 8.0), + child: FittedBox( + fit: BoxFit + .scaleDown, + child: Text( + sectionItem + .validation! + .isRequired + ? '${sectionItem.name}:*' + : '${sectionItem.name}:', + style: TextStyle( + color: Colors + .orange + .shade800, + fontSize: 18.0, + // fontSize: isTablet + // ? 18 + // : 12, + ), ), ), ), - ), - // SizedBox( - // height: isTablet ? 15 : 5, - // ), - returnWidget( - sectionItem: sectionItem, - item: item, - provider: provider, - list: list, - gridIndex: i, - listIndex: index, - widgetData: - sectionItem.widget!, - multiple: false), - // SizedBox( - // height: isTablet ? 15 : 5, - // ), + // SizedBox( + // height: isTablet ? 15 : 5, + // ), + returnWidget( + sectionItem: sectionItem, + item: item, + provider: provider, + list: list, + gridIndex: i, + listIndex: index, + widgetData: + sectionItem.widget!, + multiple: false), + // SizedBox( + // height: isTablet ? 15 : 5, + // ), - // sectionItem.depid == 'pooja' - // ? Text( - // sectionItem.validation! - // .isRequired - // ? '${sectionItem.depid}:*' - // : '${sectionItem.depid}:', - // style: TextStyle( - // color: Colors - // .orange.shade800, - // fontSize: isTablet - // ? 18 - // : 12, - // ), - // ) - // : const SizedBox.shrink(), - ], - ); - }, + // sectionItem.depid == 'pooja' + // ? Text( + // sectionItem.validation! + // .isRequired + // ? '${sectionItem.depid}:*' + // : '${sectionItem.depid}:', + // style: TextStyle( + // color: Colors + // .orange.shade800, + // fontSize: isTablet + // ? 18 + // : 12, + // ), + // ) + // : const SizedBox.shrink(), + ], + ); + }, + ), ), ), - ), - // SizedBox( - // height: isTablet ? 15 : 5, - // ), - item.multiple - ? gridViewWidget( - provider, - item.sectionName, - item.multipleList ?? [], - orientation, - item, - index) - : const SizedBox.shrink(), - provider.interactionReponseList.length == - index - 1 - ? saveActions(provider) - : const SizedBox.shrink() - //const Spacer(), - ], + // SizedBox( + // height: isTablet ? 15 : 5, + // ), + item.multiple + ? gridViewWidget( + provider, + item.sectionName, + item.multipleList ?? [], + orientation, + item, + index) + : const SizedBox.shrink(), + provider.interactionReponseList.length == + index - 1 + ? saveActions(provider) + : const SizedBox.shrink() + //const Spacer(), + ], + ), ), - ), - ]); - }, + ]); + }, + ), ), - ), - // const Spacer(), - // saveActions(provider), - ], - )); + // const Spacer(), + // saveActions(provider), + ], + )), + ); }), ); }); @@ -474,7 +483,7 @@ class _InteractionScreenState extends State { : sectionItem.input == "textArea" ? Expanded( child: InteractionTextField( - maxchars: int.parse(sectionItem.validation!.chars ?? "0"), + // maxchars: int.parse(sectionItem.validation!.chars ?? "0"), controller: sectionItem.controller!, labelText: sectionItem.name, // maxlines: 8, @@ -510,6 +519,8 @@ class _InteractionScreenState extends State { labelText: sectionItem.name, onChanged: (val) { sectionItem.selectedValue = []; + // sectionItem.selectedValue!.clear(); + provider.setTextValue(val, sectionItem, multiple); }, ), @@ -620,13 +631,53 @@ class _InteractionScreenState extends State { child: CustomButton( backgroundColor: Colors.green.shade500, onPressed: () async { - if (textFieldsValidation(provider).isEmpty) { - String record = - await provider.saveJsonObject(context, widget.form); - showAlertDialog(context, record); + // if (textFieldsValidation(provider).isEmpty) { + // print("Form_issss: ${widget.form}"); + // String record = + // await provider.saveJsonObject(context, widget.form); + // showAlertDialog(context, record); + // } else { + // _displaySnackBar(textFieldsValidation(provider)); + // } + + ////////////////////////////////////////////////actual code/////////////////// + /// + // String record = + // await provider.saveJsonObject(context, widget.form); + // showAlertDialog(context, record); + + ///Cnahging Code////////////// + /// + /// + ///validateTextFields + + // if (provider.validateTextFields()) { + // print("Form_issss: ${widget.form}"); + String record = + await provider.saveJsonObject(context, widget.form); + // showAlertDialog(context, record); + + // for (int i = 0; i < sectionList.length; i++) { + // SectionList sectionItem = sectionList[i]; + + // print( + // "ValidationMandotary_isss: ${sectionItem.validation!.isRequired}"); + // } + + print("Validation_isss: ${provider.isLoading}"); + + if (provider.isLoading == false) { + print("Validation_false"); + showAlertDialog(context, "Please fill all the fields"); } else { - _displaySnackBar(textFieldsValidation(provider)); + showAlertDialog(context, "Form $record Saved Successfully!"); + print("Validation_True"); } + + // print("Interaction_Type:"); + // } else { + // _displaySnackBar(textFieldsValidation(provider)); + // } }, textColor: Colors.white, title: "Save", @@ -1052,6 +1103,200 @@ class _InteractionScreenState extends State { ); } + // Widget gridViewWidget( + // InteractionProvider provider, + // String sectionName, + // List sectionList, + // Orientation orientation, + // FormFieldData item, + // int listIndex) { + // print("ListInex: $listIndex"); + // print("sectionName: $sectionName"); + // print("sectionName: $sectionName"); + + // print("gridsectionlost_is: $sectionList"); + // print("gridsectionlostleangth_is: ${sectionList.length}"); + + // List pooja = sectionList; + + // print("Pooja_isss: $pooja"); + + // return Padding( + // padding: isTablet + // ? const EdgeInsets.only(left: 8.0) + // : const EdgeInsets.only(left: 12.0, right: 12.0), + // child: GridView.count( + // physics: const NeverScrollableScrollPhysics(), + // // crossAxisCount: context.responsive( + // // 1, // default + // // sm: 1, // small + // // md: 1, // medium + // // lg: sectionList.length == 1 ? 1 : 4, // large + // // xl: 5, // extra large screen + // // ), + // crossAxisCount: context.responsive( + // 1, + // sm: 1, // small + // md: 1, // medium + // lg: sectionList.length == 1 + // ? 1 + // : (sectionList.length >= 1 ? 3 : 3), // large + // xl: 3, // extra large screen + // ), + // 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, + // // childAspectRatio: sectionList.length == 1 + // // ? orientation == Orientation.landscape + // // ? 10 + // // : 4.8 + // // : isTablet + // // ? 2.8 + // // : 3.0, + // childAspectRatio: MediaQuery.of(context).size.width / + // (MediaQuery.of(context).size.height / 3), + // children: List.generate( + // sectionList.length, + // (i) { + // print(sectionList); + // SectionList sectionItem = sectionList[i]; + // dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN + // ? sectionItem.value ?? "Select" + // : ' '; + // List 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 Wrap(children: [ + // Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // sectionItem.widget == InteractionWidget.BUTTON && + // sectionItem.input == 'add' || + // sectionItem.input == 'deletebtn' + // ? const SizedBox.shrink() + // : Text( + // '${sectionItem.name}:*', + // style: TextStyle( + // color: Colors.orange.shade800, + // fontSize: isTablet ? 18 : 14, + // ), + // ), + // // const SizedBox( + // // height: 15, + // // ), + // sectionItem.widget == InteractionWidget.BUTTON + // ? sectionItem.input == 'chooseFile' + // ? Row( + // children: [ + // 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( + // 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), + // ], + // ), + // ]); + // }, + // ), + // ), + // ); + // } +//////////////////////////////////////Poojaaaa///////////////////// + /// + /// + Widget gridViewWidget( InteractionProvider provider, String sectionName, @@ -1059,159 +1304,262 @@ class _InteractionScreenState extends State { Orientation orientation, FormFieldData item, int listIndex) { - return Padding( - padding: isTablet - ? const EdgeInsets.only(left: 8.0) - : const EdgeInsets.only(left: 12.0, right: 12.0), - child: GridView.count( - physics: const NeverScrollableScrollPhysics(), - crossAxisCount: context.responsive( - 1, // default - sm: 1, // small - md: 1, // medium - lg: sectionList.length == 1 ? 1 : 4, // large - xl: 5, // extra large screen - ), - 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, - children: List.generate( - sectionList.length, - (i) { - print(sectionList); - SectionList sectionItem = sectionList[i]; - dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN - ? sectionItem.value ?? "Select" - : ' '; - List 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) - : []; + print("ListInex: $listIndex"); + print("sectionName: $sectionName"); + print("sectionName: $sectionName"); - return Wrap(children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - sectionItem.widget == InteractionWidget.BUTTON && - sectionItem.input == 'add' || - sectionItem.input == 'deletebtn' - ? const SizedBox.shrink() - : Text( - '${sectionItem.name}:*', - style: TextStyle( - color: Colors.orange.shade800, - fontSize: isTablet ? 18 : 14, - ), - ), - // const SizedBox( - // height: 15, - // ), - sectionItem.widget == InteractionWidget.BUTTON - ? sectionItem.input == 'chooseFile' - ? Row( - children: [ - CustomButton( - backgroundColor: const Color.fromARGB( - 255, 233, 229, 229), - onPressed: () async { - sectionItem.selectedValue = []; - sectionItem.extension = []; - sectionItem.fileName = []; - await getEncodedFile(sectionItem); + print("gridsectionlost_is: $sectionList"); + print("gridsectionlostleangth_is: ${sectionList.length}"); - 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); + List pooja = sectionList; - setState(() {}); - }, - icon: const Icon( - Icons.cancel, - size: 30, - color: Color.fromARGB(255, 8, 39, 92), + print("Pooja_isss: $pooja"); + print("Pooja_leangth_isss: ${pooja.length}"); + + ////////////////////////////////////mycode/////////////////////////// + /// + /// + // final provider = context.read(); + // var yourVariable = provider.ge; + // print("ProviderLength: $yourVariable"); + // print("ProviderLength: ${yourVariable.length}"); + + List> convertedArray = []; + print("Provider_leangth: ${item.sectionList.length}"); + + for (int i = 0; i < pooja.length; i += item.sectionList.length + 1) { + print("poojaleangth: $pooja"); + + convertedArray.add(pooja.sublist(i, i + item.sectionList.length + 1)); + } + print("ConvertedArray.leangth: $convertedArray"); + print("ConvertedArray.leangth: ${convertedArray.length}"); + + return + // Container( + // decoration: BoxDecoration( + // border: Border.all( + // width: 0, + // ), + // ), + // child: + DecoratedBox( + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(10.0), + ), + child: Padding( + padding: isTablet + ? const EdgeInsets.only(left: 8.0) + : const EdgeInsets.only(left: 12.0, right: 12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + for (var i = 0; i < convertedArray.length; i++) + GridView.builder( + physics: const NeverScrollableScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: context.responsive( + 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), + ), + shrinkWrap: true, + padding: EdgeInsets.zero, + itemCount: convertedArray[i].length, + itemBuilder: (context, index) { + // SectionList sectionItem = + // convertedArray.expand((list) => list).toList()[index]; + + // List.generate( + // sectionList.length, + // (i) { + // print(sectionList); + // // SectionList sectionItem = sectionList[i]; + // SectionList sectionItem = + // convertedArray.expand((list) => list).toList()[index]; + // dropdownvalue = + // sectionItem.widget == InteractionWidget.DROPDOWN + // ? sectionItem.value ?? "Select" + // : ' '; + // List 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 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 Wrap(children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + sectionItem.widget == InteractionWidget.BUTTON && + sectionItem.input == 'add' || + sectionItem.input == 'deletebtn' + ? const SizedBox.shrink() + : Padding( + padding: const EdgeInsets.only( + left: 8.0, right: 8.0), + child: FittedBox( + fit: BoxFit.scaleDown, + child: Text( + '${sectionItem.name}:*', + style: TextStyle( + color: Colors.orange.shade800, + fontSize: 18), + ), + ), ), - ) - : 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); + // const SizedBox( + // height: 15, + // ), + sectionItem.widget == InteractionWidget.BUTTON + ? sectionItem.input == 'chooseFile' + ? Row( + children: [ + CustomButton( + backgroundColor: + const Color.fromARGB( + 255, 233, 229, 229), + onPressed: () async { + sectionItem.selectedValue = []; + sectionItem.extension = []; + sectionItem.fileName = []; + await getEncodedFile( + sectionItem); - setState(() {}); - }, - // width: 80, - // height: 30, + 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); - height: 40, + 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); - // 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), - ], - ), - ]); - }, + 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), + ], + ), + ), + ]); + }) + ], ), ), ); + //); } String fieldsValidation(InteractionProvider provider) { @@ -1322,7 +1670,7 @@ class _InteractionScreenState extends State { // set up the AlertDialog AlertDialog alert = AlertDialog( title: const Text(""), - content: Text("Form $record Saved Successfully!"), + content: Text(record), actions: [ cancelButton, ], @@ -1337,3 +1685,3569 @@ class _InteractionScreenState extends State { ); } } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// import 'dart:convert'; +// import 'dart:io'; +// import 'dart:js_util'; + +// import 'package:discover_module/constants.dart'; +// import 'package:discover_module/ui_screen/add_event/add_hcp.dart'; +// import 'package:discover_module/ui_screen/interactionform/interactionprovider.dart'; +// import 'package:discover_module/ui_screen/interactionform/model/interaction_data.dart'; +// import 'package:discover_module/ui_screen/interactionform/util.dart'; +// import 'package:discover_module/ui_screen/interactionform/widget/custombutton.dart'; +// import 'package:discover_module/ui_screen/interactionform/widget/customrangeslider.dart'; +// import 'package:discover_module/ui_screen/interactionform/widget/interatciontextfield.dart'; +// import 'package:discover_module/ui_screen/interactionform/widget/responsive_ext.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter/services.dart'; +// import 'package:flutter/widgets.dart'; +// import 'package:intl/intl.dart'; +// import 'package:path_provider/path_provider.dart'; +// import 'package:provider/provider.dart'; +// import 'package:dropdown_button2/dropdown_button2.dart'; + +// import 'package:file_picker/file_picker.dart'; +// // import 'package:pwa_ios/widgets/responsive_ext.dart'; +// import 'package:permission_handler/permission_handler.dart'; +// import 'package:path/path.dart' as p; + +// class InteractionScreen extends StatefulWidget { +// int index; +// String form; +// InteractionScreen({super.key, required this.index, required this.form}); + +// @override +// State createState() => _InteractionScreenState(); +// } + +// class _InteractionScreenState extends State { +// List interactionReponseList = []; +// List sectionList = []; +// List textEditingControllerList = []; +// int textfieldIndex = 0; +// String dropdownvalue = 'Select value'; +// String? fileName; +// final TextEditingController textEditingController = TextEditingController(); +// @override +// void initState() { +// WidgetsBinding.instance.addPostFrameCallback((timeStamp) { +// // if (mytimer!.isActive) { +// // cancelTimer(); +// // } +// init(); +// }); + +// super.initState(); +// } + +// init() async { +// await Provider.of(context, listen: false) +// .init(widget.index); +// setState(() {}); +// } + +// @override +// Widget build(BuildContext context) { +// return Consumer( +// builder: (BuildContext context, provider, Widget? child) { +// return GestureDetector( +// onTap: () { +// FocusScope.of(context).requestFocus(FocusNode()); +// }, +// child: OrientationBuilder(builder: (context, orientation) { +// return Scaffold( +// //resizeToAvoidBottomInset: false, +// appBar: AppBar( +// title: const FittedBox( +// fit: BoxFit.scaleDown, +// child: Text( +// 'Record New Interaction', +// style: TextStyle( +// // fontSize: isTablet ? 22 : 14, color: Colors.white +// // fontSize: 20, +// color: Colors.white), +// ), +// ), +// // backgroundColor: const Color(0xFF2b9af3), +// automaticallyImplyLeading: false, +// actions: [saveActions(provider)], +// leading: InkWell( +// onTap: () { +// Navigator.pop(context); +// }, +// child: const Icon( +// Icons.arrow_back_ios, +// color: Colors.white, +// ), +// ), +// ), +// body: Column( +// children: [ +// Expanded( +// child: ListView.builder( +// itemCount: provider.interactionReponseList.length, +// padding: EdgeInsets.zero, +// cacheExtent: double.parse( +// provider.interactionReponseList.length.toString()), +// itemBuilder: (context, index) { +// var item = provider.interactionReponseList[index]; +// sectionList = item.sectionList; +// return ExpansionTile( +// maintainState: true, +// // backgroundColor: Colors.white, +// // collapsedBackgroundColor: Color(0xFF2b9af3), +// initiallyExpanded: true, +// title: Stack( +// alignment: AlignmentDirectional.center, +// children: [ +// Container( +// // height: double.infinity, +// width: double.infinity, +// padding: const EdgeInsets.all(8.0), +// decoration: BoxDecoration( +// // color: Color(0xFF2b9af3), +// color: Constants.k2color, +// ), +// child: Text( +// item.sectionName, +// style: const TextStyle( +// color: Colors.white, +// fontWeight: FontWeight.bold, +// // fontSize: isTablet ? 18 : 14 +// ), +// )), +// item.multiple +// ? Align( +// alignment: Alignment.centerRight, +// child: IconButton( +// onPressed: () { +// if (item.sectionName == "HCP") { +// Navigator.push( +// context, +// MaterialPageRoute( +// builder: (context) => +// Addhcp())); + +// provider.getSectionItem( +// item.sectionName, +// item.sectionList.length); +// // print("index is $listIndex"); +// setState(() { +// // for (var item +// }); +// } else { +// provider.getSectionItem( +// item.sectionName, +// item.sectionList.length); +// // print("index is $listIndex"); +// setState(() { +// // provider.getSectionItem( +// // item.sectionName, +// // item.sectionList.length); + +// // item.sectionList.length = +// // item.sectionList.length; +// }); +// } +// }, +// icon: const Icon( +// Icons.add_circle_outline, +// size: 30, +// color: Colors.white, +// ), +// ), +// ) +// : const SizedBox.shrink() +// ]), +// children: [ +// Padding( +// padding: const EdgeInsets.all(8.0), +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.center, +// children: [ +// // const SizedBox( +// // height: 20, +// // ), + +// Padding( +// padding: isTablet +// ? const EdgeInsets.only(left: 14.0) +// : const EdgeInsets.only( +// left: 12.0, right: 12.0), +// child: GridView.count( +// physics: +// const NeverScrollableScrollPhysics(), +// crossAxisCount: context.responsive( +// 1, +// sm: 1, // small +// md: 1, // medium +// lg: sectionList.length == 1 +// ? 1 +// : 3, // large +// xl: 3, // extra large screen +// ), +// // crossAxisCount: +// // orientation == Orientation.portrait +// // ? 1 +// // : 3, +// // crossAxisCount: (MediaQuery.of(context) +// // .orientation == +// // Orientation.landscape) +// // ? 3 +// // : 1, + +// mainAxisSpacing: +// sectionList.length == 1 || !isTablet +// ? 1 +// : 3.5, +// // mainAxisSpacing: +// // orientation == Orientation.portrait +// // ? 1 +// // : 3, +// shrinkWrap: true, +// padding: EdgeInsets.zero, +// // childAspectRatio: MediaQuery.of(context) +// // .size +// // .aspectRatio * +// // 0.10, +// // childAspectRatio: +// // sectionList.length == 1 +// // ? orientation == +// // Orientation.landscape +// // ? 10 +// // : 3.8 +// // : 2.4, +// // childAspectRatio: +// // sectionList.length == 1 +// // ? orientation == +// // Orientation.landscape +// // ? 10 +// // : 3.8 +// // : isTablet +// // ? 2.8 +// // : 3.8, + +// childAspectRatio: +// sectionList.length == 1 +// ? orientation == +// Orientation.landscape +// ? 10 +// : 4.8 +// : isTablet +// ? 2.8 +// : 3.0, +// // /:2.4, +// // childAspectRatio: 3.8, + +// children: List.generate( +// sectionList.length, +// (i) { +// SectionList sectionItem = +// sectionList[i]; +// dropdownvalue = sectionItem +// .widget == +// InteractionWidget.DROPDOWN +// ? sectionItem.value ?? "Select" +// : ' '; +// List 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 Column( +// crossAxisAlignment: +// CrossAxisAlignment.start, +// children: [ +// sectionItem.widget == +// InteractionWidget +// .BUTTON && +// sectionItem.input == +// 'add' +// ? const SizedBox.shrink() +// : Padding( +// padding: +// const EdgeInsets +// .only( +// left: 8.0, +// right: 8.0), +// child: FittedBox( +// fit: BoxFit.scaleDown, +// child: Text( +// sectionItem +// .validation! +// .isRequired +// ? '${sectionItem.name}:*' +// : '${sectionItem.name}:', +// style: TextStyle( +// color: Colors +// .orange +// .shade800, +// fontSize: 18.0, +// // fontSize: isTablet +// // ? 18 +// // : 12, +// ), +// ), +// ), +// ), +// // SizedBox( +// // height: isTablet ? 15 : 5, +// // ), +// returnWidget( +// sectionItem: sectionItem, +// item: item, +// provider: provider, +// list: list, +// gridIndex: i, +// listIndex: index, +// widgetData: +// sectionItem.widget!, +// multiple: false), +// // SizedBox( +// // height: isTablet ? 15 : 5, +// // ), + +// // sectionItem.depid == 'pooja' +// // ? Text( +// // sectionItem.validation! +// // .isRequired +// // ? '${sectionItem.depid}:*' +// // : '${sectionItem.depid}:', +// // style: TextStyle( +// // color: Colors +// // .orange.shade800, +// // fontSize: isTablet +// // ? 18 +// // : 12, +// // ), +// // ) +// // : const SizedBox.shrink(), +// ], +// ); +// }, +// ), +// ), +// ), +// // SizedBox( +// // height: isTablet ? 15 : 5, +// // ), +// item.multiple +// ? gridViewWidget( +// provider, +// item.sectionName, +// item.multipleList ?? [], +// orientation, +// item, +// index) +// : const SizedBox.shrink(), +// provider.interactionReponseList.length == +// index - 1 +// ? saveActions(provider) +// : const SizedBox.shrink() +// //const Spacer(), +// ], +// ), +// ), +// ]); +// }, +// ), +// ), +// // const Spacer(), +// // saveActions(provider), +// ], +// )); +// }), +// ); +// }); +// } + +// Widget returnWidget({ +// required SectionList sectionItem, +// required FormFieldData item, +// required InteractionProvider provider, +// required List list, +// required int gridIndex, +// required int listIndex, +// required InteractionWidget widgetData, +// required bool multiple, +// }) { +// switch (widgetData) { +// case InteractionWidget.CHECKBOX: +// return (sectionItem.inputList!.length >= 5) +// ? customMultiselectDropdown( +// sectionItem, provider, sectionItem.inputList!, multiple) +// : buildCheckbox(sectionItem, item.sectionName, provider, multiple); + +// case InteractionWidget.AUTOCOMPLETE: +// return customAutoCompletedropdown( +// sectionItem, provider, list, multiple); + +// case InteractionWidget.MULTISELECT: +// return customMultiselectDropdown(sectionItem, provider, list, multiple); + +// case InteractionWidget.RADIO: +// return (sectionItem.inputList!.length >= 5) +// ? customdropdown( +// sectionItem, provider, sectionItem.inputList!, multiple) +// : buildRadio(sectionItem, provider); + +// case InteractionWidget.LABEL: +// return Text(sectionItem.input!); + +// case InteractionWidget.RANGESLIDER: +// return CustomRangeSlider( +// max: double.parse(sectionItem.max!), +// min: double.parse(sectionItem.min!), +// sliderPos: sectionItem.selectedValue!.isNotEmpty +// ? double.parse(sectionItem.selectedValue!.last.toString()) +// : double.parse(sectionItem.min!), +// onChanged: (val) { +// setState(() { +// sectionItem.selectedValue = []; +// sectionItem.selectedId = val.toString(); +// sectionItem.selectedValue!.add(val.toInt()); +// }); +// }, +// ); + +// case InteractionWidget.BUTTON: +// return sectionItem.input == 'add' +// ? const Offstage( +// offstage: true, +// child: Text("Visible"), +// ) +// : Row( +// children: [ +// 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!.length > 1 +// ? 'Files uploaded' +// : "File Uploaded" +// : 'No file uploaded', +// style: TextStyle( +// color: sectionItem.selectedValue!.isNotEmpty +// ? Colors.green +// : Colors.red), +// ), +// ], +// ); + +// case InteractionWidget.TEXT: +// return sectionItem.input == 'Date' +// ? buildDateWidget(sectionItem) +// : sectionItem.input == "textArea" +// ? Expanded( +// child: InteractionTextField( +// maxchars: int.parse(sectionItem.validation!.chars ?? "0"), +// controller: sectionItem.controller!, +// labelText: sectionItem.name, +// // maxlines: 8, +// //minlines: 4, +// onChanged: (val) { +// sectionItem.selectedValue = []; +// setState(() {}); + +// sectionItem.selectedValue!.add(val); +// }, +// ), +// ) +// ////Poojaaaaa +// : sectionItem.input == "text1" +// ? Text( +// sectionItem.depid!, +// style: TextStyle( +// fontSize: 18.0, fontWeight: FontWeight.normal), +// ) +// : Padding( +// padding: const EdgeInsets.only(left: 8.0, right: 8.0), +// child: SizedBox( +// // width: +// // isTablet ? 200 : MediaQuery.of(context).size.width, +// //height: isTablet ? 50 : 40, +// width: MediaQuery.of(context).size.width, +// 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 = []; +// provider.setTextValue(val, sectionItem, multiple); +// }, +// ), +// ), +// ); +// case InteractionWidget.DROPDOWN: +// return customdropdown(sectionItem, provider, list, multiple); +// } +// } + +// Future requestPermission(Permission permission) async { +// final status = await permission.request(); + +// setState(() { +// print(status); +// // _permissionStatus = status; +// // print(_permissionStatus); +// }); +// } + +// Widget buildDateWidget(SectionList sectionItem) { +// return Padding( +// padding: const EdgeInsets.only(left: 8.0, right: 8.0), +// child: SizedBox( +// // width: isTablet ? 200 : MediaQuery.of(context).size.width, +// // height: isTablet ? 50 : 40, +// width: MediaQuery.of(context).size.width, +// child: TextField( +// controller: +// sectionItem.controller, //editing controller of this TextField +// decoration: InputDecoration( +// // border: OutlineInputBorder(), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(10.0), +// ), +// labelStyle: const TextStyle(fontSize: 16), +// suffixIcon: const Icon(Icons.calendar_today), //icon of text field +// labelText: "Enter Date" //label text of field +// ), +// readOnly: true, //set it true, so that user will not able to edit text +// onTap: () async { +// DateTime? pickedDate = await showDatePicker( +// context: context, +// initialDate: DateTime.now(), +// firstDate: DateTime( +// 2000), //DateTime.now() - not to allow to choose before today. +// lastDate: DateTime(2101)); + +// if (pickedDate != null) { +// print( +// pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000 +// String formattedDate = +// DateFormat('yyyy-MM-dd').format(pickedDate); +// print( +// formattedDate); //formatted date output using intl package => 2021-03-16 +// //you can implement different kind of Date Format here according to your requirement + +// setState(() { +// sectionItem.controller!.text = formattedDate; +// sectionItem.selectedValue = []; +// sectionItem.selectedValue! +// .add(formattedDate); //set output date to TextField value. +// }); +// } else { +// print("Date is not selected"); +// } +// }, +// ), +// ), +// ); +// } + +// Widget saveActions(InteractionProvider provider) { +// return Align( +// alignment: Alignment.centerRight, +// child: Row( +// mainAxisAlignment: MainAxisAlignment.spaceEvenly, +// children: [ +// Padding( +// padding: const EdgeInsets.all(4.0), +// child: CustomButton( +// backgroundColor: Colors.red.shade800, +// onPressed: () { +// //showDeleteProfileAlertDialog(context); +// for (var textcontrollers +// in provider.textEditingControllerList) { +// textcontrollers.text = ''; +// } + +// // setState(() { +// // provider.resetAllWidgetsData(); +// // }); +// }, +// textColor: Colors.white, +// title: "Reset", +// // height: 40, +// // width: isTablet ? 100 : 80, +// height: MediaQuery.of(context).size.height * 0.2, + +// fontsize: isTablet ? 15 : 10.2, +// ), +// ), +// SizedBox( +// width: isTablet ? 20 : 4, +// ), +// Padding( +// padding: const EdgeInsets.all(4.0), +// child: CustomButton( +// backgroundColor: Colors.green.shade500, +// onPressed: () async { +// // if (textFieldsValidation(provider).isEmpty) { +// // print("Form_issss: ${widget.form}"); +// String record = +// await provider.saveJsonObject(context, widget.form); +// showAlertDialog(context, record); +// // } else { +// // _displaySnackBar(textFieldsValidation(provider)); +// //} +// }, +// textColor: Colors.white, +// title: "Save", +// // height: 40, +// // width: isTablet ? 100 : 80, +// height: MediaQuery.of(context).size.height * 0.2, + +// // width: MediaQuery.of(context).size.width * 0.1, +// fontsize: isTablet ? 16 : 12, +// ), +// ), +// SizedBox( +// width: isTablet ? 20 : 2, +// ), +// ], +// ), +// ); +// } + +// Widget buildRadio(SectionList sectionItem, InteractionProvider provider) { +// List list = provider.getData2(sectionItem); +// // .map((itemWord) => InputClass.fromJson(itemWord)) +// // .toList(); +// return Padding( +// padding: const EdgeInsets.only(left: 8.0, right: 8.0), +// child: SizedBox( +// // width: isTablet ? 250 : MediaQuery.of(context).size.width, +// width: MediaQuery.of(context).size.width, + +// child: Row( +// children: [ +// for (InputClass value in list) +// Row( +// children: [ +// Radio( +// value: value.name, +// activeColor: Colors.black, +// groupValue: provider.radioValue, +// onChanged: (String? value) { +// setState(() { +// print(value); +// provider.radioValue = value!; +// int index = +// list.indexWhere((element) => element.name == value); +// sectionItem.selectedValue!.add(list[index].id); +// }); +// }, +// ), +// Text(value.name), +// ], +// ), +// ], +// ), +// ), +// ); +// } + +// Widget buildCheckbox(SectionList sectionItem, String sectionName, +// InteractionProvider provider, bool multiple) { +// return Padding( +// padding: const EdgeInsets.only(left: 8.0, right: 8.0), +// child: SizedBox( +// // width: 250, +// width: MediaQuery.of(context).size.width, + +// child: Row( +// children: [ +// for (var value in provider.checkboxlist) +// Row( +// children: [ +// FittedBox( +// fit: BoxFit.scaleDown, +// child: Checkbox( +// value: value.ischecked ?? false, +// activeColor: Colors.black, +// checkColor: Colors.white, +// onChanged: (bool? newvalue) { +// value.ischecked = newvalue!; +// provider.setcheckBoxValue(sectionItem, sectionName, +// newvalue, value.id, multiple); +// //setState(() {}); +// }, +// ), +// ), +// Text(value.name), +// ], +// ), +// ], +// ), +// ), +// ); +// } + +// Widget customdropdown(SectionList sectionItem, InteractionProvider provider, +// List list, bool multiple) { +// // sectionItem.value = ''; + +// if (list.isEmpty) { +// list = []; +// InputClass inputClass = +// InputClass(id: "no value", name: "Select ${sectionItem.name}"); +// list.add(inputClass); +// sectionItem.selectedObject = list[0]; +// } +// // InputClass selectedObj = list[0]; +// return Padding( +// padding: const EdgeInsets.only(left: 8.0, right: 8.0), +// child: SizedBox( +// width: MediaQuery.of(context).size.width, +// // height: isTablet ? 60 : 40, +// child: DropdownButtonFormField2( +// isExpanded: true, +// decoration: InputDecoration( +// // Add Horizontal padding using menuItemStyleData.padding so it matches +// // the menu padding when button's width is not specified. +// contentPadding: const EdgeInsets.symmetric(vertical: 5), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(15), +// ), +// // Add more decoration.. +// ), +// hint: Text( +// 'Select ${sectionItem.name}', +// style: const TextStyle(fontSize: 14), +// ), +// items: list +// .map((item) => DropdownMenuItem( +// value: item, +// child: Text( +// item.name, +// style: const TextStyle( +// fontSize: 14, +// ), +// ), +// )) +// .toList(), +// value: sectionItem.selectedObject ?? list[0], +// // // provider.getDropDownValue(sectionItem.value!, sectionItem, list) +// // sectionItem.value ?? list[0].name, +// validator: (value) { +// if (value == null) { +// return 'Please select ${sectionItem.name}'; +// } +// return null; +// }, +// onChanged: (value) { +// //Do something when selected item is changed. +// sectionItem.selectedObject = value!; +// sectionItem.value = value.id; +// provider.setDropDownValue(value.id, sectionItem, multiple); +// print("selected ${sectionItem.value}"); +// // setState(() {}); +// }, +// onSaved: (value) { +// sectionItem.selectedObject = value!; +// sectionItem.value = value.id; +// provider.setDropDownValue(value.id, sectionItem, multiple); +// // setState(() {}); +// }, +// buttonStyleData: const ButtonStyleData( +// padding: EdgeInsets.only(right: 8), +// ), +// iconStyleData: const IconStyleData( +// icon: Icon( +// Icons.arrow_drop_down, +// color: Colors.black45, +// ), +// iconSize: 24, +// ), +// dropdownStyleData: DropdownStyleData( +// decoration: BoxDecoration( +// borderRadius: BorderRadius.circular(15), +// ), +// ), +// menuItemStyleData: const MenuItemStyleData( +// padding: EdgeInsets.symmetric(horizontal: 16), +// ), +// ), +// ), +// ); +// } + +// Widget customAutoCompletedropdown(SectionList sectionItem, +// InteractionProvider provider, List list, bool multiple) { +// // sectionItem.value = list[0].name; + +// // if (list.isEmpty) { +// // print("list is empty"); +// list = sectionItem.inputList!; +// print("***Autocomplete list ${list[0].name}"); +// //} +// //InputClass selectedObj = list[0]; +// return Padding( +// padding: const EdgeInsets.only(left: 8.0, right: 8.0), +// child: SizedBox( +// // width: isTablet ? 200 : MediaQuery.of(context).size.width, +// // height: isTablet ? 60 : 40, +// width: MediaQuery.of(context).size.width, + +// child: DropdownButtonHideUnderline( +// child: DropdownButtonFormField2( +// isExpanded: true, +// decoration: InputDecoration( +// // Add Horizontal padding using menuItemStyleData.padding so it matches +// // the menu padding when button's width is not specified. +// contentPadding: const EdgeInsets.symmetric(vertical: 5), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(15), +// ), +// // Add more decoration.. +// ), +// hint: Text( +// 'Select Item', +// style: TextStyle( +// fontSize: 14, +// color: Theme.of(context).hintColor, +// ), +// ), +// items: list +// .map((item) => DropdownMenuItem( +// value: item, +// child: Text( +// item.name, +// style: const TextStyle( +// fontSize: 14, +// ), +// ), +// )) +// .toList(), +// value: sectionItem.selectedObject, +// onSaved: (value) { +// sectionItem.selectedObject = value!; +// provider.setAutoCompleteValue(value.id, sectionItem, multiple); +// sectionItem.value = value.name; +// }, +// onChanged: (value) { +// // setState(() { +// sectionItem.selectedObject = value!; +// provider.setAutoCompleteValue(value.id, sectionItem, multiple); +// sectionItem.value = value.name; +// // setState(() {}); +// //}); +// }, + +// buttonStyleData: const ButtonStyleData( +// padding: EdgeInsets.symmetric(horizontal: 16), +// height: 40, +// width: 200, +// ), +// dropdownStyleData: const DropdownStyleData( +// maxHeight: 200, +// ), +// menuItemStyleData: const MenuItemStyleData( +// height: 40, +// ), +// dropdownSearchData: DropdownSearchData( +// searchController: textEditingController, +// searchInnerWidgetHeight: 50, +// searchInnerWidget: Container( +// height: 50, +// padding: const EdgeInsets.only( +// top: 8, +// bottom: 4, +// right: 8, +// left: 8, +// ), +// child: TextFormField( +// expands: true, +// maxLines: null, +// controller: textEditingController, +// decoration: InputDecoration( +// isDense: true, +// contentPadding: const EdgeInsets.symmetric( +// horizontal: 10, +// vertical: 8, +// ), +// hintText: 'Search for an item...', +// hintStyle: const TextStyle(fontSize: 12), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(8), +// ), +// ), +// ), +// ), +// searchMatchFn: (item, searchValue) { +// return item.value!.name.toString().contains(searchValue); +// }, +// ), +// //This to clear the search value when you close the menu +// onMenuStateChange: (isOpen) { +// if (!isOpen) { +// textEditingController.clear(); +// } +// }, +// ), +// ), +// ), +// ); +// } + +// Widget customMultiselectDropdown(SectionList sectionItem, +// InteractionProvider provider, List list, bool multiple) { +// if (list.isEmpty) { +// list = sectionItem.inputList!; +// } +// InputClass selectedObj = list[0]; + +// return Padding( +// padding: const EdgeInsets.only(left: 8.0, right: 8.0), +// child: SizedBox( +// // width: isTablet ? 200 : MediaQuery.of(context).size.width, +// // height: isTablet ? 60 : 40, +// width: MediaQuery.of(context).size.width, +// // height: MediaQuery.of(context).size.height, + +// child: DropdownButtonHideUnderline( +// child: DropdownButtonFormField2( +// isExpanded: true, +// decoration: InputDecoration( +// // Add Horizontal padding using menuItemStyleData.padding so it matches +// // the menu padding when button's width is not specified. +// contentPadding: const EdgeInsets.symmetric(vertical: 5), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(15), +// ), +// // Add more decoration.. +// ), +// hint: Text( +// 'Select Items', +// style: TextStyle( +// fontSize: 14, +// color: Theme.of(context).hintColor, +// ), +// ), +// items: list.map((item) { +// return DropdownMenuItem( +// value: item, +// //disable default onTap to avoid closing menu when selecting an item +// enabled: false, +// child: StatefulBuilder( +// builder: (context, menuSetState) { +// final isSelected = +// sectionItem.selectedValue!.contains(item.name); +// return InkWell( +// onTap: () { +// isSelected +// ? sectionItem.selectedValue!.remove(item.name) +// : sectionItem.selectedValue!.add(item.name); +// //This rebuilds the StatefulWidget to update the button's text +// setState(() {}); +// //This rebuilds the dropdownMenu Widget to update the check mark +// menuSetState(() {}); +// }, +// child: Container( +// height: double.infinity, +// padding: const EdgeInsets.symmetric(horizontal: 16.0), +// child: Row( +// children: [ +// if (isSelected) +// const Icon(Icons.check_box_outlined) +// else +// const Icon(Icons.check_box_outline_blank), +// const SizedBox(width: 16), +// Expanded( +// child: Text( +// item.name, +// style: const TextStyle( +// fontSize: 14, +// ), +// ), +// ), +// ], +// ), +// ), +// ); +// }, +// ), +// ); +// }).toList(), +// //Use last selected item as the current value so if we've limited menu height, it scroll to last item. +// value: selectedObj, +// // ? null +// // : provider.selectedItems.last, +// onChanged: (value) { +// selectedObj = value!; +// provider.setAutoCompleteValue(value.id, sectionItem, multiple); +// sectionItem.value = value.name; +// }, +// onSaved: (value) { +// selectedObj = value!; +// provider.setAutoCompleteValue(value.id, sectionItem, multiple); +// sectionItem.value = value.name; +// }, +// selectedItemBuilder: (context) { +// return list.map( +// (item) { +// return Container( +// alignment: AlignmentDirectional.center, +// child: Text( +// sectionItem.selectedValue!.join(', '), +// style: const TextStyle( +// fontSize: 14, +// overflow: TextOverflow.ellipsis, +// ), +// maxLines: 1, +// ), +// ); +// }, +// ).toList(); +// }, +// buttonStyleData: const ButtonStyleData( +// padding: EdgeInsets.only(left: 16, right: 8), +// height: 40, +// width: 140, +// ), +// menuItemStyleData: const MenuItemStyleData( +// height: 40, +// padding: EdgeInsets.zero, +// ), +// ), +// ), +// ), +// ); +// } + +// // Widget gridViewWidget( +// // InteractionProvider provider, +// // String sectionName, +// // List sectionList, +// // Orientation orientation, +// // FormFieldData item, +// // int listIndex) { +// // print("ListInex: $listIndex"); +// // print("sectionName: $sectionName"); +// // print("sectionName: $sectionName"); + +// // print("gridsectionlost_is: $sectionList"); +// // print("gridsectionlostleangth_is: ${sectionList.length}"); + +// // List pooja = sectionList; + +// // print("Pooja_isss: $pooja"); + +// // return Padding( +// // padding: isTablet +// // ? const EdgeInsets.only(left: 8.0) +// // : const EdgeInsets.only(left: 12.0, right: 12.0), +// // child: GridView.count( +// // physics: const NeverScrollableScrollPhysics(), +// // // crossAxisCount: context.responsive( +// // // 1, // default +// // // sm: 1, // small +// // // md: 1, // medium +// // // lg: sectionList.length == 1 ? 1 : 4, // large +// // // xl: 5, // extra large screen +// // // ), +// // crossAxisCount: context.responsive( +// // 1, +// // sm: 1, // small +// // md: 1, // medium +// // lg: sectionList.length == 1 +// // ? 1 +// // : (sectionList.length >= 1 ? 3 : 3), // large +// // xl: 3, // extra large screen +// // ), +// // 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, +// // // childAspectRatio: sectionList.length == 1 +// // // ? orientation == Orientation.landscape +// // // ? 10 +// // // : 4.8 +// // // : isTablet +// // // ? 2.8 +// // // : 3.0, +// // childAspectRatio: MediaQuery.of(context).size.width / +// // (MediaQuery.of(context).size.height / 3), +// // children: List.generate( +// // sectionList.length, +// // (i) { +// // print(sectionList); +// // SectionList sectionItem = sectionList[i]; +// // dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN +// // ? sectionItem.value ?? "Select" +// // : ' '; +// // List 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 Wrap(children: [ +// // Column( +// // crossAxisAlignment: CrossAxisAlignment.start, +// // children: [ +// // sectionItem.widget == InteractionWidget.BUTTON && +// // sectionItem.input == 'add' || +// // sectionItem.input == 'deletebtn' +// // ? const SizedBox.shrink() +// // : Text( +// // '${sectionItem.name}:*', +// // style: TextStyle( +// // color: Colors.orange.shade800, +// // fontSize: isTablet ? 18 : 14, +// // ), +// // ), +// // // const SizedBox( +// // // height: 15, +// // // ), +// // sectionItem.widget == InteractionWidget.BUTTON +// // ? sectionItem.input == 'chooseFile' +// // ? Row( +// // children: [ +// // 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( +// // 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), +// // ], +// // ), +// // ]); +// // }, +// // ), +// // ), +// // ); +// // } +// //////////////////////////////////////Poojaaaa///////////////////// +// /// +// /// + +// Widget gridViewWidget( +// InteractionProvider provider, +// String sectionName, +// List sectionList, +// Orientation orientation, +// FormFieldData item, +// int listIndex) { +// print("ListInex: $listIndex"); +// print("sectionName: $sectionName"); +// print("sectionName: $sectionName"); + +// print("gridsectionlost_is: $sectionList"); +// print("gridsectionlostleangth_is: ${sectionList.length}"); + +// List pooja = sectionList; + +// print("Pooja_isss: $pooja"); +// print("Pooja_leangth_isss: ${pooja.length}"); + +// ////////////////////////////////////mycode/////////////////////////// +// /// +// /// +// // final provider = context.read(); +// // var yourVariable = provider.ge; +// // print("ProviderLength: $yourVariable"); +// // print("ProviderLength: ${yourVariable.length}"); + +// List> convertedArray = []; +// print("Provider_leangth: ${item.sectionList.length}"); + +// for (int i = 0; i < pooja.length; i += item.sectionList.length + 1) { +// print("poojaleangth: $pooja"); + +// convertedArray.add(pooja.sublist(i, i + item.sectionList.length + 1)); +// } +// print("ConvertedArray.leangth: $convertedArray"); +// print("ConvertedArray.leangth: ${convertedArray.length}"); + +// return Padding( +// padding: isTablet +// ? const EdgeInsets.only(left: 8.0) +// : const EdgeInsets.only(left: 12.0, right: 12.0), +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// for (var i = 0; i < convertedArray.length; i++) +// GridView.builder( +// physics: const NeverScrollableScrollPhysics(), +// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( +// crossAxisCount: context.responsive( +// 1, +// sm: 1, // small +// md: 1, // 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: MediaQuery.of(context).size.width / +// (MediaQuery.of(context).size.height / 3), +// ), +// shrinkWrap: true, +// padding: EdgeInsets.zero, +// itemCount: convertedArray[i].length, +// itemBuilder: (context, index) { +// // SectionList sectionItem = +// // convertedArray.expand((list) => list).toList()[index]; + +// // List.generate( +// // sectionList.length, +// // (i) { +// // print(sectionList); +// // // SectionList sectionItem = sectionList[i]; +// // SectionList sectionItem = +// // convertedArray.expand((list) => list).toList()[index]; +// // dropdownvalue = +// // sectionItem.widget == InteractionWidget.DROPDOWN +// // ? sectionItem.value ?? "Select" +// // : ' '; +// // List 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 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 Wrap(children: [ +// Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// sectionItem.widget == InteractionWidget.BUTTON && +// sectionItem.input == 'add' || +// sectionItem.input == 'deletebtn' +// ? const SizedBox.shrink() +// : Text( +// '${sectionItem.name}:*', +// style: TextStyle( +// color: Colors.orange.shade800, +// fontSize: isTablet ? 18 : 14, +// ), +// ), +// // const SizedBox( +// // height: 15, +// // ), +// sectionItem.widget == InteractionWidget.BUTTON +// ? sectionItem.input == 'chooseFile' +// ? Row( +// children: [ +// 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( +// 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), +// ], +// ), +// ]); +// }) +// ], +// ), +// ); +// } + +// String fieldsValidation(InteractionProvider provider) { +// List secList = provider.sectionList +// .where((element) => element.validation!.isRequired = true) +// .toList(); +// if (secList.any((element) => element.selectedValue!.isEmpty)) { +// return 'Fields cannot be empty'; +// } +// return ''; +// } + +// String textFieldsValidation(InteractionProvider provider) { +// // if (provider.sectionList +// // .any((element) => element.widget == InteractionWidget.TEXT)) { +// // if (provider.sectionList +// // .any((element) => element.controller!.text.isEmpty)) { +// // return 'Fields cannot be empty'; +// // } +// // if (provider.textEditingControllerList.isNotEmpty) { +// // if (provider.validateTextFields()) { +// // return 'Fields cannot be empty'; +// // } +// // } + +// // if (provider.multipletextEditingControllerList.isNotEmpty) { +// // if (provider.validateMultipleRows()) { +// // return 'Fields cannot be empty'; +// // } +// // } +// // } + +// return ''; +// } + +// _displaySnackBar(String msg) { +// final snackBar = SnackBar( +// content: Text( +// msg, +// style: const TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold), +// )); +// ScaffoldMessenger.of(context).showSnackBar(snackBar); +// //scaffoldKeyLogin.currentState!.showSnackBar(snackBar); +// } + +// Future getEncodedFile(SectionList sectionItem) async { +// String base64Image = ''; +// var status = Platform.isAndroid +// ? await Permission.manageExternalStorage.status +// : await Permission.storage.status; +// if (status.isGranted) { +// FilePickerResult? result = +// await FilePicker.platform.pickFiles(allowMultiple: true); + +// if (result != null) { +// print(result.files.first.path); +// print(result.files.last.path); +// for (var files in result.files) { +// File file = File(files.path!); +// print("check file path : ${file.path}"); +// fileName = file.path.split('/').last; +// // Get the application folder directory +// Directory? directory = Platform.isAndroid +// ? await getExternalStorageDirectory() //FOR ANDROID +// : await getApplicationDocumentsDirectory(); +// String newPath = ""; //FOR ios +// String convertedDirectoryPath = (directory?.path).toString(); + +// print("see the converted directory path $convertedDirectoryPath"); + +// newPath = "$convertedDirectoryPath/konectar/files"; +// print("new path :$newPath"); +// directory = Directory(newPath); +// if (!await directory.exists()) { +// await directory.create(recursive: true); +// } +// File newFile = await file.copy('${directory.path}/$fileName'); +// print("new path is ${newFile.path}"); +// final extension = p.extension(newFile.path); +// List imageBytes = await newFile.readAsBytes(); +// Uint8List imageUint8List = Uint8List.fromList(imageBytes); +// base64Image = base64Encode(imageUint8List); +// sectionItem.selectedValue!.add(base64Image); +// sectionItem.extension!.add(extension); +// sectionItem.fileName!.add(fileName); +// } +// } +// } else { +// print("not permitted"); +// await requestPermission(Platform.isAndroid +// ? Permission.manageExternalStorage +// : Permission.storage); +// } +// } + +// showAlertDialog(BuildContext context, String record) { +// // set up the buttons +// // ViewInteractionProvider provider = +// // Provider.of(context, listen: false); +// Widget cancelButton = TextButton( +// child: const Text("Ok"), +// onPressed: () async { +// Navigator.of(context).pop(); +// Navigator.of(context).pop(); +// }, +// ); + +// // set up the AlertDialog +// AlertDialog alert = AlertDialog( +// title: const Text(""), +// content: Text("Form $record Saved Successfully!"), +// actions: [ +// cancelButton, +// ], +// ); + +// // show the dialog +// showDialog( +// context: context, +// builder: (BuildContext context) { +// return alert; +// }, +// ); +// } +// } + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// import 'dart:convert'; +// import 'dart:io'; +// import 'dart:js_util'; + +// import 'package:discover_module/constants.dart'; +// import 'package:discover_module/ui_screen/add_event/add_hcp.dart'; +// import 'package:discover_module/ui_screen/interactionform/interactionprovider.dart'; +// import 'package:discover_module/ui_screen/interactionform/model/interaction_data.dart'; +// import 'package:discover_module/ui_screen/interactionform/util.dart'; +// import 'package:discover_module/ui_screen/interactionform/widget/custombutton.dart'; +// import 'package:discover_module/ui_screen/interactionform/widget/customrangeslider.dart'; +// import 'package:discover_module/ui_screen/interactionform/widget/interatciontextfield.dart'; +// import 'package:discover_module/ui_screen/interactionform/widget/responsive_ext.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter/services.dart'; +// import 'package:flutter/widgets.dart'; +// import 'package:intl/intl.dart'; +// import 'package:path_provider/path_provider.dart'; +// import 'package:provider/provider.dart'; +// import 'package:dropdown_button2/dropdown_button2.dart'; + +// import 'package:file_picker/file_picker.dart'; +// // import 'package:pwa_ios/widgets/responsive_ext.dart'; +// import 'package:permission_handler/permission_handler.dart'; +// import 'package:path/path.dart' as p; + +// class InteractionScreen extends StatefulWidget { +// int index; +// String form; +// InteractionScreen({super.key, required this.index, required this.form}); + +// @override +// State createState() => _InteractionScreenState(); +// } + +// class _InteractionScreenState extends State { +// List interactionReponseList = []; +// List sectionList = []; +// List textEditingControllerList = []; +// int textfieldIndex = 0; +// String dropdownvalue = 'Select value'; +// String? fileName; +// final TextEditingController textEditingController = TextEditingController(); +// @override +// void initState() { +// WidgetsBinding.instance.addPostFrameCallback((timeStamp) { +// // if (mytimer!.isActive) { +// // cancelTimer(); +// // } +// init(); +// }); + +// super.initState(); +// } + +// init() async { +// await Provider.of(context, listen: false) +// .init(widget.index); +// setState(() {}); +// } + +// @override +// Widget build(BuildContext context) { +// return Consumer( +// builder: (BuildContext context, provider, Widget? child) { +// return GestureDetector( +// onTap: () { +// FocusScope.of(context).requestFocus(FocusNode()); +// }, +// child: OrientationBuilder(builder: (context, orientation) { +// return Scaffold( +// //resizeToAvoidBottomInset: false, +// appBar: AppBar( +// title: const FittedBox( +// fit: BoxFit.scaleDown, +// child: Text( +// 'Record New Interaction', +// style: TextStyle( +// // fontSize: isTablet ? 22 : 14, color: Colors.white +// // fontSize: 20, +// color: Colors.white), +// ), +// ), +// // backgroundColor: const Color(0xFF2b9af3), +// automaticallyImplyLeading: false, +// actions: [saveActions(provider)], +// leading: InkWell( +// onTap: () { +// Navigator.pop(context); +// }, +// child: const Icon( +// Icons.arrow_back_ios, +// color: Colors.white, +// ), +// ), +// ), +// body: Column( +// children: [ +// Expanded( +// child: ListView.builder( +// itemCount: provider.interactionReponseList.length, +// padding: EdgeInsets.zero, +// cacheExtent: double.parse( +// provider.interactionReponseList.length.toString()), +// itemBuilder: (context, index) { +// var item = provider.interactionReponseList[index]; +// sectionList = item.sectionList; +// return ExpansionTile( +// maintainState: true, +// // backgroundColor: Colors.white, +// // collapsedBackgroundColor: Color(0xFF2b9af3), +// initiallyExpanded: true, +// title: Stack( +// alignment: AlignmentDirectional.center, +// children: [ +// Container( +// // height: double.infinity, +// width: double.infinity, +// padding: const EdgeInsets.all(8.0), +// decoration: BoxDecoration( +// // color: Color(0xFF2b9af3), +// color: Constants.k2color, +// ), +// child: Text( +// item.sectionName, +// style: const TextStyle( +// color: Colors.white, +// fontWeight: FontWeight.bold, +// // fontSize: isTablet ? 18 : 14 +// ), +// )), +// item.multiple +// ? Align( +// alignment: Alignment.centerRight, +// child: IconButton( +// onPressed: () { +// if (item.sectionName == "HCP") { +// Navigator.push( +// context, +// MaterialPageRoute( +// builder: (context) => +// Addhcp())); + +// provider.getSectionItem( +// item.sectionName, +// item.sectionList.length); +// // print("index is $listIndex"); +// setState(() { +// // for (var item +// }); +// } else { +// provider.getSectionItem( +// item.sectionName, +// item.sectionList.length); +// // print("index is $listIndex"); +// setState(() { +// // for (var item +// }); +// } +// }, +// icon: const Icon( +// Icons.add_circle_outline, +// size: 30, +// color: Colors.white, +// ), +// ), +// ) +// : const SizedBox.shrink() +// ]), +// children: [ +// Padding( +// padding: const EdgeInsets.all(8.0), +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.center, +// children: [ +// // const SizedBox( +// // height: 20, +// // ), + +// Padding( +// padding: isTablet +// ? const EdgeInsets.only(left: 14.0) +// : const EdgeInsets.only( +// left: 12.0, right: 12.0), +// child: GridView.count( +// physics: +// const NeverScrollableScrollPhysics(), +// crossAxisCount: context.responsive( +// 1, +// sm: 1, // small +// md: 1, // medium +// lg: sectionList.length == 1 +// ? 1 +// : 3, // large +// xl: 3, // extra large screen +// ), +// // crossAxisCount: +// // orientation == Orientation.portrait +// // ? 1 +// // : 3, +// // crossAxisCount: (MediaQuery.of(context) +// // .orientation == +// // Orientation.landscape) +// // ? 3 +// // : 1, + +// mainAxisSpacing: +// sectionList.length == 1 || !isTablet +// ? 1 +// : 3.5, +// // mainAxisSpacing: +// // orientation == Orientation.portrait +// // ? 1 +// // : 3, +// shrinkWrap: true, +// padding: EdgeInsets.zero, +// // childAspectRatio: MediaQuery.of(context) +// // .size +// // .aspectRatio * +// // 0.10, +// // childAspectRatio: +// // sectionList.length == 1 +// // ? orientation == +// // Orientation.landscape +// // ? 10 +// // : 3.8 +// // : 2.4, +// // childAspectRatio: +// // sectionList.length == 1 +// // ? orientation == +// // Orientation.landscape +// // ? 10 +// // : 3.8 +// // : isTablet +// // ? 2.8 +// // : 3.8, + +// childAspectRatio: +// sectionList.length == 1 +// ? orientation == +// Orientation.landscape +// ? 10 +// : 4.8 +// : isTablet +// ? 2.8 +// : 3.0, +// // /:2.4, +// // childAspectRatio: 3.8, + +// children: List.generate( +// sectionList.length, +// (i) { +// SectionList sectionItem = +// sectionList[i]; +// dropdownvalue = sectionItem +// .widget == +// InteractionWidget.DROPDOWN +// ? sectionItem.value ?? "Select" +// : ' '; +// List 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 Column( +// crossAxisAlignment: +// CrossAxisAlignment.start, +// children: [ +// sectionItem.widget == +// InteractionWidget +// .BUTTON && +// sectionItem.input == +// 'add' +// ? const SizedBox.shrink() +// : Padding( +// padding: +// const EdgeInsets +// .only( +// left: 8.0, +// right: 8.0), +// child: FittedBox( +// fit: BoxFit.scaleDown, +// child: Text( +// sectionItem +// .validation! +// .isRequired +// ? '${sectionItem.name}:*' +// : '${sectionItem.name}:', +// style: TextStyle( +// color: Colors +// .orange +// .shade800, +// fontSize: 18.0, +// // fontSize: isTablet +// // ? 18 +// // : 12, +// ), +// ), +// ), +// ), +// // SizedBox( +// // height: isTablet ? 15 : 5, +// // ), +// returnWidget( +// sectionItem: sectionItem, +// item: item, +// provider: provider, +// list: list, +// gridIndex: i, +// listIndex: index, +// widgetData: +// sectionItem.widget!, +// multiple: false), +// // SizedBox( +// // height: isTablet ? 15 : 5, +// // ), + +// // sectionItem.depid == 'pooja' +// // ? Text( +// // sectionItem.validation! +// // .isRequired +// // ? '${sectionItem.depid}:*' +// // : '${sectionItem.depid}:', +// // style: TextStyle( +// // color: Colors +// // .orange.shade800, +// // fontSize: isTablet +// // ? 18 +// // : 12, +// // ), +// // ) +// // : const SizedBox.shrink(), +// ], +// ); +// }, +// ), +// ), +// ), +// // SizedBox( +// // height: isTablet ? 15 : 5, +// // ), +// // item.multiple +// // ? +// gridViewWidget( +// provider, +// item.sectionName, +// item.multipleList ?? [], +// orientation, +// item, +// index), +// // : const SizedBox.shrink(), +// provider.interactionReponseList.length == +// index - 1 +// ? saveActions(provider) +// : const SizedBox.shrink() +// //const Spacer(), +// ], +// ), +// ), +// ]); +// }, +// ), +// ), +// // const Spacer(), +// // saveActions(provider), +// ], +// )); +// }), +// ); +// }); +// } + +// Widget returnWidget({ +// required SectionList sectionItem, +// required FormFieldData item, +// required InteractionProvider provider, +// required List list, +// required int gridIndex, +// required int listIndex, +// required InteractionWidget widgetData, +// required bool multiple, +// }) { +// switch (widgetData) { +// case InteractionWidget.CHECKBOX: +// return (sectionItem.inputList!.length >= 5) +// ? customMultiselectDropdown( +// sectionItem, provider, sectionItem.inputList!, multiple) +// : buildCheckbox(sectionItem, item.sectionName, provider, multiple); + +// case InteractionWidget.AUTOCOMPLETE: +// return customAutoCompletedropdown( +// sectionItem, provider, list, multiple); + +// case InteractionWidget.MULTISELECT: +// return customMultiselectDropdown(sectionItem, provider, list, multiple); + +// case InteractionWidget.RADIO: +// return (sectionItem.inputList!.length >= 5) +// ? customdropdown( +// sectionItem, provider, sectionItem.inputList!, multiple) +// : buildRadio(sectionItem, provider); + +// case InteractionWidget.LABEL: +// return Text(sectionItem.input!); + +// case InteractionWidget.RANGESLIDER: +// return CustomRangeSlider( +// max: double.parse(sectionItem.max!), +// min: double.parse(sectionItem.min!), +// sliderPos: sectionItem.selectedValue!.isNotEmpty +// ? double.parse(sectionItem.selectedValue!.last.toString()) +// : double.parse(sectionItem.min!), +// onChanged: (val) { +// setState(() { +// sectionItem.selectedValue = []; +// sectionItem.selectedId = val.toString(); +// sectionItem.selectedValue!.add(val.toInt()); +// }); +// }, +// ); + +// case InteractionWidget.BUTTON: +// return sectionItem.input == 'add' +// ? const Offstage( +// offstage: true, +// child: Text("Visible"), +// ) +// : Row( +// children: [ +// 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!.length > 1 +// ? 'Files uploaded' +// : "File Uploaded" +// : 'No file uploaded', +// style: TextStyle( +// color: sectionItem.selectedValue!.isNotEmpty +// ? Colors.green +// : Colors.red), +// ), +// ], +// ); + +// case InteractionWidget.TEXT: +// return sectionItem.input == 'Date' +// ? buildDateWidget(sectionItem) +// : sectionItem.input == "textArea" +// ? Expanded( +// child: InteractionTextField( +// maxchars: int.parse(sectionItem.validation!.chars ?? "0"), +// controller: sectionItem.controller!, +// labelText: sectionItem.name, +// // maxlines: 8, +// //minlines: 4, +// onChanged: (val) { +// sectionItem.selectedValue = []; +// setState(() {}); + +// sectionItem.selectedValue!.add(val); +// }, +// ), +// ) +// ////Poojaaaaa +// : sectionItem.input == "text1" +// ? Text( +// sectionItem.depid!, +// style: TextStyle( +// fontSize: 18.0, fontWeight: FontWeight.normal), +// ) +// : Padding( +// padding: const EdgeInsets.only(left: 8.0, right: 8.0), +// child: SizedBox( +// // width: +// // isTablet ? 200 : MediaQuery.of(context).size.width, +// //height: isTablet ? 50 : 40, +// width: MediaQuery.of(context).size.width, +// 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 = []; +// provider.setTextValue(val, sectionItem, multiple); +// }, +// ), +// ), +// ); +// case InteractionWidget.DROPDOWN: +// return customdropdown(sectionItem, provider, list, multiple); +// } +// } + +// Future requestPermission(Permission permission) async { +// final status = await permission.request(); + +// setState(() { +// print(status); +// // _permissionStatus = status; +// // print(_permissionStatus); +// }); +// } + +// Widget buildDateWidget(SectionList sectionItem) { +// return Padding( +// padding: const EdgeInsets.only(left: 8.0, right: 8.0), +// child: SizedBox( +// // width: isTablet ? 200 : MediaQuery.of(context).size.width, +// // height: isTablet ? 50 : 40, +// width: MediaQuery.of(context).size.width, +// child: TextField( +// controller: +// sectionItem.controller, //editing controller of this TextField +// decoration: InputDecoration( +// // border: OutlineInputBorder(), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(10.0), +// ), +// labelStyle: const TextStyle(fontSize: 16), +// suffixIcon: const Icon(Icons.calendar_today), //icon of text field +// labelText: "Enter Date" //label text of field +// ), +// readOnly: true, //set it true, so that user will not able to edit text +// onTap: () async { +// DateTime? pickedDate = await showDatePicker( +// context: context, +// initialDate: DateTime.now(), +// firstDate: DateTime( +// 2000), //DateTime.now() - not to allow to choose before today. +// lastDate: DateTime(2101)); + +// if (pickedDate != null) { +// print( +// pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000 +// String formattedDate = +// DateFormat('yyyy-MM-dd').format(pickedDate); +// print( +// formattedDate); //formatted date output using intl package => 2021-03-16 +// //you can implement different kind of Date Format here according to your requirement + +// setState(() { +// sectionItem.controller!.text = formattedDate; +// sectionItem.selectedValue = []; +// sectionItem.selectedValue! +// .add(formattedDate); //set output date to TextField value. +// }); +// } else { +// print("Date is not selected"); +// } +// }, +// ), +// ), +// ); +// } + +// Widget saveActions(InteractionProvider provider) { +// return Align( +// alignment: Alignment.centerRight, +// child: Row( +// mainAxisAlignment: MainAxisAlignment.spaceEvenly, +// children: [ +// Padding( +// padding: const EdgeInsets.all(4.0), +// child: CustomButton( +// backgroundColor: Colors.red.shade800, +// onPressed: () { +// //showDeleteProfileAlertDialog(context); +// for (var textcontrollers +// in provider.textEditingControllerList) { +// textcontrollers.text = ''; +// } + +// // setState(() { +// // provider.resetAllWidgetsData(); +// // }); +// }, +// textColor: Colors.white, +// title: "Reset", +// // height: 40, +// // width: isTablet ? 100 : 80, +// height: MediaQuery.of(context).size.height * 0.2, + +// fontsize: isTablet ? 15 : 10.2, +// ), +// ), +// SizedBox( +// width: isTablet ? 20 : 4, +// ), +// Padding( +// padding: const EdgeInsets.all(4.0), +// child: CustomButton( +// backgroundColor: Colors.green.shade500, +// onPressed: () async { +// if (textFieldsValidation(provider).isEmpty) { +// String record = +// await provider.saveJsonObject(context, widget.form); +// showAlertDialog(context, record); +// } else { +// _displaySnackBar(textFieldsValidation(provider)); +// } +// }, +// textColor: Colors.white, +// title: "Save", +// // height: 40, +// // width: isTablet ? 100 : 80, +// height: MediaQuery.of(context).size.height * 0.2, + +// // width: MediaQuery.of(context).size.width * 0.1, +// fontsize: isTablet ? 16 : 12, +// ), +// ), +// SizedBox( +// width: isTablet ? 20 : 2, +// ), +// ], +// ), +// ); +// } + +// Widget buildRadio(SectionList sectionItem, InteractionProvider provider) { +// List list = provider.getData2(sectionItem); +// // .map((itemWord) => InputClass.fromJson(itemWord)) +// // .toList(); +// return Padding( +// padding: const EdgeInsets.only(left: 8.0, right: 8.0), +// child: SizedBox( +// // width: isTablet ? 250 : MediaQuery.of(context).size.width, +// width: MediaQuery.of(context).size.width, + +// child: Row( +// children: [ +// for (InputClass value in list) +// Row( +// children: [ +// Radio( +// value: value.name, +// activeColor: Colors.black, +// groupValue: provider.radioValue, +// onChanged: (String? value) { +// setState(() { +// print(value); +// provider.radioValue = value!; +// int index = +// list.indexWhere((element) => element.name == value); +// sectionItem.selectedValue!.add(list[index].id); +// }); +// }, +// ), +// Text(value.name), +// ], +// ), +// ], +// ), +// ), +// ); +// } + +// Widget buildCheckbox(SectionList sectionItem, String sectionName, +// InteractionProvider provider, bool multiple) { +// return Padding( +// padding: const EdgeInsets.only(left: 8.0, right: 8.0), +// child: SizedBox( +// // width: 250, +// width: MediaQuery.of(context).size.width, + +// child: Row( +// children: [ +// for (var value in provider.checkboxlist) +// Row( +// children: [ +// FittedBox( +// fit: BoxFit.scaleDown, +// child: Checkbox( +// value: value.ischecked ?? false, +// activeColor: Colors.black, +// checkColor: Colors.white, +// onChanged: (bool? newvalue) { +// value.ischecked = newvalue!; +// provider.setcheckBoxValue(sectionItem, sectionName, +// newvalue, value.id, multiple); +// //setState(() {}); +// }, +// ), +// ), +// Text(value.name), +// ], +// ), +// ], +// ), +// ), +// ); +// } + +// Widget customdropdown(SectionList sectionItem, InteractionProvider provider, +// List list, bool multiple) { +// // sectionItem.value = ''; + +// if (list.isEmpty) { +// list = []; +// InputClass inputClass = +// InputClass(id: "no value", name: "Select ${sectionItem.name}"); +// list.add(inputClass); +// sectionItem.selectedObject = list[0]; +// } +// // InputClass selectedObj = list[0]; +// return Padding( +// padding: const EdgeInsets.only(left: 8.0, right: 8.0), +// child: SizedBox( +// width: MediaQuery.of(context).size.width, +// // height: isTablet ? 60 : 40, +// child: DropdownButtonFormField2( +// isExpanded: true, +// decoration: InputDecoration( +// // Add Horizontal padding using menuItemStyleData.padding so it matches +// // the menu padding when button's width is not specified. +// contentPadding: const EdgeInsets.symmetric(vertical: 5), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(15), +// ), +// // Add more decoration.. +// ), +// hint: Text( +// 'Select ${sectionItem.name}', +// style: const TextStyle(fontSize: 14), +// ), +// items: list +// .map((item) => DropdownMenuItem( +// value: item, +// child: Text( +// item.name, +// style: const TextStyle( +// fontSize: 14, +// ), +// ), +// )) +// .toList(), +// value: sectionItem.selectedObject ?? list[0], +// // // provider.getDropDownValue(sectionItem.value!, sectionItem, list) +// // sectionItem.value ?? list[0].name, +// validator: (value) { +// if (value == null) { +// return 'Please select ${sectionItem.name}'; +// } +// return null; +// }, +// onChanged: (value) { +// //Do something when selected item is changed. +// sectionItem.selectedObject = value!; +// sectionItem.value = value.id; +// provider.setDropDownValue(value.id, sectionItem, multiple); +// print("selected ${sectionItem.value}"); +// // setState(() {}); +// }, +// onSaved: (value) { +// sectionItem.selectedObject = value!; +// sectionItem.value = value.id; +// provider.setDropDownValue(value.id, sectionItem, multiple); +// // setState(() {}); +// }, +// buttonStyleData: const ButtonStyleData( +// padding: EdgeInsets.only(right: 8), +// ), +// iconStyleData: const IconStyleData( +// icon: Icon( +// Icons.arrow_drop_down, +// color: Colors.black45, +// ), +// iconSize: 24, +// ), +// dropdownStyleData: DropdownStyleData( +// decoration: BoxDecoration( +// borderRadius: BorderRadius.circular(15), +// ), +// ), +// menuItemStyleData: const MenuItemStyleData( +// padding: EdgeInsets.symmetric(horizontal: 16), +// ), +// ), +// ), +// ); +// } + +// Widget customAutoCompletedropdown(SectionList sectionItem, +// InteractionProvider provider, List list, bool multiple) { +// // sectionItem.value = list[0].name; + +// // if (list.isEmpty) { +// // print("list is empty"); +// list = sectionItem.inputList!; +// print("***Autocomplete list ${list[0].name}"); +// //} +// //InputClass selectedObj = list[0]; +// return Padding( +// padding: const EdgeInsets.only(left: 8.0, right: 8.0), +// child: SizedBox( +// // width: isTablet ? 200 : MediaQuery.of(context).size.width, +// // height: isTablet ? 60 : 40, +// width: MediaQuery.of(context).size.width, + +// child: DropdownButtonHideUnderline( +// child: DropdownButtonFormField2( +// isExpanded: true, +// decoration: InputDecoration( +// // Add Horizontal padding using menuItemStyleData.padding so it matches +// // the menu padding when button's width is not specified. +// contentPadding: const EdgeInsets.symmetric(vertical: 5), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(15), +// ), +// // Add more decoration.. +// ), +// hint: Text( +// 'Select Item', +// style: TextStyle( +// fontSize: 14, +// color: Theme.of(context).hintColor, +// ), +// ), +// items: list +// .map((item) => DropdownMenuItem( +// value: item, +// child: Text( +// item.name, +// style: const TextStyle( +// fontSize: 14, +// ), +// ), +// )) +// .toList(), +// value: sectionItem.selectedObject, +// onSaved: (value) { +// sectionItem.selectedObject = value!; +// provider.setAutoCompleteValue(value.id, sectionItem, multiple); +// sectionItem.value = value.name; +// }, +// onChanged: (value) { +// // setState(() { +// sectionItem.selectedObject = value!; +// provider.setAutoCompleteValue(value.id, sectionItem, multiple); +// sectionItem.value = value.name; +// // setState(() {}); +// //}); +// }, + +// buttonStyleData: const ButtonStyleData( +// padding: EdgeInsets.symmetric(horizontal: 16), +// height: 40, +// width: 200, +// ), +// dropdownStyleData: const DropdownStyleData( +// maxHeight: 200, +// ), +// menuItemStyleData: const MenuItemStyleData( +// height: 40, +// ), +// dropdownSearchData: DropdownSearchData( +// searchController: textEditingController, +// searchInnerWidgetHeight: 50, +// searchInnerWidget: Container( +// height: 50, +// padding: const EdgeInsets.only( +// top: 8, +// bottom: 4, +// right: 8, +// left: 8, +// ), +// child: TextFormField( +// expands: true, +// maxLines: null, +// controller: textEditingController, +// decoration: InputDecoration( +// isDense: true, +// contentPadding: const EdgeInsets.symmetric( +// horizontal: 10, +// vertical: 8, +// ), +// hintText: 'Search for an item...', +// hintStyle: const TextStyle(fontSize: 12), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(8), +// ), +// ), +// ), +// ), +// searchMatchFn: (item, searchValue) { +// return item.value!.name.toString().contains(searchValue); +// }, +// ), +// //This to clear the search value when you close the menu +// onMenuStateChange: (isOpen) { +// if (!isOpen) { +// textEditingController.clear(); +// } +// }, +// ), +// ), +// ), +// ); +// } + +// Widget customMultiselectDropdown(SectionList sectionItem, +// InteractionProvider provider, List list, bool multiple) { +// if (list.isEmpty) { +// list = sectionItem.inputList!; +// } +// InputClass selectedObj = list[0]; + +// return Padding( +// padding: const EdgeInsets.only(left: 8.0, right: 8.0), +// child: SizedBox( +// // width: isTablet ? 200 : MediaQuery.of(context).size.width, +// // height: isTablet ? 60 : 40, +// width: MediaQuery.of(context).size.width, +// // height: MediaQuery.of(context).size.height, + +// child: DropdownButtonHideUnderline( +// child: DropdownButtonFormField2( +// isExpanded: true, +// decoration: InputDecoration( +// // Add Horizontal padding using menuItemStyleData.padding so it matches +// // the menu padding when button's width is not specified. +// contentPadding: const EdgeInsets.symmetric(vertical: 5), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(15), +// ), +// // Add more decoration.. +// ), +// hint: Text( +// 'Select Items', +// style: TextStyle( +// fontSize: 14, +// color: Theme.of(context).hintColor, +// ), +// ), +// items: list.map((item) { +// return DropdownMenuItem( +// value: item, +// //disable default onTap to avoid closing menu when selecting an item +// enabled: false, +// child: StatefulBuilder( +// builder: (context, menuSetState) { +// final isSelected = +// sectionItem.selectedValue!.contains(item.name); +// return InkWell( +// onTap: () { +// isSelected +// ? sectionItem.selectedValue!.remove(item.name) +// : sectionItem.selectedValue!.add(item.name); +// //This rebuilds the StatefulWidget to update the button's text +// setState(() {}); +// //This rebuilds the dropdownMenu Widget to update the check mark +// menuSetState(() {}); +// }, +// child: Container( +// height: double.infinity, +// padding: const EdgeInsets.symmetric(horizontal: 16.0), +// child: Row( +// children: [ +// if (isSelected) +// const Icon(Icons.check_box_outlined) +// else +// const Icon(Icons.check_box_outline_blank), +// const SizedBox(width: 16), +// Expanded( +// child: Text( +// item.name, +// style: const TextStyle( +// fontSize: 14, +// ), +// ), +// ), +// ], +// ), +// ), +// ); +// }, +// ), +// ); +// }).toList(), +// //Use last selected item as the current value so if we've limited menu height, it scroll to last item. +// value: selectedObj, +// // ? null +// // : provider.selectedItems.last, +// onChanged: (value) { +// selectedObj = value!; +// provider.setAutoCompleteValue(value.id, sectionItem, multiple); +// sectionItem.value = value.name; +// }, +// onSaved: (value) { +// selectedObj = value!; +// provider.setAutoCompleteValue(value.id, sectionItem, multiple); +// sectionItem.value = value.name; +// }, +// selectedItemBuilder: (context) { +// return list.map( +// (item) { +// return Container( +// alignment: AlignmentDirectional.center, +// child: Text( +// sectionItem.selectedValue!.join(', '), +// style: const TextStyle( +// fontSize: 14, +// overflow: TextOverflow.ellipsis, +// ), +// maxLines: 1, +// ), +// ); +// }, +// ).toList(); +// }, +// buttonStyleData: const ButtonStyleData( +// padding: EdgeInsets.only(left: 16, right: 8), +// height: 40, +// width: 140, +// ), +// menuItemStyleData: const MenuItemStyleData( +// height: 40, +// padding: EdgeInsets.zero, +// ), +// ), +// ), +// ), +// ); +// } + +// Widget gridViewWidget( +// InteractionProvider provider, +// String sectionName, +// List sectionList, +// Orientation orientation, +// FormFieldData item, +// int listIndex) { +// print("ListInex: $listIndex"); +// print("sectionName: $sectionName"); +// print("sectionName: $sectionName"); + +// print("gridsectionlost_is: $sectionList"); +// print("gridsectionlostleangth_is: ${sectionList.length}"); + +// List pooja = sectionList; + +// print("Pooja_isss: $pooja"); + +// return Padding( +// padding: isTablet +// ? const EdgeInsets.only(left: 8.0) +// : const EdgeInsets.only(left: 12.0, right: 12.0), +// child: GridView.count( +// physics: const NeverScrollableScrollPhysics(), +// // crossAxisCount: context.responsive( +// // 1, // default +// // sm: 1, // small +// // md: 1, // medium +// // lg: sectionList.length == 1 ? 1 : 4, // large +// // xl: 5, // extra large screen +// // ), +// crossAxisCount: context.responsive( +// 1, +// sm: 1, // small +// md: 1, // medium +// lg: sectionList.length == 1 +// ? 1 +// : (sectionList.length >= 1 ? 3 : 3), // large +// xl: 3, // extra large screen +// ), +// 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, +// // childAspectRatio: sectionList.length == 1 +// // ? orientation == Orientation.landscape +// // ? 10 +// // : 4.8 +// // : isTablet +// // ? 2.8 +// // : 3.0, +// childAspectRatio: MediaQuery.of(context).size.width / +// (MediaQuery.of(context).size.height / 3), +// children: List.generate( +// sectionList.length, +// (i) { +// print(sectionList); +// SectionList sectionItem = sectionList[i]; +// dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN +// ? sectionItem.value ?? "Select" +// : ' '; +// List 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 Wrap(children: [ +// Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// sectionItem.widget == InteractionWidget.BUTTON && +// sectionItem.input == 'add' || +// sectionItem.input == 'deletebtn' +// ? const SizedBox.shrink() +// : Text( +// '${sectionItem.name}:*', +// style: TextStyle( +// color: Colors.orange.shade800, +// fontSize: isTablet ? 18 : 14, +// ), +// ), +// // const SizedBox( +// // height: 15, +// // ), +// sectionItem.widget == InteractionWidget.BUTTON +// ? sectionItem.input == 'chooseFile' +// ? Row( +// children: [ +// 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( +// 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), +// ], +// ), +// ]); +// }, +// ), +// ), +// ); +// } +// //////////////////////////////////////Poojaaaa///////////////////// + +// // Widget gridViewWidget( +// // InteractionProvider provider, +// // String sectionName, +// // List sectionList, +// // Orientation orientation, +// // FormFieldData item, +// // int count, +// // int listIndex) { +// // print("ListInex: $listIndex"); +// // print("sectionName: $sectionName"); +// // print("sectionName: $sectionName"); +// // print("section_count: $count"); + +// // print("gridsectionlost_is: $sectionList"); +// // print("gridsectionlostleangth_is: ${sectionList.length}"); + +// // List pooja = sectionList; + +// // print("Pooja_isss: $pooja"); +// // print("Pooja_Leangth_isss: ${pooja.length}"); + +// // List> convertedArray = []; + +// // // for (int i = 0; i < pooja.length; i += 4) { +// // // print("poojaleangth: $pooja"); + +// // // convertedArray.add(pooja.sublist(i, i + 4)); +// // // } + +// // // for (int i = 0; i < pooja.length; i + pooja.length) { +// // // print("poojaleangth: $pooja"); +// // // if (pooja[i] == delete) { +// // // convertedArray.add(pooja.sublist(i, i + pooja.length)); +// // // }} +// // // for (int i = 0; i < pooja.length; i += pooja.length) { +// // // print("poojaleangth: $pooja"); + +// // // convertedArray.add(pooja.sublist(i, i + pooja.length)); +// // // } + +// // // int arraylen +// // // print("Pooja_issscheckkk: ${pooja.first.inputList}"); + +// // print("Provider_leangth: ${item.sectionList.length}"); + +// // for (int i = 0; i < pooja.length; i += 5) { +// // print("poojaleangth: $pooja"); + +// // convertedArray.add(pooja.sublist(i, i + 5)); +// // } + +// // print("convertedArray"); + +// // print(convertedArray); + +// // print("ConvertedArray.leangth: $convertedArray"); +// // print("ConvertedArray.leangth: ${convertedArray.length}"); + +// // // sectionList = convertedArray; +// // // sectionList= convertedArray.expand((list) => list).toList(); +// // // print(convertedArray); +// // return Padding( +// // padding: isTablet +// // ? const EdgeInsets.only(left: 8.0) +// // : const EdgeInsets.only(left: 12.0, right: 12.0), +// // child: Column( +// // crossAxisAlignment: CrossAxisAlignment.start, +// // children: [ +// // for (var i = 0; i < convertedArray.length; i++) +// // GridView.builder( +// // physics: const NeverScrollableScrollPhysics(), +// // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( +// // crossAxisCount: 3, // Keep the same crossAxisCount +// // mainAxisSpacing: +// // sectionList.length == 1 || !isTablet ? 1.0 : 2.0, +// // crossAxisSpacing: 1.0, +// // childAspectRatio: MediaQuery.of(context).size.width / +// // (MediaQuery.of(context).size.height / 3), +// // ), +// // shrinkWrap: true, +// // padding: EdgeInsets.zero, +// // itemCount: convertedArray[0].length, // Only one item per section +// // itemBuilder: (context, index) { +// // SectionList sectionItem = +// // convertedArray.expand((list) => list).toList()[index]; + +// // print("Sectionloop_item_isss: $sectionItem"); +// // dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN +// // ? sectionItem.value ?? "Select" +// // : ' '; +// // List 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 Column( +// // crossAxisAlignment: CrossAxisAlignment.start, +// // children: [ +// // sectionItem.widget == InteractionWidget.BUTTON && +// // (sectionItem.input == 'add' || +// // sectionItem.input == 'deletebtn') +// // ? const SizedBox.shrink() +// // : Text( +// // '${sectionItem.name}:*', +// // style: TextStyle( +// // color: Colors.orange.shade800, +// // fontSize: isTablet ? 18 : 14, +// // ), +// // ), +// // sectionItem.widget == InteractionWidget.BUTTON +// // ? sectionItem.input == 'chooseFile' +// // ? Row( +// // children: [ +// // 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 +// // ? 'File 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( +// // 255, 233, 75, 75), +// // onPressed: () { +// // provider.deleteMultipleRows( +// // sectionItem.gid!, +// // sectionList[i], +// // sectionName); +// // setState(() {}); +// // }, +// // height: 40, +// // 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, +// // ), +// // ], +// // ); +// // }, +// // ), +// // ], +// // ), +// // ); + +// ///////////////////////////////////////////////////////////////////////// +// // Widget gridViewWidget( +// // InteractionProvider provider, +// // String sectionName, +// // List sectionList, +// // Orientation orientation, +// // FormFieldData item, +// // int listIndex) { +// // print("ListInex: $listIndex"); +// // print("sectionName: $sectionName"); +// // print("sectionName: $sectionName"); + +// // print("gridsectionlost_is: $sectionList"); +// // print("gridsectionlostleangth_is: ${sectionList.length}"); + +// // List pooja = sectionList; + +// // print("Pooja_isss: $pooja"); + +// // List> convertedArray = []; + +// // for (int i = 0; i < pooja.length; i += 4) { +// // convertedArray.add(pooja.sublist(i, i + 4)); +// // } +// // print("convertedArray"); + +// // print(convertedArray); + +// // print("ConvertedArray.leangth: $convertedArray"); +// // print("ConvertedArray.leangth: ${convertedArray.length}"); + +// // // sectionList = convertedArray; +// // // sectionList= convertedArray.expand((list) => list).toList(); +// // // print(convertedArray); +// // return Padding( +// // padding: isTablet +// // ? const EdgeInsets.only(left: 8.0) +// // : const EdgeInsets.only(left: 12.0, right: 12.0), +// // child: Column( +// // crossAxisAlignment: CrossAxisAlignment.start, +// // children: [ +// // for (var i = 0; i < convertedArray.length; i++) +// // GridView.builder( +// // physics: const NeverScrollableScrollPhysics(), +// // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( +// // crossAxisCount: 3, // Keep the same crossAxisCount +// // mainAxisSpacing: +// // sectionList.length == 1 || !isTablet ? 1.0 : 2.0, +// // crossAxisSpacing: 1.0, +// // childAspectRatio: MediaQuery.of(context).size.width / +// // (MediaQuery.of(context).size.height / 3), +// // ), +// // shrinkWrap: true, +// // padding: EdgeInsets.zero, +// // itemCount: convertedArray[0].length, // Only one item per section +// // itemBuilder: (context, index) { +// // SectionList sectionItem = +// // convertedArray.expand((list) => list).toList()[index]; + +// // print("Sectionloop_item_isss: $sectionItem"); +// // dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN +// // ? sectionItem.value ?? "Select" +// // : ' '; +// // List 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 Column( +// // crossAxisAlignment: CrossAxisAlignment.start, +// // children: [ +// // sectionItem.widget == InteractionWidget.BUTTON && +// // (sectionItem.input == 'add' || +// // sectionItem.input == 'deletebtn') +// // ? const SizedBox.shrink() +// // : Text( +// // '${sectionItem.name}:*', +// // style: TextStyle( +// // color: Colors.orange.shade800, +// // fontSize: isTablet ? 18 : 14, +// // ), +// // ), +// // sectionItem.widget == InteractionWidget.BUTTON +// // ? sectionItem.input == 'chooseFile' +// // ? Row( +// // children: [ +// // 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 +// // ? 'File 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( +// // 255, 233, 75, 75), +// // onPressed: () { +// // provider.deleteMultipleRows( +// // sectionItem.gid!, +// // sectionList[i], +// // sectionName); +// // setState(() {}); +// // }, +// // height: 40, +// // 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, +// // ), +// // ], +// // ); +// // }, +// // ), +// // ], +// // ), +// // ); + +// // return Padding( +// // padding: isTablet +// // ? const EdgeInsets.only(left: 8.0) +// // : const EdgeInsets.only(left: 12.0, right: 12.0), +// // child: GridView.count( +// // physics: const NeverScrollableScrollPhysics(), +// // crossAxisCount: context.responsive( +// // 1, +// // sm: 1, // small +// // md: 1, // medium +// // lg: sectionList.length == 1 +// // ? 1 +// // : (sectionList.length >= 1 ? 3 : 3), // large +// // xl: 3, // extra large screen +// // ), +// // mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 2, +// // shrinkWrap: true, +// // padding: EdgeInsets.zero, +// // childAspectRatio: MediaQuery.of(context).size.width / +// // (MediaQuery.of(context).size.height / 3), +// // children: List.generate( +// // sectionList.length, +// // (i) { +// // print("sectionList_issss: $sectionList"); +// // SectionList sectionItem = sectionList[i]; +// // dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN +// // ? sectionItem.value ?? "Select" +// // : ' '; +// // List 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 Wrap(children: [ +// // Column( +// // crossAxisAlignment: CrossAxisAlignment.start, +// // children: [ +// // sectionItem.widget == InteractionWidget.BUTTON && +// // sectionItem.input == 'add' || +// // sectionItem.input == 'deletebtn' +// // ? const SizedBox.shrink() +// // : Text( +// // '${sectionItem.name}:*', +// // style: TextStyle( +// // color: Colors.orange.shade800, +// // fontSize: isTablet ? 18 : 14, +// // ), +// // ), +// // // const SizedBox( +// // // height: 15, +// // // ), +// // sectionItem.widget == InteractionWidget.BUTTON +// // ? sectionItem.input == 'chooseFile' +// // ? Row( +// // children: [ +// // 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( +// // 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), +// // ], +// // ), +// // ]); +// // }, +// // ), +// // ), +// // ); +// //} + +// String fieldsValidation(InteractionProvider provider) { +// List secList = provider.sectionList +// .where((element) => element.validation!.isRequired = true) +// .toList(); +// if (secList.any((element) => element.selectedValue!.isEmpty)) { +// return 'Fields cannot be empty'; +// } +// return ''; +// } + +// String textFieldsValidation(InteractionProvider provider) { +// // if (provider.sectionList +// // .any((element) => element.widget == InteractionWidget.TEXT)) { +// // if (provider.sectionList +// // .any((element) => element.controller!.text.isEmpty)) { +// // return 'Fields cannot be empty'; +// // } +// // if (provider.textEditingControllerList.isNotEmpty) { +// // if (provider.validateTextFields()) { +// // return 'Fields cannot be empty'; +// // } +// // } + +// // if (provider.multipletextEditingControllerList.isNotEmpty) { +// // if (provider.validateMultipleRows()) { +// // return 'Fields cannot be empty'; +// // } +// // } +// // } + +// return ''; +// } + +// _displaySnackBar(String msg) { +// final snackBar = SnackBar( +// content: Text( +// msg, +// style: const TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold), +// )); +// ScaffoldMessenger.of(context).showSnackBar(snackBar); +// //scaffoldKeyLogin.currentState!.showSnackBar(snackBar); +// } + +// Future getEncodedFile(SectionList sectionItem) async { +// String base64Image = ''; +// var status = Platform.isAndroid +// ? await Permission.manageExternalStorage.status +// : await Permission.storage.status; +// if (status.isGranted) { +// FilePickerResult? result = +// await FilePicker.platform.pickFiles(allowMultiple: true); + +// if (result != null) { +// print(result.files.first.path); +// print(result.files.last.path); +// for (var files in result.files) { +// File file = File(files.path!); +// print("check file path : ${file.path}"); +// fileName = file.path.split('/').last; +// // Get the application folder directory +// Directory? directory = Platform.isAndroid +// ? await getExternalStorageDirectory() //FOR ANDROID +// : await getApplicationDocumentsDirectory(); +// String newPath = ""; //FOR ios +// String convertedDirectoryPath = (directory?.path).toString(); + +// print("see the converted directory path $convertedDirectoryPath"); + +// newPath = "$convertedDirectoryPath/konectar/files"; +// print("new path :$newPath"); +// directory = Directory(newPath); +// if (!await directory.exists()) { +// await directory.create(recursive: true); +// } +// File newFile = await file.copy('${directory.path}/$fileName'); +// print("new path is ${newFile.path}"); +// final extension = p.extension(newFile.path); +// List imageBytes = await newFile.readAsBytes(); +// Uint8List imageUint8List = Uint8List.fromList(imageBytes); +// base64Image = base64Encode(imageUint8List); +// sectionItem.selectedValue!.add(base64Image); +// sectionItem.extension!.add(extension); +// sectionItem.fileName!.add(fileName); +// } +// } +// } else { +// print("not permitted"); +// await requestPermission(Platform.isAndroid +// ? Permission.manageExternalStorage +// : Permission.storage); +// } +// } + +// showAlertDialog(BuildContext context, String record) { +// // set up the buttons +// // ViewInteractionProvider provider = +// // Provider.of(context, listen: false); +// Widget cancelButton = TextButton( +// child: const Text("Ok"), +// onPressed: () async { +// Navigator.of(context).pop(); +// Navigator.of(context).pop(); +// }, +// ); + +// // set up the AlertDialog +// AlertDialog alert = AlertDialog( +// title: const Text(""), +// content: Text("Form $record Saved Successfully!"), +// actions: [ +// cancelButton, +// ], +// ); + +// // show the dialog +// showDialog( +// context: context, +// builder: (BuildContext context) { +// return alert; +// }, +// ); +// } +// } diff --git a/lib/ui_screen/interactionform/interactionlistscreen.dart b/lib/ui_screen/interactionform/interactionlistscreen.dart index 9b82a39..0486bc3 100644 --- a/lib/ui_screen/interactionform/interactionlistscreen.dart +++ b/lib/ui_screen/interactionform/interactionlistscreen.dart @@ -47,120 +47,125 @@ class _InteractionListScreenState extends State { Widget build(BuildContext context) { return Consumer( builder: (BuildContext context, provider, Widget? child) { - return Scaffold( - appBar: AppBar( - title: Text( - 'Interaction Forms', - //style: TextStyle(fontSize: isTablet ? 22 : 14, color: Colors.white), - ), - automaticallyImplyLeading: false, - // backgroundColor: const Color(0xFF2b9af3), - leading: InkWell( - onTap: () { - Navigator.pop(context); - }, - child: const Icon( - Icons.arrow_back_ios, - color: Colors.white, + return SafeArea( + child: Scaffold( + appBar: AppBar( + title: Text( + 'Interaction Forms', + //style: TextStyle(fontSize: isTablet ? 22 : 14, color: Colors.white), + ), + automaticallyImplyLeading: false, + // backgroundColor: const Color(0xFF2b9af3), + leading: InkWell( + onTap: () { + Navigator.pop(context); + }, + child: const Icon( + Icons.arrow_back_ios, + color: Colors.white, + ), ), ), - ), - body: Container( - child: Center( - child: ListView.builder( - itemCount: provider.intConfigDataList.length, - cacheExtent: double.parse( - provider.intConfigDataList.length.toString()), - itemBuilder: (context, index) { - return Column( - children: [ - ListTile( - title: Row( - children: [ - Text( - provider.intConfigDataList[index].name, - ), - const SizedBox( - width: 20, - ), - IconButton( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => - InteractionScreen( - index: index, - form: provider - .intConfigDataList[index] - .name, - ))); - }, - icon: const Icon( - Icons.arrow_circle_right_outlined, - size: 30, - color: Color.fromARGB(255, 8, 39, 92), + body: Container( + child: Center( + child: ListView.builder( + itemCount: provider.intConfigDataList.length, + cacheExtent: double.parse( + provider.intConfigDataList.length.toString()), + itemBuilder: (context, index) { + return Column( + children: [ + ListTile( + title: Row( + children: [ + Text( + provider.intConfigDataList[index].name, ), - ), - ], - ), - trailing: provider.savedList.indexWhere((element) => - element.form == - provider.intConfigDataList[index].name) != - -1 - ? InkWell( - onTap: () { - if (getCount( - provider - .intConfigDataList[index].name, - provider) != - 0) { - provider.savedList - .where((element) => - element.form == - provider.intConfigDataList[index] - .name) - .toList(); - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => - SavedFormListScreen( - formname: provider - .intConfigDataList[ - index] - .name, - ))); - } + const SizedBox( + width: 20, + ), + IconButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => + InteractionScreen( + index: index, + form: provider + .intConfigDataList[index] + .name, + ))); }, - child: FittedBox( - fit: BoxFit.scaleDown, - child: Text( - "${provider.savedList.where((element) => element.form == provider.intConfigDataList[index].name).length} record(s) saved", - style: TextStyle( - // fontSize: isTablet ? 18.0 : 14, - fontSize: 18.0, - color: Colors.blue.shade900), - ), + icon: const Icon( + Icons.arrow_circle_right_outlined, + size: 30, + color: Color.fromARGB(255, 8, 39, 92), ), - ) - : const SizedBox.shrink(), - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => - InteractionScreen( - index: index, - form: provider - .intConfigDataList[index].name, - ))); - }, - ), - const Divider(), - ], - ); - })), + ), + ], + ), + trailing: provider.savedList.indexWhere((element) => + element.form == + provider + .intConfigDataList[index].name) != + -1 + ? InkWell( + onTap: () { + if (getCount( + provider.intConfigDataList[index] + .name, + provider) != + 0) { + provider.savedList + .where((element) => + element.form == + provider + .intConfigDataList[index] + .name) + .toList(); + Navigator.push( + context, + MaterialPageRoute( + builder: + (BuildContext context) => + SavedFormListScreen( + formname: provider + .intConfigDataList[ + index] + .name, + ))); + } + }, + child: FittedBox( + fit: BoxFit.scaleDown, + child: Text( + "${provider.savedList.where((element) => element.form == provider.intConfigDataList[index].name).length} record(s) saved", + style: TextStyle( + // fontSize: isTablet ? 18.0 : 14, + fontSize: 18.0, + color: Colors.blue.shade900), + ), + ), + ) + : const SizedBox.shrink(), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => + InteractionScreen( + index: index, + form: provider + .intConfigDataList[index].name, + ))); + }, + ), + const Divider(), + ], + ); + })), + ), ), ); }); diff --git a/lib/ui_screen/interactionform/interactionprovider.dart b/lib/ui_screen/interactionform/interactionprovider.dart index 1fbfafd..745b287 100644 --- a/lib/ui_screen/interactionform/interactionprovider.dart +++ b/lib/ui_screen/interactionform/interactionprovider.dart @@ -1,3 +1,952 @@ +// import 'dart:convert'; +// // import 'dart:html'; + +// import 'package:discover_module/ui_screen/interactionform/model/interaction_config_data.dart'; +// import 'package:discover_module/ui_screen/interactionform/model/interaction_data.dart'; +// import 'package:discover_module/ui_screen/interactionform/repository/hive_repository.dart'; +// import 'package:discover_module/ui_screen/interactionform/util.dart'; +// import 'package:flutter/cupertino.dart'; +// import 'package:flutter/material.dart'; +// import 'package:hive_flutter/hive_flutter.dart'; + +// import 'package:discover_module/ui_screen/interactionform/model/json_form_data.dart'; + +// import 'package:discover_module/ui_screen/interactionform/model/location_model.dart'; + +// import 'package:discover_module/ui_screen/interactionform/model/save_interaction.dart'; + +// class InteractionProvider extends ChangeNotifier { +// List interactionReponseList = []; +// // List sectionList = []; +// List sectionList = []; +// late Location locationList; +// List textEditingControllerList = []; +// List multipletextEditingControllerList = []; +// int textfieldIndex = 0; + +// List checkboxlist = []; + +// String radioValue = ''; +// bool checkboxValue = false; + +// //List data = []; +// List newList = []; +// String sectionName = ''; +// late String selectedCity = 'Selected City', selectedState = 'Selected State'; + +// String? selectedValue; +// List selectedItems = []; +// InputClass? selectedObj; +// List savedList = []; +// List intConfigDataList = []; +// String? intId, intName; +// final HiveDataRepository _hiveprovider = HiveDataRepository( +// Hive.box('InteractionConfigDataBox')); + +// late bool _isLoading; + +// get isLoading => _isLoading; + +// initConfigData() async { +// _hiveprovider.openHiveBox(); +// intConfigDataList = _hiveprovider.getAllDataFromHive(); +// notifyListeners(); +// } + +// Future getRecords() async { +// var box = Hive.box('InteractionDataBox'); + +// if (!box.isOpen) { +// box = await Hive.openBox('InteractionDataBox'); +// } + +// savedList = box.values.toList(); +// print("savedListt: $savedList"); +// notifyListeners(); +// } + +// init(int index) async { +// await initConfigData(); +// InteractionConfigData interactionConfigData = intConfigDataList[index]; +// intId = intConfigDataList[index].id; +// intName = intConfigDataList[index].name; + +// radioValue = ''; +// print("data $intConfigDataList"); + +// await fetchData(interactionConfigData.widgets); +// notifyListeners(); +// } + +// initSavedForm(SaveInteraction saveInteractiondata) { +// interactionReponseList = saveInteractiondata.save +// .map((e) => FormFieldData( +// multipleList: e.multipleList == null +// ? [] +// : e.multipleList! +// .map((mobj) => SectionList( +// depid: mobj.depid, +// id: mobj.id, +// inputList: mobj.inputList, +// isRequired: mobj.isRequired, +// name: mobj.name, +// param: mobj.param, +// selectedValue: mobj.selectedValue, +// fileName: mobj.fileName, +// extension: mobj.extension, +// widget: mobj.widget, +// controller: mobj.controller, +// 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, +// isRequired: obj.isRequired, +// name: obj.name, +// param: obj.param, +// fileName: obj.fileName, +// extension: obj.extension, +// selectedValue: 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(); + +// textEditingControllerList.clear(); + +// for (var item in interactionReponseList) { +// sectionList = item.sectionList; +// for (var sectionItem in item.sectionList) { +// if (sectionItem.widget == InteractionWidget.TEXT) { +// var textEditingController = TextEditingController(); + +// textEditingControllerList.add(textEditingController); +// sectionItem.controller = textEditingControllerList.last; +// } +// if (sectionItem.widget == InteractionWidget.DROPDOWN || +// sectionItem.widget == InteractionWidget.AUTOCOMPLETE || +// sectionItem.widget == InteractionWidget.MULTISELECT) { +// List list = sectionItem.inputList!; +// sectionItem.value = list[0].id; +// print("value : ${list.first} "); +// } +// } +// } +// print(interactionReponseList); +// print("check textcontrollers ${textEditingControllerList.length}"); +// } + +// String getDataValue(String widgetId, String id) { +// print("issue *************"); +// if (id != "") { +// List list = []; +// String value = ' '; + +// for (FormFieldData obj1 in interactionReponseList) { +// // List list = +// for (SectionList obj in obj1.sectionList) { +// if (obj.id == widgetId) { +// list = obj.inputList!; +// } +// } +// } + +// if (list.isNotEmpty) { +// int index = list.indexWhere((element) => element.id.toString() == id); + +// if (index != -1) { +// value = list[index].name; +// } +// } + +// return value; +// } else { +// return " "; +// } +// } + +// // TODO: Search for widget with depid and check if selected is not null and by selected id get the data of current widget + +// List getData2(SectionList sectionItem) { +// print("SEctionItemmmmm: $selectedValue"); +// List list = []; +// // if (sectionItem.inputList != null) { +// list = sectionItem.inputList!; +// if (sectionItem.depid != "") { +// // print("check depid : ${sectionItem.depid}"); +// int i = 0; +// for (var obj in interactionReponseList) { +// i = obj.sectionList +// .indexWhere((element) => element.id == sectionItem.depid); +// // print("check depid index: $i"); +// if (i != -1) { +// //print("check depid value: ${obj.sectionList[i].value}"); +// if (obj.sectionList[i].value != null) { +// if (list +// .where((element) => element.pid == obj.sectionList[i].value) +// .isNotEmpty) { +// list = list +// .where((element) => element.pid == obj.sectionList[i].value) +// .toList(); + +// sectionItem.selectedObject = list[0]; +// } else { +// // InputClass obj = InputClass( +// // id: "obj.sectionList[i].value", +// // name: "Select ${sectionItem.name}"); +// list = []; +// // list.add(obj); +// sectionItem.selectedObject = null; +// } +// } else { +// // int index = obj.sectionList +// // .indexWhere((element) => element.id == sectionItem.id); + +// // list = obj.sectionList[index].inputList; +// } +// } +// } + +// // int index = data[i].data.indexWhere((element) => element.) +// } +// // } +// return list; +// } + +// setDropDownValue(String value, SectionList sectionItem, bool multiple) { +// int i = 0; +// print("selected $value"); +// for (var obj in interactionReponseList) { +// if (multiple && obj.multipleList != null) { +// i = obj.multipleList! +// .indexWhere((element) => element.id == sectionItem.id); +// if (i != -1) { +// obj.multipleList![i].value = value; +// obj.multipleList![i].selectedValue!.add(value); +// } +// } else { +// i = obj.sectionList +// .indexWhere((element) => element.id == sectionItem.id); +// if (i != -1) { +// obj.sectionList[i].value = value; +// obj.sectionList[i].selectedValue!.add(value); +// } +// } +// } +// notifyListeners(); +// } + +// // setTextValue(String value, SectionList sectionItem, bool multiple) { +// // print("Text_val = $value, $sectionItem, $multiple"); +// // int i = 0; +// // for (var obj in interactionReponseList) { +// // if (multiple && obj.multipleList != null) { +// // i = obj.multipleList! +// // .indexWhere((element) => element.id == sectionItem.id); +// // if (i != -1) { +// // obj.multipleList![i].value = value; +// // obj.multipleList![i].selectedValue!.add(value); +// // } +// // } else { +// // i = obj.sectionList +// // .indexWhere((element) => element.id == sectionItem.id); +// // if (i != -1) { +// // obj.sectionList[i].value = value; +// // obj.sectionList[i].selectedValue!.add(value); +// // } +// // } +// // } +// // notifyListeners(); +// // } + +// setTextValue(String value, SectionList sectionItem, bool multiple) { +// int i = 0; +// for (var obj in interactionReponseList) { +// if (multiple && obj.multipleList != null) { +// 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); +// } +// } else { +// i = obj.sectionList +// .indexWhere((element) => element.id == sectionItem.id); +// if (i != -1) { +// obj.sectionList[i].value = value; +// obj.sectionList[i].selectedValue!.add(value); +// } +// } +// } +// notifyListeners(); +// } + +// setAutoCompleteValue(String value, SectionList sectionItem, bool multiple) { +// int i = 0; +// for (var obj in interactionReponseList) { +// if (multiple && obj.multipleList != null) { +// i = obj.multipleList! +// .indexWhere((element) => element.id == sectionItem.id); +// if (i != -1) { +// obj.multipleList![i].value = value; +// obj.multipleList![i].selectedValue!.add(value); +// } +// } else { +// i = obj.sectionList +// .indexWhere((element) => element.id == sectionItem.id); +// if (i != -1) { +// obj.sectionList[i].value = value; +// obj.sectionList[i].selectedValue!.add(value); +// } +// } +// } +// notifyListeners(); +// } + +// Future fetchData(InteractionResultData interactionResultData) async { +// InteractionResultData interactionConfig = interactionResultData; + +// print("itemCategoryModel Item = + ${interactionConfig.result}"); +// // } +// interactionReponseList = interactionConfig.result; +// print("check stored: $interactionReponseList"); + +// textEditingControllerList.clear(); + +// for (var item in interactionReponseList) { +// sectionList = item.sectionList; +// for (var sectionItem in item.sectionList) { +// sectionItem.selectedValue = []; +// if (sectionItem.widget == InteractionWidget.TEXT) { +// var textEditingController = TextEditingController(); + +// textEditingControllerList.add(textEditingController); +// sectionItem.controller = textEditingControllerList.last; +// } +// if (sectionItem.widget == InteractionWidget.DROPDOWN || +// sectionItem.widget == InteractionWidget.AUTOCOMPLETE || +// sectionItem.widget == InteractionWidget.MULTISELECT) { +// // int index = data +// // .indexWhere((element) => element.widgetId == sectionItem.id); +// // List list = data[index].data; +// List list = sectionItem.inputList!; +// sectionItem.value = list[0].id; +// if (sectionItem.widget == InteractionWidget.MULTISELECT) { +// sectionItem.selectedValue!.add(list[0].name); +// } else { +// sectionItem.selectedValue!.add(list[0].id); +// } + +// sectionItem.selectedObject = list[0]; +// print("value : ${list.first} "); +// } else if (sectionItem.widget == InteractionWidget.CHECKBOX) { +// List list = sectionItem.inputList!; +// if (list.isNotEmpty) { +// for (var element in sectionItem.inputList!) { +// element.ischecked = false; +// } +// } +// // sectionItem.value = list[0].id; +// // sectionItem.selectedValue!.add(list[0].id); +// } +// } +// } +// print(interactionReponseList); +// print("check textcontrollers ${textEditingControllerList.length}"); +// notifyListeners(); + +// return "success"; +// } + +// resetAllWidgetsData() { +// textEditingControllerList.clear(); + +// for (var item in interactionReponseList) { +// item.multipleList = []; +// sectionList = item.sectionList; +// for (var sectionItem in item.sectionList) { +// sectionItem.selectedValue = []; +// // sectionItem.value = ''; +// // sectionItem.selectedObject = InputClass(id: '', name: ''); +// if (sectionItem.widget == InteractionWidget.TEXT) { +// var textEditingController = TextEditingController(); + +// textEditingControllerList.add(textEditingController); +// sectionItem.controller = textEditingControllerList.last; +// } +// if (item.sectionName != "Other") { +// if (sectionItem.widget == InteractionWidget.DROPDOWN || +// sectionItem.widget == InteractionWidget.AUTOCOMPLETE || +// sectionItem.widget == InteractionWidget.MULTISELECT) { +// // int index = data +// // .indexWhere((element) => element.widgetId == sectionItem.id); +// print("Selected widget : ${sectionItem.id}"); +// List list = sectionItem.inputList!; +// sectionItem.value = list[0].id; +// sectionItem.selectedObject = list[0]; +// print("value : ${list.first.name} "); +// } +// } +// } +// } +// print(interactionReponseList); +// print("check textcontrollers ${textEditingControllerList.length}"); +// notifyListeners(); +// } + +// setRadioValue(SectionList sectionItem) { +// List list = (sectionItem.input as List) +// .map((itemWord) => InputClass.fromJson(itemWord)) +// .toList(); +// radioValue = list[0].name; + +// notifyListeners(); +// } + +// setcheckBoxValue(SectionList sectionItem, String sectionName, bool newValue, +// String id, bool multiple) { +// int index = +// sectionItem.inputList!.indexWhere((element) => element.id == id); +// sectionItem.inputList![index].ischecked = newValue; +// // sectionItem.selectedValue.add(data[i].data[index].id); +// int index2 = 0; +// for (var obj in interactionReponseList) { +// if (multiple && obj.multipleList != null) { +// index2 = obj.multipleList! +// .indexWhere((element) => element.id == sectionItem.id); +// if (index2 != -1) { +// obj.multipleList![index2].value = sectionItem.inputList![index].id; +// obj.multipleList![index2].selectedValue! +// .add(sectionItem.inputList![index].id); +// } +// } else { +// index2 = obj.sectionList +// .indexWhere((element) => element.id == sectionItem.id); +// if (index2 != -1) { +// obj.sectionList[index2].value = sectionItem.inputList![index].id; +// obj.sectionList[index2].selectedValue! +// .add(sectionItem.inputList![index].id); +// } +// } +// } +// notifyListeners(); +// } + +// // getSectionItem(String sectionName) { +// // print("sectionName_issss : $sectionName"); +// // newList = []; +// // List addList = []; +// // int index = interactionReponseList +// // .indexWhere((element) => element.sectionName == sectionName); + +// // print("addList_isss: $addList"); + +// // addList = interactionReponseList[index] +// // .sectionList +// // .map((e) => SectionList( +// // depid: e.depid, +// // id: e.id, +// // inputList: e.inputList, +// // isRequired: e.isRequired, +// // name: e.name, +// // param: e.param, +// // selectedValue: [], +// // widget: e.widget, +// // controller: e.controller, +// // gid: e.gid, +// // input: e.input, +// // selectedId: e.selectedId, +// // value: e.value)) +// // .toList(); +// // SectionList delItem = SectionList( +// // name: "delete", +// // param: "deletebtn", +// // id: "deletebtn", +// // selectedValue: [], +// // depid: "", +// // widget: InteractionWidget.BUTTON, +// // inputList: [], +// // isRequired: true); + +// // addList.add(delItem); + +// // // if (interactionReponseList[index].multipleList!.isEmpty) { +// // // newList = addList; +// // // } else { +// // if (interactionReponseList[index].multipleList == null) { +// // interactionReponseList[index].multipleList = addList; +// // print("iff: $addList"); +// // } else { +// // // interactionReponseList[index].multipleList = +// // // // interactionReponseList[index].multipleList! + addList; +// // // interactionReponseList[index].multipleList! + addList; + +// // interactionReponseList[index].multipleList = +// // interactionReponseList[index].multipleList! + addList; + +// // print("iffelse: $addList"); +// // } + +// // newList = interactionReponseList[index].multipleList!; + +// // print("newList_iss: $newList"); + +// // // newList = newList + addList; +// // // } +// // 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) { +// // print("objectt"); +// // var textEditingController = TextEditingController(); + +// // multipletextEditingControllerList.add(textEditingController); +// // obj.controller = multipletextEditingControllerList.last; +// // } +// // // newList.add(obj); +// // } +// // } + +// // print( +// // "check length : ${interactionReponseList[index].multipleList!.length}"); +// // notifyListeners(); +// // } + +// getSectionItem(String sectionName) { +// newList = []; +// List addList = []; +// int index = interactionReponseList +// .indexWhere((element) => element.sectionName == sectionName); +// var textEditingController = TextEditingController(); +// addList = interactionReponseList[index] +// .sectionList +// .map((e) => SectionList( +// depid: e.depid, +// id: e.id, +// inputList: e.inputList, +// isRequired: e.isRequired, +// name: e.name, +// param: e.param, +// selectedValue: [], +// widget: e.widget, +// controller: e.controller, +// gid: e.gid, +// input: e.input, +// selectedId: e.selectedId, +// value: e.value)) +// .toList(); +// SectionList delItem = SectionList( +// name: "delete", +// param: "deletebtn", +// id: "deletebtn", +// selectedValue: [], +// depid: "", +// widget: InteractionWidget.BUTTON, +// inputList: [], +// isRequired: true); + +// addList.add(delItem); + +// 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; +// } +// // newList.add(obj); +// } + +// // if (interactionReponseList[index].multipleList!.isEmpty) { +// // newList = addList; +// // } else { +// if (interactionReponseList[index].multipleList == null) { +// interactionReponseList[index].multipleList = addList; +// } else { +// interactionReponseList[index].multipleList = +// interactionReponseList[index].multipleList! + addList; +// } + +// newList = interactionReponseList[index].multipleList!; +// // newList = newList + addList; +// // } +// 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(); + +// // multipletextEditingControllerList.add(textEditingController); +// // obj.controller = multipletextEditingControllerList.last; +// // } +// //newList.add(obj); +// } +// } + +// print( +// "check length : ${interactionReponseList[index].multipleList!.length}"); +// notifyListeners(); +// } + +// deleteMultipleRows( +// int gid, SectionList sectionItem, String selectedSectionName) { +// int index = interactionReponseList +// .indexWhere((element) => element.sectionName == selectedSectionName); + +// print("controllerssssss : ${multipletextEditingControllerList.length}"); +// interactionReponseList[index] +// .multipleList! +// .removeWhere((item) => item.gid == gid); + +// notifyListeners(); +// } + +// bool validateMultipleRows() { +// for (var obj in interactionReponseList) { +// if (obj.multipleList != null) { +// for (var mulobj in obj.multipleList!) { +// if (mulobj.widget == InteractionWidget.TEXT) { +// if (mulobj.controller!.text.isEmpty) { +// return true; +// } +// } +// } +// } +// } +// return false; +// } + +// // bool validateTextFields() { +// // for (var obj in interactionReponseList) { +// // print("validateForm_is: ${obj.sectionList}"); +// // for (var mulobj in obj.sectionList) { +// // print("mulobj_is: ${mulobj}"); +// // print("mulobj_is: ${mulobj.widget}"); +// // print("mulobj_is: ${mulobj.isRequired}"); + +// // if (mulobj.widget == InteractionWidget.TEXT) { +// // if (mulobj.controller!.text.isEmpty) { +// // return true; +// // } +// // } +// // } +// // } +// // return false; +// // } + +// bool validateTextFields() { +// print("Validation_is : ${interactionReponseList.isEmpty}"); +// for (var obj in interactionReponseList) { +// print("validateForm_is: ${obj.sectionList}"); +// for (var mulobj in obj.sectionList) { +// print("mulobj_is: ${mulobj}"); +// print("mulobj_is: ${mulobj.widget}"); +// print("mulobj_is: ${mulobj.validation!.isRequired}"); + +// // if (mulobj.widget == InteractionWidget.TEXT) { +// // if (mulobj.controller!.text.isEmpty) { +// // print("I_amTextWidget"); +// // return false; +// // } +// // } + +// if (mulobj.validation!.isRequired == true) { +// if (mulobj.widget == InteractionWidget.TEXT) { +// if (mulobj.controller!.text.isEmpty) { +// print("Text_isEmpty"); +// //return false; +// } +// } else if (mulobj.widget == InteractionWidget.AUTOCOMPLETE) { +// if (mulobj.selectedId == null) { +// print("Auto_isEmpty"); +// //return false; +// } +// } else if (mulobj.widget == InteractionWidget.DROPDOWN) { +// if (mulobj.selectedId == null) { +// print("Dropdown_isEmpty"); +// //return false; +// } +// } else if (mulobj.widget == InteractionWidget.values) { +// if (mulobj.selectedId == null) { +// print("Dropdown_isEmpty"); +// //return false; +// } +// } +// // showDialog(context: context, builder: (_){ + +// // return AboutDialog() +// // }); +// } +// } +// return false; +// } +// return false; +// } + +// Future saveJsonObject(BuildContext context, String form, +// {bool isEdit = false}) async { +// print("form_data: $form"); +// List 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, +// name: mobj.name, +// param: mobj.param, +// selectedValue: mobj.selectedValue, +// extension: mobj.extension, +// fileName: mobj.fileName, +// widget: mobj.widget, +// // controller: mobj.controller, +// 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, +// isRequired: obj.isRequired, +// name: obj.name, +// param: obj.param, +// selectedValue: obj.selectedValue, +// widget: obj.widget, +// controller: obj.controller, +// gid: obj.gid, +// input: obj.input, +// extension: obj.extension, +// fileName: obj.fileName, +// selectedId: obj.selectedId, +// value: obj.value)) +// .toList(), +// sectionName: e.sectionName, +// multiple: e.multiple)) +// .toList(); + +// String generateId = '${intId}R${await getNextAutoIncrementValue()}'; + +// print("Result_data_is: ${FormFieldData}"); + +// if (validateSectionList(resultData)) { +// _isLoading = true; +// notifyListeners(); +// final data = SaveInteraction( +// save: resultData, +// id: generateId, +// updatedTime: DateTime.now().toString(), +// form: form, +// intId: intId ?? "id", +// intName: intName ?? "name"); +// var box = Hive.box('InteractionDataBox'); + +// if (!box.isOpen) { +// box = await Hive.openBox('InteractionDataBox'); +// } + +// print("Data_Result_is: ${data}"); + +// // // if (validateJson1(data.save.first)) { +// await box.put(await getNextAutoIncrementValue(), data); +// } else { +// _isLoading = false; +// notifyListeners(); + +// // Handle validation error +// print("JSON data is not valid according to the schema."); +// } +// // box.close(); +// await getRecords(); +// return generateId; +// } + +// List getModifiedList(List sectionList) { +// List newSectionList = []; +// for (var obj in sectionList) { +// if (obj.id != 'deletebtn') { +// if (obj.input == 'chooseFile') { +// MultipleSectionList newobj = MultipleSectionList( +// id: obj.id, +// selectedValue: obj.selectedValue!, +// extension: obj.extension!, +// fileName: obj.fileName!, +// ); + +// newSectionList.add(newobj); +// } else { +// MultipleSectionList newobj = MultipleSectionList( +// id: obj.id, +// selectedValue: obj.selectedValue!, +// ); +// newSectionList.add(newobj); +// } +// } +// } +// return newSectionList; +// } + +// List> getMultipleSectionList( +// List sectionList, List multipleList) { +// List> list = []; +// List> listing = []; +// List secList = getModifiedList(sectionList); +// List multipleList0 = getModifiedList(multipleList); +// list.add(secList); +// listing.add(secList); +// // List listing = []; +// if (multipleList.isNotEmpty) { +// final releaseDateMap = multipleList.groupBy((m) => m.gid); +// print("see map : $releaseDateMap"); + +// if (releaseDateMap.isNotEmpty) { +// listing = []; +// List> mulList = +// releaseDateMap.values.toList(growable: true); +// for (var item in mulList) { +// listing.add(getModifiedList(item)); +// } +// listing.add(secList); +// list = [...listing]; + +// //}); +// } +// } +// return list; +// } + +// SaveInteractionFormJson formJson(SaveInteraction saveInteraction) { +// List saveList = []; +// for (var obj in saveInteraction.save) { +// Save saveobj = Save( +// sectionName: obj.sectionName, +// multipleSectionList: +// getMultipleSectionList(obj.sectionList, obj.multipleList!)); +// saveList.add(saveobj); +// } + +// SaveInteractionFormJson saveInteractionFormJson = SaveInteractionFormJson( +// interactionForm1: saveInteraction.form!, +// intId: saveInteraction.id, +// intName: saveInteraction.intName, +// save: saveList); +// return saveInteractionFormJson; +// } + +// bool validateJson1(FormFieldData data) { +// print("Checking_data1 ${data.sectionName}"); + +// print("Checking_data1 ${data.sectionList}"); +// return false; +// } + +// bool validateSectionList(List resultData) { +// for (var formData in resultData) { +// for (var section in formData.sectionList) { +// print("Section_isssss: $section"); +// print("Section_isssss: ${section.isRequired}"); +// print("Section_isssss: ${section.widget}"); + +// 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) { +// // if (msection.controller!.text.isEmpty) { +// // debugPrint("Iam 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; +// } + +// String? validateId(String? value) { +// if (value == null || value.isEmpty) { +// print("D is required"); +// return 'ID is required'; +// } +// // Add more validation rules if needed +// return null; +// } +// } + import 'dart:convert'; // import 'dart:html'; @@ -42,6 +991,10 @@ class InteractionProvider extends ChangeNotifier { final HiveDataRepository _hiveprovider = HiveDataRepository( Hive.box('InteractionConfigDataBox')); + late bool _isLoading; + + get isLoading => _isLoading; + initConfigData() async { _hiveprovider.openHiveBox(); intConfigDataList = _hiveprovider.getAllDataFromHive(); @@ -246,8 +1199,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 +1373,7 @@ class InteractionProvider extends ChangeNotifier { List addList = []; int index = interactionReponseList .indexWhere((element) => element.sectionName == sectionName); - + var textEditingController = TextEditingController(); addList = interactionReponseList[index] .sectionList .map((e) => SectionList( @@ -450,6 +1403,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 +1430,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 +1489,12 @@ class InteractionProvider extends ChangeNotifier { Future 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 resultData = interactionReponseList .map((e) => FormFieldData( multipleList: e.multipleList == null @@ -541,7 +1511,7 @@ class InteractionProvider extends ChangeNotifier { extension: mobj.extension, fileName: mobj.fileName, widget: mobj.widget, - // controller: mobj.controller, + // controller: mobj.controller, gid: mobj.gid, input: mobj.input, selectedId: mobj.selectedId, @@ -570,24 +1540,53 @@ class InteractionProvider extends ChangeNotifier { .toList(); String generateId = '${intId}R${await getNextAutoIncrementValue()}'; + if (validateSectionList(resultData)) { + _isLoading = true; + notifyListeners(); + final data = SaveInteraction( + save: resultData, + id: generateId, + updatedTime: DateTime.now().toString(), + form: form, + intId: intId ?? "id", + intName: intName ?? "name"); + var box = Hive.box('InteractionDataBox'); - final data = SaveInteraction( - save: resultData, - id: generateId, - updatedTime: DateTime.now().toString(), - form: form, - intId: intId ?? "id", - intName: intName ?? "name"); - var box = Hive.box('InteractionDataBox'); + if (!box.isOpen) { + box = await Hive.openBox('InteractionDataBox'); + } - if (!box.isOpen) { - box = await Hive.openBox('InteractionDataBox'); + print("Data_Result_is: ${data}"); + + // // if (validateJson1(data.save.first)) { + await box.put(await getNextAutoIncrementValue(), data); + } else { + _isLoading = false; + notifyListeners(); + + // Handle validation error + print("JSON data is not valid according to the schema."); } - - await box.put(await getNextAutoIncrementValue(), data); - // box.close(); await getRecords(); return generateId; + + // final data = SaveInteraction( + // save: resultData, + // id: generateId, + // updatedTime: DateTime.now().toString(), + // form: form, + // intId: intId ?? "id", + // intName: intName ?? "name"); + // var box = Hive.box('InteractionDataBox'); + + // if (!box.isOpen) { + // box = await Hive.openBox('InteractionDataBox'); + // } + + // await box.put(await getNextAutoIncrementValue(), data); + // // box.close(); + // await getRecords(); + // return generateId; // await MockApiCall().postFormData(data); // await prov.addOfflineData(data); } @@ -663,4 +1662,95 @@ class InteractionProvider extends ChangeNotifier { save: saveList); return saveInteractionFormJson; } + + bool validateSectionList(List 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; + } } diff --git a/lib/ui_screen/interactionform/mockapi.dart b/lib/ui_screen/interactionform/mockapi.dart index dfd9ad1..4d4ed2b 100644 --- a/lib/ui_screen/interactionform/mockapi.dart +++ b/lib/ui_screen/interactionform/mockapi.dart @@ -16,10 +16,12 @@ class MockApiCall { final response = await dio.get('https://passvault.konectar.io/forms'); - print("response1"); + print("response1_isssss"); // print(response.data.toString()); - log('${jsonEncode(response.data)}'); + // log(jsonEncode(response.data)); + final parsedJson = json.encode(response.data); + print(parsedJson); return response.data; } diff --git a/lib/ui_screen/interactionform/model/interaction_data.dart b/lib/ui_screen/interactionform/model/interaction_data.dart index dfb1493..ffd2807 100644 --- a/lib/ui_screen/interactionform/model/interaction_data.dart +++ b/lib/ui_screen/interactionform/model/interaction_data.dart @@ -98,6 +98,11 @@ class FormFieldData { Map saveToJson() => { "sectionName": sectionName, }; + @override + String toString() { + // TODO: implement toString + return multiple.toString(); + } } @HiveType(typeId: 5) diff --git a/lib/ui_screen/interactionform/model/save_interaction.dart b/lib/ui_screen/interactionform/model/save_interaction.dart index fb8597b..56dd893 100644 --- a/lib/ui_screen/interactionform/model/save_interaction.dart +++ b/lib/ui_screen/interactionform/model/save_interaction.dart @@ -62,6 +62,12 @@ class SaveInteraction { "form": form, "intId": intId, }; + + @override + String toString() { + // TODO: implement toString + return save.toString(); + } } class JsonFormat {} diff --git a/lib/ui_screen/interactionform/repository/hive_repository.dart b/lib/ui_screen/interactionform/repository/hive_repository.dart index ffdc22f..3248fd6 100644 --- a/lib/ui_screen/interactionform/repository/hive_repository.dart +++ b/lib/ui_screen/interactionform/repository/hive_repository.dart @@ -10,7 +10,7 @@ class HiveDataRepository extends ChangeNotifier { HiveDataRepository(this._hiveBox); List getAllDataFromHive() { - print("Stored_ALL_valuesssss : ${_hiveBox.values.toList()}"); + print("Stored_ALL_valuesssss : ${_hiveBox.values.toList().toString()}"); print( "Stored_ALL_valuesssss_leangthhh : ${_hiveBox.values.toList().length}"); diff --git a/lib/ui_screen/interactionform/view_forms_list.dart b/lib/ui_screen/interactionform/view_forms_list.dart index 5379486..38e8710 100644 --- a/lib/ui_screen/interactionform/view_forms_list.dart +++ b/lib/ui_screen/interactionform/view_forms_list.dart @@ -39,110 +39,113 @@ class _SavedFormListScreenState extends State { Widget build(BuildContext context) { return Consumer( builder: (BuildContext context, provider, Widget? child) { - return Scaffold( - appBar: AppBar( - title: Text( - 'Records of ${widget.formname}', - style: TextStyle(fontSize: isTablet ? 22 : 14, color: Colors.white), - ), - automaticallyImplyLeading: false, - // backgroundColor: const Color(0xFF2b9af3), - leading: InkWell( - onTap: () { - Navigator.pop(context); - }, - child: const Icon( - Icons.arrow_back_ios, - color: Colors.white, + return SafeArea( + child: Scaffold( + appBar: AppBar( + title: Text( + 'Records of ${widget.formname}', + style: + TextStyle(fontSize: isTablet ? 22 : 14, color: Colors.white), + ), + automaticallyImplyLeading: false, + // backgroundColor: const Color(0xFF2b9af3), + leading: InkWell( + onTap: () { + Navigator.pop(context); + }, + child: const Icon( + Icons.arrow_back_ios, + color: Colors.white, + ), ), ), - ), - body: Container( - child: Center( - child: ListView.builder( - itemCount: provider.savedList.length, - cacheExtent: - double.parse(provider.savedList.length.toString()), - itemBuilder: (context, index) { - return Column( - children: [ - ListTile( - subtitle: Text( - 'Updated on ${provider.savedList[index].updatedTime}', - //style: TextStyle(fontStyle: FontStyle.italic), - ), - title: Text( - provider.savedList[index].id, - ), - trailing: SizedBox( - width: 150, - child: Row(children: [ - IconButton( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => - ViewInteractionScreen( - saveInteraction: - provider.savedList[index], - ))); - }, - icon: const Icon( - Icons.info_outline, - size: 24, - color: Color.fromARGB(255, 8, 39, 92), - ), - ), - IconButton( - onPressed: () async { - await provider.initConfigData().then({ + body: Container( + child: Center( + child: ListView.builder( + itemCount: provider.savedList.length, + cacheExtent: + double.parse(provider.savedList.length.toString()), + itemBuilder: (context, index) { + return Column( + children: [ + ListTile( + subtitle: Text( + 'Updated on ${provider.savedList[index].updatedTime}', + //style: TextStyle(fontStyle: FontStyle.italic), + ), + title: Text( + provider.savedList[index].id, + ), + trailing: SizedBox( + width: 150, + child: Row(children: [ + IconButton( + onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (BuildContext context) => - EditInteractionScreen( + ViewInteractionScreen( saveInteraction: provider.savedList[index], - ))) - }); - }, - icon: const Icon( - Icons.edit, - size: 24, - color: Color.fromARGB(255, 8, 39, 92), + ))); + }, + icon: const Icon( + Icons.info_outline, + size: 24, + color: Color.fromARGB(255, 8, 39, 92), + ), ), - ), - IconButton( - onPressed: () { - showDeleteRecordAlertDialog( - context, - provider.savedList[index].id, - provider.savedList[index]); - }, - icon: const Icon( - Icons.delete, - size: 24, - color: Color.fromARGB(255, 8, 39, 92), + IconButton( + onPressed: () async { + await provider.initConfigData().then({ + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => + EditInteractionScreen( + saveInteraction: provider + .savedList[index], + ))) + }); + }, + icon: const Icon( + Icons.edit, + size: 24, + color: Color.fromARGB(255, 8, 39, 92), + ), ), - ), - ]), + IconButton( + onPressed: () { + showDeleteRecordAlertDialog( + context, + provider.savedList[index].id, + provider.savedList[index]); + }, + icon: const Icon( + Icons.delete, + size: 24, + color: Color.fromARGB(255, 8, 39, 92), + ), + ), + ]), + ), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => + ViewInteractionScreen( + saveInteraction: + provider.savedList[index], + ))); + }, ), - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => - ViewInteractionScreen( - saveInteraction: - provider.savedList[index], - ))); - }, - ), - const Divider(), - ], - ); - })), + const Divider(), + ], + ); + })), + ), ), ); }); diff --git a/lib/ui_screen/interactionform/view_interaction_screen.dart b/lib/ui_screen/interactionform/view_interaction_screen.dart index a5f3a21..5957711 100644 --- a/lib/ui_screen/interactionform/view_interaction_screen.dart +++ b/lib/ui_screen/interactionform/view_interaction_screen.dart @@ -51,219 +51,229 @@ class _ViewInteractionScreenState extends State { FocusScope.of(context).requestFocus(FocusNode()); }, child: OrientationBuilder(builder: (context, orientation) { - return Scaffold( - //resizeToAvoidBottomInset: false, - appBar: AppBar( - title: Text( - widget.saveInteraction.id, - style: TextStyle( - fontSize: isTablet ? 22 : 14, color: Colors.white), - ), - // backgroundColor: const Color(0xFF2b9af3), - automaticallyImplyLeading: false, - leading: InkWell( - onTap: () { - Navigator.pop(context); - }, - child: const Icon( - Icons.arrow_back_ios, - color: Colors.white, + return SafeArea( + child: Scaffold( + //resizeToAvoidBottomInset: false, + appBar: AppBar( + title: Text( + widget.saveInteraction.id, + style: TextStyle( + fontSize: isTablet ? 22 : 14, color: Colors.white), ), - ), - ), - body: Column( - children: [ - Expanded( - child: ListView.builder( - itemCount: provider.interactionReponseList.length, - cacheExtent: double.parse( - provider.interactionReponseList.length.toString()), - itemBuilder: (context, index) { - var item = provider.interactionReponseList[index]; - sectionList = item.sectionList; - return ExpansionTile( - initiallyExpanded: true, - title: Stack( - alignment: AlignmentDirectional.center, - children: [ - Container( - // height: double.infinity, - width: double.infinity, - padding: const EdgeInsets.all(8.0), - decoration: BoxDecoration( - // color: Color(0xFF2b9af3), - color: Constants.k2color, - ), - child: Text( - item.sectionName, - style: const TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 18.0), - )), - ]), - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const SizedBox( - height: 20, - ), - - Padding( - padding: isTablet - ? const EdgeInsets.only(left: 18.0) - : const EdgeInsets.only( - left: 12.0, right: 12.0), - child: GridView.count( - physics: - const NeverScrollableScrollPhysics(), - // crossAxisCount: context.responsive( - // 1, - // sm: 1, // small - // md: 1, // medium - // lg: sectionList.length == 1 - // ? 1 - // : 4, // large - // xl: 3, // extra large screen - // ), - // mainAxisSpacing: - // sectionList.length == 1 || !isTablet - // ? 1 - // : 3.5, - // shrinkWrap: true, - // padding: EdgeInsets.zero, - // childAspectRatio: - // sectionList.length == 1 || !isTablet - // ? orientation == - // Orientation.landscape - // ? 10 - // : 3.8 - // : 2.8, - crossAxisCount: context.responsive( - 1, - sm: 1, // small - md: 2, // medium - lg: sectionList.length == 1 - ? 1 - : 3, // large - xl: 3, // extra large screen - ), - mainAxisSpacing: - sectionList.length == 1 || !isTablet - ? 1 - : 3.5, - childAspectRatio: - sectionList.length == 1 - ? orientation == - Orientation.landscape - ? 10 - : 4.8 - : isTablet - ? 2.8 - : 3.0, - shrinkWrap: true, - padding: EdgeInsets.zero, - children: List.generate( - sectionList.length, - (i) { - print(sectionList); - SectionList sectionItem = - sectionList[i]; - dropdownvalue = sectionItem - .widget == - InteractionWidget.DROPDOWN - ? sectionItem.value ?? "Select" - : ' '; - List 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 Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - sectionItem.widget == - InteractionWidget - .BUTTON && - sectionItem.param == - 'add' - ? const SizedBox.shrink() - : Text( - '${sectionItem.name}:*', - style: TextStyle( - color: Colors - .orange.shade800, - fontSize: isTablet - ? 18 - : 12, - ), - ), - SizedBox( - height: isTablet ? 15 : 5, - ), - returnWidget( - sectionItem: sectionItem, - item: item, - provider: provider, - list: list, - gridIndex: i, - listIndex: index, - widgetData: - sectionItem.widget!), - SizedBox( - height: isTablet ? 15 : 5, - ), - ], - ); - }, - ), - ), - ), - SizedBox( - height: isTablet ? 15 : 5, - ), - item.multiple - ? gridViewWidget( - provider, - item.sectionName, - item.multipleList ?? [], - orientation, - item, - index) - : const SizedBox.shrink(), - provider.interactionReponseList.length == - index - 1 - ? saveActions(provider) - : const SizedBox.shrink() - //const Spacer(), - ], - ), - ), - ]); - }, + // backgroundColor: const Color(0xFF2b9af3), + automaticallyImplyLeading: false, + leading: InkWell( + onTap: () { + Navigator.pop(context); + }, + child: const Icon( + Icons.arrow_back_ios, + color: Colors.white, ), ), - // const Spacer(), - // saveActions(provider), - ], - )); + ), + body: Column( + children: [ + Expanded( + child: ListView.builder( + itemCount: provider.interactionReponseList.length, + cacheExtent: double.parse( + provider.interactionReponseList.length.toString()), + itemBuilder: (context, index) { + var item = provider.interactionReponseList[index]; + sectionList = item.sectionList; + return ExpansionTile( + initiallyExpanded: true, + title: Stack( + alignment: AlignmentDirectional.center, + children: [ + Container( + // height: double.infinity, + width: double.infinity, + padding: const EdgeInsets.all(8.0), + decoration: BoxDecoration( + // color: Color(0xFF2b9af3), + color: Constants.k2color, + ), + child: Text( + item.sectionName, + style: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18.0), + )), + ]), + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + const SizedBox( + height: 20, + ), + + Padding( + padding: isTablet + ? const EdgeInsets.only(left: 18.0) + : const EdgeInsets.only( + left: 12.0, right: 12.0), + child: GridView.count( + physics: + const NeverScrollableScrollPhysics(), + // crossAxisCount: context.responsive( + // 1, + // sm: 1, // small + // md: 1, // medium + // lg: sectionList.length == 1 + // ? 1 + // : 4, // large + // xl: 3, // extra large screen + // ), + // mainAxisSpacing: + // sectionList.length == 1 || !isTablet + // ? 1 + // : 3.5, + // shrinkWrap: true, + // padding: EdgeInsets.zero, + // childAspectRatio: + // sectionList.length == 1 || !isTablet + // ? orientation == + // Orientation.landscape + // ? 10 + // : 3.8 + // : 2.8, + crossAxisCount: + context.responsive( + 1, + sm: 1, // small + md: 2, // medium + lg: sectionList.length == 1 + ? 1 + : 3, // large + xl: 3, // extra large screen + ), + mainAxisSpacing: + sectionList.length == 1 || + !isTablet + ? 1 + : 3.5, + childAspectRatio: + sectionList.length == 1 + ? orientation == + Orientation.landscape + ? 10 + : 4.8 + : isTablet + ? 2.8 + : 3.0, + shrinkWrap: true, + padding: EdgeInsets.zero, + 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) + : []; + + return Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + sectionItem.widget == + InteractionWidget + .BUTTON && + sectionItem.param == + 'add' + ? const SizedBox.shrink() + : Text( + '${sectionItem.name}:*', + style: TextStyle( + color: Colors.orange + .shade800, + fontSize: isTablet + ? 18 + : 12, + ), + ), + SizedBox( + height: isTablet ? 15 : 5, + ), + returnWidget( + sectionItem: sectionItem, + item: item, + provider: provider, + list: list, + gridIndex: i, + listIndex: index, + widgetData: + sectionItem.widget!), + SizedBox( + height: isTablet ? 15 : 5, + ), + ], + ); + }, + ), + ), + ), + SizedBox( + height: isTablet ? 15 : 5, + ), + item.multiple + ? gridViewWidget( + provider, + item.sectionName, + item.multipleList ?? [], + orientation, + item, + index) + : const SizedBox.shrink(), + provider.interactionReponseList.length == + index - 1 + ? saveActions(provider) + : const SizedBox.shrink() + //const Spacer(), + ], + ), + ), + ]); + }, + ), + ), + // const Spacer(), + // saveActions(provider), + ], + )), + ); }), ); }); @@ -375,6 +385,88 @@ class _ViewInteractionScreenState extends State { ); } + // Widget gridViewWidget( + // InteractionProvider provider, + // String sectionName, + // List sectionList, + // Orientation orientation, + // FormFieldData item, + // int listIndex) { + // return Padding( + // padding: isTablet + // ? const EdgeInsets.only(left: 22.0) + // : const EdgeInsets.only(left: 12.0, right: 12.0), + // child: GridView.count( + // physics: const NeverScrollableScrollPhysics(), + // crossAxisCount: context.responsive( + // 1, // default + // sm: 1, // small + // md: 1, // medium + // lg: sectionList.length == 1 ? 1 : 4, // large + // xl: 5, // extra large screen + // ), + // 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, + // children: List.generate( + // sectionList.length, + // (i) { + // print(sectionList); + // SectionList sectionItem = sectionList[i]; + // dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN + // ? sectionItem.value ?? "Select" + // : ' '; + // List 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 Wrap(children: [ + // 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!), + // ], + // ), + // ]); + // }, + // ), + // ), + // ); + // } + Widget gridViewWidget( InteractionProvider provider, String sectionName, @@ -382,77 +474,118 @@ class _ViewInteractionScreenState extends State { Orientation orientation, FormFieldData item, int listIndex) { + List pooja = sectionList; + + print("Pooja: $pooja"); + + List> convertedArray = []; + print("Provider Length: ${item.sectionList.length}"); + + for (int i = 0; i < sectionList.length; i += item.sectionList.length + 1) { + print("Section List11111: $sectionList"); + print("item.sectionList.length List11111: ${item.sectionList.length}"); + + convertedArray + .add(sectionList.sublist(i, i + item.sectionList.length + 1)); + } + print("ConvertedArrayEdit.leangth: $convertedArray"); + print("ConvertedArray.leangth2323: ${convertedArray.length}"); + return Padding( padding: isTablet ? const EdgeInsets.only(left: 22.0) : const EdgeInsets.only(left: 12.0, right: 12.0), - child: GridView.count( - physics: const NeverScrollableScrollPhysics(), - crossAxisCount: context.responsive( - 1, // default - sm: 1, // small - md: 1, // medium - lg: sectionList.length == 1 ? 1 : 4, // large - xl: 5, // extra large screen - ), - 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, - children: List.generate( - sectionList.length, - (i) { - print(sectionList); - SectionList sectionItem = sectionList[i]; - dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN - ? sectionItem.value ?? "Select" - : ' '; - List list = - sectionItem.widget == InteractionWidget.DROPDOWN || + child: Column( + children: [ + for (var i = 0; i < convertedArray.length; i++) + GridView.builder( + physics: const NeverScrollableScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: context.responsive( + 1, // default + sm: 1, // small + md: 1, // medium + lg: sectionList.length == 1 ? 1 : 4, // large + xl: 5, // extra large screen + ), + 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 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 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) - : []; + provider.checkboxlist = + sectionItem.widget == InteractionWidget.CHECKBOX + ? provider.getData2(sectionItem) + : []; - return Wrap(children: [ - 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, + 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!), + ], ), - returnWidget( - sectionItem: sectionItem, - item: item, - provider: provider, - list: list, - gridIndex: i, - listIndex: listIndex, - widgetData: sectionItem.widget!), - ], - ), - ]); - }, - ), + ); + }, + ), + //), + ], ), ); } diff --git a/lib/ui_screen/interactionform/viewinteractionprovider.dart b/lib/ui_screen/interactionform/viewinteractionprovider.dart index 9f415c7..a522957 100644 --- a/lib/ui_screen/interactionform/viewinteractionprovider.dart +++ b/lib/ui_screen/interactionform/viewinteractionprovider.dart @@ -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 resultData = interactionReponseList .map((e) => FormFieldData( multipleList: e.multipleList == null @@ -793,3 +823,814 @@ class ViewInteractionProvider extends ChangeNotifier { return false; } } + + + + + + + + + + +// import 'dart:convert'; + +// import 'package:dio/dio.dart'; +// import 'package:discover_module/ui_screen/interactionform/interactionprovider.dart'; +// import 'package:discover_module/ui_screen/interactionform/model/interaction_config_data.dart'; +// import 'package:discover_module/ui_screen/interactionform/model/interaction_data.dart'; +// import 'package:discover_module/ui_screen/interactionform/model/json_form_data.dart'; +// import 'package:discover_module/ui_screen/interactionform/model/location_model.dart'; +// import 'package:discover_module/ui_screen/interactionform/model/save_interaction.dart'; +// import 'package:discover_module/ui_screen/interactionform/repository/hive_repository.dart'; +// import 'package:flutter/cupertino.dart'; +// import 'package:flutter/services.dart'; +// import 'package:hive_flutter/hive_flutter.dart'; + +// class ViewInteractionProvider extends ChangeNotifier { +// List interactionReponseList = []; +// // List sectionList = []; +// List sectionList = []; +// late Location locationList; +// List textEditingControllerList = []; +// List multipletextEditingControllerList = []; +// int textfieldIndex = 0; +// List countryList = []; +// List stateList = []; +// List cityList = []; +// List checkboxlist = []; +// String selectedCountry = 'Selected Country'; +// String radioValue = ''; +// bool checkboxValue = false; + +// late SaveInteraction saveInteraction; +// List saveData = []; + +// List newList = []; +// String sectionName = ''; +// late String selectedCity = 'Selected City', selectedState = 'Selected State'; +// String customdropdownValue = ''; +// String? selectedValue; +// List selectedItems = []; +// InputClass? selectedObj; +// List savedList = []; +// List intConfigDataList = []; +// String? intId, intName; +// final HiveDataRepository _hiveprovider = HiveDataRepository( +// Hive.box('InteractionConfigDataBox')); + +// late final InteractionProvider interactionProvider; +// initConfigData() async { +// intConfigDataList = _hiveprovider.getAllDataFromHive(); +// notifyListeners(); +// } + +// Future getRecords(String formname) async { +// var box = await Hive.openBox('InteractionDataBox'); +// savedList = box.values.toList(); +// savedList = savedList +// .where( +// (element) => element.form == formname, +// ) +// .toList(); +// notifyListeners(); +// } + +// Future> getAllRecords() async { +// var box = await Hive.openBox('InteractionDataBox'); +// List savedList = box.values.toList(); + +// return savedList; +// } + +// init(int index) async { +// // _hiveprovider = HiveDataRepository( +// // Hive.box('InteractionConfigDataBox')); +// // intConfigDataList = _hiveprovider.getAllDataFromHive(); +// InteractionConfigData interactionConfigData = intConfigDataList[index]; +// intId = intConfigDataList[index].id; +// intName = intConfigDataList[index].name; + +// print("data $intConfigDataList"); +// // await fetchSaveDataJson(); +// // await fetchDataSet(); +// await fetchData(interactionConfigData.widgets); +// await fetchLocationData(); +// } + +// initSavedForm(SaveInteraction saveInteractiondata) { +// intConfigDataList +// .indexWhere((element) => element.id == saveInteractiondata.intId); + +// interactionReponseList = saveInteractiondata.save +// .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, +// selectedObject: mobj.selectedObject, +// name: mobj.name, +// param: mobj.param, +// selectedValue: mobj.selectedValue, +// widget: mobj.widget, +// controller: mobj.controller, +// 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, +// isRequired: obj.isRequired, +// extension: obj.extension, +// fileName: obj.fileName, +// name: obj.name, +// param: obj.param, +// selectedObject: obj.selectedObject, +// selectedValue: 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(); + +// textEditingControllerList.clear(); + +// for (var item in interactionReponseList) { +// sectionList = item.sectionList; + +// for (SectionList obj in item.multipleList!) { +// obj.gid = obj.gid ?? item.multipleList!.length; +// if (obj.widget == InteractionWidget.TEXT) { +// 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 = textEditingController; + +// } +// if (obj.widget == InteractionWidget.DROPDOWN || +// obj.widget == InteractionWidget.AUTOCOMPLETE || +// obj.widget == InteractionWidget.MULTISELECT) { +// List list = obj.inputList!; +// if (obj.selectedObject != null) { +// } else { +// obj.selectedObject = obj.selectedValue!.isNotEmpty +// ? getDataObject(obj.id, obj.selectedValue!.last, list) +// : list[0]; +// } + +// print("value : ${list.first.name} "); +// } +// if (obj.widget == InteractionWidget.CHECKBOX) { +// List selectedvalues = []; +// if (obj.selectedValue!.isNotEmpty) { +// for (var id in obj.selectedValue!) { +// int ind = +// obj.inputList!.indexWhere((element) => element.id == id); +// if (ind != -1) { +// obj.inputList![ind].ischecked = true; +// selectedvalues.add(obj.inputList![ind].name); +// } +// } +// } +// } +// if (obj.widget == InteractionWidget.RADIO) { +// List list = obj.inputList!; + +// if (obj.selectedValue!.isNotEmpty) { +// int ind = list +// .indexWhere((element) => element.id == obj.selectedValue!.last); +// if (ind != -1) { +// obj.inputList![ind].ischecked = true; +// radioValue = obj.inputList![ind].name; +// } +// } +// } +// // newList.add(obj); +// } +// for (var sectionItem in item.sectionList) { +// if (sectionItem.widget == InteractionWidget.TEXT) { +// var textEditingController = TextEditingController(); +// textEditingController.text = sectionItem.selectedValue!.isNotEmpty +// ? sectionItem.selectedValue!.last ?? " " +// : " "; +// textEditingControllerList.add(textEditingController); + +// sectionItem.controller = textEditingControllerList.last; +// } +// if (sectionItem.widget == InteractionWidget.DROPDOWN) { +// List list = sectionItem.inputList!; +// if (sectionItem.selectedObject != null) { +// print("#######not null"); +// } else { +// print("#######is_null"); +// if (sectionItem.selectedValue == null) { +// print("#######is_null#####"); +// } else { +// print('###${sectionItem.selectedValue}'); +// } +// sectionItem.selectedObject = sectionItem.selectedValue!.isNotEmpty +// ? getDataObject( +// sectionItem.id, sectionItem.selectedValue!.last, list) +// : list[0]; +// } + +// print("valuesssss : ${sectionItem.selectedObject!.name} "); +// } + +// if (sectionItem.widget == InteractionWidget.AUTOCOMPLETE || +// sectionItem.widget == InteractionWidget.MULTISELECT) { +// List list = sectionItem.inputList!; +// if (sectionItem.selectedObject != null) { +// } else { +// sectionItem.selectedObject = sectionItem.selectedValue!.isNotEmpty +// ? getDataObject( +// sectionItem.id, sectionItem.selectedValue!.last, list) +// : list[0]; +// } + +// print("value : ${list.first.name} "); +// } +// if (sectionItem.widget == InteractionWidget.CHECKBOX) { +// List selectedvalues = []; +// if (sectionItem.selectedValue!.isNotEmpty) { +// for (var id in sectionItem.selectedValue!) { +// int ind = sectionItem.inputList! +// .indexWhere((element) => element.id == id); +// if (ind != -1) { +// sectionItem.inputList![ind].ischecked = true; +// selectedvalues.add(sectionItem.inputList![ind].name); +// } +// } +// } +// } +// if (sectionItem.widget == InteractionWidget.RADIO) { +// List list = sectionItem.inputList!; + +// if (sectionItem.selectedValue!.isNotEmpty) { +// int ind = list.indexWhere( +// (element) => element.id == sectionItem.selectedValue!.last); +// if (ind != -1) { +// sectionItem.inputList![ind].ischecked = true; +// radioValue = sectionItem.inputList![ind].name; +// } +// } +// } +// if (sectionItem.widget == InteractionWidget.BUTTON && +// sectionItem.param == 'chooseFile' && +// sectionItem.selectedValue!.isNotEmpty) { +// print("choosed file"); +// print(sectionItem.selectedValue!.last); +// } +// } +// } +// print(interactionReponseList); +// print("check textcontrollers ${textEditingControllerList.length}"); +// } + +// Future fetchDataSet() async { +// List list = getData("intlocation_1"); +// print(list); +// return "success"; +// } + +// List getData(String widgetId) { +// List list = []; + +// return list; +// } + +// InputClass getDataObject(String widgetId, String id, List list) { +// // if (id != "") { +// // List list = []; +// InputClass value = InputClass(id: '', name: ''); + +// if (list.isNotEmpty) { +// int index = list.indexWhere((element) => element.id.toString() == id); + +// if (index != -1) { +// value = list[index]; +// } +// } + +// return value; +// } + +// // TODO: Search for widget with depid and check if selected is not null and by selected id get the data of current widget +// List getData2(SectionList sectionItem) { +// List list = []; +// // if (sectionItem.inputList != null) { +// list = sectionItem.inputList!; +// if (sectionItem.depid != "") { +// // print("check depid : ${sectionItem.depid}"); +// int i = 0; +// for (var obj in interactionReponseList) { +// i = obj.sectionList +// .indexWhere((element) => element.id == sectionItem.depid); +// // print("check depid index: $i"); +// if (i != -1) { +// //print("check depid value: ${obj.sectionList[i].value}"); +// if (obj.sectionList[i].value != null) { +// if (list +// .where((element) => element.pid == obj.sectionList[i].value) +// .isNotEmpty) { +// list = list +// .where((element) => element.pid == obj.sectionList[i].value) +// .toList(); + +// sectionItem.selectedObject = list[0]; +// } else { +// // InputClass obj = InputClass( +// // id: "obj.sectionList[i].value", +// // name: "Select ${sectionItem.name}"); +// list = []; +// // list.add(obj); +// sectionItem.selectedObject = null; +// } +// } else { +// // int index = obj.sectionList +// // .indexWhere((element) => element.id == sectionItem.id); + +// // list = obj.sectionList[index].inputList; +// } +// } +// } + +// // int index = data[i].data.indexWhere((element) => element.) +// } +// // } + +// print("I_am_Returning_list: $list"); +// return list; +// } + +// setDropDownValue(String value, SectionList sectionItem, bool multiple, +// InputClass selectedObject) { +// int i = 0; +// for (var obj in interactionReponseList) { +// if (multiple && obj.multipleList != null) { +// i = obj.multipleList!.indexWhere((element) => +// element.id == sectionItem.id && element.gid == sectionItem.gid); +// if (i != -1) { +// obj.multipleList![i].value = value; +// obj.multipleList![i].tempselectedValue = []; +// obj.multipleList![i].tempselectedValue!.add(value); +// // obj.multipleList![i].selectedObject = selectedObj; +// } +// } else { +// i = obj.sectionList +// .indexWhere((element) => element.id == sectionItem.id); +// if (i != -1) { +// obj.sectionList[i].value = value; +// obj.sectionList[i].tempselectedValue = []; +// obj.sectionList[i].tempselectedValue!.add(value); +// // obj.sectionList[i].selectedObject = selectedObj; +// } +// } +// } +// notifyListeners(); +// } + +// Future disposeValues() async { +// print("dispose called"); +// // await _hiveprovider.closeHiveBox(); +// for (var obj in interactionReponseList) { +// obj.multipleList!.clear(); +// // for (var obj2 in obj.sectionList) { +// // obj2.selectedObject = null; +// // } + +// obj.sectionList.clear(); +// } +// interactionReponseList.clear(); +// } + +// setTextValue(String value, SectionList sectionItem, bool multiple) { +// int i = 0; +// for (var obj in interactionReponseList) { +// if (multiple && obj.multipleList != null) { +// 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); +// } +// } else { +// i = obj.sectionList +// .indexWhere((element) => element.id == sectionItem.id); +// if (i != -1) { +// obj.sectionList[i].value = value; +// obj.sectionList[i].selectedValue!.add(value); +// } +// } +// } +// notifyListeners(); +// } + +// setAutoCompleteValue(String value, SectionList sectionItem, bool multiple) { +// int i = 0; +// for (var obj in interactionReponseList) { +// if (multiple && obj.multipleList != null) { +// i = obj.multipleList!.indexWhere((element) => +// element.id == sectionItem.id && element.gid == sectionItem.gid); +// if (i != -1) { +// obj.multipleList![i].value = value; +// obj.multipleList![i].tempselectedValue = []; +// obj.multipleList![i].tempselectedValue!.add(value); +// } +// } else { +// i = obj.sectionList +// .indexWhere((element) => element.id == sectionItem.id); +// if (i != -1) { +// obj.sectionList[i].value = value; +// obj.sectionList[i].tempselectedValue = []; +// obj.sectionList[i].tempselectedValue!.add(value); +// } +// } +// } +// notifyListeners(); +// } +// String getDropDownValue( +// String value, SectionList sectionItem, List list) { +// int i = 0; +// String svalue = ''; + +// i = list.indexWhere((element) => element.id == value); +// if (i != -1) { +// svalue = list[i].name; +// } else { +// svalue = list[0].name; +// } + +// return svalue; +// } + +// Future fetchData(InteractionResultData interactionResultData) async { +// InteractionResultData interactionConfig = interactionResultData; + +// print("itemCategoryModel Item = + ${interactionConfig.result}"); + +// interactionReponseList = interactionConfig.result; +// print("check stored: $interactionReponseList"); +// textEditingControllerList.clear(); + +// for (var item in interactionReponseList) { +// sectionList = item.sectionList; +// for (var sectionItem in item.sectionList) { +// if (sectionItem.widget == InteractionWidget.TEXT) { +// var textEditingController = TextEditingController(); + +// textEditingControllerList.add(textEditingController); +// sectionItem.controller = textEditingControllerList.last; +// } +// if (sectionItem.widget == InteractionWidget.DROPDOWN || +// sectionItem.widget == InteractionWidget.AUTOCOMPLETE || +// sectionItem.widget == InteractionWidget.MULTISELECT) { +// List list = sectionItem.inputList!; +// sectionItem.value = list[0].name; +// print("value : ${list.first} "); +// } +// } +// } +// print(interactionReponseList); +// print("check textcontrollers ${textEditingControllerList.length}"); + +// return "success"; +// } + +// Future fetchLocationData() async { +// var data = +// await rootBundle.loadString("assets/images/locationdetailsform.json"); + +// Locations loc = +// Locations(location: Location.fromJson(json.decode(data)["location"])); +// locationList = loc.location; +// countryList = locationList.country; +// stateList = locationList.state; +// cityList = locationList.city; + +// print(locationList); +// notifyListeners(); +// return "success"; +// } + +// List getState(String cid) { +// List states = +// stateList.where((element) => element.countryId == cid).toList(); + +// return states; +// } + +// List getCity(String sid) { +// List city = +// cityList.where((element) => element.stateId == sid).toList(); + +// return city; +// } + +// String getCountryId(String name) { +// if (countryList.isNotEmpty) { +// int i = countryList.indexWhere((element) => element.countryName == name); +// return countryList[i].countryId; +// } +// return ''; +// } + +// String getStateId(String name) { +// if (stateList.isNotEmpty) { +// int i = stateList.indexWhere((element) => element.stateName == name); +// return stateList[i].stateId; +// } +// return ''; +// } + +// String getCityId(String name) { +// if (cityList.isNotEmpty) { +// int i = cityList.indexWhere((element) => element.cityName == name); +// return cityList[i].distId; +// } +// return ''; +// } + +// setRadioValue(SectionList sectionItem) { +// List list = (sectionItem.input as List) +// .map((itemWord) => InputClass.fromJson(itemWord)) +// .toList(); +// radioValue = list[0].name; + +// notifyListeners(); +// } + +// setcheckBoxValue(SectionList sectionItem, String sectionName, bool newValue, +// String id, bool multiple) { +// int index = +// sectionItem.inputList!.indexWhere((element) => element.id == id); +// sectionItem.inputList![index].ischecked = newValue; +// // sectionItem.selectedValue.add(data[i].data[index].id); +// int index2 = 0; +// for (var obj in interactionReponseList) { +// if (multiple && obj.multipleList != null) { +// index2 = obj.multipleList!.indexWhere((element) => +// element.id == sectionItem.id && element.gid == sectionItem.gid); +// if (index2 != -1) { +// obj.multipleList![index2].value = sectionItem.inputList![index].id; +// obj.multipleList![index2].selectedValue! +// .add(sectionItem.inputList![index].id); +// } +// } else { +// index2 = obj.sectionList +// .indexWhere((element) => element.id == sectionItem.id); +// if (index2 != -1) { +// obj.sectionList[index2].value = sectionItem.inputList![index].id; +// obj.sectionList[index2].selectedValue! +// .add(sectionItem.inputList![index].id); +// } +// } +// } +// notifyListeners(); +// } + +// getSectionItem(String sectionName) { +// newList = []; +// List addList = []; +// int index = interactionReponseList +// .indexWhere((element) => element.sectionName == sectionName); + +// addList = interactionReponseList[index] +// .sectionList +// .map((e) => SectionList( +// depid: e.depid, +// id: e.id, +// inputList: e.inputList, +// isRequired: e.isRequired, +// name: e.name, +// param: e.param, +// selectedValue: [], +// widget: e.widget, +// controller: e.controller, +// gid: e.gid, +// input: e.input, +// selectedId: e.selectedId, +// value: e.value)) +// .toList(); +// SectionList delItem = SectionList( +// name: "delete", +// param: "deletebtn", +// id: "deletebtn", +// selectedValue: [], +// depid: "", +// widget: InteractionWidget.BUTTON, +// inputList: [], +// isRequired: true); + +// addList.add(delItem); + +// // if (interactionReponseList[index].multipleList!.isEmpty) { +// // newList = addList; +// // } else { +// if (interactionReponseList[index].multipleList == null) { +// interactionReponseList[index].multipleList = addList; +// } else { +// interactionReponseList[index].multipleList = +// interactionReponseList[index].multipleList! + addList; +// } + +// newList = interactionReponseList[index].multipleList!; +// // newList = newList + addList; +// // } +// 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(); + +// multipletextEditingControllerList.add(textEditingController); +// obj.controller = multipletextEditingControllerList.last; +// obj.controller!.text = +// obj.selectedValue != null && obj.selectedValue!.isNotEmpty +// ? obj.selectedValue!.last +// : ''; +// } +// // newList.add(obj); +// } +// } + +// print( +// "check length : ${interactionReponseList[index].multipleList!.length}"); +// notifyListeners(); +// } + +// deleteMultipleRows( +// int gid, SectionList sectionItem, String selectedSectionName) { +// int index = interactionReponseList +// .indexWhere((element) => element.sectionName == selectedSectionName); +// interactionReponseList[index] +// .multipleList! +// .removeWhere((item) => item.gid == gid); + +// notifyListeners(); +// } + +// saveJsonObject(BuildContext context, String form, +// SaveInteraction saveInteraction) async { +// List 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('InteractionDataBox'); + +// if (!box.isOpen) { +// box = await Hive.openBox('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); +// } + +// Future deleteRecord(SaveInteraction saveInteraction) async { +// var box = await Hive.openBox('InteractionDataBox'); +// final Map deliveriesmap = box.toMap(); +// dynamic deleteKey; +// deliveriesmap.forEach((key, value) { +// if (value.id == saveInteraction.id) { +// deleteKey = key; +// } +// }); +// box.delete(deleteKey); +// await getRecords(saveInteraction.form!); +// //box.close(); +// } + +// List getModifiedList(List sectionList) { +// List newSectionList = []; +// for (var obj in sectionList) { +// if (obj.id != 'deletebtn') { +// if (obj.id == 'chooseFile') { +// List files = []; +// if (obj.selectedValue!.isNotEmpty && obj.selectedValue != null) { +// for (var file in obj.selectedValue!) { +// files.add(MultipartFile.fromFileSync(file)); +// } +// } +// MultipleSectionList newobj = MultipleSectionList( +// id: obj.id, +// selectedValue: files, +// ); + +// newSectionList.add(newobj); +// } else { +// MultipleSectionList newobj = MultipleSectionList( +// id: obj.id, +// selectedValue: obj.selectedValue!, +// ); +// newSectionList.add(newobj); +// } +// } +// } +// return newSectionList; +// } + +// bool validateMultipleRows() { +// for (var obj in interactionReponseList) { +// if (obj.multipleList != null) { +// for (var mulobj in obj.multipleList!) { +// if (mulobj.widget == InteractionWidget.TEXT) { +// if (mulobj.controller!.text.isEmpty) { +// return true; +// } +// } +// } +// } +// } +// return false; +// } + +// bool validateTextFields() { +// for (var obj in interactionReponseList) { +// for (var mulobj in obj.sectionList) { +// if (mulobj.widget == InteractionWidget.TEXT) { +// if (mulobj.controller!.text.isEmpty) { +// return true; +// } +// } +// } +// } +// return false; +// } +// } diff --git a/lib/ui_screen/interactionform/widget/interatciontextfield.dart b/lib/ui_screen/interactionform/widget/interatciontextfield.dart index d957dd1..f4ff2c7 100644 --- a/lib/ui_screen/interactionform/widget/interatciontextfield.dart +++ b/lib/ui_screen/interactionform/widget/interatciontextfield.dart @@ -42,6 +42,9 @@ class InteractionTextField extends StatelessWidget { onChanged: (value) { onChanged(value); }, + onSubmitted: (value) { + onChanged(value); + }, inputFormatters: [ inputType == TextInputType.number ? FilteringTextInputFormatter.digitsOnly diff --git a/lib/ui_screen/listview.dart b/lib/ui_screen/listview.dart index 0c5939a..7e92c06 100644 --- a/lib/ui_screen/listview.dart +++ b/lib/ui_screen/listview.dart @@ -8,82 +8,84 @@ class DataTableDemo extends StatefulWidget { class _DataTableDemoState extends State { Widget build(BuildContext context) { - return Scaffold( - body: ListView( - padding: const EdgeInsets.all(3), - children: [ - PaginatedDataTable( - header: const Text( - 'HCP RANKING', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18.0, - fontStyle: FontStyle.normal), + return SafeArea( + child: Scaffold( + body: ListView( + padding: const EdgeInsets.all(3), + children: [ + PaginatedDataTable( + header: const Text( + 'HCP RANKING', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18.0, + fontStyle: FontStyle.normal), + ), + showFirstLastButtons: true, + showEmptyRows: false, + showCheckboxColumn: false, + // actions: const [Text("jii")], + rowsPerPage: 5, + columns: const [ + DataColumn( + label: Text('Name', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Opt-in Status', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Country', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Rank', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Score', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Event', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Affliations', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Publications', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Trails', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + ], + source: _DataSource(context), ), - showFirstLastButtons: true, - showEmptyRows: false, - showCheckboxColumn: false, - // actions: const [Text("jii")], - rowsPerPage: 5, - columns: const [ - DataColumn( - label: Text('Name', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Opt-in Status', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Country', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Rank', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Score', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Event', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Affliations', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Publications', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Trails', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - ], - source: _DataSource(context), - ), - ], + ], + ), ), ); } diff --git a/lib/ui_screen/newformlist.dart b/lib/ui_screen/newformlist.dart index 4d67883..5ecd8f1 100644 --- a/lib/ui_screen/newformlist.dart +++ b/lib/ui_screen/newformlist.dart @@ -14,88 +14,90 @@ class FormList extends StatefulWidget { class _FormListState extends State { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text("Form List"), - ), - body: ListView( - children: [ - ListTile( - title: const Text( - "Add My Event", - style: TextStyle(fontSize: 18.0), - ), - onTap: () async { - final ConfigDataProvider configDataProvider = - ConfigDataProvider(); + return SafeArea( + child: Scaffold( + appBar: AppBar( + title: Text("Form List"), + ), + body: ListView( + children: [ + ListTile( + title: const Text( + "Add My Event", + style: TextStyle(fontSize: 18.0), + ), + onTap: () async { + final ConfigDataProvider configDataProvider = + ConfigDataProvider(); - await configDataProvider.initConfigUIData123(); - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const InteractionListScreen())); - // Navigator.push(context, - // MaterialPageRoute(builder: (context) => AddEventScreen())); - }, - trailing: const Icon(Icons.arrow_forward_ios), - ), - Divider(), - ListTile( - title: const Text( - "Interaction", - style: TextStyle(fontSize: 18.0), + await configDataProvider.initConfigUIData123(); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const InteractionListScreen())); + // Navigator.push(context, + // MaterialPageRoute(builder: (context) => AddEventScreen())); + }, + trailing: const Icon(Icons.arrow_forward_ios), ), - onTap: () async { - print("I am Interaction"); - final ConfigDataProvider configDataProvider = - ConfigDataProvider(); + Divider(), + ListTile( + title: const Text( + "Interaction", + style: TextStyle(fontSize: 18.0), + ), + onTap: () async { + print("I am Interaction"); + final ConfigDataProvider configDataProvider = + ConfigDataProvider(); - await configDataProvider.initConfigUIData(); - // Navigator.push(context, MaterialPageRoute(builder: (context)))=> InteractionScreen(); - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => InteractionListScreen())); - }, - trailing: const Icon(Icons.arrow_forward_ios), - ), - const Divider(), - ListTile( - title: const Text( - "New Medical Insight", - style: TextStyle(fontSize: 18.0), + await configDataProvider.initConfigUIData(); + // Navigator.push(context, MaterialPageRoute(builder: (context)))=> InteractionScreen(); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => InteractionListScreen())); + }, + trailing: const Icon(Icons.arrow_forward_ios), ), - onTap: () async { - final ConfigDataProvider configDataProvider = - ConfigDataProvider(); + const Divider(), + ListTile( + title: const Text( + "New Medical Insight", + style: TextStyle(fontSize: 18.0), + ), + onTap: () async { + final ConfigDataProvider configDataProvider = + ConfigDataProvider(); - await configDataProvider.initConfigUIDataMedical(); - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const InteractionListScreen())); - }, - trailing: Icon(Icons.arrow_forward_ios), - ), - Divider(), - ListTile( - title: const Text( - "Engagement", - style: TextStyle(fontSize: 18.0), + await configDataProvider.initConfigUIDataMedical(); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const InteractionListScreen())); + }, + trailing: Icon(Icons.arrow_forward_ios), ), - onTap: () async { - final ConfigDataProvider configDataProvider = - ConfigDataProvider(); - await configDataProvider.initConfigUIDataEng(); - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const InteractionListScreen())); - }, - trailing: const Icon(Icons.arrow_forward_ios), - ), - Divider(), - ], + Divider(), + ListTile( + title: const Text( + "Engagement", + style: TextStyle(fontSize: 18.0), + ), + onTap: () async { + final ConfigDataProvider configDataProvider = + ConfigDataProvider(); + await configDataProvider.initConfigUIDataEng(); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const InteractionListScreen())); + }, + trailing: const Icon(Icons.arrow_forward_ios), + ), + Divider(), + ], + ), ), ); } diff --git a/lib/ui_screen/profile.dart b/lib/ui_screen/profile.dart index a06e29e..44482f4 100644 --- a/lib/ui_screen/profile.dart +++ b/lib/ui_screen/profile.dart @@ -14,349 +14,352 @@ class Profile extends StatefulWidget { class _ProfileState extends State { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text('Profile'), - actions: const [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Text("View Similar"), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Text("Request Profile"), - ) - ], - ), - body: ListView( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Row( - children: [ - const Padding( - padding: EdgeInsets.all(10.0), - child: ProfilePicture( - name: 'Gerosa, Gino', - radius: 31, - fontsize: 21, + return SafeArea( + child: Scaffold( + appBar: AppBar( + title: const Text('Profile'), + actions: const [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text("View Similar"), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text("Request Profile"), + ) + ], + ), + body: ListView( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Row( + children: [ + const Padding( + padding: EdgeInsets.all(10.0), + child: ProfilePicture( + name: 'Gerosa, Gino', + radius: 31, + fontsize: 21, + ), ), - ), - Column( - children: [ - // Text( - // "Gerosa, Gino", - // style: TextStyle( - // fontSize: 22.0, - // color: Colors.black, - // ), - // ), - Text1( - title: "Gerosa, Gino", - txtcolor: Colors.black, - txtfont: 22.0), - // Text( - // "Cardiac Surgery", - // style: TextStyle( - // fontWeight: FontWeight.bold, fontSize: 14.0), - // ), - Text1( - title: "Cardiac Surgery", + Column( + children: [ + // Text( + // "Gerosa, Gino", + // style: TextStyle( + // fontSize: 22.0, + // color: Colors.black, + // ), + // ), + Text1( + title: "Gerosa, Gino", + txtcolor: Colors.black, + txtfont: 22.0), + // Text( + // "Cardiac Surgery", + // style: TextStyle( + // fontWeight: FontWeight.bold, fontSize: 14.0), + // ), + Text1( + title: "Cardiac Surgery", + txtcolor: Colors.black, + fontweight: FontWeight.bold, + txtfont: 14.0), + ], + ), + ], + ), + Padding( + padding: const EdgeInsets.symmetric( + vertical: 30.0, horizontal: 14.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row(children: [ + const Icon( + Icons.location_city_sharp, + color: Color.fromARGB(255, 0, 71, 132), + ), + const SizedBox( + width: 3.0, + ), + Expanded( + // child: Text( + // "Azienda Ospedaliera di Padova", + // style: TextStyle( + // fontWeight: FontWeight.bold, fontSize: 14.0), + // ), + child: Text1( + title: "Azienda Ospedaliera di Padova", txtcolor: Colors.black, + txtfont: 14.0, fontweight: FontWeight.bold, - txtfont: 14.0), - ], - ), - ], - ), - Padding( - padding: const EdgeInsets.symmetric( - vertical: 30.0, horizontal: 14.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row(children: [ - const Icon( - Icons.location_city_sharp, - color: Color.fromARGB(255, 0, 71, 132), - ), + )), + ]), const SizedBox( - width: 3.0, + height: 8.0, ), - Expanded( + Row(children: [ + const Icon( + Icons.location_pin, + color: Color.fromARGB(255, 0, 71, 132), + ), + const SizedBox( + width: 3.0, + ), + Expanded( // child: Text( - // "Azienda Ospedaliera di Padova", + // "Via Giustiniani, 2, Padova, Veneto 35128, Italy", // style: TextStyle( // fontWeight: FontWeight.bold, fontSize: 14.0), // ), child: Text1( - title: "Azienda Ospedaliera di Padova", - txtcolor: Colors.black, - txtfont: 14.0, - fontweight: FontWeight.bold, - )), - ]), - const SizedBox( - height: 8.0, - ), - Row(children: [ - const Icon( - Icons.location_pin, - color: Color.fromARGB(255, 0, 71, 132), - ), + title: + "Via Giustiniani, 2, Padova, Veneto 35128, Italy", + txtcolor: Colors.black, + fontweight: FontWeight.bold, + txtfont: 14.0), + ), + ]), const SizedBox( - width: 3.0, + height: 8.0, ), - Expanded( - // child: Text( - // "Via Giustiniani, 2, Padova, Veneto 35128, Italy", + Row(children: [ + const Icon( + Icons.phone, + color: Color.fromARGB(255, 0, 71, 132), + ), + const SizedBox( + width: 3.0, + ), + // Text( + // "+390498212410 X 12", // style: TextStyle( // fontWeight: FontWeight.bold, fontSize: 14.0), // ), - child: Text1( - title: - "Via Giustiniani, 2, Padova, Veneto 35128, Italy", + Text1( + title: "+390498212410 X 12", txtcolor: Colors.black, fontweight: FontWeight.bold, txtfont: 14.0), - ), - ]), - const SizedBox( - height: 8.0, - ), - Row(children: [ - const Icon( - Icons.phone, - color: Color.fromARGB(255, 0, 71, 132), - ), + ]), const SizedBox( - width: 3.0, - ), - // Text( - // "+390498212410 X 12", - // style: TextStyle( - // fontWeight: FontWeight.bold, fontSize: 14.0), - // ), - Text1( - title: "+390498212410 X 12", - txtcolor: Colors.black, - fontweight: FontWeight.bold, - txtfont: 14.0), - ]), - const SizedBox( - height: 8.0, - ), - Row(children: [ - const Icon( - Icons.call, - color: Color.fromARGB(255, 0, 71, 132), + height: 8.0, ), + Row(children: [ + const Icon( + Icons.call, + color: Color.fromARGB(255, 0, 71, 132), + ), + const SizedBox( + width: 3.0, + ), + Text1( + title: "+390498212410 X 12", + txtcolor: Colors.black, + fontweight: FontWeight.bold, + txtfont: 14.0), + ]), const SizedBox( - width: 3.0, + height: 8.0, ), - Text1( - title: "+390498212410 X 12", - txtcolor: Colors.black, - fontweight: FontWeight.bold, - txtfont: 14.0), - ]), - const SizedBox( - height: 8.0, - ), - Row(children: [ - const Icon( - Icons.email, - color: Color.fromARGB(255, 0, 71, 132), - ), - const SizedBox( - width: 3.0, - ), - // Text( - // "Gerosa,Gino@gmail.com", - // style: TextStyle( - // fontWeight: FontWeight.bold, fontSize: 14.0), - // ), - Text1( - title: "Gerosa,Gino@gmail.com", - txtcolor: Colors.black, - fontweight: FontWeight.bold, - txtfont: 14.0), - ]), - ], - ), - ), - Padding( - padding: EdgeInsets.only(bottom: 18.0), - child: Card( - surfaceTintColor: Colors.white, - margin: EdgeInsets.symmetric(horizontal: 15.0, vertical: 5.0), - clipBehavior: Clip.antiAlias, - color: Colors.white, - elevation: 5.0, - child: Padding( - padding: - EdgeInsets.symmetric(horizontal: 1.0, vertical: 22.0), - child: Row( - children: [ - Expanded( - child: Column( - children: [ - // Text( - // "Affliations", - // style: TextStyle( - // color: Color.fromARGB(255, 0, 71, 137), - // fontSize: 13.0, - // fontWeight: FontWeight.bold, - // ), - // ), - Text1( - title: "Affliations", - txtcolor: Color.fromARGB(255, 0, 71, 137), - fontweight: FontWeight.bold, - txtfont: 13.0), - const SizedBox( - height: 5.0, - ), - // Text( - // "75", - // style: TextStyle( - // fontSize: 13.0, - // color: Color.fromARGB(255, 0, 71, 137), - // ), - // ) - Text1( - title: "75", - txtfont: 13.0, - txtcolor: Color.fromARGB(255, 0, 71, 137), - ) - ], - ), + Row(children: [ + const Icon( + Icons.email, + color: Color.fromARGB(255, 0, 71, 132), ), - Expanded( - child: Column( - children: [ - // Text( - // "Events", - // style: TextStyle( - // color: Color.fromARGB(255, 0, 71, 137), - // fontSize: 13.0, - // fontWeight: FontWeight.bold, - // ), - // ), - Text1( - title: "Events", - txtcolor: Color.fromARGB(255, 0, 71, 137), - fontweight: FontWeight.bold, - txtfont: 13.0), - const SizedBox( - height: 5.0, - ), - // Text( - // "0", - // style: TextStyle( - // fontSize: 13.0, - // color: Color.fromARGB(255, 0, 71, 137), - // ), - // ) - Text1( - title: "0", - txtfont: 13.0, - txtcolor: Color.fromARGB(255, 0, 71, 137), - ) - ], - ), + const SizedBox( + width: 3.0, ), - Expanded( - child: Column( - children: [ - // Text( - // "Publications", - // style: TextStyle( - // color: Color.fromARGB(255, 0, 71, 137), - // fontSize: 13.0, - // fontWeight: FontWeight.bold, - // ), - // ), - Text1( - title: "Publications", - txtcolor: Color.fromARGB(255, 0, 71, 137), - fontweight: FontWeight.bold, - txtfont: 13.0), - SizedBox( - height: 5.0, - ), - // Text( - // "251", - // style: TextStyle( - // fontSize: 13.0, - // color: Color.fromARGB(255, 0, 71, 137), - // ), - // ) - Text1( - title: "251", - txtfont: 13.0, - txtcolor: Color.fromARGB(255, 0, 71, 137), - ) - ], - ), - ), - Expanded( - child: Column( - children: [ - // Text( - // "Trails", - // style: TextStyle( - // color: Color.fromARGB(255, 0, 71, 137), - // fontSize: 13.0, - // fontWeight: FontWeight.bold, - // ), - // ), - Text1( - title: "Trails", - txtcolor: Color.fromARGB(255, 0, 71, 137), - fontweight: FontWeight.bold, - txtfont: 13.0), - SizedBox( - height: 5.0, - ), - // Text( - // "1", - // style: TextStyle( - // fontSize: 13.0, - // color: Color.fromARGB(255, 0, 71, 137), - // ), - // ) - Text1( - title: "1", - txtfont: 13.0, - txtcolor: Color.fromARGB(255, 0, 71, 137), - ) - ], - ), - ), - ], - ), + // Text( + // "Gerosa,Gino@gmail.com", + // style: TextStyle( + // fontWeight: FontWeight.bold, fontSize: 14.0), + // ), + Text1( + title: "Gerosa,Gino@gmail.com", + txtcolor: Colors.black, + fontweight: FontWeight.bold, + txtfont: 14.0), + ]), + ], ), ), - ) - ], + Padding( + padding: EdgeInsets.only(bottom: 18.0), + child: Card( + surfaceTintColor: Colors.white, + margin: + EdgeInsets.symmetric(horizontal: 15.0, vertical: 5.0), + clipBehavior: Clip.antiAlias, + color: Colors.white, + elevation: 5.0, + child: Padding( + padding: + EdgeInsets.symmetric(horizontal: 1.0, vertical: 22.0), + child: Row( + children: [ + Expanded( + child: Column( + children: [ + // Text( + // "Affliations", + // style: TextStyle( + // color: Color.fromARGB(255, 0, 71, 137), + // fontSize: 13.0, + // fontWeight: FontWeight.bold, + // ), + // ), + Text1( + title: "Affliations", + txtcolor: Color.fromARGB(255, 0, 71, 137), + fontweight: FontWeight.bold, + txtfont: 13.0), + const SizedBox( + height: 5.0, + ), + // Text( + // "75", + // style: TextStyle( + // fontSize: 13.0, + // color: Color.fromARGB(255, 0, 71, 137), + // ), + // ) + Text1( + title: "75", + txtfont: 13.0, + txtcolor: Color.fromARGB(255, 0, 71, 137), + ) + ], + ), + ), + Expanded( + child: Column( + children: [ + // Text( + // "Events", + // style: TextStyle( + // color: Color.fromARGB(255, 0, 71, 137), + // fontSize: 13.0, + // fontWeight: FontWeight.bold, + // ), + // ), + Text1( + title: "Events", + txtcolor: Color.fromARGB(255, 0, 71, 137), + fontweight: FontWeight.bold, + txtfont: 13.0), + const SizedBox( + height: 5.0, + ), + // Text( + // "0", + // style: TextStyle( + // fontSize: 13.0, + // color: Color.fromARGB(255, 0, 71, 137), + // ), + // ) + Text1( + title: "0", + txtfont: 13.0, + txtcolor: Color.fromARGB(255, 0, 71, 137), + ) + ], + ), + ), + Expanded( + child: Column( + children: [ + // Text( + // "Publications", + // style: TextStyle( + // color: Color.fromARGB(255, 0, 71, 137), + // fontSize: 13.0, + // fontWeight: FontWeight.bold, + // ), + // ), + Text1( + title: "Publications", + txtcolor: Color.fromARGB(255, 0, 71, 137), + fontweight: FontWeight.bold, + txtfont: 13.0), + SizedBox( + height: 5.0, + ), + // Text( + // "251", + // style: TextStyle( + // fontSize: 13.0, + // color: Color.fromARGB(255, 0, 71, 137), + // ), + // ) + Text1( + title: "251", + txtfont: 13.0, + txtcolor: Color.fromARGB(255, 0, 71, 137), + ) + ], + ), + ), + Expanded( + child: Column( + children: [ + // Text( + // "Trails", + // style: TextStyle( + // color: Color.fromARGB(255, 0, 71, 137), + // fontSize: 13.0, + // fontWeight: FontWeight.bold, + // ), + // ), + Text1( + title: "Trails", + txtcolor: Color.fromARGB(255, 0, 71, 137), + fontweight: FontWeight.bold, + txtfont: 13.0), + SizedBox( + height: 5.0, + ), + // Text( + // "1", + // style: TextStyle( + // fontSize: 13.0, + // color: Color.fromARGB(255, 0, 71, 137), + // ), + // ) + Text1( + title: "1", + txtfont: 13.0, + txtcolor: Color.fromARGB(255, 0, 71, 137), + ) + ], + ), + ), + ], + ), + ), + ), + ) + ], + ), + ], + ), + floatingActionButton: Visibility( + visible: true, + child: FloatingActionButton( + onPressed: () { + Navigator.push( + context, MaterialPageRoute(builder: (context) => FormList())); + }, + foregroundColor: Colors.white, + backgroundColor: const Color.fromARGB(255, 0, 71, 132), + child: new Icon(Icons.add), ), - ], - ), - floatingActionButton: Visibility( - visible: true, - child: FloatingActionButton( - onPressed: () { - Navigator.push( - context, MaterialPageRoute(builder: (context) => FormList())); - }, - foregroundColor: Colors.white, - backgroundColor: const Color.fromARGB(255, 0, 71, 132), - child: new Icon(Icons.add), ), ), ); diff --git a/lib/ui_screen/ranking.dart b/lib/ui_screen/ranking.dart index 0ec9683..65c3e67 100644 --- a/lib/ui_screen/ranking.dart +++ b/lib/ui_screen/ranking.dart @@ -1,5 +1,6 @@ import 'dart:convert'; import 'dart:io'; +import 'dart:js_interop'; import 'package:discover_module/custom_widget/floating_btn.dart'; import 'package:discover_module/custom_widget/show_alert.dart'; @@ -19,8 +20,9 @@ class Ranking extends StatefulWidget { } class _RankingState extends State { - late _DataSource _dataSource; // Instance variable for _DataSource + late _DataSource _dataSource; + List selectedno = []; @override void initState() { super.initState(); @@ -28,146 +30,153 @@ class _RankingState extends State { _dataSource = _DataSource(context); // Initialize _DataSource } - @override @override Widget build(BuildContext context) { - return Scaffold( - body: ListView( - padding: const EdgeInsets.all(3), - children: [ - PaginatedDataTable( - header: const Text( - 'HCP RANKING', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18.0, - fontStyle: FontStyle.normal), + return SafeArea( + child: Scaffold( + body: ListView( + padding: const EdgeInsets.all(3), + children: [ + PaginatedDataTable( + header: const Text( + 'HCP RANKING', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18.0, + fontStyle: FontStyle.normal), + ), + showFirstLastButtons: true, + showEmptyRows: false, + showCheckboxColumn: true, + actions: [ + IconButton( + onPressed: () { + _createExcel(); + }, + icon: const Icon(Icons.download, + color: Color.fromARGB(255, 0, 71, 132))) + ], + rowsPerPage: 5, + columns: const [ + DataColumn( + label: FittedBox( + fit: BoxFit.scaleDown, + child: Text('Name', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal)), + )), + DataColumn( + label: FittedBox( + fit: BoxFit.scaleDown, + child: Text('Tier', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal)), + )), + DataColumn( + label: FittedBox( + fit: BoxFit.scaleDown, + child: Text('Rank', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal)), + )), + DataColumn( + label: FittedBox( + fit: BoxFit.scaleDown, + child: Text('Score', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal)), + )), + DataColumn( + label: FittedBox( + fit: BoxFit.scaleDown, + child: Text('Event', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal)), + )), + DataColumn( + label: FittedBox( + fit: BoxFit.scaleDown, + child: Text('Affliations', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal)), + )), + DataColumn( + label: FittedBox( + fit: BoxFit.scaleDown, + child: Text('Publications', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal)), + )), + DataColumn( + label: FittedBox( + fit: BoxFit.scaleDown, + child: Text('Trails', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal)), + )), + ], + source: _dataSource, ), - showFirstLastButtons: true, - showEmptyRows: false, - showCheckboxColumn: true, - actions: [ - IconButton( - onPressed: () { - _createExcel(); - }, - icon: const Icon(Icons.download, - color: Color.fromARGB(255, 0, 71, 132))) - ], - rowsPerPage: 5, - columns: const [ - DataColumn( - label: FittedBox( - fit: BoxFit.scaleDown, - child: Text('Name', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal)), - )), - DataColumn( - label: FittedBox( - fit: BoxFit.scaleDown, - child: Text('Tier', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal)), - )), - DataColumn( - label: FittedBox( - fit: BoxFit.scaleDown, - child: Text('Rank', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal)), - )), - DataColumn( - label: FittedBox( - fit: BoxFit.scaleDown, - child: Text('Score', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal)), - )), - DataColumn( - label: FittedBox( - fit: BoxFit.scaleDown, - child: Text('Event', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal)), - )), - DataColumn( - label: FittedBox( - fit: BoxFit.scaleDown, - child: Text('Affliations', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal)), - )), - DataColumn( - label: FittedBox( - fit: BoxFit.scaleDown, - child: Text('Publications', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal)), - )), - DataColumn( - label: FittedBox( - fit: BoxFit.scaleDown, - child: Text('Trails', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal)), - )), - ], - source: _dataSource, - ), - ], - ), - floatingActionButton: Visibility( - visible: true, - child: FloatingBtn( - icon: Icons.add, - title: "add", - onTap: () { - List selectedRowIds = _dataSource.getSelectedRowIds(); - // Do something with selectedRowIds - print('Selected Row IDstrndsss: $selectedRowIds'); + ], + ), + floatingActionButton: Visibility( + visible: true, + child: FloatingBtn( + icon: Icons.add, + title: "add", + onTap: () async { + List selectedRowIds = _dataSource.getSelectedRowIds(); + // Do something with selectedRowIds + print('Selected Row IDstrndsss: $selectedRowIds'); - for (int i = 0; i < selectedRowIds.length; i++) { - print("checking_value_istrends: ${selectedRowIds[i]}"); + for (int i = 0; i < selectedRowIds.length; i++) { + print('The id id : ${selectedRowIds[i]}'); - // _contactbox.put(i, selectedRowIds[i]); + print("checking_value_istrends: ${selectedRowIds[i]}"); - HiveFunctions.createUser({ - "name": selectedRowIds[i], - "org": "Azienda Ospedaliera di Padova", - "adrr": "Via Giustiniani 2, Padova, Veneto 35128, Italy", - "phone": "+390498212410X12", - "Pphone": "+390498212410X12", - "email": "Gerosa,Gino@gmail.com", - "affno": "75", - "eveno": "8", - "pubno": "251", - "trailno": "1" - }); - } - showDialog( - context: context, - builder: (_) { - return Alert(data: "User Added Successfully"); + // selectedno.add(selectedRowIds[i]); + + HiveFunctions.addno(selectedRowIds[i]); + + // _contactbox.put(i, selectedRowIds[i]); + + HiveFunctions.createUser({ + "name": "Gerosa,Gino", + "org": "Azienda Ospedaliera di Padova", + "adrr": "Via Giustiniani 2, Padova, Veneto 35128, Italy", + "phone": "+390498212410X12", + "Pphone": "+390498212410X12", + "email": "Gerosa,Gino@gmail.com", + "affno": "75", + "eveno": "8", + "pubno": "251", + "trailno": "1" }); - }, - )), + } + showDialog( + context: context, + builder: (_) { + return Alert(data: "User Added Successfully"); + }); + }, + )), + ), ); } @@ -291,6 +300,7 @@ class HiveFunctions { // String userHiveBox="User Box"; // Box which will use to store the things static final _contactbox = Hive.box("mycontact"); + static var box1 = Hive.box('checkvalue'); static createUser(Map data) { _contactbox.add(data); @@ -337,11 +347,35 @@ class HiveFunctions { return data.reversed.toList(); } + + static addno(int selectedRowId) { + // final box1 = Hive.box("mycontact"); + + print("SelectedStoredvaluessss: $selectedRowId"); + + box1.add(selectedRowId); + } + + static getno() { + // final box1 = Hive.box("mycontact"); + + return box1.values; + } } class _Row { - _Row(this.identifier, this.valueA, this.valueC, this.valueD, this.valueE, - this.valueF, this.valueG, this.valueH, this.valueI); + _Row( + this.identifier, + this.valueA, + this.valueC, + this.valueD, + this.valueE, + this.valueF, + this.valueG, + this.valueH, + this.valueI, + this.selected, // Add selected parameter + ); final int identifier; final String valueA; @@ -360,17 +394,18 @@ class _DataSource extends DataTableSource { final BuildContext context; late List<_Row> _rows; // late List _selectedRowsIndexes = []; // List to track selected rows - final List _selectedRowIds = []; + final List _selectedRowIds = []; _DataSource(this.context) { _rows = <_Row>[ for (int i = 0; i < 20; i++) - _Row(i, 'Gerosa, Gino', 'Tier1', '1', '0', '0', '0', '0', '0'), + _Row( + i, 'Gerosa, Gino', 'Tier1', '1', '0', '0', '0', '0', '0', check(i)), ]; //} } - List getSelectedRowIds() { + List getSelectedRowIds() { return _selectedRowIds; // Return a copy to prevent direct modification } @@ -392,11 +427,11 @@ class _DataSource extends DataTableSource { if (value) { print("Selected"); - _selectedRowIds.add(row.valueA); // Add the row ID to the list + _selectedRowIds.add(row.identifier); // Add the row ID to the list print("Selected_selectedRowIds :$_selectedRowIds"); } else { _selectedRowIds - .remove(row.valueA); // Remove the row ID from the list + .remove(row.identifier); // Remove the row ID from the list } notifyListeners(); @@ -433,4 +468,17 @@ class _DataSource extends DataTableSource { @override int get selectedRowCount => _selectedCount; + + bool check(int i) { + // print("I_am_i: $i"); + print("_selectedRowIds_i: ${HiveFunctions.getno()}"); + + //HiveFunctions.getno(); + if (HiveFunctions.getno().contains(i)) { + print("Iam_in: $i"); + return true; + } + + return false; + } } diff --git a/lib/ui_screen/rising_stars.dart b/lib/ui_screen/rising_stars.dart index 0b558c1..8d6f3c2 100644 --- a/lib/ui_screen/rising_stars.dart +++ b/lib/ui_screen/rising_stars.dart @@ -23,114 +23,116 @@ class RisingStarState extends State { @override Widget build(BuildContext context) { - return Scaffold( - body: ListView( - padding: const EdgeInsets.all(3), - children: [ - PaginatedDataTable( - header: const Text( - 'HCP RANKING', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18.0, - fontStyle: FontStyle.normal), + return SafeArea( + child: Scaffold( + body: ListView( + padding: const EdgeInsets.all(3), + children: [ + PaginatedDataTable( + header: const Text( + 'HCP RANKING', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18.0, + fontStyle: FontStyle.normal), + ), + showFirstLastButtons: true, + showEmptyRows: false, + showCheckboxColumn: true, + // actions: const [Text("jii")], + rowsPerPage: 5, + columns: const [ + DataColumn( + label: Text('Name', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Specialty', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Rank', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Discover Rank', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Indicator', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Previous year \n (2018-2022)', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Current year \n (2022-2024)', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Status', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + ], + source: _dataSource, ), - showFirstLastButtons: true, - showEmptyRows: false, - showCheckboxColumn: true, - // actions: const [Text("jii")], - rowsPerPage: 5, - columns: const [ - DataColumn( - label: Text('Name', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Specialty', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Rank', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Discover Rank', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Indicator', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Previous year \n (2018-2022)', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Current year \n (2022-2024)', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Status', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - ], - source: _dataSource, - ), - ], - ), - floatingActionButton: Visibility( - visible: true, - child: FloatingBtn( - icon: Icons.add, - title: "add", - onTap: () { - List selectedRowIds = _dataSource.getSelectedRowIds(); - // Do something with selectedRowIds - print('Selected Row IDstrndsss: $selectedRowIds'); + ], + ), + floatingActionButton: Visibility( + visible: true, + child: FloatingBtn( + icon: Icons.add, + title: "add", + onTap: () { + List selectedRowIds = _dataSource.getSelectedRowIds(); + // Do something with selectedRowIds + print('Selected Row IDstrndsss: $selectedRowIds'); - for (int i = 0; i < selectedRowIds.length; i++) { - print("checking_value_istrends: ${selectedRowIds[i]}"); + for (int i = 0; i < selectedRowIds.length; i++) { + print("checking_value_istrends: ${selectedRowIds[i]}"); - // _contactbox.put(i, selectedRowIds[i]); + // _contactbox.put(i, selectedRowIds[i]); - HiveFunctions.createUser({ - "name": selectedRowIds[i], - "org": "Azienda Ospedaliera di Padova", - "adrr": "Via Giustiniani 2, Padova, Veneto 35128, Italy", - "phone": "+390498212410X12", - "Pphone": "+390498212410X12", - "email": "Gerosa,Gino@gmail.com", - "affno": "75", - "eveno": "8", - "pubno": "251", - "trailno": "1" - }); - } - showDialog( - context: context, - builder: (_) { - return Alert( - data: "User Added Successfully", - ); + HiveFunctions.createUser({ + "name": selectedRowIds[i], + "org": "Azienda Ospedaliera di Padova", + "adrr": "Via Giustiniani 2, Padova, Veneto 35128, Italy", + "phone": "+390498212410X12", + "Pphone": "+390498212410X12", + "email": "Gerosa,Gino@gmail.com", + "affno": "75", + "eveno": "8", + "pubno": "251", + "trailno": "1" }); - }, - )), + } + showDialog( + context: context, + builder: (_) { + return Alert( + data: "User Added Successfully", + ); + }); + }, + )), + ), ); } } diff --git a/lib/ui_screen/trends.dart b/lib/ui_screen/trends.dart index d35f95e..ba15156 100644 --- a/lib/ui_screen/trends.dart +++ b/lib/ui_screen/trends.dart @@ -22,88 +22,90 @@ class _TrendsState extends State { @override Widget build(BuildContext context) { - return Scaffold( - body: ListView( - padding: const EdgeInsets.all(3), - children: [ - PaginatedDataTable( - header: const Text( - 'HCP RANKING', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18.0, - fontStyle: FontStyle.normal), + return SafeArea( + child: Scaffold( + body: ListView( + padding: const EdgeInsets.all(3), + children: [ + PaginatedDataTable( + header: const Text( + 'HCP RANKING', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18.0, + fontStyle: FontStyle.normal), + ), + showFirstLastButtons: true, + showEmptyRows: false, + showCheckboxColumn: true, + // actions: const [Text("jii")], + rowsPerPage: 5, + columns: const [ + DataColumn( + label: Text('Name', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Last 5 Years', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Last 3 Years', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + DataColumn( + label: Text('Last 1 Year', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + fontStyle: FontStyle.normal))), + ], + source: _dataSource, ), - showFirstLastButtons: true, - showEmptyRows: false, - showCheckboxColumn: true, - // actions: const [Text("jii")], - rowsPerPage: 5, - columns: const [ - DataColumn( - label: Text('Name', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Last 5 Years', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Last 3 Years', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - DataColumn( - label: Text('Last 1 Year', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, - fontStyle: FontStyle.normal))), - ], - source: _dataSource, - ), - ], - ), - floatingActionButton: Visibility( - visible: true, - child: FloatingBtn( - icon: Icons.add, - title: "add", - onTap: () { - List selectedRowIds = _dataSource.getSelectedRowIds(); - // Do something with selectedRowIds - print('Selected Row IDstrndsss: $selectedRowIds'); + ], + ), + floatingActionButton: Visibility( + visible: true, + child: FloatingBtn( + icon: Icons.add, + title: "add", + onTap: () { + List selectedRowIds = _dataSource.getSelectedRowIds(); + // Do something with selectedRowIds + print('Selected Row IDstrndsss: $selectedRowIds'); - for (int i = 0; i < selectedRowIds.length; i++) { - print("checking_value_istrends: ${selectedRowIds[i]}"); + for (int i = 0; i < selectedRowIds.length; i++) { + print("checking_value_istrends: ${selectedRowIds[i]}"); - // _contactbox.put(i, selectedRowIds[i]); + // _contactbox.put(i, selectedRowIds[i]); - HiveFunctions.createUser({ - "name": selectedRowIds[i], - "org": "Azienda Ospedaliera di Padova", - "adrr": "Via Giustiniani 2, Padova, Veneto 35128, Italy", - "phone": "+390498212410X12", - "Pphone": "+390498212410X12", - "email": "Gerosa,Gino@gmail.com", - "affno": "75", - "eveno": "8", - "pubno": "251", - "trailno": "1" - }); - } - showDialog( - context: context, - builder: (_) { - return Alert(data: "User Added Successfully"); + HiveFunctions.createUser({ + "name": selectedRowIds[i], + "org": "Azienda Ospedaliera di Padova", + "adrr": "Via Giustiniani 2, Padova, Veneto 35128, Italy", + "phone": "+390498212410X12", + "Pphone": "+390498212410X12", + "email": "Gerosa,Gino@gmail.com", + "affno": "75", + "eveno": "8", + "pubno": "251", + "trailno": "1" }); - }, - )), + } + showDialog( + context: context, + builder: (_) { + return Alert(data: "User Added Successfully"); + }); + }, + )), + ), ); } }