From 12542f353407f8757b8ae55e518aa07fbdbff629 Mon Sep 17 00:00:00 2001 From: poojakhatawate Date: Wed, 12 Jun 2024 14:59:51 +0530 Subject: [PATCH] PaddingIssue --- lib/custom_widget/show_alert.dart | 22 +- lib/ui_screen/filters_menu.dart | 7 +- .../edit_interaction_screen.dart | 78 +++- .../interactionform/interaction_screen.dart | 395 +++++++++++------- lib/ui_screen/interactionform/util.dart | 2 +- .../view_interaction_screen.dart | 222 +++++----- .../viewinteractionprovider.dart | 216 +++++++++- lib/ui_screen/ranking.dart | 70 ++-- lib/ui_screen/rising_stars.dart | 3 + lib/ui_screen/trends.dart | 7 +- 10 files changed, 702 insertions(+), 320 deletions(-) diff --git a/lib/custom_widget/show_alert.dart b/lib/custom_widget/show_alert.dart index b566d57..66b4fbd 100644 --- a/lib/custom_widget/show_alert.dart +++ b/lib/custom_widget/show_alert.dart @@ -1,15 +1,13 @@ import 'package:discover_module/custom_widget/text.dart'; import 'package:flutter/material.dart'; +import 'package:http_mock_adapter/http_mock_adapter.dart'; -class Alert extends StatefulWidget { - Alert({super.key, required this.data}); +class Alert extends StatelessWidget { + Alert({super.key, required this.data, required this.onPressed}); String? data; + VoidCallbackAction? oidCallbackAction; + final void Function() onPressed; - @override - State createState() => _AlertState(); -} - -class _AlertState extends State { @override Widget build(BuildContext context) { return AlertDialog( @@ -18,16 +16,10 @@ class _AlertState extends State { txtfont: 22.0, ), content: Text1( - title: widget.data!, + title: data!, txtfont: 18.0, ), - actions: [ - TextButton( - onPressed: () { - Navigator.pop(context); - }, - child: Text("Cancel")) - ], + actions: [TextButton(onPressed: onPressed, child: Text("Ok"))], ); } } diff --git a/lib/ui_screen/filters_menu.dart b/lib/ui_screen/filters_menu.dart index 0200cc5..903c362 100644 --- a/lib/ui_screen/filters_menu.dart +++ b/lib/ui_screen/filters_menu.dart @@ -226,7 +226,12 @@ class _FiltersState extends State { showDialog( context: context, builder: (_) { - return Alert(data: "Please select the Filter"); + return Alert( + data: "Please select the Filter", + onPressed: () { + Navigator.of(context).pop(); + }, + ); }); } }, diff --git a/lib/ui_screen/interactionform/edit_interaction_screen.dart b/lib/ui_screen/interactionform/edit_interaction_screen.dart index 80211e1..6626c05 100644 --- a/lib/ui_screen/interactionform/edit_interaction_screen.dart +++ b/lib/ui_screen/interactionform/edit_interaction_screen.dart @@ -239,6 +239,17 @@ class _EditInteractionScreenState extends State { // : 3.8 // : 2.4, + // childAspectRatio: + // sectionList.length == 1 + // ? orientation == + // Orientation + // .landscape + // ? 10 + // : 4.8 + // : isTablet + // ? 3.6 + // : 3.0, + childAspectRatio: sectionList.length == 1 ? orientation == @@ -247,7 +258,7 @@ class _EditInteractionScreenState extends State { ? 10 : 4.8 : isTablet - ? 3.6 + ? 2.8 : 3.0, children: List.generate( sectionList.length, @@ -574,7 +585,18 @@ class _EditInteractionScreenState extends State { // if (textFieldsValidation(provider).isEmpty) { await provider.saveJsonObject(context, widget.saveInteraction.intId, widget.saveInteraction); - showAlertDialog(context, widget.saveInteraction.id); + + // showAlertDialog(context, widget.saveInteraction.id); + + print("Validation_isss: ${provider.isLoading}"); + + if (provider.isLoading == false) { + print("Validation_false"); + showAlertDialog1(context, "Please fill all the fields"); + } else { + showAlertDialog(context, widget.saveInteraction.id); + print("Validation_True"); + } // } else { // _displaySnackBar(textFieldsValidation(provider)); // } @@ -1228,11 +1250,19 @@ class _EditInteractionScreenState extends State { // (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), + // 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), + + 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 @@ -1388,8 +1418,9 @@ class _EditInteractionScreenState extends State { setState(() {}); }, - width: 80, - height: 30, + // width: 80, + // height: 30, + height: 40, fontsize: 12, textColor: Colors.white, title: "Delete"), @@ -1530,6 +1561,35 @@ class _EditInteractionScreenState extends State { ); } + showAlertDialog1(BuildContext context, String record) { + // set up the buttons + // ViewInteractionProvider provider = + // Provider.of(context, listen: false); + Widget cancelButton = TextButton( + child: const Text("Ok"), + onPressed: () async { + Navigator.of(context).pop(); + }, + ); + + // 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; + }, + ); + } + showFilesAlertDialog( BuildContext context, String files, SectionList sectionItem) { // set up the buttons diff --git a/lib/ui_screen/interactionform/interaction_screen.dart b/lib/ui_screen/interactionform/interaction_screen.dart index c8e7bff..a2aac49 100644 --- a/lib/ui_screen/interactionform/interaction_screen.dart +++ b/lib/ui_screen/interactionform/interaction_screen.dart @@ -1,6 +1,6 @@ import 'dart:convert'; import 'dart:io'; -import 'dart:js_util'; +// import 'dart:js_util'; import 'package:discover_module/constants.dart'; import 'package:discover_module/ui_screen/add_event/add_hcp.dart'; @@ -182,16 +182,33 @@ class _InteractionScreenState extends State { 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: 1, // medium + md: isTablet + ? 2 + : orientation == + Orientation.landscape + ? 2 + : 1, // medium lg: sectionList.length == 1 ? 1 : 3, // large xl: 3, // extra large screen ), + // crossAxisCount: // orientation == Orientation.portrait // ? 1 @@ -503,26 +520,31 @@ class _InteractionScreenState extends State { style: TextStyle( fontSize: 18.0, fontWeight: FontWeight.normal), ) - : Padding( - padding: const EdgeInsets.only(left: 8.0, right: 8.0), - child: SizedBox( - // width: - // isTablet ? 200 : MediaQuery.of(context).size.width, - //height: isTablet ? 50 : 40, - width: MediaQuery.of(context).size.width, - child: InteractionTextField( - inputType: sectionItem.input == "number" - ? TextInputType.number - : TextInputType.name, - maxchars: int.parse(sectionItem.chars ?? "0"), - controller: sectionItem.controller!, - labelText: sectionItem.name, - onChanged: (val) { - sectionItem.selectedValue = []; - // sectionItem.selectedValue!.clear(); + : 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, - provider.setTextValue(val, sectionItem, multiple); - }, + 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); + }, + ), ), ), ); @@ -668,7 +690,7 @@ class _InteractionScreenState extends State { if (provider.isLoading == false) { print("Validation_false"); - showAlertDialog(context, "Please fill all the fields"); + showAlertDialog1(context, "Please fill all the fields"); } else { showAlertDialog(context, "Form $record Saved Successfully!"); print("Validation_True"); @@ -1335,22 +1357,14 @@ class _InteractionScreenState extends State { print("ConvertedArray.leangth: $convertedArray"); print("ConvertedArray.leangth: ${convertedArray.length}"); - return - // Container( - // decoration: BoxDecoration( - // border: Border.all( - // width: 0, - // ), - // ), - // child: - DecoratedBox( + return DecoratedBox( decoration: BoxDecoration( border: Border.all(color: Colors.black), borderRadius: BorderRadius.circular(10.0), ), child: Padding( padding: isTablet - ? const EdgeInsets.only(left: 8.0) + ? const EdgeInsets.only(left: 14.0) : const EdgeInsets.only(left: 12.0, right: 12.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -1358,30 +1372,68 @@ class _InteractionScreenState extends State { for (var i = 0; i < convertedArray.length; i++) GridView.builder( physics: const NeverScrollableScrollPhysics(), + // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + // crossAxisCount: context.responsive( + // 1, + // sm: 1, // small + // md: orientation == Orientation.landscape + // ? 1 + // : 2, // medium + // lg: sectionList.length == 1 + // ? 1 + // : (sectionList.length >= 1 ? 3 : 3), // large + // xl: 3, // extra large screen + // ), + // mainAxisSpacing: + // sectionList.length == 1 || !isTablet ? 1 : 2, + // // childAspectRatio: isTablet + // // ? MediaQuery.of(context).size.width / + // // (MediaQuery.of(context).size.height * 0.3) + // // : MediaQuery.of(context).size.width / + // // (MediaQuery.of(context).size.height * 0.1), + // childAspectRatio: isTablet + // ? MediaQuery.of(context).size.width / + // (MediaQuery.of(context).size.height / 3) + // : MediaQuery.of(context).size.width / + // (MediaQuery.of(context).size.height * 0.2), + // ), 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 + 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 : 2, + 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: isTablet - ? MediaQuery.of(context).size.width / - (MediaQuery.of(context).size.height / 3) - : MediaQuery.of(context).size.width / - (MediaQuery.of(context).size.height * 0.2), + + childAspectRatio: sectionList.length == 1 + ? orientation == Orientation.landscape + ? 10 + : 4.8 + : 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, @@ -1430,130 +1482,126 @@ class _InteractionScreenState extends State { sectionItem.widget == InteractionWidget.CHECKBOX ? provider.getData2(sectionItem) : []; - return Wrap(children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - sectionItem.widget == InteractionWidget.BUTTON && - sectionItem.input == 'add' || - sectionItem.input == 'deletebtn' - ? const SizedBox.shrink() - : Padding( - padding: const EdgeInsets.only( - left: 8.0, right: 8.0), - child: FittedBox( - fit: BoxFit.scaleDown, - child: Text( - '${sectionItem.name}:*', - style: TextStyle( - color: Colors.orange.shade800, - fontSize: 18), - ), + return SizedBox( + height: MediaQuery.of(context).size.height, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + sectionItem.widget == InteractionWidget.BUTTON && + sectionItem.input == 'add' || + sectionItem.input == 'deletebtn' + ? const SizedBox.shrink() + : Padding( + padding: const EdgeInsets.only( + left: 8.0, right: 8.0), + child: FittedBox( + fit: BoxFit.scaleDown, + child: Text( + '${sectionItem.name}:*', + style: TextStyle( + color: Colors.orange.shade800, + fontSize: 18), ), ), - // 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); + ), + // 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(() {}); }, - 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); + 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(() {}); - }, - // width: 80, - // height: 30, + setState(() {}); + }, + icon: const Icon( + Icons.cancel, + size: 30, + color: + Color.fromARGB(255, 8, 39, 92), + ), + ) + : Padding( + padding: const EdgeInsets.only( + left: 3.0, top: 5), + child: CustomButton( + backgroundColor: + const Color.fromARGB( + 255, 233, 75, 75), + onPressed: () { + provider.deleteMultipleRows( + sectionItem.gid!, + sectionList[i], + sectionName); - height: 40, + setState(() {}); + }, + // width: 80, + // height: 30, - // 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), - ], - ), + 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), + ], ), - ]); + ); }) ], ), @@ -1684,6 +1732,35 @@ class _InteractionScreenState extends State { }, ); } + + showAlertDialog1(BuildContext context, String record) { + // set up the buttons + // ViewInteractionProvider provider = + // Provider.of(context, listen: false); + Widget cancelButton = TextButton( + child: const Text("Ok"), + onPressed: () async { + Navigator.of(context).pop(); + }, + ); + + // 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; + }, + ); + } } diff --git a/lib/ui_screen/interactionform/util.dart b/lib/ui_screen/interactionform/util.dart index ac9eab7..2e20268 100644 --- a/lib/ui_screen/interactionform/util.dart +++ b/lib/ui_screen/interactionform/util.dart @@ -46,7 +46,7 @@ bool get isTablet { final logicalShortestSide = firstView.physicalSize.shortestSide / firstView.devicePixelRatio; // print("size:${logicalShortestSide > 600} tablet "); - return logicalShortestSide > 600; + return logicalShortestSide > 500; } Future formJsonForSync() async { diff --git a/lib/ui_screen/interactionform/view_interaction_screen.dart b/lib/ui_screen/interactionform/view_interaction_screen.dart index 5957711..2b6febc 100644 --- a/lib/ui_screen/interactionform/view_interaction_screen.dart +++ b/lib/ui_screen/interactionform/view_interaction_screen.dart @@ -144,6 +144,7 @@ class _ViewInteractionScreenState extends State { // ? 10 // : 3.8 // : 2.8, + crossAxisCount: context.responsive( 1, @@ -168,6 +169,15 @@ class _ViewInteractionScreenState extends State { : isTablet ? 2.8 : 3.0, + // childAspectRatio: + // sectionList.length == 1 + // ? orientation == + // Orientation.landscape + // ? 10 + // : 4.8 + // : isTablet + // ? 2.8 + // : 3.0, shrinkWrap: true, padding: EdgeInsets.zero, children: List.generate( @@ -491,101 +501,125 @@ class _ViewInteractionScreenState extends State { print("ConvertedArrayEdit.leangth: $convertedArray"); print("ConvertedArray.leangth2323: ${convertedArray.length}"); - return Padding( - padding: isTablet - ? const EdgeInsets.only(left: 22.0) - : const EdgeInsets.only(left: 12.0, right: 12.0), - child: Column( - children: [ - for (var i = 0; i < convertedArray.length; i++) - GridView.builder( - physics: const NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: context.responsive( - 1, // default - sm: 1, // small - md: 1, // medium - lg: sectionList.length == 1 ? 1 : 4, // large - xl: 5, // extra large screen - ), - mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 2, - ), - shrinkWrap: true, - padding: EdgeInsets.zero, - // childAspectRatio: sectionList.length == 1 || !isTablet - // ? orientation == Orientation.landscape - // ? 10 - // : 4.2 - // : 1.8, - itemCount: convertedArray[i].length, - itemBuilder: (context, index) { - // children: List.generate( - // sectionList.length, - // (i) { - // print(sectionList); - // SectionList sectionItem = sectionList[i]; - // dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN - // ? sectionItem.value ?? "Select" - // : ' '; - // List list = - // sectionItem.widget == InteractionWidget.DROPDOWN || - // sectionItem.widget == InteractionWidget.AUTOCOMPLETE || - // sectionItem.widget == InteractionWidget.MULTISELECT - // ? provider.getData2(sectionItem) - // : []; - // provider.checkboxlist = - // sectionItem.widget == InteractionWidget.CHECKBOX - // ? provider.getData2(sectionItem) - // : []; - SectionList sectionItem = convertedArray[i][index]; - dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN - ? sectionItem.value ?? "Select" - : ' '; - List list = sectionItem.widget == - InteractionWidget.DROPDOWN || - sectionItem.widget == InteractionWidget.AUTOCOMPLETE || - sectionItem.widget == InteractionWidget.MULTISELECT - ? provider.getData2(sectionItem) - : []; - provider.checkboxlist = - sectionItem.widget == InteractionWidget.CHECKBOX - ? provider.getData2(sectionItem) - : []; - - return SizedBox( - height: MediaQuery.of(context).size.height, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - sectionItem.widget == InteractionWidget.BUTTON && - sectionItem.param == 'add' || - sectionItem.param == 'deletebtn' - ? const SizedBox.shrink() - : Text( - '${sectionItem.name}:*', - style: TextStyle( - color: Colors.orange.shade800, - fontSize: isTablet ? 18 : 14, - ), - ), - const SizedBox( - height: 15, - ), - returnWidget( - sectionItem: sectionItem, - item: item, - provider: provider, - list: list, - gridIndex: i, - listIndex: listIndex, - widgetData: sectionItem.widget!), - ], + 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( + physics: const NeverScrollableScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: context.responsive( + 1, // default + sm: 1, // small + md: 2, // medium + lg: sectionList.length == 1 + ? 1 + : (sectionList.length >= 1 ? 3 : 3), + // lg: sectionList.length == 1 ? 1 : 3, // large + xl: 3, // extra large screen ), - ); - }, - ), - //), - ], + childAspectRatio: sectionList.length == 1 + ? orientation == Orientation.landscape + ? 10 + : 4.8 + : isTablet + ? 2.8 + : 3.0, + + mainAxisSpacing: + sectionList.length == 1 || !isTablet ? 1 : 3.5, + // mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 2, + ), + shrinkWrap: true, + padding: EdgeInsets.zero, + + // childAspectRatio: sectionList.length == 1 || !isTablet + // ? orientation == Orientation.landscape + // ? 10 + // : 4.2 + // : 1.8, + itemCount: convertedArray[i].length, + itemBuilder: (context, index) { + // children: List.generate( + // sectionList.length, + // (i) { + // print(sectionList); + // SectionList sectionItem = sectionList[i]; + // dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN + // ? sectionItem.value ?? "Select" + // : ' '; + // List list = + // sectionItem.widget == InteractionWidget.DROPDOWN || + // sectionItem.widget == InteractionWidget.AUTOCOMPLETE || + // sectionItem.widget == InteractionWidget.MULTISELECT + // ? provider.getData2(sectionItem) + // : []; + // provider.checkboxlist = + // sectionItem.widget == InteractionWidget.CHECKBOX + // ? provider.getData2(sectionItem) + // : []; + SectionList sectionItem = convertedArray[i][index]; + dropdownvalue = + sectionItem.widget == InteractionWidget.DROPDOWN + ? sectionItem.value ?? "Select" + : ' '; + List list = sectionItem.widget == + InteractionWidget.DROPDOWN || + sectionItem.widget == + InteractionWidget.AUTOCOMPLETE || + sectionItem.widget == InteractionWidget.MULTISELECT + ? provider.getData2(sectionItem) + : []; + provider.checkboxlist = + sectionItem.widget == InteractionWidget.CHECKBOX + ? provider.getData2(sectionItem) + : []; + + 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() + + // ? const SizedBox.shrink() + : Text( + '${sectionItem.name}:*', + style: TextStyle( + color: Colors.orange.shade800, + fontSize: isTablet ? 18 : 14, + ), + ), + const SizedBox( + height: 15, + ), + returnWidget( + sectionItem: sectionItem, + item: item, + provider: provider, + list: list, + gridIndex: i, + listIndex: listIndex, + widgetData: sectionItem.widget!), + ], + ), + ); + }, + ), + //), + ], + ), ), ); } diff --git a/lib/ui_screen/interactionform/viewinteractionprovider.dart b/lib/ui_screen/interactionform/viewinteractionprovider.dart index a522957..e6516fb 100644 --- a/lib/ui_screen/interactionform/viewinteractionprovider.dart +++ b/lib/ui_screen/interactionform/viewinteractionprovider.dart @@ -45,6 +45,10 @@ class ViewInteractionProvider extends ChangeNotifier { Hive.box('InteractionConfigDataBox')); late final InteractionProvider interactionProvider; + late bool _isLoadingView; + + get isLoading => _isLoadingView; + initConfigData() async { intConfigDataList = _hiveprovider.getAllDataFromHive(); notifyListeners(); @@ -673,6 +677,85 @@ class ViewInteractionProvider extends ChangeNotifier { notifyListeners(); } + // saveJsonObject(BuildContext context, String form, + // SaveInteraction saveInteraction) async { + // for (var res in interactionReponseList) { + // for (var sec in res.sectionList) { + // debugPrint("print ${sec.selectedValue}"); + // } + // for (var sec in res.multipleList!) { + // debugPrint("printmultiple ${sec.selectedValue}"); + // } + // } + // List resultData = interactionReponseList + // .map((e) => FormFieldData( + // multipleList: e.multipleList == null + // ? [] + // : e.multipleList! + // .map((mobj) => SectionList( + // depid: mobj.depid, + // id: mobj.id, + // inputList: mobj.inputList, + // isRequired: mobj.isRequired, + // extension: mobj.extension, + // fileName: mobj.fileName, + // name: mobj.name, + // param: mobj.param, + // selectedValue: + // mobj.tempselectedValue ?? mobj.selectedValue, + // widget: mobj.widget, + // gid: mobj.gid, + // input: mobj.input, + // selectedId: mobj.selectedId, + // value: mobj.value)) + // .toList(), + // sectionList: e.sectionList + // .map((obj) => SectionList( + // depid: obj.depid, + // id: obj.id, + // inputList: obj.inputList, + // extension: obj.extension, + // fileName: obj.fileName, + // isRequired: obj.isRequired, + // name: obj.name, + // param: obj.param, + // selectedValue: obj.tempselectedValue ?? obj.selectedValue, + // widget: obj.widget, + // controller: obj.controller, + // gid: obj.gid, + // input: obj.input, + // selectedId: obj.selectedId, + // value: obj.value)) + // .toList(), + // sectionName: e.sectionName, + // multiple: e.multiple, + // )) + // .toList(); + + // final data = SaveInteraction( + // save: resultData, + // id: saveInteraction.id, + // updatedTime: DateTime.now().toString(), + // form: saveInteraction.form, + // intId: saveInteraction.intId, + // intName: saveInteraction.intName, + // ); + // var box = Hive.box('InteractionDataBox'); + + // if (!box.isOpen) { + // box = await Hive.openBox('InteractionDataBox'); + // } + + // int index = + // box.values.toList().indexWhere((element) => element.id == data.id); + + // box.putAt(index, data); + // await getRecords(saveInteraction.form!); + // // box.close(); + + // // await MockApiCall().postFormData(data); + // } + saveJsonObject(BuildContext context, String form, SaveInteraction saveInteraction) async { for (var res in interactionReponseList) { @@ -727,25 +810,35 @@ class ViewInteractionProvider extends ChangeNotifier { multiple: e.multiple, )) .toList(); + if (validateSectionList(resultData)) { + _isLoadingView = true; + notifyListeners(); - final data = SaveInteraction( - save: resultData, - id: saveInteraction.id, - updatedTime: DateTime.now().toString(), - form: saveInteraction.form, - intId: saveInteraction.intId, - intName: saveInteraction.intName, - ); - var box = Hive.box('InteractionDataBox'); + final data = SaveInteraction( + save: resultData, + id: saveInteraction.id, + updatedTime: DateTime.now().toString(), + form: saveInteraction.form, + intId: saveInteraction.intId, + intName: saveInteraction.intName, + ); + var box = Hive.box('InteractionDataBox'); - if (!box.isOpen) { - box = await Hive.openBox('InteractionDataBox'); + if (!box.isOpen) { + box = await Hive.openBox('InteractionDataBox'); + } + + int index = + box.values.toList().indexWhere((element) => element.id == data.id); + + box.putAt(index, data); + } else { + _isLoadingView = false; + notifyListeners(); + + // Handle validation error + print("JSON data is not valid according to the schema."); } - - int index = - box.values.toList().indexWhere((element) => element.id == data.id); - - box.putAt(index, data); await getRecords(saveInteraction.form!); // box.close(); @@ -822,6 +915,97 @@ class ViewInteractionProvider extends ChangeNotifier { } return false; } + + bool validateSectionList(List resultData) { + for (var formData in resultData) { + for (var section in formData.sectionList) { + // print("Section.leangthiss: ${resultData.length}"); + // for (int i = 0; i <= resultData.length; i++) { + // SectionList sectionItem = formData.sectionList[i]; + // print("Section_isssss1111: ${sectionItem.validation!.isRequired}"); + // } + + print("Section_isssss: $section"); + print("Section_isssss: ${section.widget}"); + print("Section_isssss: ${section.selectedId}"); + + if (section.widget == InteractionWidget.TEXT) { + if (section.controller!.text.isEmpty) { + debugPrint("Iam text and empty"); + notifyListeners(); + + return false; + } + } else if (section.widget == InteractionWidget.AUTOCOMPLETE) { + if (section.selectedValue!.isEmpty) { + debugPrint("Iam AUTOCOMPLETE and empty"); + notifyListeners(); + + return false; + } + } else if (section.widget == InteractionWidget.DROPDOWN) { + if (section.selectedValue!.isEmpty) { + debugPrint("Iam dropdown and empty"); + notifyListeners(); + + return false; + } + } else if (section.widget == InteractionWidget.CHECKBOX) { + if (section.selectedValue!.isEmpty) { + debugPrint("Iam CHECKBOX and empty"); + notifyListeners(); + + return false; + } + } + } + print("Multilist"); + for (var msection in formData.multipleList!) { + print("Multilist Enter"); + + print("Multilist Enterwidget: ${msection.widget}"); + + if (msection.widget == InteractionWidget.TEXT) { + print("Checkinggg: ${msection.id}"); + print("Checkinggg: ${msection.depid}"); + print("Checkinggg: ${msection.chars}"); + print("Checkinggg: ${msection.selectedId}"); + print("Checkinggg: ${msection.selectedValue!}"); + + if (msection.selectedValue!.isEmpty) { + debugPrint("Iam multi text and empty"); + notifyListeners(); + + return false; + } + } else if (msection.widget == InteractionWidget.AUTOCOMPLETE) { + if (msection.selectedValue!.isEmpty) { + debugPrint("Iam AUTOCOMPLETE and empty"); + notifyListeners(); + + return false; + } + } else if (msection.widget == InteractionWidget.DROPDOWN) { + if (msection.selectedValue!.isEmpty) { + debugPrint("Iam dropdown and empty"); + notifyListeners(); + + return false; + } + } else if (msection.widget == InteractionWidget.CHECKBOX) { + if (msection.selectedValue!.isEmpty) { + debugPrint("Iam CHECKBOX and empty"); + notifyListeners(); + + return false; + } + } + } + } + notifyListeners(); + + return true; + } } diff --git a/lib/ui_screen/ranking.dart b/lib/ui_screen/ranking.dart index 65c3e67..7469377 100644 --- a/lib/ui_screen/ranking.dart +++ b/lib/ui_screen/ranking.dart @@ -1,9 +1,10 @@ import 'dart:convert'; import 'dart:io'; -import 'dart:js_interop'; +// import 'dart:js_interop'; import 'package:discover_module/custom_widget/floating_btn.dart'; import 'package:discover_module/custom_widget/show_alert.dart'; +import 'package:discover_module/ui_screen/contacts.dart'; import 'package:discover_module/ui_screen/profile.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart' show kIsWeb; @@ -145,35 +146,56 @@ class _RankingState extends State { // Do something with selectedRowIds print('Selected Row IDstrndsss: $selectedRowIds'); - for (int i = 0; i < selectedRowIds.length; i++) { - print('The id id : ${selectedRowIds[i]}'); + if (selectedRowIds.isEmpty) { + showDialog( + context: context, + builder: (_) { + return Alert( + data: "Please Select the user", + onPressed: () { + Navigator.of(context).pop(); + print('OK button pressed'); + }, + ); + }); + } else { + for (int i = 0; i < selectedRowIds.length; i++) { + print('The id id : ${selectedRowIds[i]}'); - print("checking_value_istrends: ${selectedRowIds[i]}"); + print("checking_value_istrends: ${selectedRowIds[i]}"); - // selectedno.add(selectedRowIds[i]); + // selectedno.add(selectedRowIds[i]); - HiveFunctions.addno(selectedRowIds[i]); + HiveFunctions.addno(selectedRowIds[i]); - // _contactbox.put(i, selectedRowIds[i]); + // _contactbox.put(i, selectedRowIds[i]); - HiveFunctions.createUser({ - "name": "Gerosa,Gino", - "org": "Azienda Ospedaliera di Padova", - "adrr": "Via Giustiniani 2, Padova, Veneto 35128, Italy", - "phone": "+390498212410X12", - "Pphone": "+390498212410X12", - "email": "Gerosa,Gino@gmail.com", - "affno": "75", - "eveno": "8", - "pubno": "251", - "trailno": "1" - }); - } - showDialog( - context: context, - builder: (_) { - return Alert(data: "User Added Successfully"); + HiveFunctions.createUser({ + "name": "Gerosa,Gino", + "org": "Azienda Ospedaliera di Padova", + "adrr": "Via Giustiniani 2, Padova, Veneto 35128, Italy", + "phone": "+390498212410X12", + "Pphone": "+390498212410X12", + "email": "Gerosa,Gino@gmail.com", + "affno": "75", + "eveno": "8", + "pubno": "251", + "trailno": "1" }); + } + showDialog( + context: context, + builder: (_) { + return Alert( + data: "User Added Successfully", + onPressed: () { + Navigator.of(context).pop(); + // Navigator.push(context, + // MaterialPageRoute(builder: (_) => Contacts())); + }, + ); + }); + } }, )), ), diff --git a/lib/ui_screen/rising_stars.dart b/lib/ui_screen/rising_stars.dart index 8d6f3c2..9ecdc37 100644 --- a/lib/ui_screen/rising_stars.dart +++ b/lib/ui_screen/rising_stars.dart @@ -128,6 +128,9 @@ class RisingStarState extends State { builder: (_) { return Alert( data: "User Added Successfully", + onPressed: () { + Navigator.of(context).pop(); + }, ); }); }, diff --git a/lib/ui_screen/trends.dart b/lib/ui_screen/trends.dart index ba15156..79e198a 100644 --- a/lib/ui_screen/trends.dart +++ b/lib/ui_screen/trends.dart @@ -101,7 +101,12 @@ class _TrendsState extends State { showDialog( context: context, builder: (_) { - return Alert(data: "User Added Successfully"); + return Alert( + data: "User Added Successfully", + onPressed: () { + Navigator.of(context).pop(); + }, + ); }); }, )),