From e1d39b59fd27f9d5aa5a96102584f23f3db35ae8 Mon Sep 17 00:00:00 2001 From: poojakhatawate Date: Fri, 19 Jul 2024 14:15:14 +0530 Subject: [PATCH] Carousel --- lib/constants.dart | 4 +- lib/provider_class/hcp _provider.dart | 26 + .../interactionlistscreen.dart | 5 +- .../interactionform/new_dynamicform.dart | 4219 +++++++++++++++++ lib/ui_screen/new_contacts.dart | 888 +++- lib/ui_screen/new_profile.dart | 57 +- lib/ui_screen/newformlist.dart | 148 +- pubspec.lock | 16 + pubspec.yaml | 2 + 9 files changed, 5015 insertions(+), 350 deletions(-) create mode 100644 lib/ui_screen/interactionform/new_dynamicform.dart diff --git a/lib/constants.dart b/lib/constants.dart index 4267fd3..1b925c4 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -4,6 +4,6 @@ class Constants { static Color k2color = Color.fromARGB(255, 0, 71, 132); //static const url = "http://192.168.172.50:8082/api"; - static const url = 'http://192.168.2.143:8082/api'; - //static const url = 'http://192.168.153.50:8081/api'; + static const url = 'http://192.168.2.143:8084/api'; + //static const url = 'http://192.168.153.50:8082/api'; } diff --git a/lib/provider_class/hcp _provider.dart b/lib/provider_class/hcp _provider.dart index 7b4ce2d..93de637 100644 --- a/lib/provider_class/hcp _provider.dart +++ b/lib/provider_class/hcp _provider.dart @@ -15,4 +15,30 @@ class hcpProvider extends ChangeNotifier { notifyListeners(); } + + List searchHCP(String query) { + if (query.isEmpty) { + return List.from(_list); // Return full list if query is empty + } else { + // return _list + // .where( + // (hcp) => hcp['name'].toLowerCase().contains(query.toLowerCase())) + // .toList(); + + return _list + .where((hcp) => + hcp['name'].toLowerCase().contains(query.toLowerCase()) || + hcp['speciality'].toLowerCase().contains(query.toLowerCase()) || + hcp['addr'].toLowerCase().contains(query.toLowerCase())) + .toList(); + + // return _list.where((hcp) { + // // Perform multiple checks using logical AND (&&) + // return hcp['name'].toLowerCase().contains(query.toLowerCase()) && + // hcp['speciality'].toLowerCase().contains(query.toLowerCase()) && + // hcp['addr'].toLowerCase().contains(query.toLowerCase()); + // // Add more conditions as needed + // }).toList(); + } + } } diff --git a/lib/ui_screen/interactionform/interactionlistscreen.dart b/lib/ui_screen/interactionform/interactionlistscreen.dart index 25b7ac2..571fae1 100644 --- a/lib/ui_screen/interactionform/interactionlistscreen.dart +++ b/lib/ui_screen/interactionform/interactionlistscreen.dart @@ -1,6 +1,7 @@ import 'package:discover_module/ui_screen/interactionform/interaction_screen.dart'; import 'package:discover_module/ui_screen/interactionform/interactionprovider.dart'; import 'package:discover_module/ui_screen/interactionform/model/save_interaction.dart'; +import 'package:discover_module/ui_screen/interactionform/new_dynamicform.dart'; import 'package:discover_module/ui_screen/interactionform/view_forms_list.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -91,7 +92,7 @@ class _InteractionListScreenState extends State { context, MaterialPageRoute( builder: (BuildContext context) => - InteractionScreen( + InteractionScreen1( index: index, form: provider .intConfigDataList[index] @@ -157,7 +158,7 @@ class _InteractionListScreenState extends State { context, MaterialPageRoute( builder: (BuildContext context) => - InteractionScreen( + InteractionScreen1( index: index, form: provider .intConfigDataList[index].name, diff --git a/lib/ui_screen/interactionform/new_dynamicform.dart b/lib/ui_screen/interactionform/new_dynamicform.dart new file mode 100644 index 0000000..848a551 --- /dev/null +++ b/lib/ui_screen/interactionform/new_dynamicform.dart @@ -0,0 +1,4219 @@ +import 'dart:convert'; +import 'dart:io'; + +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/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.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:popover/popover.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; +//import 'package:carousel_slider/carousel_slider.dart'; +import 'package:flutter_carousel_widget/flutter_carousel_widget.dart'; + +// import 'package:popover/popover.dart'; + +class InteractionScreen1 extends StatefulWidget { + int index; + String form; + InteractionScreen1({super.key, required this.index, required this.form}); + + @override + State createState() => _InteractionScreen1State(); +} + +class _InteractionScreen1State extends State { + List interactionReponseList = []; + List sectionList = []; + List textEditingControllerList = []; + int textfieldIndex = 0; + String dropdownvalue = 'Select value'; + String? fileName; + final TextEditingController textEditingController = TextEditingController(); + + bool _isExpanded = false; + + late int _value; + + var list; + + var item1; + + int _currentPage = 0; + late int _totalPages = + Provider.of(context, listen: false) + .interactionReponseList + .length; + @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 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, + // ), + // ), + // ), + // body: Column( + // mainAxisSize: MainAxisSize.min, + // 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 Column( + // children: [ + // Card( + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(0.0), + // ), + // elevation: 5, + // color: Constants.k2color, + // child: ExpansionTile( + // maintainState: true, + // backgroundColor: Constants.k2color, + // onExpansionChanged: (bool expanded) { + // setState(() { + // _isExpanded = expanded; + // }); + // }, + // trailing: Icon( + // _isExpanded + // ? Icons.keyboard_arrow_up + // : Icons.keyboard_arrow_down, + // color: Colors.white), + // // collapsedBackgroundColor: Color(0xFF2b9af3), + // initiallyExpanded: true, + // title: + // // Stack( + // // alignment: AlignmentDirectional.center, + // // children: [Contact Module Mobile app Filter section api issue Pooja p1 in-progress + // Text( + // item.sectionName, + // style: const TextStyle( + // color: Colors.white, + // fontWeight: FontWeight.normal, + // // fontSize: isTablet ? 18 : 14 + // ), + // ), + // children: [ + // Container( + // color: Colors.white, + // child: Padding( + // padding: + // const EdgeInsets.only(top: 8.0), + // child: Column( + // mainAxisSize: MainAxisSize.min, + // crossAxisAlignment: + // CrossAxisAlignment.center, + // children: [ + // GridView.count( + // physics: + // const NeverScrollableScrollPhysics(), + + // crossAxisCount: + // context.responsive( + // 1, + // sm: 1, // small + // md: isTablet + // ? 2 + // : orientation == + // Orientation + // .landscape + // ? 2 + // : 1, // medium + // lg: sectionList.length == 1 + // ? 1 + // : 3, // large + // xl: 3, // extra large screen + // ), + + // mainAxisSpacing: + // sectionList.length == 1 || + // !isTablet + // ? 1 + // : 3.5, + // // mainAxisSpacing: + // // orientation == Orientation.portrait + // // ? 1 + // // : 3, + // shrinkWrap: true, + // padding: EdgeInsets.zero, + + // childAspectRatio: + // sectionList.length == 1 + // ? orientation == + // Orientation + // .landscape + // ? 10 + // : 4.8 + // : isTablet + // ? 2.8 + // : 3.5, + + // 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( + // //mainAxisSize: MainAxisSize.min, + // 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, + // ), + // ), + // ), + // ), + // returnWidget( + // sectionItem: + // sectionItem, + // item: item, + // provider: provider, + // list: list, + // gridIndex: i, + // listIndex: index, + // widgetData: + // sectionItem + // .widget!, + // multiple: false), + // ], + // ); + // }, + // ), + // ), + // // 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), + // Align( + // alignment: Alignment.bottomRight, + // child: Container( + // height: 80.0, + // width: 80.0, + + // //child: + // // Text(provider.interactionReponseList.toString()))) + // child: _offsetPopup(provider.interactionReponseList))) + // ], + // ), + // ), + // ); + // }), + // ); + // }); + // } + final CarouselController _controller = CarouselController(); + + @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 SafeArea( + child: Scaffold( + backgroundColor: Colors.white, + appBar: AppBar( + title: const FittedBox( + fit: BoxFit.scaleDown, + child: Text( + 'Record New Interaction', + style: TextStyle(color: Colors.white, fontSize: 18.0), + ), + ), + 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, + // cacheExtent: double.parse(provider + // .interactionReponseList.length + // .toString()), + // itemBuilder: (context, index) { + // var item = provider.interactionReponseList[index]; + // sectionList = item.sectionList; + // print("Section_ListttPooja: $sectionList"); + FlutterCarousel( + options: CarouselOptions( + onPageChanged: (index, reason) { + setState(() { + _currentPage = index; + }); + // Example: Perform actions when reaching the last page + // if (_currentPage == _totalPages - 1) { + // print('Reached the last page!'); + // // Add your actions here + // } + }, + controller: _controller, + + height: MediaQuery.of(context) + .size + .height, // Adjust as needed + // aspectRatio: 16 / 9, // Optional aspect ratio adjustment + //viewportFraction: 0.9, + viewportFraction: 1.0, + + initialPage: 0, + enableInfiniteScroll: false, + reverse: false, + autoPlay: false, + autoPlayInterval: Duration(seconds: 3), + autoPlayAnimationDuration: Duration(milliseconds: 800), + autoPlayCurve: Curves.fastOutSlowIn, + enlargeCenterPage: false, + disableCenter: false, + showIndicator: true, + scrollDirection: Axis.horizontal, + + slideIndicator: CircularWaveSlideIndicator( + alignment: Alignment.bottomCenter, + currentIndicatorColor: Constants.k2color, + indicatorBackgroundColor: Colors.grey), + ), + items: provider.interactionReponseList.map((item) { + sectionList = item.sectionList; + print("Item_sectionListt11: ${item.sectionName}"); + + print("Item_sectionListt: ${item.sectionList}"); + + // provider.interactionReponseList[index] + // .map((item) { + return ListView( + children: [ + ColoredBox( + color: Colors.white, + child: + // ExpansionTile( + // maintainState: true, + // // backgroundColor: Constants.k2color, + // onExpansionChanged: (bool expanded) { + // setState(() { + // _isExpanded = expanded; + // }); + // }, + // trailing: Icon( + // _isExpanded + // ? Icons.keyboard_arrow_up + // : Icons.keyboard_arrow_down, + // color: Colors.white), + // // collapsedBackgroundColor: Color(0xFF2b9af3), + // initiallyExpanded: true, + // title: + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + item.sectionName, + textAlign: TextAlign.center, + style: const TextStyle( + color: Colors.black, + fontSize: 18.0, + + fontWeight: FontWeight.bold, + // fontSize: isTablet ? 18 : 14 + ), + ), + ), + // children: [], + // ), + ), + Container( + color: Colors.white, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + ColoredBox( + color: Colors.white, + child: Padding( + padding: const EdgeInsets.only(top: 5.0), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + GridView.count( + physics: + const NeverScrollableScrollPhysics(), + + crossAxisCount: + context.responsive( + 1, + sm: 1, // small + md: isTablet + ? 2 + : orientation == + Orientation.landscape + ? 2 + : 1, // medium + lg: sectionList.length == 1 + ? 1 + : 3, // large + xl: 3, // extra large screen + ), + + // mainAxisSpacing: + // sectionList.length == 1 || + // !isTablet + // ? 1.8 + // : 3.5, + mainAxisSpacing: + sectionList.length == 1 || + !isTablet + ? 1.8 + : 3.5, + // mainAxisSpacing: + // orientation == Orientation.portrait + // ? 1 + // : 3, + shrinkWrap: true, + padding: EdgeInsets.zero, + + // childAspectRatio: + // sectionList.length == 1 + // ? orientation == + // Orientation.landscape + // ? 10 + // : 4.8 + // : isTablet + // ? 2.8 + // : 3.0, + + // childAspectRatio: + // sectionList.length == 1 + // ? orientation == + // Orientation + // .landscape + // ? 10 + // : 4.8 + // : isTablet + // ? 2.8 + // : 3.5, + childAspectRatio: + sectionList.length == 1 + ? orientation == + Orientation + .landscape + ? 10 + : 4.8 + : isTablet + ? 2.8 + : 4.5, + + 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( + mainAxisSize: + MainAxisSize.min, + 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, + color: Constants + .k2color, + + fontSize: + 14.0, + // fontSize: isTablet + // ? 18 + // : 12, + ), + ), + ), + ), + returnWidget( + sectionItem: + sectionItem, + item: item, + provider: provider, + list: list, + gridIndex: i, + listIndex: 0, + widgetData: + sectionItem.widget!, + multiple: false), + ], + ); + }, + ), + ), + // SizedBox( + // height: isTablet ? 15 : 5, + // ), + item.multiple + ? gridViewWidget( + provider, + item.sectionName, + item.multipleList ?? [], + orientation, + item, + 0) + : const SizedBox.shrink(), + provider.interactionReponseList + .length == + 0 - 1 + ? saveActions(provider) + : const SizedBox.shrink(), + + // Add your actions here + + //const Spacer(), + ], + ), + ), + ), + ], + ), + ), + item.multiple + ? Container( + color: Colors.white, + child: Align( + alignment: Alignment.center, + child: Padding( + padding: + const EdgeInsets.only(bottom: 18.0), + child: OutlinedButton( + onPressed: () { + provider.getSectionItem( + item.sectionName, + ); + }, + child: Text( + 'Add More', + style: TextStyle( + color: Constants.k2color), + ), + style: OutlinedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(12), + ), + ), + ), + ), + ), + ) + : SizedBox.shrink(), + _currentPage == _totalPages - 1 + ? Container( + color: Colors.white, + child: Align( + alignment: Alignment.center, + child: Padding( + padding: + const EdgeInsets.only(bottom: 18.0), + child: OutlinedButton( + // onPressed: () {}, + onPressed: () async { + String record = + await provider.saveJsonObject( + context, widget.form); + + print( + "Validation_isss: ${provider.isLoading}"); + + if (provider.isLoading == false) { + print("Validation_false"); + showAlertDialog1(context, + "Please fill all the fields"); + } else { + showAlertDialog(context, + "Form $record Saved Successfully!"); + print("Validation_True"); + } + }, + child: Text( + 'Submit', + style: TextStyle( + color: Constants.k2color), + ), + style: OutlinedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(12), + ), + ), + ), + ), + ), + ) + : SizedBox.shrink(), + ], + ); + }).toList(), + ) + //}), + ), + //const SizedBox(height: 16.0), + + Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: Align( + alignment: Alignment.bottomCenter, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible( + child: OutlinedButton( + style: OutlinedButton.styleFrom( + shape: CircleBorder()), + onPressed: () { + //if (_currentPageIndex > _totalPages - 1) + _controller.previousPage(); + }, + child: Padding( + padding: EdgeInsets.all(8.0), + child: Icon( + Icons.arrow_back, + color: Constants.k2color, + ), + ), + ), + ), + Flexible( + child: OutlinedButton( + style: OutlinedButton.styleFrom( + shape: CircleBorder()), + // onPressed: () { + // _controller.nextPage( + // duration: Duration(milliseconds: 300), + // curve: Curves.ease, + // ); + // }, + onPressed: () { + _controller.nextPage( + duration: Duration(milliseconds: 300), + curve: Curves.ease, + ); + }, + child: Padding( + padding: EdgeInsets.all(8.0), + child: Icon( + Icons.arrow_forward, + color: Constants.k2color, + ), + ), + ), + ), + ], + ), + ), + ), + ], + ), + ), + ); + }), + ); + }, + ); + } + + // @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 SafeArea( + // child: Scaffold( + // appBar: AppBar( + // title: const FittedBox( + // fit: BoxFit.scaleDown, + // child: Text( + // 'Record New Interaction', + // style: TextStyle(color: Colors.white), + // ), + // ), + // 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: CarouselSlider.builder( + // itemCount: provider.interactionReponseList.length, + // options: CarouselOptions( + // height: MediaQuery.of(context) + // .size + // .height, // Adjust as needed + // aspectRatio: + // 16 / 9, // Optional aspect ratio adjustment + // viewportFraction: 0.9, + // initialPage: 0, + // enableInfiniteScroll: false, + // reverse: false, + // autoPlay: false, + // autoPlayInterval: Duration(seconds: 3), + // autoPlayAnimationDuration: + // Duration(milliseconds: 800), + // autoPlayCurve: Curves.fastOutSlowIn, + // enlargeCenterPage: true, + // scrollDirection: Axis.horizontal, + // ), + // itemBuilder: + // (BuildContext context, int index, int realIndex) { + // var item = provider.interactionReponseList[index]; + // sectionList = item.sectionList; + // return Card( + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(0.0), + // ), + // elevation: 5, + // color: Constants.k2color, + // child: Text("pooja ${index}"), + // // ExpansionTile( + // // maintainState: true, + // // backgroundColor: Constants.k2color, + // // onExpansionChanged: (bool expanded) { + // // setState(() { + // // _isExpanded = expanded; + // // }); + // // }, + // // trailing: Icon( + // // _isExpanded + // // ? Icons.keyboard_arrow_up + // // : Icons.keyboard_arrow_down, + // // color: Colors.white, + // // ), + // // initiallyExpanded: true, + // // title: Text( + // // item.sectionName, + // // style: const TextStyle( + // // color: Colors.white, + // // fontWeight: FontWeight.normal, + // // ), + // // ), + // // children: [ + // // Container( + // // color: Colors.white, + // // child: Padding( + // // padding: const EdgeInsets.only(top: 8.0), + // // child: Column( + // // mainAxisSize: MainAxisSize.min, + // // crossAxisAlignment: + // // CrossAxisAlignment.center, + // // children: [ + // // GridView.count( + // // physics: + // // const NeverScrollableScrollPhysics(), + // // crossAxisCount: + // // context.responsive( + // // 1, + // // sm: 1, // small + // // md: isTablet + // // ? 2 + // // : orientation == + // // Orientation.landscape + // // ? 2 + // // : 1, // 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.5, + // // children: List.generate( + // // sectionList.length, + // // (i) { + // // SectionList sectionItem = + // // sectionList[i]; + // // // Your existing code for building widgets inside the GridView + // // return returnWidget( + // // sectionItem: sectionItem, + // // item: item, + // // provider: provider, + // // list: list, + // // gridIndex: i, + // // listIndex: index, + // // widgetData: + // // sectionItem.widget!, + // // multiple: false); + // // }, + // // ), + // // ), + // // // Other widgets inside the ExpansionTile's children + // // ], + // // ), + // // ), + // // ), + // // ], + // // ), + // // ); + // ); + // }, + // ), + // ), + // Align( + // alignment: Alignment.bottomRight, + // child: Container( + // height: 80.0, + // width: 80.0, + // child: _offsetPopup(provider.interactionReponseList), + // ), + // ), + // ], + // ), + // ), + // ); + // }), + // ); + // }, + // ); + // } + + 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: Padding( + padding: const EdgeInsets.only(left: 8.0, right: 8.0), + 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), + ) + : Expanded( + child: 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, + height: isTablet ? 50 : 40, + + child: InteractionTextField( + inputType: sectionItem.input == "number" + ? TextInputType.number + : TextInputType.name, + maxchars: int.parse(sectionItem.chars ?? "0"), + controller: sectionItem.controller!, + labelText: sectionItem.name, + onChanged: (val) { + sectionItem.selectedValue = []; + // sectionItem.selectedValue!.clear(); + + provider.setTextValue( + val, sectionItem, multiple); + }, + ), + ), + ), + ); + case InteractionWidget.DROPDOWN: + // return customdropdown(sectionItem, provider, list, multiple); + + return customAutoCompletedropdown( + 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), + padding: const EdgeInsets.only(top: 8.0, bottom: 8.0, right: 5.0), + + child: CustomButton( + backgroundColor: Colors.red.shade800, + onPressed: () { + //showDeleteProfileAlertDialog(context); + for (var textcontrollers + in provider.textEditingControllerList) { + textcontrollers.text = ''; + } + }, + textColor: Colors.white, + title: "Reset", + // height: 40, + // width: isTablet ? 100 : 80, + height: MediaQuery.of(context).size.height * 0.2, + + // fontsize: isTablet ? 15 : 10.2, + fontsize: isTablet ? 16 : 12, + ), + ), + SizedBox( + //width: isTablet ? 20 : 4, + width: isTablet ? 20 : 2, + ), + Padding( + // padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), + + child: CustomButton( + backgroundColor: Colors.green.shade500, + onPressed: () async { + String record = + await provider.saveJsonObject(context, widget.form); + + print("Validation_isss: ${provider.isLoading}"); + + if (provider.isLoading == false) { + print("Validation_false"); + showAlertDialog1(context, "Please fill all the fields"); + } else { + showAlertDialog(context, "Form $record Saved Successfully!"); + print("Validation_True"); + } + }, + 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: CheckboxListTile( + dense: true, + //contentPadding: const EdgeInsets.symmetric(vertical: 5), + 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. + isDense: true, + contentPadding: const EdgeInsets.symmetric(vertical: 5), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + ), + // 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(10.0), + ), + ), + menuItemStyleData: const MenuItemStyleData( + padding: EdgeInsets.symmetric(horizontal: 16), + ), + ), + ), + ); + } + + Widget customAutoCompletedropdown(SectionList sectionItem, + InteractionProvider provider, List list, bool multiple) { + 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. + isDense: true, + contentPadding: const EdgeInsets.symmetric(vertical: 5), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + ), + // 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: 18, + ), + hintText: 'Search for an item...', + hintStyle: const TextStyle(fontSize: 12), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + ), + ), + ), + ), + 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. + isDense: true, + contentPadding: const EdgeInsets.symmetric(vertical: 5), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + ), + // 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"); + print("Pooja_leangth_isss: ${pooja.length}"); + + ////////////////////////////////////mycode/////////////////////////// + + 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 Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + for (var i = 0; i < convertedArray.length; i++) + DecoratedBox( + decoration: BoxDecoration( + // border: Border.all(color: Colors.black), + // borderRadius: BorderRadius.circular(10.0), + color: i % 2 == 0 + ? Color.fromARGB(133, 213, 241, 254) + : Colors.white, + ), + child: GridView.builder( + physics: const NeverScrollableScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: context.responsive( + 1, + sm: 1, // small + md: isTablet + ? 2 + : orientation == Orientation.landscape + ? 2 + : 1, // medium + lg: sectionList.length == 1 ? 1 : 3, // large + xl: 3, // extra large screen + ), + mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 1, + // childAspectRatio: sectionList.length == 1 + // ? orientation == Orientation.landscape + // ? 10 + // : 4.8 + // : isTablet + // ? 2.8 + // : 3.7, + childAspectRatio: sectionList.length == 1 + ? orientation == Orientation.landscape + ? 10 + : 4.8 + : isTablet + ? 2.8 + : 4.5, + ), + shrinkWrap: true, + padding: EdgeInsets.zero, + itemCount: convertedArray[i].length, + itemBuilder: (context, index) { + 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 Padding( + padding: const EdgeInsets.only(top: 12.0), + child: Column( + mainAxisSize: MainAxisSize.min, + 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.validation!.isRequired + ? "${sectionItem.name}*" + : sectionItem.name, + style: TextStyle( + //color: Colors.orange.shade800, + color: Constants.k2color, + fontSize: 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: 8.0, right: 8.0), + child: CustomButton( + backgroundColor: + const Color.fromARGB( + 255, 233, 75, 75), + onPressed: () { + provider.deleteMultipleRows( + sectionItem.gid!, + sectionList[i], + sectionName); + + setState(() {}); + }, + 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) { + 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) { + 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(record), + actions: [ + cancelButton, + ], + ); + + // show the dialog + showDialog( + context: context, + builder: (BuildContext context) { + return alert; + }, + ); + } + + showAlertDialog1(BuildContext context, String record) { + Widget cancelButton = TextButton( + child: const Text("Ok"), + onPressed: () async { + Navigator.of(context).pop(); + }, + ); + + // set up the AlertDialog + AlertDialog alert = AlertDialog( + title: const Text(""), + content: Text(record), + actions: [ + cancelButton, + ], + ); + + // show the dialog + showDialog( + context: context, + builder: (BuildContext context) { + return alert; + }, + ); + } + + Widget _offsetPopup(List interactionReponseList) { + List trueElements = + interactionReponseList.where((element) => element.multiple).toList(); + print("trueElements_iss: $trueElements"); + + return PopupMenuButton( + onSelected: (newValue) { + var provider = + Provider.of(context, listen: false); + setState(() { + _value = newValue; // it gives the value which is selected + + var item = trueElements[_value]; + + provider.getSectionItem( + item.sectionName, + ); + }); + print("Clicked Section111 $_value "); // add this property + print( + "interactionReponseList1 ${interactionReponseList} "); // add this property + }, + itemBuilder: (context) { + return List.generate(trueElements.length, (index) { + var provider = + Provider.of(context, listen: false); + + var item = trueElements[index]; + + print("itemitemitemitem_isss: ${item.multiple}"); + + return PopupMenuItem( + value: index, + child: item.multiple == true + ? GestureDetector( + onTap: () { + print("Clicked Section ${item.sectionName}"); + // provider.getSectionItem( + // item.sectionName, + // ); + //print("Clicked Section : ${sectionList}") + setState(() { + provider.getSectionItem( + item.sectionName, + ); + }); + + const DecoratedBox( + decoration: BoxDecoration( + // border: Border.all(color: Colors.black), + // borderRadius: BorderRadius.circular(10.0), + border: Border( + bottom: + BorderSide(width: 1.5, color: Colors.black), + //top: BorderSide(width: 1.5, color: Colors.black), + ), + ), + ); + }, + child: item.multiple == true + ? Text(' ${item.sectionName}') + : const SizedBox.shrink()) + : SizedBox.shrink(), + ); + }); + }, + icon: Container( + height: double.infinity, + width: double.infinity, + decoration: const ShapeDecoration( + color: Color.fromARGB(255, 8, 39, 92), + shape: StadiumBorder( + side: BorderSide(color: Colors.white, width: 2), + ), + ), + child: Icon(Icons.add, color: Colors.white), + )); + } +} + +// import 'dart:convert'; +// import 'dart:io'; + +// 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/cupertino.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter/rendering.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:popover/popover.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; +// //import 'package:carousel_slider/carousel_slider.dart'; +// import 'package:flutter_carousel_widget/flutter_carousel_widget.dart'; + +// // import 'package:popover/popover.dart'; + +// class InteractionScreen1 extends StatefulWidget { +// int index; +// String form; +// InteractionScreen1({super.key, required this.index, required this.form}); + +// @override +// State createState() => _InteractionScreen1State(); +// } + +// class _InteractionScreen1State extends State { +// List interactionReponseList = []; +// List sectionList = []; +// List textEditingControllerList = []; +// int textfieldIndex = 0; +// String dropdownvalue = 'Select value'; +// String? fileName; +// final TextEditingController textEditingController = TextEditingController(); + +// bool _isExpanded = false; + +// late int _value; + +// var list; + +// var item1; +// @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 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, +// // ), +// // ), +// // ), +// // body: Column( +// // mainAxisSize: MainAxisSize.min, +// // 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 Column( +// // children: [ +// // Card( +// // shape: RoundedRectangleBorder( +// // borderRadius: BorderRadius.circular(0.0), +// // ), +// // elevation: 5, +// // color: Constants.k2color, +// // child: ExpansionTile( +// // maintainState: true, +// // backgroundColor: Constants.k2color, +// // onExpansionChanged: (bool expanded) { +// // setState(() { +// // _isExpanded = expanded; +// // }); +// // }, +// // trailing: Icon( +// // _isExpanded +// // ? Icons.keyboard_arrow_up +// // : Icons.keyboard_arrow_down, +// // color: Colors.white), +// // // collapsedBackgroundColor: Color(0xFF2b9af3), +// // initiallyExpanded: true, +// // title: +// // // Stack( +// // // alignment: AlignmentDirectional.center, +// // // children: [Contact Module Mobile app Filter section api issue Pooja p1 in-progress +// // Text( +// // item.sectionName, +// // style: const TextStyle( +// // color: Colors.white, +// // fontWeight: FontWeight.normal, +// // // fontSize: isTablet ? 18 : 14 +// // ), +// // ), +// // children: [ +// // Container( +// // color: Colors.white, +// // child: Padding( +// // padding: +// // const EdgeInsets.only(top: 8.0), +// // child: Column( +// // mainAxisSize: MainAxisSize.min, +// // crossAxisAlignment: +// // CrossAxisAlignment.center, +// // children: [ +// // GridView.count( +// // physics: +// // const NeverScrollableScrollPhysics(), + +// // crossAxisCount: +// // context.responsive( +// // 1, +// // sm: 1, // small +// // md: isTablet +// // ? 2 +// // : orientation == +// // Orientation +// // .landscape +// // ? 2 +// // : 1, // medium +// // lg: sectionList.length == 1 +// // ? 1 +// // : 3, // large +// // xl: 3, // extra large screen +// // ), + +// // mainAxisSpacing: +// // sectionList.length == 1 || +// // !isTablet +// // ? 1 +// // : 3.5, +// // // mainAxisSpacing: +// // // orientation == Orientation.portrait +// // // ? 1 +// // // : 3, +// // shrinkWrap: true, +// // padding: EdgeInsets.zero, + +// // childAspectRatio: +// // sectionList.length == 1 +// // ? orientation == +// // Orientation +// // .landscape +// // ? 10 +// // : 4.8 +// // : isTablet +// // ? 2.8 +// // : 3.5, + +// // 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( +// // //mainAxisSize: MainAxisSize.min, +// // 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, +// // ), +// // ), +// // ), +// // ), +// // returnWidget( +// // sectionItem: +// // sectionItem, +// // item: item, +// // provider: provider, +// // list: list, +// // gridIndex: i, +// // listIndex: index, +// // widgetData: +// // sectionItem +// // .widget!, +// // multiple: false), +// // ], +// // ); +// // }, +// // ), +// // ), +// // // 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), +// // Align( +// // alignment: Alignment.bottomRight, +// // child: Container( +// // height: 80.0, +// // width: 80.0, + +// // //child: +// // // Text(provider.interactionReponseList.toString()))) +// // child: _offsetPopup(provider.interactionReponseList))) +// // ], +// // ), +// // ), +// // ); +// // }), +// // ); +// // }); +// // } +// final CarouselController _controller = CarouselController(); + +// @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 SafeArea( +// child: Scaffold( +// appBar: AppBar( +// title: const FittedBox( +// fit: BoxFit.scaleDown, +// child: Text( +// 'Record New Interaction', +// style: TextStyle(color: Colors.white), +// ), +// ), +// 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, +// // cacheExtent: double.parse(provider +// // .interactionReponseList.length +// // .toString()), +// // itemBuilder: (context, index) { +// // var item = provider.interactionReponseList[index]; +// // sectionList = item.sectionList; +// // print("Section_ListttPooja: $sectionList"); +// FlutterCarousel( +// options: CarouselOptions( +// controller: _controller, + +// height: MediaQuery.of(context) +// .size +// .height, // Adjust as needed +// // aspectRatio: 16 / 9, // Optional aspect ratio adjustment +// //viewportFraction: 0.9, +// viewportFraction: 1.0, + +// initialPage: 0, +// enableInfiniteScroll: false, +// reverse: false, +// autoPlay: false, +// autoPlayInterval: Duration(seconds: 3), +// autoPlayAnimationDuration: Duration(milliseconds: 800), +// autoPlayCurve: Curves.fastOutSlowIn, +// enlargeCenterPage: false, +// disableCenter: false, +// showIndicator: true, +// scrollDirection: Axis.horizontal, + +// slideIndicator: CircularWaveSlideIndicator( +// alignment: Alignment.bottomCenter, +// currentIndicatorColor: Colors.black, +// indicatorBackgroundColor: Colors.grey), +// ), +// items: provider.interactionReponseList.map((item) { +// sectionList = item.sectionList; +// print("Item_sectionListt11: ${item.sectionName}"); + +// print("Item_sectionListt: ${item.sectionList}"); + +// // provider.interactionReponseList[index] +// // .map((item) { +// return ListView( +// children: [ +// Container( +// //width: MediaQuery.of(context).size.width, +// // shape: RoundedRectangleBorder( +// // borderRadius: BorderRadius.circular(0.0), +// // ), +// //elevation: 5, +// color: Constants.k2color, +// child: ExpansionTile( +// maintainState: true, +// // backgroundColor: Constants.k2color, +// onExpansionChanged: (bool expanded) { +// setState(() { +// _isExpanded = expanded; +// }); +// }, +// trailing: Icon( +// _isExpanded +// ? Icons.keyboard_arrow_up +// : Icons.keyboard_arrow_down, +// color: Colors.white), +// // collapsedBackgroundColor: Color(0xFF2b9af3), +// initiallyExpanded: true, +// title: Stack( +// alignment: AlignmentDirectional.center, +// children: [ +// Container( +// // height: double.infinity, +// width: double.infinity, +// padding: const EdgeInsets.all(0.0), +// decoration: BoxDecoration( +// // color: Color(0xFF2b9af3), +// color: Constants.k2color, +// ), +// child: Text( +// item.sectionName, +// style: const TextStyle( +// color: Colors.white, +// fontWeight: FontWeight.normal, +// // fontSize: isTablet ? 18 : 14 +// ), +// )), +// item.multiple +// ? Align( +// alignment: +// Alignment.centerRight, +// child: IconButton( +// onPressed: () { +// provider.getSectionItem( +// item.sectionName, +// ); +// // print("index is $listIndex"); +// setState(() {}); +// }, +// icon: const Icon( +// Icons.add_circle_outline, +// size: 24, +// color: Colors.white, +// ), +// ), +// ) +// : const SizedBox.shrink() +// ]), +// // children: [ +// // Column( +// // mainAxisSize: MainAxisSize.max, +// // children: [ +// // Container( +// // color: Colors.white, +// // child: Text("pojaaa")), +// // ], +// // ) +// // ], + +// children: [ +// Column( +// mainAxisSize: MainAxisSize.min, +// children: [ +// ColoredBox( +// color: Colors.white, +// child: Padding( +// padding: +// const EdgeInsets.only(top: 8.0), +// child: Column( +// mainAxisSize: MainAxisSize.min, +// crossAxisAlignment: +// CrossAxisAlignment.center, +// children: [ +// GridView.count( +// physics: +// const NeverScrollableScrollPhysics(), + +// crossAxisCount: +// context.responsive( +// 1, +// sm: 1, // small +// md: isTablet +// ? 2 +// : orientation == +// Orientation +// .landscape +// ? 2 +// : 1, // medium +// lg: sectionList.length == 1 +// ? 1 +// : 3, // large +// xl: 3, // extra large screen +// ), + +// mainAxisSpacing: +// sectionList.length == 1 || +// !isTablet +// ? 1 +// : 3.5, +// // mainAxisSpacing: +// // orientation == Orientation.portrait +// // ? 1 +// // : 3, +// shrinkWrap: true, +// padding: EdgeInsets.zero, + +// // childAspectRatio: +// // sectionList.length == 1 +// // ? orientation == +// // Orientation.landscape +// // ? 10 +// // : 4.8 +// // : isTablet +// // ? 2.8 +// // : 3.0, + +// childAspectRatio: +// sectionList.length == 1 +// ? orientation == +// Orientation +// .landscape +// ? 10 +// : 4.8 +// : isTablet +// ? 2.8 +// : 3.5, + +// 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( +// mainAxisSize: +// MainAxisSize.min, +// 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, +// ), +// ), +// ), +// ), +// returnWidget( +// sectionItem: +// sectionItem, +// item: item, +// provider: +// provider, +// list: list, +// gridIndex: i, +// listIndex: 0, +// widgetData: +// sectionItem +// .widget!, +// multiple: false), +// ], +// ); +// }, +// ), +// ), +// // SizedBox( +// // height: isTablet ? 15 : 5, +// // ), +// item.multiple +// ? gridViewWidget( +// provider, +// item.sectionName, +// item.multipleList ?? [], +// orientation, +// item, +// 0) +// : const SizedBox.shrink(), +// provider.interactionReponseList +// .length == +// 0 - 1 +// ? saveActions(provider) +// : const SizedBox.shrink() +// //const Spacer(), +// ], +// ), +// ), +// ), +// ], +// ), +// ], +// )), +// item.multiple +// ? Padding( +// padding: const EdgeInsets.all(18.0), +// child: ElevatedButton( +// onPressed: () { +// provider.getSectionItem( +// item.sectionName, +// ); +// }, +// child: Text("Add "), +// ), +// ) +// : SizedBox.shrink() +// ], +// ); +// }).toList(), +// ) +// //}), +// ), +// //const SizedBox(height: 16.0), + +// Align( +// alignment: Alignment.bottomCenter, +// child: Row( +// mainAxisAlignment: MainAxisAlignment.spaceBetween, +// children: [ +// Flexible( +// child: ElevatedButton( +// onPressed: () { +// //if (_currentPageIndex > _totalPages - 1) +// _controller.previousPage(); +// }, +// child: const Padding( +// padding: EdgeInsets.all(8.0), +// child: Icon(Icons.arrow_back), +// ), +// ), +// ), +// Flexible( +// child: ElevatedButton( +// // onPressed: () { +// // _controller.nextPage( +// // duration: Duration(milliseconds: 300), +// // curve: Curves.ease, +// // ); +// // }, +// onPressed: () { +// _controller.nextPage( +// duration: Duration(milliseconds: 300), +// curve: Curves.ease, +// ); +// }, +// child: const Padding( +// padding: EdgeInsets.all(8.0), +// child: Icon(Icons.arrow_forward), +// ), +// ), +// ), +// ], +// ), +// ), + +// // Align( +// // alignment: Alignment.bottomRight, +// // child: Container( +// // height: 80.0, +// // width: 80.0, +// // child: _offsetPopup(provider.interactionReponseList), +// // ), +// // ), +// ], +// ), +// ), +// ); +// }), +// ); +// }, +// ); +// } + +// // @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 SafeArea( +// // child: Scaffold( +// // appBar: AppBar( +// // title: const FittedBox( +// // fit: BoxFit.scaleDown, +// // child: Text( +// // 'Record New Interaction', +// // style: TextStyle(color: Colors.white), +// // ), +// // ), +// // 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: CarouselSlider.builder( +// // itemCount: provider.interactionReponseList.length, +// // options: CarouselOptions( +// // height: MediaQuery.of(context) +// // .size +// // .height, // Adjust as needed +// // aspectRatio: +// // 16 / 9, // Optional aspect ratio adjustment +// // viewportFraction: 0.9, +// // initialPage: 0, +// // enableInfiniteScroll: false, +// // reverse: false, +// // autoPlay: false, +// // autoPlayInterval: Duration(seconds: 3), +// // autoPlayAnimationDuration: +// // Duration(milliseconds: 800), +// // autoPlayCurve: Curves.fastOutSlowIn, +// // enlargeCenterPage: true, +// // scrollDirection: Axis.horizontal, +// // ), +// // itemBuilder: +// // (BuildContext context, int index, int realIndex) { +// // var item = provider.interactionReponseList[index]; +// // sectionList = item.sectionList; +// // return Card( +// // shape: RoundedRectangleBorder( +// // borderRadius: BorderRadius.circular(0.0), +// // ), +// // elevation: 5, +// // color: Constants.k2color, +// // child: Text("pooja ${index}"), +// // // ExpansionTile( +// // // maintainState: true, +// // // backgroundColor: Constants.k2color, +// // // onExpansionChanged: (bool expanded) { +// // // setState(() { +// // // _isExpanded = expanded; +// // // }); +// // // }, +// // // trailing: Icon( +// // // _isExpanded +// // // ? Icons.keyboard_arrow_up +// // // : Icons.keyboard_arrow_down, +// // // color: Colors.white, +// // // ), +// // // initiallyExpanded: true, +// // // title: Text( +// // // item.sectionName, +// // // style: const TextStyle( +// // // color: Colors.white, +// // // fontWeight: FontWeight.normal, +// // // ), +// // // ), +// // // children: [ +// // // Container( +// // // color: Colors.white, +// // // child: Padding( +// // // padding: const EdgeInsets.only(top: 8.0), +// // // child: Column( +// // // mainAxisSize: MainAxisSize.min, +// // // crossAxisAlignment: +// // // CrossAxisAlignment.center, +// // // children: [ +// // // GridView.count( +// // // physics: +// // // const NeverScrollableScrollPhysics(), +// // // crossAxisCount: +// // // context.responsive( +// // // 1, +// // // sm: 1, // small +// // // md: isTablet +// // // ? 2 +// // // : orientation == +// // // Orientation.landscape +// // // ? 2 +// // // : 1, // 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.5, +// // // children: List.generate( +// // // sectionList.length, +// // // (i) { +// // // SectionList sectionItem = +// // // sectionList[i]; +// // // // Your existing code for building widgets inside the GridView +// // // return returnWidget( +// // // sectionItem: sectionItem, +// // // item: item, +// // // provider: provider, +// // // list: list, +// // // gridIndex: i, +// // // listIndex: index, +// // // widgetData: +// // // sectionItem.widget!, +// // // multiple: false); +// // // }, +// // // ), +// // // ), +// // // // Other widgets inside the ExpansionTile's children +// // // ], +// // // ), +// // // ), +// // // ), +// // // ], +// // // ), +// // // ); +// // ); +// // }, +// // ), +// // ), +// // Align( +// // alignment: Alignment.bottomRight, +// // child: Container( +// // height: 80.0, +// // width: 80.0, +// // child: _offsetPopup(provider.interactionReponseList), +// // ), +// // ), +// // ], +// // ), +// // ), +// // ); +// // }), +// // ); +// // }, +// // ); +// // } + +// 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: Padding( +// padding: const EdgeInsets.only(left: 8.0, right: 8.0), +// 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), +// ) +// : Expanded( +// child: 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, +// height: isTablet ? 50 : 40, + +// child: InteractionTextField( +// inputType: sectionItem.input == "number" +// ? TextInputType.number +// : TextInputType.name, +// maxchars: int.parse(sectionItem.chars ?? "0"), +// controller: sectionItem.controller!, +// labelText: sectionItem.name, +// onChanged: (val) { +// sectionItem.selectedValue = []; +// // sectionItem.selectedValue!.clear(); + +// provider.setTextValue( +// val, sectionItem, multiple); +// }, +// ), +// ), +// ), +// ); +// case InteractionWidget.DROPDOWN: +// // return customdropdown(sectionItem, provider, list, multiple); + +// return customAutoCompletedropdown( +// 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), +// padding: const EdgeInsets.only(top: 8.0, bottom: 8.0, right: 5.0), + +// child: CustomButton( +// backgroundColor: Colors.red.shade800, +// onPressed: () { +// //showDeleteProfileAlertDialog(context); +// for (var textcontrollers +// in provider.textEditingControllerList) { +// textcontrollers.text = ''; +// } +// }, +// textColor: Colors.white, +// title: "Reset", +// // height: 40, +// // width: isTablet ? 100 : 80, +// height: MediaQuery.of(context).size.height * 0.2, + +// // fontsize: isTablet ? 15 : 10.2, +// fontsize: isTablet ? 16 : 12, +// ), +// ), +// SizedBox( +// //width: isTablet ? 20 : 4, +// width: isTablet ? 20 : 2, +// ), +// Padding( +// // padding: const EdgeInsets.all(8.0), +// padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), + +// child: CustomButton( +// backgroundColor: Colors.green.shade500, +// onPressed: () async { +// String record = +// await provider.saveJsonObject(context, widget.form); + +// print("Validation_isss: ${provider.isLoading}"); + +// if (provider.isLoading == false) { +// print("Validation_false"); +// showAlertDialog1(context, "Please fill all the fields"); +// } else { +// showAlertDialog(context, "Form $record Saved Successfully!"); +// print("Validation_True"); +// } +// }, +// 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: CheckboxListTile( +// dense: true, +// //contentPadding: const EdgeInsets.symmetric(vertical: 5), +// 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. +// isDense: true, +// contentPadding: const EdgeInsets.symmetric(vertical: 5), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(10.0), +// ), +// // 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(10.0), +// ), +// ), +// menuItemStyleData: const MenuItemStyleData( +// padding: EdgeInsets.symmetric(horizontal: 16), +// ), +// ), +// ), +// ); +// } + +// Widget customAutoCompletedropdown(SectionList sectionItem, +// InteractionProvider provider, List list, bool multiple) { +// 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. +// isDense: true, +// contentPadding: const EdgeInsets.symmetric(vertical: 5), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(10.0), +// ), +// // 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: 18, +// ), +// hintText: 'Search for an item...', +// hintStyle: const TextStyle(fontSize: 12), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(10.0), +// ), +// ), +// ), +// ), +// 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. +// isDense: true, +// contentPadding: const EdgeInsets.symmetric(vertical: 5), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(10.0), +// ), +// // 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"); +// print("Pooja_leangth_isss: ${pooja.length}"); + +// ////////////////////////////////////mycode/////////////////////////// + +// 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 Column( +// mainAxisSize: MainAxisSize.min, +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// for (var i = 0; i < convertedArray.length; i++) +// DecoratedBox( +// decoration: BoxDecoration( +// // border: Border.all(color: Colors.black), +// // borderRadius: BorderRadius.circular(10.0), +// color: i % 2 == 0 +// ? Color.fromARGB(133, 213, 241, 254) +// : Colors.white, +// ), +// child: GridView.builder( +// physics: const NeverScrollableScrollPhysics(), +// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( +// crossAxisCount: context.responsive( +// 1, +// sm: 1, // small +// md: isTablet +// ? 2 +// : orientation == Orientation.landscape +// ? 2 +// : 1, // medium +// lg: sectionList.length == 1 ? 1 : 3, // large +// xl: 3, // extra large screen +// ), +// mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 1, +// childAspectRatio: sectionList.length == 1 +// ? orientation == Orientation.landscape +// ? 10 +// : 4.8 +// : isTablet +// ? 2.8 +// : 3.7, +// ), +// shrinkWrap: true, +// padding: EdgeInsets.zero, +// itemCount: convertedArray[i].length, +// itemBuilder: (context, index) { +// 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 Padding( +// padding: const EdgeInsets.only(top: 12.0), +// child: Column( +// mainAxisSize: MainAxisSize.min, +// 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.validation!.isRequired +// ? "${sectionItem.name}*" +// : sectionItem.name, +// style: TextStyle( +// color: Colors.orange.shade800, fontSize: 18), +// ), +// ), +// ), +// // 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: 8.0, right: 8.0), +// child: CustomButton( +// backgroundColor: +// const Color.fromARGB( +// 255, 233, 75, 75), +// onPressed: () { +// provider.deleteMultipleRows( +// sectionItem.gid!, +// sectionList[i], +// sectionName); + +// setState(() {}); +// }, +// 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) { +// 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) { +// 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(record), +// actions: [ +// cancelButton, +// ], +// ); + +// // show the dialog +// showDialog( +// context: context, +// builder: (BuildContext context) { +// return alert; +// }, +// ); +// } + +// showAlertDialog1(BuildContext context, String record) { +// Widget cancelButton = TextButton( +// child: const Text("Ok"), +// onPressed: () async { +// Navigator.of(context).pop(); +// }, +// ); + +// // set up the AlertDialog +// AlertDialog alert = AlertDialog( +// title: const Text(""), +// content: Text(record), +// actions: [ +// cancelButton, +// ], +// ); + +// // show the dialog +// showDialog( +// context: context, +// builder: (BuildContext context) { +// return alert; +// }, +// ); +// } + +// Widget _offsetPopup(List interactionReponseList) { +// List trueElements = +// interactionReponseList.where((element) => element.multiple).toList(); +// print("trueElements_iss: $trueElements"); + +// return PopupMenuButton( +// onSelected: (newValue) { +// var provider = +// Provider.of(context, listen: false); +// setState(() { +// _value = newValue; // it gives the value which is selected + +// var item = trueElements[_value]; + +// provider.getSectionItem( +// item.sectionName, +// ); +// }); +// print("Clicked Section111 $_value "); // add this property +// print( +// "interactionReponseList1 ${interactionReponseList} "); // add this property +// }, +// itemBuilder: (context) { +// return List.generate(trueElements.length, (index) { +// var provider = +// Provider.of(context, listen: false); + +// var item = trueElements[index]; + +// print("itemitemitemitem_isss: ${item.multiple}"); + +// return PopupMenuItem( +// value: index, +// child: item.multiple == true +// ? GestureDetector( +// onTap: () { +// print("Clicked Section ${item.sectionName}"); +// // provider.getSectionItem( +// // item.sectionName, +// // ); +// //print("Clicked Section : ${sectionList}") +// setState(() { +// provider.getSectionItem( +// item.sectionName, +// ); +// }); + +// const DecoratedBox( +// decoration: BoxDecoration( +// // border: Border.all(color: Colors.black), +// // borderRadius: BorderRadius.circular(10.0), +// border: Border( +// bottom: +// BorderSide(width: 1.5, color: Colors.black), +// //top: BorderSide(width: 1.5, color: Colors.black), +// ), +// ), +// ); +// }, +// child: item.multiple == true +// ? Text(' ${item.sectionName}') +// : const SizedBox.shrink()) +// : SizedBox.shrink(), +// ); +// }); +// }, +// icon: Container( +// height: double.infinity, +// width: double.infinity, +// decoration: const ShapeDecoration( +// color: Color.fromARGB(255, 8, 39, 92), +// shape: StadiumBorder( +// side: BorderSide(color: Colors.white, width: 2), +// ), +// ), +// child: Icon(Icons.add, color: Colors.white), +// )); +// } +// } diff --git a/lib/ui_screen/new_contacts.dart b/lib/ui_screen/new_contacts.dart index f401de8..0bfca71 100644 --- a/lib/ui_screen/new_contacts.dart +++ b/lib/ui_screen/new_contacts.dart @@ -1,13 +1,607 @@ +// // import 'package:discover_module/provider_class/hcp%20_provider.dart'; +// // import 'package:discover_module/ui_screen/interactionform/NewtworkConnectivity.dart'; +// // import 'package:discover_module/ui_screen/new_profile.dart'; +// // import 'package:flutter/cupertino.dart'; +// // import 'package:flutter/material.dart'; +// // import 'package:flutter_profile_picture/flutter_profile_picture.dart'; +// // import 'package:hive_flutter/hive_flutter.dart'; +// // import 'package:provider/provider.dart'; +// // import 'package:flutter/services.dart'; +// // import 'package:discover_module/ui_screen/profile.dart'; + +// // class Contacts1 extends StatefulWidget { +// // const Contacts1({Key? key}) : super(key: key); + +// // @override +// // State createState() => _Contacts1State(); +// // } + +// // class _Contacts1State extends State { +// // final _contactBox = Hive.box("mycontact"); +// // bool _switchValue = false; +// // bool isOnline2 = true; + +// // final TextEditingController _searchController = TextEditingController(); + +// // @override +// // void initState() { +// // super.initState(); +// // setupConnectivityListener(); +// // getCall(); +// // } + +// // Future setupConnectivityListener() async { +// // while (true) { +// // bool isOnline = await NetworkConnectivity().isInternetAvailable(); +// // print('Internet contact available: $isOnline'); +// // await Future.delayed(Duration(seconds: 2)); +// // if (mounted) { +// // setState(() { +// // isOnline2 = isOnline; +// // }); +// // } +// // } +// // } + +// // // @override +// // // void dispose() { +// // // // TODO: implement dispose +// // // } +// // void getCall() async { +// // await Provider.of(context, listen: false).getHCPProvider(); +// // } + +// // @override +// // Widget build(BuildContext context) { +// // SystemChrome.setSystemUIOverlayStyle( +// // SystemUiOverlayStyle(statusBarColor: Color.fromARGB(255, 0, 71, 132))); + +// // return SafeArea( +// // child: Scaffold( +// // body: Consumer( +// // builder: (context, value, child) { +// // return Column( +// // children: [ +// // Row( +// // mainAxisAlignment: MainAxisAlignment.center, +// // 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, +// // ), +// // ), +// // ), +// // ), +// // Row( +// // mainAxisSize: MainAxisSize.min, +// // children: [ +// // _switchValue +// // ? const Text( +// // 'All', +// // style: TextStyle( +// // fontSize: 12, +// // decoration: TextDecoration.lineThrough, +// // decorationThickness: 0.85, +// // ), +// // ) +// // : const Text( +// // 'All', +// // style: TextStyle( +// // fontSize: 12, +// // ), +// // ), +// // CupertinoSwitch( +// // activeColor: Color.fromARGB(255, 0, 71, 132), +// // value: _switchValue, +// // onChanged: (value) { +// // setState(() { +// // _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, +// // ), +// // ), +// // ) +// // ], +// // ), +// // ], +// // ), + +// // Padding( +// // padding: const EdgeInsets.only( +// // top: 8.0, bottom: 8.0, left: 20.0, right: 20.0), +// // child: Center( +// // child: TextField( +// // controller: _searchController, +// // onChanged: (value) { +// // setState(() { +// // Provider.of(context, listen: false) +// // .getHCPProvider(); +// // // Provider.of(context, +// // // listen: false) +// // // .searchInHive( +// // // value); // Update the search results +// // }); +// // }, +// // // ignore: prefer_const_constructors +// // decoration: InputDecoration( +// // contentPadding: const EdgeInsets.symmetric( +// // vertical: 9.0), // Adjust the vertical padding + +// // border: const OutlineInputBorder(), +// // labelText: ' Search', +// // prefixIcon: const Icon(Icons.search), +// // )), +// // ), +// // ), +// // !_switchValue ? Listdisplay(value) : Listdisplay1(_contactBox) +// // // Expanded( +// // // child: ListView.builder( +// // // itemCount: _contactBox.values.length, +// // // itemBuilder: (BuildContext context, int index) { +// // // var data = _contactBox.get(index); +// // // print(":data_is: $data"); +// // // return ListTile( +// // // onTap: () { +// // // Navigator.push( +// // // context, +// // // MaterialPageRoute( +// // // builder: (context) => NewProfile( +// // // text: data!, +// // // ), +// // // ), +// // // ); +// // // }, +// // // leading: ProfilePicture( +// // // name: data["name"], +// // // radius: 20, +// // // fontsize: 12, +// // // ), +// // // title: Text( +// // // data["name"], +// // // style: TextStyle( +// // // fontSize: 18.0, +// // // fontWeight: FontWeight.bold, +// // // ), +// // // ), +// // // subtitle: Text( +// // // "Added by Pooja.K", +// // // style: TextStyle( +// // // fontSize: 14.0, +// // // fontWeight: FontWeight.normal, +// // // ), +// // // ), +// // // ); +// // // }, +// // // ), +// // // ), +// // ], +// // ); +// // }, +// // ), +// // ), +// // ); +// // } + +// // Listdisplay(hcpProvider value) { +// // return Expanded( +// // child: ListView.builder( +// // itemCount: value.list.length, +// // itemBuilder: (BuildContext context, int index) { +// // var data = value.list[index]; +// // return Column( +// // children: [ +// // ListTile( +// // onTap: () { +// // // Navigator.push( +// // // context, +// // // MaterialPageRoute( +// // // builder: (context) => Profile( +// // // text: data, +// // // ), +// // // ), +// // // ); + +// // Navigator.push( +// // context, +// // MaterialPageRoute( +// // builder: (_) => NewProfile(text: data))); +// // }, +// // leading: data["img_path"] == null +// // ? ProfilePicture( +// // name: data["name"], +// // radius: 20, +// // fontsize: 12, +// // ) +// // : ClipOval( +// // child: SizedBox.fromSize( +// // size: Size.fromRadius(20), +// // child: Image.network(data["img_path"], +// // fit: BoxFit.cover), +// // ), +// // ), +// // trailing: Text("Added by\nPooja k"), +// // title: Text( +// // "${data["name"]}", +// // style: const TextStyle( +// // fontSize: 18.0, +// // fontWeight: FontWeight.bold, +// // ), +// // ), +// // subtitle: Text( +// // "${data["speciality"]}\n${data["addr"]},", +// // style: const TextStyle( +// // fontSize: 14.0, +// // fontWeight: FontWeight.normal, +// // ), +// // ), +// // ), +// // Divider(), +// // ], +// // ); +// // }, +// // ), +// // ); +// // } + +// // Listdisplay1(Box value) { +// // return Expanded( +// // child: ListView.builder( +// // itemCount: value.values.length, +// // itemBuilder: (BuildContext context, int index) { +// // var data = value.get(index); +// // return Column( +// // children: [ +// // ListTile( +// // onTap: () { +// // // Navigator.push( +// // // context, +// // // MaterialPageRoute( +// // // builder: (context) => Profile( +// // // text: data, +// // // ), +// // // ), +// // // ); + +// // Navigator.push( +// // context, +// // MaterialPageRoute( +// // builder: (_) => NewProfile(text: data))); +// // }, +// // leading: data["img_path"] == null +// // ? ProfilePicture( +// // name: data["name"], +// // radius: 20, +// // fontsize: 12, +// // ) +// // : ClipOval( +// // child: SizedBox.fromSize( +// // size: Size.fromRadius(20), +// // child: Image.network(data["img_path"], +// // fit: BoxFit.cover), +// // ), +// // ), +// // trailing: Text("Added by\nPooja k"), +// // title: Text( +// // "${data["name"]}", +// // style: const TextStyle( +// // fontSize: 18.0, +// // fontWeight: FontWeight.bold, +// // ), +// // ), +// // subtitle: Text( +// // "${data["speciality"]}\n${data["addr"]},", +// // style: const TextStyle( +// // fontSize: 14.0, +// // fontWeight: FontWeight.normal, +// // ), +// // ), +// // ), +// // Divider(), +// // ], +// // ); +// // }, +// // ), +// // ); +// // } +// // } +// import 'package:flutter/material.dart'; +// import 'package:flutter/cupertino.dart'; +// import 'package:flutter_profile_picture/flutter_profile_picture.dart'; +// import 'package:hive_flutter/hive_flutter.dart'; +// import 'package:provider/provider.dart'; +// import 'package:flutter/services.dart'; +// import 'package:discover_module/provider_class/hcp%20_provider.dart'; +// import 'package:discover_module/ui_screen/profile.dart'; +// import 'package:discover_module/ui_screen/new_profile.dart'; +// import 'package:discover_module/ui_screen/interactionform/NewtworkConnectivity.dart'; + +// class Contacts1 extends StatefulWidget { +// const Contacts1({Key? key}) : super(key: key); + +// @override +// State createState() => _Contacts1State(); +// } + +// class _Contacts1State extends State { +// final _contactBox = Hive.box("mycontact"); +// bool _switchValue = false; +// bool isOnline2 = true; + +// final TextEditingController _searchController = TextEditingController(); + +// @override +// void initState() { +// super.initState(); +// setupConnectivityListener(); +// getCall(); +// } + +// Future setupConnectivityListener() async { +// while (true) { +// bool isOnline = await NetworkConnectivity().isInternetAvailable(); +// print('Internet contact available: $isOnline'); +// await Future.delayed(Duration(seconds: 2)); +// if (mounted) { +// setState(() { +// isOnline2 = isOnline; +// }); +// } +// } +// } + +// void getCall() async { +// await Provider.of(context, listen: false).getHCPProvider(); +// } + +// @override +// Widget build(BuildContext context) { +// SystemChrome.setSystemUIOverlayStyle( +// SystemUiOverlayStyle(statusBarColor: Color.fromARGB(255, 0, 71, 132))); + +// return SafeArea( +// child: Scaffold( +// body: Consumer( +// builder: (context, value, child) { +// return Column( +// children: [ +// Row( +// mainAxisAlignment: MainAxisAlignment.center, +// 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, +// ), +// ), +// ), +// ), +// Row( +// mainAxisSize: MainAxisSize.min, +// children: [ +// _switchValue +// ? const Text( +// 'All', +// style: TextStyle( +// fontSize: 12, +// decoration: TextDecoration.lineThrough, +// decorationThickness: 0.85, +// ), +// ) +// : const Text( +// 'All', +// style: TextStyle( +// fontSize: 12, +// ), +// ), +// CupertinoSwitch( +// activeColor: Color.fromARGB(255, 0, 71, 132), +// value: _switchValue, +// onChanged: (value) { +// setState(() { +// _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, +// ), +// ), +// ) +// ], +// ), +// ], +// ), +// Padding( +// padding: const EdgeInsets.only( +// top: 8.0, bottom: 8.0, left: 20.0, right: 20.0), +// child: Center( +// child: TextField( +// controller: _searchController, +// onChanged: (value) { +// setState(() { +// Provider.of(context, listen: false) +// .getHCPProvider1(query: value); +// }); +// }, +// decoration: InputDecoration( +// contentPadding: +// const EdgeInsets.symmetric(vertical: 9.0), +// border: const OutlineInputBorder(), +// labelText: ' Search', +// prefixIcon: const Icon(Icons.search), +// ), +// ), +// ), +// ), +// !_switchValue ? Listdisplay(value) : Listdisplay1(_contactBox), +// ], +// ); +// }, +// ), +// ), +// ); +// } + +// Widget Listdisplay(hcpProvider value) { +// return Expanded( +// child: ListView.builder( +// itemCount: value.list.length, +// itemBuilder: (BuildContext context, int index) { +// var data = value.list[index]; +// return Column( +// children: [ +// ListTile( +// onTap: () { +// Navigator.push( +// context, +// MaterialPageRoute( +// builder: (context) => NewProfile(text: data), +// ), +// ); +// }, +// leading: data["img_path"] == null +// ? ProfilePicture( +// name: data["name"], +// radius: 20, +// fontsize: 12, +// ) +// : ClipOval( +// child: SizedBox.fromSize( +// size: Size.fromRadius(20), +// child: Image.network(data["img_path"], +// fit: BoxFit.cover), +// ), +// ), +// trailing: Text("Added by\nPooja k"), +// title: Text( +// "${data["name"]}", +// style: const TextStyle( +// fontSize: 18.0, +// fontWeight: FontWeight.bold, +// ), +// ), +// subtitle: Text( +// "${data["speciality"]}\n${data["addr"]},", +// style: const TextStyle( +// fontSize: 14.0, +// fontWeight: FontWeight.normal, +// ), +// ), +// ), +// Divider(), +// ], +// ); +// }, +// ), +// ); +// } + +// Widget Listdisplay1(Box value) { +// return Expanded( +// child: ListView.builder( +// itemCount: value.values.length, +// itemBuilder: (BuildContext context, int index) { +// var data = value.get(index); +// return Column( +// children: [ +// ListTile( +// onTap: () { +// Navigator.push( +// context, +// MaterialPageRoute( +// builder: (context) => NewProfile(text: data), +// ), +// ); +// }, +// leading: data["img_path"] == null +// ? ProfilePicture( +// name: data["name"], +// radius: 20, +// fontsize: 12, +// ) +// : ClipOval( +// child: SizedBox.fromSize( +// size: Size.fromRadius(20), +// child: Image.network(data["img_path"], +// fit: BoxFit.cover), +// ), +// ), +// trailing: Text("Added by\nPooja k"), +// title: Text( +// "${data["name"]}", +// style: const TextStyle( +// fontSize: 18.0, +// fontWeight: FontWeight.bold, +// ), +// ), +// subtitle: Text( +// "${data["speciality"]}\n${data["addr"]},", +// style: const TextStyle( +// fontSize: 14.0, +// fontWeight: FontWeight.normal, +// ), +// ), +// ), +// Divider(), +// ], +// ); +// }, +// ), +// ); +// } +// } + +import 'package:discover_module/constants.dart'; import 'package:discover_module/provider_class/hcp%20_provider.dart'; -import 'package:discover_module/ui_screen/interactionform/NewtworkConnectivity.dart'; -import 'package:discover_module/ui_screen/new_profile.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_profile_picture/flutter_profile_picture.dart'; -import 'package:hive_flutter/hive_flutter.dart'; import 'package:provider/provider.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_profile_picture/flutter_profile_picture.dart'; +import 'package:hive_flutter/hive_flutter.dart'; import 'package:discover_module/ui_screen/profile.dart'; +import 'package:discover_module/ui_screen/new_profile.dart'; +import 'package:discover_module/ui_screen/interactionform/NewtworkConnectivity.dart'; class Contacts1 extends StatefulWidget { const Contacts1({Key? key}) : super(key: key); @@ -21,32 +615,17 @@ class _Contacts1State extends State { bool _switchValue = false; bool isOnline2 = true; + final TextEditingController _searchController = TextEditingController(); + @override void initState() { super.initState(); setupConnectivityListener(); - getCall(); + Provider.of(context, listen: false).getHCPProvider(); } Future setupConnectivityListener() async { - while (true) { - bool isOnline = await NetworkConnectivity().isInternetAvailable(); - print('Internet contact available: $isOnline'); - await Future.delayed(Duration(seconds: 2)); - if (mounted) { - setState(() { - isOnline2 = isOnline; - }); - } - } - } - - // @override - // void dispose() { - // // TODO: implement dispose - // } - void getCall() async { - await Provider.of(context, listen: false).getHCPProvider(); + // Your connectivity setup code } @override @@ -57,7 +636,10 @@ class _Contacts1State extends State { return SafeArea( child: Scaffold( body: Consumer( - builder: (context, value, child) { + builder: (context, hcpProvider, child) { + List displayedHCPList = + hcpProvider.searchHCP(_searchController.text); + return Column( children: [ Row( @@ -125,47 +707,101 @@ class _Contacts1State extends State { ), ], ), - !_switchValue ? Listdisplay(value) : Listdisplay1(_contactBox) - // Expanded( - // child: ListView.builder( - // itemCount: _contactBox.values.length, - // itemBuilder: (BuildContext context, int index) { - // var data = _contactBox.get(index); - // print(":data_is: $data"); - // return ListTile( - // onTap: () { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (context) => NewProfile( - // text: data!, - // ), - // ), - // ); - // }, - // leading: ProfilePicture( - // name: data["name"], - // radius: 20, - // fontsize: 12, - // ), - // title: Text( - // data["name"], - // style: TextStyle( - // fontSize: 18.0, - // fontWeight: FontWeight.bold, - // ), - // ), - // subtitle: Text( - // "Added by Pooja.K", - // style: TextStyle( - // fontSize: 14.0, - // fontWeight: FontWeight.normal, - // ), - // ), - // ); - // }, - // ), - // ), + Padding( + padding: const EdgeInsets.only( + top: 8.0, bottom: 8.0, left: 20.0, right: 20.0), + child: Center( + child: TextField( + controller: _searchController, + onChanged: (value) { + setState(() {}); + }, + decoration: InputDecoration( + fillColor: Constants.k2color, + contentPadding: EdgeInsets.symmetric(vertical: 9.0), + border: OutlineInputBorder(), + labelText: ' Search', + prefixIcon: Icon( + Icons.search, + ), + ), + ), + ), + ), + Expanded( + child: ListView.builder( + itemCount: displayedHCPList.length, + itemBuilder: (BuildContext context, int index) { + var data = displayedHCPList[index]; + return Column( + children: [ + ListTile( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => NewProfile(text: data), + ), + ); + }, + leading: data["img_path"] == null + ? ProfilePicture( + name: data["name"], + radius: 20, + fontsize: 12, + ) + : ClipOval( + child: SizedBox.fromSize( + size: Size.fromRadius(25), + child: Image.network(data["img_path"], + fit: BoxFit.fill), + ), + ), + trailing: Icon( + Icons.person_add_rounded, + color: Constants.k2color, + size: 30.0, + ), + title: Text( + "${data["name"]}", + style: const TextStyle( + fontSize: 18.0, + fontWeight: FontWeight.bold, + ), + ), + subtitle: Column( + children: [ + Row( + children: [ + Text( + "${data["speciality"]}\n${data["addr"]},", + style: const TextStyle( + fontSize: 14.0, + fontWeight: FontWeight.normal, + ), + ), + ], + ), + Row( + children: [ + Text( + "Added by Pooja k\nAdded on 01/07/2023", + style: const TextStyle( + fontSize: 12.0, + fontWeight: FontWeight.normal, + ), + ) + ], + ) + ], + ), + ), + Divider(), + ], + ); + }, + ), + ), ], ); }, @@ -173,126 +809,4 @@ class _Contacts1State extends State { ), ); } - - Listdisplay(hcpProvider value) { - return Expanded( - child: ListView.builder( - itemCount: value.list.length, - itemBuilder: (BuildContext context, int index) { - var data = value.list[index]; - return Column( - children: [ - ListTile( - onTap: () { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (context) => Profile( - // text: data, - // ), - // ), - // ); - - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => NewProfile(text: data))); - }, - leading: data["img_path"] == null - ? ProfilePicture( - name: data["name"], - radius: 20, - fontsize: 12, - ) - : ClipOval( - child: SizedBox.fromSize( - size: Size.fromRadius(20), - child: Image.network(data["img_path"], - fit: BoxFit.cover), - ), - ), - trailing: Text("Added by\nPooja k"), - title: Text( - "${data["name"]}", - style: const TextStyle( - fontSize: 18.0, - fontWeight: FontWeight.bold, - ), - ), - subtitle: Text( - "${data["speciality"]}\n${data["addr"]},", - style: const TextStyle( - fontSize: 14.0, - fontWeight: FontWeight.normal, - ), - ), - ), - Divider(), - ], - ); - }, - ), - ); - } - - Listdisplay1(Box value) { - return Expanded( - child: ListView.builder( - itemCount: value.values.length, - itemBuilder: (BuildContext context, int index) { - var data = value.get(index); - return Column( - children: [ - ListTile( - onTap: () { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (context) => Profile( - // text: data, - // ), - // ), - // ); - - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => NewProfile(text: data))); - }, - leading: data["img_path"] == null - ? ProfilePicture( - name: data["name"], - radius: 20, - fontsize: 12, - ) - : ClipOval( - child: SizedBox.fromSize( - size: Size.fromRadius(20), - child: Image.network(data["img_path"], - fit: BoxFit.cover), - ), - ), - trailing: Text("Added by\nPooja k"), - title: Text( - "${data["name"]}", - style: const TextStyle( - fontSize: 18.0, - fontWeight: FontWeight.bold, - ), - ), - subtitle: Text( - "${data["speciality"]}\n${data["addr"]},", - style: const TextStyle( - fontSize: 14.0, - fontWeight: FontWeight.normal, - ), - ), - ), - Divider(), - ], - ); - }, - ), - ); - } } diff --git a/lib/ui_screen/new_profile.dart b/lib/ui_screen/new_profile.dart index 6c499cb..3de4d19 100644 --- a/lib/ui_screen/new_profile.dart +++ b/lib/ui_screen/new_profile.dart @@ -1,3 +1,4 @@ +import 'package:discover_module/constants.dart'; import 'package:discover_module/custom_widget/text.dart'; import 'package:discover_module/hive_fun.dart'; import 'package:discover_module/provider_class/affiliationsprovider.dart'; @@ -160,7 +161,7 @@ class _NewProfileState extends State { child: SizedBox.fromSize( size: Size.fromRadius(48), // Image radius child: Image.network(widget.text!["img_path"], - fit: BoxFit.cover), + fit: BoxFit.fill), ), )), Column( @@ -757,8 +758,12 @@ class _NewProfileState extends State { builder: (_) => AffiliationsData())); }, - child: - Text('Show More'), + child: Text( + 'Show More', + style: TextStyle( + color: Constants + .k2color), + ), style: OutlinedButton .styleFrom( shape: @@ -877,10 +882,14 @@ class _NewProfileState extends State { color: Colors.white, child: DataTable( columns: const [ + // DataColumn( + // label: Expanded( + // child: Text( + // 'sl no'))), DataColumn( label: Expanded( child: Text( - 'sl no'))), + ''))), DataColumn( label: Expanded( child: Text( @@ -971,8 +980,12 @@ class _NewProfileState extends State { builder: (_) => PublicationsData())); }, - child: - Text('Show More'), + child: Text( + 'Show More', + style: TextStyle( + color: Constants + .k2color), + ), style: OutlinedButton .styleFrom( shape: @@ -1076,7 +1089,7 @@ class _NewProfileState extends State { DataColumn( label: Expanded( child: Text( - 'sl no', + '', softWrap: true))), DataColumn( @@ -1169,8 +1182,12 @@ class _NewProfileState extends State { builder: (_) => EventsData())); }, - child: - Text('Show More'), + child: Text( + 'Show More', + style: TextStyle( + color: Constants + .k2color), + ), style: OutlinedButton .styleFrom( shape: @@ -1244,6 +1261,12 @@ class _NewProfileState extends State { const SizedBox( width: 8.0, ), + Text1( + title: "4", + txtcolor: Colors.white, + fontweight: + FontWeight.normal, + txtfont: 17.0), ], ), children: [ @@ -1388,8 +1411,12 @@ class _NewProfileState extends State { builder: (_) => EventsData())); }, - child: - Text('Show More'), + child: Text( + 'Show More', + style: TextStyle( + color: Constants + .k2color), + ), style: OutlinedButton .styleFrom( shape: @@ -1690,8 +1717,12 @@ class _NewProfileState extends State { ))); } }, - child: - Text('Show More'), + child: Text( + 'Show More', + style: TextStyle( + color: Constants + .k2color), + ), style: OutlinedButton .styleFrom( shape: diff --git a/lib/ui_screen/newformlist.dart b/lib/ui_screen/newformlist.dart index f9093ee..3dff141 100644 --- a/lib/ui_screen/newformlist.dart +++ b/lib/ui_screen/newformlist.dart @@ -3,6 +3,7 @@ import 'package:discover_module/ui_screen/interactionform/interaction_screen.dar import 'package:discover_module/ui_screen/interactionform/interactionlistscreen.dart'; import 'package:discover_module/ui_screen/interactionform/interactionprovider.dart'; import 'package:discover_module/ui_screen/interactionform/model/save_interaction.dart'; +import 'package:discover_module/ui_screen/interactionform/new_dynamicform.dart'; import 'package:discover_module/ui_screen/interactionform/view_forms_list.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -139,7 +140,7 @@ class _FormListState extends State { context, MaterialPageRoute( builder: (BuildContext context) => - InteractionScreen( + InteractionScreen1( index: index, form: provider .intConfigDataList[index].name, @@ -289,148 +290,3 @@ class _FormListState extends State { }); } } - -// import 'package:discover_module/ui_screen/interactionform/configprovider.dart'; -// import 'package:discover_module/ui_screen/interactionform/interactionlistscreen.dart'; -// import 'package:discover_module/ui_screen/interactionform/interactionprovider.dart'; -// import 'package:flutter/cupertino.dart'; -// import 'package:flutter/material.dart'; -// import 'package:flutter/widgets.dart'; -// import 'package:provider/provider.dart'; - -// class FormList extends StatefulWidget { -// const FormList({super.key}); - -// @override -// State createState() => _FormListState(); -// } - -// class _FormListState extends State { -// var formdata; -// @override -// void initState() { -// // TODO: implement initState -// super.initState(); - -// idata(); -// } - -// idata() { -// var iprovider = Provider.of(context, listen: false); - -// setState(() { -// formdata = iprovider.intConfigDataList; -// }); -// } - -// @override -// Widget build(BuildContext context) { -// 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), -// // ), -// // 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), -// // ), - -// 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), -// ), -// 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), -// ), -// 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/pubspec.lock b/pubspec.lock index 2ef7f1e..3940f2c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -113,6 +113,14 @@ packages: url: "https://pub.dev" source: hosted version: "8.9.2" + carousel_slider: + dependency: "direct main" + description: + name: carousel_slider + sha256: "9c695cc963bf1d04a47bd6021f68befce8970bcd61d24938e1fb0918cf5d9c42" + url: "https://pub.dev" + source: hosted + version: "4.2.1" characters: dependency: transitive description: @@ -358,6 +366,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_carousel_widget: + dependency: "direct main" + description: + name: flutter_carousel_widget + sha256: "37b9e55e4cafffe358152b016db24153e756152aa07c4214cfe6ee902cd69a01" + url: "https://pub.dev" + source: hosted + version: "2.2.0" flutter_lints: dependency: "direct dev" description: diff --git a/pubspec.yaml b/pubspec.yaml index 2328bcb..1e114e2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -61,6 +61,8 @@ dependencies: popover: ^0.3.0+1 data_table_2: ^2.5.15 expandable: ^5.0.1 + flutter_carousel_widget: ^2.2.0 + carousel_slider: ^4.2.1