From c6ade88f27c59b646ebf1a58d09ba23ebd8ac516 Mon Sep 17 00:00:00 2001 From: poojakhatawate Date: Mon, 24 Jun 2024 17:06:09 +0530 Subject: [PATCH] validation_isrequired --- lib/main.dart | 1 + lib/ui_screen/contacts.dart | 3 + .../edit_interaction_screen.dart | 426 ++++--- .../interactionform/interaction_screen.dart | 1076 ++++++++--------- .../interactionform/interactionprovider.dart | 36 +- .../model/interaction_data.dart | 4 +- .../model/interaction_data.g.dart | 2 +- .../view_interaction_screen.dart | 34 +- .../viewinteractionprovider.dart | 24 +- pubspec.lock | 8 + pubspec.yaml | 1 + 11 files changed, 761 insertions(+), 854 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 5994f0a..edd195e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -73,6 +73,7 @@ class MyApp extends StatefulWidget { class _MyAppState extends State { // This widget is the root of your application. + @override Widget build(BuildContext context) { return MaterialApp( diff --git a/lib/ui_screen/contacts.dart b/lib/ui_screen/contacts.dart index 343784b..2e3fc62 100644 --- a/lib/ui_screen/contacts.dart +++ b/lib/ui_screen/contacts.dart @@ -2,6 +2,7 @@ import 'package:discover_module/ui_screen/profile.dart'; import 'package:discover_module/ui_screen/ranking.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_profile_picture/flutter_profile_picture.dart'; import 'package:hive_flutter/hive_flutter.dart'; @@ -23,6 +24,8 @@ class _ContactsState extends State { @override Widget build(BuildContext context) { + SystemChrome.setSystemUIOverlayStyle( + SystemUiOverlayStyle(statusBarColor: Color.fromARGB(255, 0, 71, 132))); print( "newdata_is: ${_contactbox.values.toList()},${_contactbox.values.toList().length}"); diff --git a/lib/ui_screen/interactionform/edit_interaction_screen.dart b/lib/ui_screen/interactionform/edit_interaction_screen.dart index 6626c05..af9e61b 100644 --- a/lib/ui_screen/interactionform/edit_interaction_screen.dart +++ b/lib/ui_screen/interactionform/edit_interaction_screen.dart @@ -11,6 +11,7 @@ import 'package:discover_module/ui_screen/interactionform/widget/custombutton.da import 'package:discover_module/ui_screen/interactionform/widget/customrangeslider.dart'; import 'package:discover_module/ui_screen/interactionform/widget/interatciontextfield.dart'; import 'package:discover_module/ui_screen/interactionform/widget/responsive_ext.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:intl/intl.dart'; @@ -312,16 +313,31 @@ class _EditInteractionScreenState extends State { .only( left: 8.0, right: 8.0), + // child: Text( + // '${sectionItem.name}:*', + // style: TextStyle( + // color: Colors + // .orange + // .shade800, + // fontSize: + // isTablet + // ? 18 + // : 12, + // ), + // ), child: Text( - '${sectionItem.name}:*', + sectionItem + .isRequired + ? '${sectionItem.name}:*' + : '${sectionItem.name}:', style: TextStyle( color: Colors .orange .shade800, - fontSize: - isTablet - ? 18 - : 12, + fontSize: 18.0, + // fontSize: isTablet + // ? 18 + // : 12, ), ), ), @@ -518,7 +534,10 @@ class _EditInteractionScreenState extends State { ), ); case InteractionWidget.DROPDOWN: - return customdropdown(sectionItem, provider, list, multiple); + // return customdropdown(sectionItem, provider, list, multiple); + + return customAutoCompletedropdown( + sectionItem, provider, list, multiple); } } @@ -1212,204 +1231,143 @@ class _EditInteractionScreenState extends State { } print("ConvertedArrayEditMulti.leangth: $convertedArray"); print("ConvertedArray.leangth: ${convertedArray.length}"); - return DecoratedBox( - decoration: BoxDecoration( - border: Border.all(color: Colors.black), - borderRadius: BorderRadius.circular(10.0), - ), - child: Padding( - padding: isTablet - ? const EdgeInsets.only(left: 14.0) - : const EdgeInsets.only(left: 12.0, right: 12.0), - child: Column( - children: [ - for (var i = 0; i < convertedArray.length; i++) - GridView.builder( - physics: const NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - // crossAxisCount: context.responsive( - // 1, // default - // sm: 1, // small - // md: 1, // medium - // lg: sectionList.length == 1 ? 1 : 4, // large - // xl: 5, // extra large screen - // ), - crossAxisCount: context.responsive( - 1, - sm: 1, // small - md: 2, // medium - lg: sectionList.length == 1 - ? 1 - : (sectionList.length >= 1 ? 3 : 3), // large - xl: 3, // extra large screen - ), - mainAxisSpacing: - sectionList.length == 1 || !isTablet ? 1 : 2, - // childAspectRatio: isTablet - // ? MediaQuery.of(context).size.width / - // (MediaQuery.of(context).size.height * 0.3) - // : MediaQuery.of(context).size.width / - // (MediaQuery.of(context).size.height * 0.1), - // childAspectRatio: isTablet - // ? MediaQuery.of(context).size.width / - // (MediaQuery.of(context).size.height / 3) - // : MediaQuery.of(context).size.width / - // (MediaQuery.of(context).size.height * 0.2), + return Padding( + padding: isTablet + ? const EdgeInsets.only(left: 0.0) + : const EdgeInsets.only(left: 12.0, right: 12.0), + child: Column( + children: [ + for (var i = 0; i < convertedArray.length; i++) + DecoratedBox( + decoration: BoxDecoration( + color: i % 2 == 0 + ? Color.fromARGB(133, 213, 241, 254) + : Colors.white, + ), + child: Wrap( + children: [ + GestureDetector(child: Text("data")), + GridView.builder( + physics: const NeverScrollableScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: context.responsive( + 1, + sm: 1, // small + md: 2, // medium + lg: sectionList.length == 1 + ? 1 + : (sectionList.length >= 1 ? 3 : 3), // large + xl: 3, // extra large screen + ), + mainAxisSpacing: + sectionList.length == 1 || !isTablet ? 1 : 2, + childAspectRatio: sectionList.length == 1 + ? orientation == Orientation.landscape + ? 10 + : 4.8 + : isTablet + ? 2.8 + : 3.0, + ), + 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) + : []; - childAspectRatio: sectionList.length == 1 - ? orientation == Orientation.landscape - ? 10 - : 4.8 - : isTablet - ? 2.8 - : 3.0, - // mainAxisSpacing: - // sectionList.length == 1 || !isTablet ? 1 : 3.5, - // childAspectRatio: sectionList.length == 1 - // ? orientation == Orientation.landscape - // ? 10 - // : 4.8 - // : isTablet - // ? 2.8 - // : 3.0, - ), - shrinkWrap: true, - padding: EdgeInsets.zero, - - // childAspectRatio: sectionList.length == 1 || !isTablet - // ? orientation == Orientation.landscape - // ? 10 - // : 4.2 - // : 1.8, - - itemCount: convertedArray[i].length, - itemBuilder: (context, index) { - // children: List.generate( - // sectionList.length, - // (i) { - // // print(sectionList); - // SectionList sectionItem = sectionList[i]; - // dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN - // ? sectionItem.value ?? "Select" - // : ' '; - // List list = - // sectionItem.widget == InteractionWidget.DROPDOWN || - // sectionItem.widget == InteractionWidget.AUTOCOMPLETE || - // sectionItem.widget == InteractionWidget.MULTISELECT - // ? provider.getData2(sectionItem) - // : []; - // provider.checkboxlist = - // sectionItem.widget == InteractionWidget.CHECKBOX - // ? provider.getData2(sectionItem) - // : []; - SectionList sectionItem = convertedArray[i][index]; - dropdownvalue = - sectionItem.widget == InteractionWidget.DROPDOWN - ? sectionItem.value ?? "Select" - : ' '; - List list = sectionItem.widget == - InteractionWidget.DROPDOWN || - sectionItem.widget == - InteractionWidget.AUTOCOMPLETE || - sectionItem.widget == InteractionWidget.MULTISELECT - ? provider.getData2(sectionItem) - : []; - provider.checkboxlist = - sectionItem.widget == InteractionWidget.CHECKBOX - ? provider.getData2(sectionItem) - : []; - return SizedBox( - height: MediaQuery.of(context).size.height, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - sectionItem.widget == InteractionWidget.BUTTON && - sectionItem.param == 'add' || - sectionItem.param == 'deletebtn' - ? const SizedBox.shrink() - : Padding( - padding: const EdgeInsets.only( - left: 8.0, right: 8.0), - child: Text( - '${sectionItem.name}:*', - style: TextStyle( - color: Colors.orange.shade800, - fontSize: isTablet ? 18 : 14, - ), - ), - ), - const SizedBox( - height: 15, - ), - sectionItem.widget == InteractionWidget.BUTTON - ? sectionItem.input == 'chooseFile' - ? Row( - children: [ - CustomButton( - backgroundColor: - const Color.fromARGB( - 255, 233, 229, 229), - onPressed: () async { - if (sectionItem - .selectedValue!.isNotEmpty) { - showFilesAlertDialog( - context, - sectionItem.fileName! - .join(','), - sectionItem); - } else { - sectionItem.selectedValue = []; - sectionItem.extension = []; - sectionItem.fileName = []; - await getEncodedFile( - sectionItem); - } - setState(() {}); - }, - width: 120, - height: 40, - fontsize: 12, - textColor: Colors.black, - title: sectionItem.name), - const SizedBox( - width: 5, + return SizedBox( + height: MediaQuery.of(context).size.height, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + sectionItem.widget == InteractionWidget.BUTTON && + sectionItem.param == 'add' || + sectionItem.param == 'deletebtn' + ? const SizedBox.shrink() + : Padding( + padding: const EdgeInsets.only( + left: 8.0, right: 8.0), + child: Text( + sectionItem.isRequired + ? '${sectionItem.name}:*' + : '${sectionItem.name}:', + style: TextStyle( + color: Colors.orange.shade800, + fontSize: 18.0, + // fontSize: isTablet + // ? 18 + // : 12, ), - Text( - sectionItem.selectedValue!.isNotEmpty - ? 'File uploaded' - : 'No file uploaded', - style: TextStyle( - color: sectionItem + )), + const SizedBox( + height: 15, + ), + sectionItem.widget == InteractionWidget.BUTTON + ? sectionItem.input == 'chooseFile' + ? Row( + children: [ + CustomButton( + backgroundColor: + const Color.fromARGB( + 255, 233, 229, 229), + onPressed: () async { + if (sectionItem.selectedValue! + .isNotEmpty) { + showFilesAlertDialog( + context, + sectionItem.fileName! + .join(','), + sectionItem); + } else { + sectionItem.selectedValue = + []; + sectionItem.extension = []; + sectionItem.fileName = []; + await getEncodedFile( + sectionItem); + } + setState(() {}); + }, + width: 120, + height: 40, + fontsize: 12, + textColor: Colors.black, + title: sectionItem.name), + const SizedBox( + width: 5, + ), + Text( + sectionItem .selectedValue!.isNotEmpty - ? 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), - ), + ? 'File uploaded' + : 'No file uploaded', + style: TextStyle( + color: sectionItem + .selectedValue! + .isNotEmpty + ? Colors.green + : Colors.red), + ), + ], ) - : Padding( - padding: const EdgeInsets.only( - left: 3.0, top: 5), - child: CustomButton( - backgroundColor: - const Color.fromARGB( - 255, 233, 75, 75), + : isTablet + ? IconButton( onPressed: () { provider.deleteMultipleRows( sectionItem.gid!, @@ -1418,28 +1376,52 @@ class _EditInteractionScreenState extends State { setState(() {}); }, - // width: 80, - // height: 30, - height: 40, - fontsize: 12, - textColor: Colors.white, - title: "Delete"), - ) - : returnWidget( - sectionItem: sectionItem, - item: item, - provider: provider, - list: list, - gridIndex: i, - listIndex: listIndex, - widgetData: sectionItem.widget!, - multiple: true), - ], - ), - ); - }), - ], - ), + icon: const Icon( + Icons.cancel, + size: 30, + color: Color.fromARGB( + 255, 8, 39, 92), + ), + ) + : Padding( + padding: const EdgeInsets.only( + left: 3.0, top: 5), + child: CustomButton( + backgroundColor: + const Color.fromARGB( + 255, 233, 75, 75), + onPressed: () { + provider.deleteMultipleRows( + sectionItem.gid!, + sectionList[i], + sectionName); + + setState(() {}); + }, + // width: 80, + // height: 30, + height: 40, + fontsize: 12, + textColor: Colors.white, + title: "Delete"), + ) + : returnWidget( + sectionItem: sectionItem, + item: item, + provider: provider, + list: list, + gridIndex: i, + listIndex: listIndex, + widgetData: sectionItem.widget!, + multiple: true), + ], + ), + ); + }), + ], + ), + ), + ], ), ); } diff --git a/lib/ui_screen/interactionform/interaction_screen.dart b/lib/ui_screen/interactionform/interaction_screen.dart index a2aac49..84662c8 100644 --- a/lib/ui_screen/interactionform/interaction_screen.dart +++ b/lib/ui_screen/interactionform/interaction_screen.dart @@ -1,8 +1,10 @@ import 'dart:convert'; import 'dart:io'; +import 'dart:js_interop'; // import 'dart:js_util'; import 'package:discover_module/constants.dart'; +import 'package:discover_module/custom_widget/floating_btn.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'; @@ -13,10 +15,12 @@ import 'package:discover_module/ui_screen/interactionform/widget/interatciontext 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'; @@ -25,6 +29,8 @@ import 'package:file_picker/file_picker.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:path/path.dart' as p; +// import 'package:popover/popover.dart'; + class InteractionScreen extends StatefulWidget { int index; String form; @@ -71,334 +77,407 @@ class _InteractionScreenState extends State { 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, - ), + //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), ), ), - body: Column( - children: [ - Expanded( - child: ListView.builder( - itemCount: provider.interactionReponseList.length, - padding: EdgeInsets.zero, - cacheExtent: double.parse( - provider.interactionReponseList.length.toString()), - itemBuilder: (context, index) { - var item = provider.interactionReponseList[index]; - sectionList = item.sectionList; - return ExpansionTile( - maintainState: true, - // backgroundColor: Colors.white, - // collapsedBackgroundColor: Color(0xFF2b9af3), - initiallyExpanded: true, - title: Stack( - alignment: AlignmentDirectional.center, - children: [ - Container( - // height: double.infinity, - width: double.infinity, - padding: const EdgeInsets.all(8.0), - decoration: BoxDecoration( - // color: Color(0xFF2b9af3), - color: Constants.k2color, + // backgroundColor: const Color(0xFF2b9af3), + automaticallyImplyLeading: false, + actions: [saveActions(provider)], + leading: InkWell( + onTap: () { + Navigator.pop(context); + }, + child: const Icon( + Icons.arrow_back_ios, + color: Colors.white, + ), + ), + ), + body: Column( + children: [ + Expanded( + child: ListView.builder( + itemCount: provider.interactionReponseList.length, + padding: EdgeInsets.zero, + cacheExtent: double.parse( + provider.interactionReponseList.length.toString()), + itemBuilder: (context, index) { + var item = provider.interactionReponseList[index]; + sectionList = item.sectionList; + return ExpansionTile( + maintainState: true, + // backgroundColor: Colors.white, + // collapsedBackgroundColor: Color(0xFF2b9af3), + initiallyExpanded: true, + title: Stack( + alignment: AlignmentDirectional.center, + children: [ + Container( + // height: double.infinity, + width: double.infinity, + padding: const EdgeInsets.all(8.0), + decoration: BoxDecoration( + // color: Color(0xFF2b9af3), + color: Constants.k2color, + ), + child: Text( + item.sectionName, + style: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + // fontSize: isTablet ? 18 : 14 ), - child: Text( - item.sectionName, - style: const TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - // fontSize: isTablet ? 18 : 14 - ), - )), - item.multiple - ? Align( - alignment: Alignment.centerRight, - child: IconButton( - onPressed: () { - if (item.sectionName == "HCP") { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - Addhcp())); + )), + item.multiple + ? Align( + alignment: Alignment.centerRight, + child: IconButton( + onPressed: () { + if (item.sectionName == "HCP") { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + Addhcp())); - provider.getSectionItem( - item.sectionName, - ); - // print("index is $listIndex"); - setState(() { - // for (var item - }); - } else { - provider.getSectionItem( - item.sectionName, - ); - // print("index is $listIndex"); - setState(() {}); - } - }, - icon: const Icon( - Icons.add_circle_outline, - size: 30, - color: Colors.white, - ), + provider.getSectionItem( + item.sectionName, + ); + // print("index is $listIndex"); + setState(() { + // for (var item + }); + } else { + provider.getSectionItem( + item.sectionName, + ); + // print("index is $listIndex"); + setState(() {}); + } + }, + icon: const Icon( + Icons.add_circle_outline, + size: 30, + color: Colors.white, ), - ) - : const SizedBox.shrink() - ]), - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Padding( - padding: isTablet - ? const EdgeInsets.only(left: 14.0) - : const EdgeInsets.only( - left: 12.0, right: 12.0), - child: GridView.count( - physics: - const NeverScrollableScrollPhysics(), - // crossAxisCount: - // context.responsive( - // 1, - // sm: 1, // small - // md: 1, // medium - // lg: sectionList.length == 1 - // ? 1 - // : 3, // large - // xl: 3, // extra large screen - // ), - - 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 ), + ) + : const SizedBox.shrink() + ]), + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: isTablet + ? const EdgeInsets.only(left: 14.0) + : const EdgeInsets.only( + left: 12.0, right: 12.0), + child: GridView.count( + physics: + const NeverScrollableScrollPhysics(), + // crossAxisCount: + // context.responsive( + // 1, + // sm: 1, // small + // md: 1, // medium + // lg: sectionList.length == 1 + // ? 1 + // : 3, // large + // xl: 3, // extra large screen + // ), - // crossAxisCount: - // orientation == Orientation.portrait - // ? 1 - // : 3, - // crossAxisCount: (MediaQuery.of(context) - // .orientation == - // Orientation.landscape) - // ? 3 - // : 1, + 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: MediaQuery.of(context) - // .size - // .aspectRatio * - // 0.10, - // childAspectRatio: - // sectionList.length == 1 - // ? orientation == - // Orientation.landscape - // ? 10 - // : 3.8 - // : 2.4, - // childAspectRatio: - // sectionList.length == 1 - // ? orientation == - // Orientation.landscape - // ? 10 - // : 3.8 - // : isTablet - // ? 2.8 - // : 3.8, + // crossAxisCount: + // orientation == Orientation.portrait + // ? 1 + // : 3, + // crossAxisCount: (MediaQuery.of(context) + // .orientation == + // Orientation.landscape) + // ? 3 + // : 1, - childAspectRatio: - sectionList.length == 1 - ? orientation == - Orientation.landscape - ? 10 - : 4.8 - : isTablet - ? 2.8 - : 3.0, - // /:2.4, - // childAspectRatio: 3.8, + mainAxisSpacing: + sectionList.length == 1 || !isTablet + ? 1 + : 3.5, + // mainAxisSpacing: + // orientation == Orientation.portrait + // ? 1 + // : 3, + shrinkWrap: true, + padding: EdgeInsets.zero, + // childAspectRatio: MediaQuery.of(context) + // .size + // .aspectRatio * + // 0.10, + // childAspectRatio: + // sectionList.length == 1 + // ? orientation == + // Orientation.landscape + // ? 10 + // : 3.8 + // : 2.4, + // childAspectRatio: + // sectionList.length == 1 + // ? orientation == + // Orientation.landscape + // ? 10 + // : 3.8 + // : isTablet + // ? 2.8 + // : 3.8, - children: List.generate( - sectionList.length, - (i) { - SectionList sectionItem = - sectionList[i]; - dropdownvalue = sectionItem - .widget == - InteractionWidget.DROPDOWN - ? sectionItem.value ?? - "Select" - : ' '; - List< - 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) - : []; + childAspectRatio: + sectionList.length == 1 + ? orientation == + Orientation.landscape + ? 10 + : 4.8 + : isTablet + ? 2.8 + : 3.0, + // /:2.4, + // childAspectRatio: 3.8, - return Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - sectionItem.widget == - InteractionWidget - .BUTTON && - sectionItem.input == - 'add' - ? const SizedBox.shrink() - : Padding( - padding: - const EdgeInsets - .only( - left: 8.0, - right: 8.0), - child: FittedBox( - fit: BoxFit - .scaleDown, - child: Text( - sectionItem - .validation! - .isRequired - ? '${sectionItem.name}:*' - : '${sectionItem.name}:', - style: TextStyle( - color: Colors - .orange - .shade800, - fontSize: 18.0, - // fontSize: isTablet - // ? 18 - // : 12, - ), + children: List.generate( + sectionList.length, + (i) { + SectionList sectionItem = + sectionList[i]; + dropdownvalue = sectionItem + .widget == + InteractionWidget.DROPDOWN + ? sectionItem.value ?? "Select" + : ' '; + List list = sectionItem + .widget == + InteractionWidget + .DROPDOWN || + sectionItem.widget == + InteractionWidget + .AUTOCOMPLETE || + sectionItem.widget == + InteractionWidget + .MULTISELECT + ? provider.getData2(sectionItem) + : []; + provider.checkboxlist = sectionItem + .widget == + InteractionWidget.CHECKBOX + ? provider.getData2(sectionItem) + : []; + + return Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + sectionItem.widget == + InteractionWidget + .BUTTON && + sectionItem.input == + 'add' + ? const SizedBox.shrink() + : Padding( + padding: + const EdgeInsets + .only( + left: 8.0, + right: 8.0), + child: FittedBox( + fit: BoxFit.scaleDown, + child: Text( + sectionItem + .validation! + .isRequired + ? '${sectionItem.name}:*' + : '${sectionItem.name}:', + style: TextStyle( + color: Colors + .orange + .shade800, + fontSize: 18.0, + // fontSize: isTablet + // ? 18 + // : 12, ), ), ), - // SizedBox( - // height: isTablet ? 15 : 5, - // ), - returnWidget( - sectionItem: sectionItem, - item: item, - provider: provider, - list: list, - gridIndex: i, - listIndex: index, - widgetData: - sectionItem.widget!, - multiple: false), - // SizedBox( - // height: isTablet ? 15 : 5, - // ), + ), + // SizedBox( + // height: isTablet ? 15 : 5, + // ), + returnWidget( + sectionItem: sectionItem, + item: item, + provider: provider, + list: list, + gridIndex: i, + listIndex: index, + widgetData: + sectionItem.widget!, + multiple: false), + // SizedBox( + // height: isTablet ? 15 : 5, + // ), - // sectionItem.depid == 'pooja' - // ? Text( - // sectionItem.validation! - // .isRequired - // ? '${sectionItem.depid}:*' - // : '${sectionItem.depid}:', - // style: TextStyle( - // color: Colors - // .orange.shade800, - // fontSize: isTablet - // ? 18 - // : 12, - // ), - // ) - // : const SizedBox.shrink(), - ], - ); - }, - ), + // sectionItem.depid == 'pooja' + // ? Text( + // sectionItem.validation! + // .isRequired + // ? '${sectionItem.depid}:*' + // : '${sectionItem.depid}:', + // style: TextStyle( + // color: Colors + // .orange.shade800, + // fontSize: isTablet + // ? 18 + // : 12, + // ), + // ) + // : const SizedBox.shrink(), + ], + ); + }, ), ), - // SizedBox( - // height: isTablet ? 15 : 5, - // ), - item.multiple - ? gridViewWidget( - provider, - item.sectionName, - item.multipleList ?? [], - orientation, - item, - index) - : const SizedBox.shrink(), - provider.interactionReponseList.length == - index - 1 - ? saveActions(provider) - : const SizedBox.shrink() - //const Spacer(), - ], - ), + ), + // SizedBox( + // height: isTablet ? 15 : 5, + // ), + item.multiple + ? gridViewWidget( + provider, + item.sectionName, + item.multipleList ?? [], + orientation, + item, + index) + : const SizedBox.shrink(), + provider.interactionReponseList.length == + index - 1 + ? saveActions(provider) + : const SizedBox.shrink() + //const Spacer(), + ], ), - ]); - }, - ), + ), + ]); + }, ), - // const Spacer(), - // saveActions(provider), - ], - )), + ), + // const Spacer(), + // saveActions(provider), + Align( + alignment: Alignment.bottomRight, + child: Container( + height: 80.0, + width: 80.0, + child: _offsetPopup(provider.interactionReponseList))) + ], + ), + // floatingActionButton: FloatingBtn( + // title: "data", + // icon: Icons.add, + // onTap: () { + // showPopover( + // context: context, + // bodyBuilder: (context) { + // return Padding( + // padding: const EdgeInsets.symmetric(vertical: 8), + // child: ListView( + // padding: const EdgeInsets.all(8), + // children: [ + // InkWell( + // onTap: () { + + // }, + // child: Container( + // height: 50, + // color: Colors.amber[100], + // child: const Center(child: Text('Entry A')), + // ), + // ), + // const Divider(), + // Container( + // height: 50, + // color: Colors.amber[200], + // child: const Center(child: Text('Entry B')), + // ), + // const Divider(), + // Container( + // height: 50, + // color: Colors.amber[300], + // child: const Center(child: Text('Entry C')), + // ), + // const Divider(), + // Container( + // height: 50, + // color: Colors.amber[400], + // child: const Center(child: Text('Entry D')), + // ), + // const Divider(), + // Container( + // height: 50, + // color: Colors.amber[500], + // child: const Center(child: Text('Entry E')), + // ), + // const Divider(), + // Container( + // height: 50, + // color: Colors.amber[600], + // child: const Center(child: Text('Entry F')), + // ), + // ], + // ), + // ); + // }, + // ); + + // var itemsectionname = + // provider.interactionReponseList.length; + + // print("ItemSectionname: $itemsectionname"); + + // for (int i = 0; i < itemsectionname; i++) { + // var item = provider.interactionReponseList[i]; + + // print( + // "Check_ProviderNameL ${item.sectionName}, ${item.multiple}"); + // } + + // // provider.getSectionItem( + // // item.sectionName, + // // ); + // }, + // ) + ), ); }), ); @@ -549,7 +628,10 @@ class _InteractionScreenState extends State { ), ); case InteractionWidget.DROPDOWN: - return customdropdown(sectionItem, provider, list, multiple); + // return customdropdown(sectionItem, provider, list, multiple); + + return customAutoCompletedropdown( + sectionItem, provider, list, multiple); } } @@ -1125,200 +1207,6 @@ class _InteractionScreenState extends State { ); } - // Widget gridViewWidget( - // InteractionProvider provider, - // String sectionName, - // List sectionList, - // Orientation orientation, - // FormFieldData item, - // int listIndex) { - // print("ListInex: $listIndex"); - // print("sectionName: $sectionName"); - // print("sectionName: $sectionName"); - - // print("gridsectionlost_is: $sectionList"); - // print("gridsectionlostleangth_is: ${sectionList.length}"); - - // List pooja = sectionList; - - // print("Pooja_isss: $pooja"); - - // return Padding( - // padding: isTablet - // ? const EdgeInsets.only(left: 8.0) - // : const EdgeInsets.only(left: 12.0, right: 12.0), - // child: GridView.count( - // physics: const NeverScrollableScrollPhysics(), - // // crossAxisCount: context.responsive( - // // 1, // default - // // sm: 1, // small - // // md: 1, // medium - // // lg: sectionList.length == 1 ? 1 : 4, // large - // // xl: 5, // extra large screen - // // ), - // crossAxisCount: context.responsive( - // 1, - // sm: 1, // small - // md: 1, // medium - // lg: sectionList.length == 1 - // ? 1 - // : (sectionList.length >= 1 ? 3 : 3), // large - // xl: 3, // extra large screen - // ), - // mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 2, - // shrinkWrap: true, - // padding: EdgeInsets.zero, - // // childAspectRatio: sectionList.length == 1 || !isTablet - // // ? orientation == Orientation.landscape - // // ? 10 - // // : 4.2 - // // : 1.8, - // // childAspectRatio: sectionList.length == 1 - // // ? orientation == Orientation.landscape - // // ? 10 - // // : 4.8 - // // : isTablet - // // ? 2.8 - // // : 3.0, - // childAspectRatio: MediaQuery.of(context).size.width / - // (MediaQuery.of(context).size.height / 3), - // children: List.generate( - // sectionList.length, - // (i) { - // print(sectionList); - // SectionList sectionItem = sectionList[i]; - // dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN - // ? sectionItem.value ?? "Select" - // : ' '; - // List list = - // sectionItem.widget == InteractionWidget.DROPDOWN || - // sectionItem.widget == InteractionWidget.AUTOCOMPLETE || - // sectionItem.widget == InteractionWidget.MULTISELECT - // ? provider.getData2(sectionItem) - // : []; - // provider.checkboxlist = - // sectionItem.widget == InteractionWidget.CHECKBOX - // ? provider.getData2(sectionItem) - // : []; - - // return Wrap(children: [ - // Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // sectionItem.widget == InteractionWidget.BUTTON && - // sectionItem.input == 'add' || - // sectionItem.input == 'deletebtn' - // ? const SizedBox.shrink() - // : Text( - // '${sectionItem.name}:*', - // style: TextStyle( - // color: Colors.orange.shade800, - // fontSize: isTablet ? 18 : 14, - // ), - // ), - // // const SizedBox( - // // height: 15, - // // ), - // sectionItem.widget == InteractionWidget.BUTTON - // ? sectionItem.input == 'chooseFile' - // ? Row( - // children: [ - // CustomButton( - // backgroundColor: const Color.fromARGB( - // 255, 233, 229, 229), - // onPressed: () async { - // sectionItem.selectedValue = []; - // sectionItem.extension = []; - // sectionItem.fileName = []; - // await getEncodedFile(sectionItem); - - // setState(() {}); - // }, - // width: 120, - // height: 40, - // fontsize: 12, - // textColor: Colors.black, - // title: sectionItem.name), - // const SizedBox( - // width: 5, - // ), - // Text( - // sectionItem.selectedValue!.isNotEmpty - // ? sectionItem.selectedValue!.isNotEmpty - // ? 'File uploaded' - // : "Files Uploaded" - // : 'No file uploaded', - // style: TextStyle( - // color: - // sectionItem.selectedValue!.isNotEmpty - // ? Colors.green - // : Colors.red), - // ), - // ], - // ) - // : isTablet - // ? IconButton( - // onPressed: () { - // provider.deleteMultipleRows( - // sectionItem.gid!, - // sectionList[i], - // sectionName); - - // setState(() {}); - // }, - // icon: const Icon( - // Icons.cancel, - // size: 30, - // color: Color.fromARGB(255, 8, 39, 92), - // ), - // ) - // : Padding( - // padding: - // const EdgeInsets.only(left: 3.0, top: 5), - // child: CustomButton( - // backgroundColor: const Color.fromARGB( - // 255, 233, 75, 75), - // onPressed: () { - // provider.deleteMultipleRows( - // sectionItem.gid!, - // sectionList[i], - // sectionName); - - // setState(() {}); - // }, - // // width: 80, - // // height: 30, - - // height: 40, - - // // height: - // // MediaQuery.of(context).size.height * - // // 0.2, - // fontsize: 12, - // textColor: Colors.white, - // title: "Delete"), - // ) - // : returnWidget( - // sectionItem: sectionItem, - // item: item, - // provider: provider, - // list: list, - // gridIndex: i, - // listIndex: listIndex, - // widgetData: sectionItem.widget!, - // multiple: true), - // ], - // ), - // ]); - // }, - // ), - // ), - // ); - // } -//////////////////////////////////////Poojaaaa///////////////////// - /// - /// - Widget gridViewWidget( InteractionProvider provider, String sectionName, @@ -1357,46 +1245,24 @@ class _InteractionScreenState extends State { print("ConvertedArray.leangth: $convertedArray"); print("ConvertedArray.leangth: ${convertedArray.length}"); - return DecoratedBox( - decoration: BoxDecoration( - border: Border.all(color: Colors.black), - borderRadius: BorderRadius.circular(10.0), - ), - child: Padding( - padding: isTablet - ? const EdgeInsets.only(left: 14.0) - : const EdgeInsets.only(left: 12.0, right: 12.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - for (var i = 0; i < convertedArray.length; i++) - GridView.builder( + return Padding( + padding: isTablet + ? const EdgeInsets.only(left: 0.0) + : const EdgeInsets.only(left: 12.0, right: 12.0), + child: Column( + 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: orientation == Orientation.landscape - // ? 1 - // : 2, // medium - // lg: sectionList.length == 1 - // ? 1 - // : (sectionList.length >= 1 ? 3 : 3), // large - // xl: 3, // extra large screen - // ), - // mainAxisSpacing: - // sectionList.length == 1 || !isTablet ? 1 : 2, - // // childAspectRatio: isTablet - // // ? MediaQuery.of(context).size.width / - // // (MediaQuery.of(context).size.height * 0.3) - // // : MediaQuery.of(context).size.width / - // // (MediaQuery.of(context).size.height * 0.1), - // childAspectRatio: isTablet - // ? MediaQuery.of(context).size.width / - // (MediaQuery.of(context).size.height / 3) - // : MediaQuery.of(context).size.width / - // (MediaQuery.of(context).size.height * 0.2), - // ), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: context.responsive( 1, @@ -1411,13 +1277,6 @@ class _InteractionScreenState extends State { ), mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 1, - - // childAspectRatio: isTablet - // ? MediaQuery.of(context).size.width / - // (MediaQuery.of(context).size.height * 0.3) - // : MediaQuery.of(context).size.width / - // (MediaQuery.of(context).size.height * 0.1), - childAspectRatio: sectionList.length == 1 ? orientation == Orientation.landscape ? 10 @@ -1425,47 +1284,11 @@ class _InteractionScreenState extends State { : isTablet ? 2.8 : 3.0, - - // childAspectRatio: isTablet - // ? MediaQuery.of(context).size.width / - // (MediaQuery.of(context).size.height / 3) - // : orientation == Orientation.landscape - // ? MediaQuery.of(context).size.width / - // (MediaQuery.of(context).size.height * 0.5) - // : MediaQuery.of(context).size.width / - // (MediaQuery.of(context).size.height * 0.1), ), shrinkWrap: true, padding: EdgeInsets.zero, itemCount: convertedArray[i].length, itemBuilder: (context, index) { - // SectionList sectionItem = - // convertedArray.expand((list) => list).toList()[index]; - - // List.generate( - // sectionList.length, - // (i) { - // print(sectionList); - // // SectionList sectionItem = sectionList[i]; - // SectionList sectionItem = - // convertedArray.expand((list) => list).toList()[index]; - // dropdownvalue = - // sectionItem.widget == InteractionWidget.DROPDOWN - // ? sectionItem.value ?? "Select" - // : ' '; - // List list = - // sectionItem.widget == InteractionWidget.DROPDOWN || - // sectionItem.widget == - // InteractionWidget.AUTOCOMPLETE || - // sectionItem.widget == - // InteractionWidget.MULTISELECT - // ? provider.getData2(sectionItem) - // : []; - // provider.checkboxlist = - // sectionItem.widget == InteractionWidget.CHECKBOX - // ? provider.getData2(sectionItem) - // : []; - SectionList sectionItem = convertedArray[i][index]; dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN @@ -1497,7 +1320,9 @@ class _InteractionScreenState extends State { child: FittedBox( fit: BoxFit.scaleDown, child: Text( - '${sectionItem.name}:*', + sectionItem.validation!.isRequired + ? "${sectionItem.name}*" + : sectionItem.name, style: TextStyle( color: Colors.orange.shade800, fontSize: 18), @@ -1602,9 +1427,9 @@ class _InteractionScreenState extends State { ], ), ); - }) - ], - ), + }), + ) + ], ), ); //); @@ -1761,6 +1586,77 @@ class _InteractionScreenState extends State { }, ); } + + Widget _offsetPopup(List interactionReponseList) => PopupMenuButton< + int>( + itemBuilder: (context) { + return List.generate(interactionReponseList.length, (index) { + var provider = + Provider.of(context, listen: false); + + var item = provider.interactionReponseList[index]; + + return PopupMenuItem( + value: index, + child: item.multiple + ? GestureDetector( + onTap: () { + print("Clicked Section ${item.sectionName}"); + // provider.getSectionItem( + // item.sectionName, + // ); + 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: Text(' ${item.sectionName}')) + : Container(), + ); + }); + }, + // itemBuilder: (context) => [ + + // const PopupMenuItem( + // value: 1, + // child: Text( + // "Flutter Open", + // style: + // TextStyle(color: Colors.black, fontWeight: FontWeight.w700), + // ), + // ), + // const PopupMenuItem( + // value: 2, + // child: Text( + // "Flutter Tutorial", + // style: + // TextStyle(color: Colors.black, fontWeight: FontWeight.w700), + // ), + // ), + // ], + 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/interactionform/interactionprovider.dart b/lib/ui_screen/interactionform/interactionprovider.dart index 745b287..c16bb84 100644 --- a/lib/ui_screen/interactionform/interactionprovider.dart +++ b/lib/ui_screen/interactionform/interactionprovider.dart @@ -1148,6 +1148,7 @@ class InteractionProvider extends ChangeNotifier { .where((element) => element.pid == obj.sectionList[i].value) .toList(); + // sectionItem.selectedObject = list[0]; sectionItem.selectedObject = list[0]; } else { // InputClass obj = InputClass( @@ -1382,6 +1383,7 @@ class InteractionProvider extends ChangeNotifier { inputList: e.inputList, isRequired: e.isRequired, name: e.name, + validation: e.validation, param: e.param, selectedValue: [], widget: e.widget, @@ -1392,13 +1394,14 @@ class InteractionProvider extends ChangeNotifier { value: e.value)) .toList(); SectionList delItem = SectionList( - name: "delete", + name: " ", param: "deletebtn", id: "deletebtn", selectedValue: [], depid: "", widget: InteractionWidget.BUTTON, inputList: [], + validation: Validation(isRequired: false), isRequired: true); addList.add(delItem); @@ -1502,9 +1505,11 @@ class InteractionProvider extends ChangeNotifier { : e.multipleList! .map((mobj) => SectionList( depid: mobj.depid, + validation: + Validation(isRequired: mobj.validation!.isRequired), id: mobj.id, inputList: mobj.inputList, - isRequired: mobj.isRequired, + isRequired: mobj.validation!.isRequired, name: mobj.name, param: mobj.param, selectedValue: mobj.selectedValue, @@ -1521,8 +1526,10 @@ class InteractionProvider extends ChangeNotifier { .map((obj) => SectionList( depid: obj.depid, id: obj.id, + validation: + Validation(isRequired: obj.validation!.isRequired), inputList: obj.inputList, - isRequired: obj.isRequired, + isRequired: obj.validation!.isRequired, name: obj.name, param: obj.param, selectedValue: obj.selectedValue, @@ -1675,30 +1682,32 @@ class InteractionProvider extends ChangeNotifier { print("Section_isssss: $section"); print("Section_isssss: ${section.widget}"); print("Section_isssss: ${section.selectedId}"); + print("Section_isssss1111: ${section.isRequired},${section.name}"); if (section.widget == InteractionWidget.TEXT) { - if (section.controller!.text.isEmpty) { + // if (section.controller!.text.isEmpty) { + if (section.isRequired == true && section.controller!.text.isEmpty) { debugPrint("Iam text and empty"); notifyListeners(); return false; } } else if (section.widget == InteractionWidget.AUTOCOMPLETE) { - if (section.selectedValue!.isEmpty) { + if (section.isRequired == true && section.selectedValue!.isEmpty) { debugPrint("Iam AUTOCOMPLETE and empty"); notifyListeners(); return false; } } else if (section.widget == InteractionWidget.DROPDOWN) { - if (section.selectedValue!.isEmpty) { + if (section.isRequired == true && section.selectedValue!.isEmpty) { debugPrint("Iam dropdown and empty"); notifyListeners(); return false; } } else if (section.widget == InteractionWidget.CHECKBOX) { - if (section.selectedValue!.isEmpty) { + if (section.isRequired == true && section.selectedValue!.isEmpty) { debugPrint("Iam CHECKBOX and empty"); notifyListeners(); @@ -1712,35 +1721,36 @@ class InteractionProvider extends ChangeNotifier { print("Multilist Enterwidget: ${msection.widget}"); - if (msection.widget == InteractionWidget.TEXT) { + if (msection.isRequired == true && + msection.widget == InteractionWidget.TEXT) { print("Checkinggg: ${msection.id}"); print("Checkinggg: ${msection.depid}"); print("Checkinggg: ${msection.chars}"); print("Checkinggg: ${msection.selectedId}"); print("Checkinggg: ${msection.selectedValue!}"); - if (msection.selectedValue!.isEmpty) { + if (msection.isRequired == true && msection.selectedValue!.isEmpty) { debugPrint("Iam multi text and empty"); notifyListeners(); return false; } } else if (msection.widget == InteractionWidget.AUTOCOMPLETE) { - if (msection.selectedValue!.isEmpty) { + if (msection.isRequired == true && msection.selectedValue!.isEmpty) { debugPrint("Iam AUTOCOMPLETE and empty"); notifyListeners(); return false; } } else if (msection.widget == InteractionWidget.DROPDOWN) { - if (msection.selectedValue!.isEmpty) { - debugPrint("Iam dropdown and empty"); + if (msection.isRequired == true && msection.selectedValue!.isEmpty) { + debugPrint("Iam dropdown and empty ${msection.widget}"); notifyListeners(); return false; } } else if (msection.widget == InteractionWidget.CHECKBOX) { - if (msection.selectedValue!.isEmpty) { + if (msection.isRequired == true && msection.selectedValue!.isEmpty) { debugPrint("Iam CHECKBOX and empty"); notifyListeners(); diff --git a/lib/ui_screen/interactionform/model/interaction_data.dart b/lib/ui_screen/interactionform/model/interaction_data.dart index ffd2807..3e1140c 100644 --- a/lib/ui_screen/interactionform/model/interaction_data.dart +++ b/lib/ui_screen/interactionform/model/interaction_data.dart @@ -126,7 +126,7 @@ class SectionList { @HiveField(8) List? inputList; @HiveField(9) - bool? isRequired; + bool isRequired; TextEditingController? controller; @HiveField(10) @@ -160,7 +160,7 @@ class SectionList { this.input, this.gid, this.inputList, - this.isRequired, + this.isRequired = false, this.controller, this.selectedObject, this.selectedId, diff --git a/lib/ui_screen/interactionform/model/interaction_data.g.dart b/lib/ui_screen/interactionform/model/interaction_data.g.dart index 94b01d4..ad5f62c 100644 --- a/lib/ui_screen/interactionform/model/interaction_data.g.dart +++ b/lib/ui_screen/interactionform/model/interaction_data.g.dart @@ -109,7 +109,7 @@ class SectionListAdapter extends TypeAdapter { input: fields[7] as String?, gid: fields[3] as int?, inputList: (fields[8] as List?)?.cast(), - isRequired: fields[9] as bool?, + isRequired: fields[9] as bool, selectedObject: fields[12] as InputClass?, selectedId: fields[11] as String?, validation: fields[13] as Validation?, diff --git a/lib/ui_screen/interactionform/view_interaction_screen.dart b/lib/ui_screen/interactionform/view_interaction_screen.dart index 2b6febc..b5a53b5 100644 --- a/lib/ui_screen/interactionform/view_interaction_screen.dart +++ b/lib/ui_screen/interactionform/view_interaction_screen.dart @@ -501,19 +501,21 @@ class _ViewInteractionScreenState extends State { print("ConvertedArrayEdit.leangth: $convertedArray"); print("ConvertedArray.leangth2323: ${convertedArray.length}"); - return DecoratedBox( - decoration: BoxDecoration( - border: Border.all(color: Colors.black), - borderRadius: BorderRadius.circular(10), - ), - child: Padding( - padding: isTablet - ? const EdgeInsets.only(left: 14.0) - : const EdgeInsets.only(left: 12.0, right: 12.0), - child: Column( - children: [ - for (var i = 0; i < convertedArray.length; i++) - GridView.builder( + return Padding( + padding: isTablet + ? const EdgeInsets.only(left: 0.0, right: 0.0) + : const EdgeInsets.only(left: 12.0, right: 12.0), + child: Column( + children: [ + for (var i = 0; i < convertedArray.length; i++) + DecoratedBox( + decoration: BoxDecoration( + // 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( @@ -617,9 +619,9 @@ class _ViewInteractionScreenState extends State { ); }, ), - //), - ], - ), + ), + //), + ], ), ); } diff --git a/lib/ui_screen/interactionform/viewinteractionprovider.dart b/lib/ui_screen/interactionform/viewinteractionprovider.dart index e6516fb..317a335 100644 --- a/lib/ui_screen/interactionform/viewinteractionprovider.dart +++ b/lib/ui_screen/interactionform/viewinteractionprovider.dart @@ -597,6 +597,7 @@ class ViewInteractionProvider extends ChangeNotifier { inputList: e.inputList, isRequired: e.isRequired, name: e.name, + validation: e.validation, param: e.param, selectedValue: [], widget: e.widget, @@ -607,13 +608,14 @@ class ViewInteractionProvider extends ChangeNotifier { value: e.value)) .toList(); SectionList delItem = SectionList( - name: "delete", + name: " ", param: "deletebtn", id: "deletebtn", selectedValue: [], depid: "", widget: InteractionWidget.BUTTON, inputList: [], + validation: Validation(isRequired: false), isRequired: true); addList.add(delItem); @@ -775,6 +777,7 @@ class ViewInteractionProvider extends ChangeNotifier { depid: mobj.depid, id: mobj.id, inputList: mobj.inputList, + validation: mobj.validation, isRequired: mobj.isRequired, extension: mobj.extension, fileName: mobj.fileName, @@ -793,9 +796,10 @@ class ViewInteractionProvider extends ChangeNotifier { depid: obj.depid, id: obj.id, inputList: obj.inputList, + validation: obj.validation, + isRequired: obj.isRequired, extension: obj.extension, fileName: obj.fileName, - isRequired: obj.isRequired, name: obj.name, param: obj.param, selectedValue: obj.tempselectedValue ?? obj.selectedValue, @@ -930,28 +934,28 @@ class ViewInteractionProvider extends ChangeNotifier { print("Section_isssss: ${section.selectedId}"); if (section.widget == InteractionWidget.TEXT) { - if (section.controller!.text.isEmpty) { + if (section.isRequired == true && section.controller!.text.isEmpty) { debugPrint("Iam text and empty"); notifyListeners(); return false; } } else if (section.widget == InteractionWidget.AUTOCOMPLETE) { - if (section.selectedValue!.isEmpty) { + if (section.isRequired == true && section.selectedValue!.isEmpty) { debugPrint("Iam AUTOCOMPLETE and empty"); notifyListeners(); return false; } } else if (section.widget == InteractionWidget.DROPDOWN) { - if (section.selectedValue!.isEmpty) { + if (section.isRequired == true && section.selectedValue!.isEmpty) { debugPrint("Iam dropdown and empty"); notifyListeners(); return false; } } else if (section.widget == InteractionWidget.CHECKBOX) { - if (section.selectedValue!.isEmpty) { + if (section.isRequired == true && section.selectedValue!.isEmpty) { debugPrint("Iam CHECKBOX and empty"); notifyListeners(); @@ -972,28 +976,28 @@ class ViewInteractionProvider extends ChangeNotifier { print("Checkinggg: ${msection.selectedId}"); print("Checkinggg: ${msection.selectedValue!}"); - if (msection.selectedValue!.isEmpty) { + if (msection.isRequired == true && msection.selectedValue!.isEmpty) { debugPrint("Iam multi text and empty"); notifyListeners(); return false; } } else if (msection.widget == InteractionWidget.AUTOCOMPLETE) { - if (msection.selectedValue!.isEmpty) { + if (msection.isRequired == true && msection.selectedValue!.isEmpty) { debugPrint("Iam AUTOCOMPLETE and empty"); notifyListeners(); return false; } } else if (msection.widget == InteractionWidget.DROPDOWN) { - if (msection.selectedValue!.isEmpty) { + if (msection.isRequired == true && msection.selectedValue!.isEmpty) { debugPrint("Iam dropdown and empty"); notifyListeners(); return false; } } else if (msection.widget == InteractionWidget.CHECKBOX) { - if (msection.selectedValue!.isEmpty) { + if (msection.isRequired == true && msection.selectedValue!.isEmpty) { debugPrint("Iam CHECKBOX and empty"); notifyListeners(); diff --git a/pubspec.lock b/pubspec.lock index 0378b46..91b1a82 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -776,6 +776,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" + popover: + dependency: "direct main" + description: + name: popover + sha256: "5cba40e04115cbbf15c35e00767b91e8bf3f769763a34beb2f8a1b9e8b5fc876" + url: "https://pub.dev" + source: hosted + version: "0.3.0+1" provider: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index f51e35a..4018223 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -58,6 +58,7 @@ dependencies: rfw: ^1.0.26 hive_generator: ^2.0.1 responsive_grid: ^2.4.4 + popover: ^0.3.0+1 dev_dependencies: