diff --git a/lib/constants.dart b/lib/constants.dart index 1b925c4..739bfde 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:8084/api'; + static const url = 'http://192.168.2.143:8085/api'; //static const url = 'http://192.168.153.50:8082/api'; } diff --git a/lib/main.dart b/lib/main.dart index d76c6a7..f07cb85 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,7 @@ import 'package:discover_module/provider_class/affiliationsprovider.dart'; import 'package:discover_module/provider_class/events_provider.dart'; import 'package:discover_module/provider_class/hcp%20_provider.dart'; +import 'package:discover_module/provider_class/medicalinsightprovider.dart'; import 'package:discover_module/provider_class/publications_provider.dart'; import 'package:discover_module/provider_class/single_hcpprovider.dart'; import 'package:discover_module/provider_class/trials_provider.dart'; @@ -15,6 +16,7 @@ import 'package:discover_module/ui_screen/interactionform/repository/hive_reposi import 'package:discover_module/ui_screen/interactionform/viewinteractionprovider.dart'; import 'package:discover_module/ui_screen/listview.dart'; import 'package:discover_module/ui_screen/filters_menu.dart'; +import 'package:discover_module/ui_screen/medical_insight.dart'; import 'package:discover_module/ui_screen/new_contacts.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -70,12 +72,14 @@ Future main() async { ChangeNotifierProvider(create: (_) => PublicatioProvider()), ChangeNotifierProvider(create: (_) => EventProvider()), ChangeNotifierProvider(create: (_) => TrialsProvider()), + ChangeNotifierProvider(create: (_) => MediacalInsightProvider()), //ChangeNotifierProvider(create: (_) => ConfigDataProvider()), ChangeNotifierProvider( create: (_) => HiveDataRepository( Hive.box('InteractionConfigDataBox'))), ], child: MyApp(), + // child: MedicalInsight(), )); } @@ -100,6 +104,7 @@ class _MyAppState extends State { foregroundColor: Colors.white //here you can give the text color )), home: const MyHomePage(title: 'Discover Module'), + // home: const MedicalInsight(), ); } } diff --git a/lib/provider_class/medicalinsightprovider.dart b/lib/provider_class/medicalinsightprovider.dart new file mode 100644 index 0000000..d1d7b40 --- /dev/null +++ b/lib/provider_class/medicalinsightprovider.dart @@ -0,0 +1,16 @@ +import 'package:discover_module/service.dart/service.dart'; +import 'package:flutter/cupertino.dart'; + +class MediacalInsightProvider extends ChangeNotifier { + final callapi = Callapi(); + + List med = []; + + List get trialsinfo => med; + + medicalinsightdata() async { + final jsonres = await callapi.getallMedicalInsightdata(); + med = jsonres; + notifyListeners(); + } +} diff --git a/lib/service.dart/service.dart b/lib/service.dart/service.dart index 3098a05..674367f 100644 --- a/lib/service.dart/service.dart +++ b/lib/service.dart/service.dart @@ -152,4 +152,18 @@ class Callapi { print("All_trialsss: $jsontrials"); return jsontrials; } + + getallMedicalInsightdata() async { + // const url = 'http://127.0.0.1:8000/api/users'; + // const url = 'http://192.168.2.143:8082/api/users'; + // const url = 'http://192.168.172.50:8082/api/users'; + // const url = 'http://192.168.172.50:8081/api/users'; + + const url = '$curl/medicalinsight'; + + final response = await Dio().get(url); + + final jsonresponse = response.data; + return jsonresponse; + } } diff --git a/lib/ui_screen/interactionform/model/medical_insight.dart b/lib/ui_screen/interactionform/model/medical_insight.dart new file mode 100644 index 0000000..b151b91 --- /dev/null +++ b/lib/ui_screen/interactionform/model/medical_insight.dart @@ -0,0 +1,60 @@ +// To parse this JSON data, do +// +// final medicalInsight = medicalInsightFromJson(jsonString); + +import 'dart:convert'; + +List medicalInsightFromJson(String str) => + List.from( + json.decode(str).map((x) => MedicalInsight.fromJson(x))); + +String medicalInsightToJson(List data) => + json.encode(List.from(data.map((x) => x.toJson()))); + +class MedicalInsight { + int id; + int interactionId; + String therapeuticArea; + String product; + String sourceType; + String topics; + String hcpName; + DateTime createdAt; + DateTime updatedAt; + + MedicalInsight({ + required this.id, + required this.interactionId, + required this.therapeuticArea, + required this.product, + required this.sourceType, + required this.topics, + required this.hcpName, + required this.createdAt, + required this.updatedAt, + }); + + factory MedicalInsight.fromJson(Map json) => MedicalInsight( + id: json["id"], + interactionId: json["Interaction Id"], + therapeuticArea: json["Therapeutic Area"], + product: json["Product"], + sourceType: json["Source Type"], + topics: json["Topics"], + hcpName: json["HCP Name"], + createdAt: DateTime.parse(json["created_at"]), + updatedAt: DateTime.parse(json["updated_at"]), + ); + + Map toJson() => { + "id": id, + "Interaction Id": interactionId, + "Therapeutic Area": therapeuticArea, + "Product": product, + "Source Type": sourceType, + "Topics": topics, + "HCP Name": hcpName, + "created_at": createdAt.toIso8601String(), + "updated_at": updatedAt.toIso8601String(), + }; +} diff --git a/lib/ui_screen/interactionform/new_dynamicform.dart b/lib/ui_screen/interactionform/new_dynamicform.dart index 848a551..77b2f63 100644 --- a/lib/ui_screen/interactionform/new_dynamicform.dart +++ b/lib/ui_screen/interactionform/new_dynamicform.dart @@ -56,6 +56,8 @@ class _InteractionScreen1State extends State { var item1; + final GlobalKey _formKey = GlobalKey(); + int _currentPage = 0; late int _totalPages = Provider.of(context, listen: false) diff --git a/lib/ui_screen/interactionform/view_forms_list.dart b/lib/ui_screen/interactionform/view_forms_list.dart index 38e8710..fcfc416 100644 --- a/lib/ui_screen/interactionform/view_forms_list.dart +++ b/lib/ui_screen/interactionform/view_forms_list.dart @@ -3,6 +3,7 @@ import 'package:discover_module/ui_screen/interactionform/model/save_interaction import 'package:discover_module/ui_screen/interactionform/util.dart'; import 'package:discover_module/ui_screen/interactionform/view_interaction_screen.dart'; import 'package:discover_module/ui_screen/interactionform/viewinteractionprovider.dart'; +import 'package:discover_module/ui_screen/new_editinteraction.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -99,11 +100,19 @@ class _SavedFormListScreenState extends State { IconButton( onPressed: () async { await provider.initConfigData().then({ + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (BuildContext context) => + // EditInteractionScreen( + // saveInteraction: provider + // .savedList[index], + // ))) Navigator.push( context, MaterialPageRoute( builder: (BuildContext context) => - EditInteractionScreen( + EditInteractionScreen1( saveInteraction: provider .savedList[index], ))) diff --git a/lib/ui_screen/interactionform/widget/interatciontextfield.dart b/lib/ui_screen/interactionform/widget/interatciontextfield.dart index 1ee76b5..1ed9984 100644 --- a/lib/ui_screen/interactionform/widget/interatciontextfield.dart +++ b/lib/ui_screen/interactionform/widget/interatciontextfield.dart @@ -1,3 +1,74 @@ +// import 'package:flutter/material.dart'; +// import 'package:flutter/services.dart'; + +// // ignore: must_be_immutable +// class InteractionTextField extends StatelessWidget { +// String labelText; +// TextEditingController controller; +// String? hintText; +// IconButton? suffixIcon; +// bool? enabled = true; +// bool? obscure = false; +// Function onChanged; +// TextInputType? inputType; +// int? maxchars = 0; +// int? maxlines = 1; +// int? minlines = 0; +// InteractionTextField( +// {super.key, +// required this.controller, +// this.hintText, +// required this.labelText, +// this.suffixIcon, +// this.enabled, +// this.maxchars, +// this.maxlines, +// this.inputType, +// this.minlines, +// required this.onChanged, +// this.obscure}); + +// @override +// Widget build(BuildContext context) { +// return TextField( +// controller: controller, +// style: const TextStyle(fontSize: 16), +// enabled: enabled, +// obscureText: obscure ?? false, +// onTap: () {}, +// maxLines: maxlines ?? 1, +// minLines: minlines, +// keyboardType: inputType ?? TextInputType.name, +// onChanged: (value) { +// onChanged(value); +// }, +// onSubmitted: (value) { +// onChanged(value); +// }, +// inputFormatters: [ +// inputType == TextInputType.number +// ? FilteringTextInputFormatter.digitsOnly +// : maxchars == 0 +// ? LengthLimitingTextInputFormatter(100) +// : LengthLimitingTextInputFormatter(maxchars), +// ], +// decoration: InputDecoration( +// isDense: true, +// // contentPadding: const EdgeInsets.symmetric( +// // horizontal: 10, +// // vertical: 18, +// // ), +// contentPadding: EdgeInsets.all(13.0), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(10.0), +// ), +// suffixIcon: suffixIcon, +// hintText: hintText, +// ), +// ); +// } +// } + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; diff --git a/lib/ui_screen/medical_insight.dart b/lib/ui_screen/medical_insight.dart new file mode 100644 index 0000000..d7e7f45 --- /dev/null +++ b/lib/ui_screen/medical_insight.dart @@ -0,0 +1,926 @@ +// import 'package:discover_module/constants.dart'; +// import 'package:discover_module/provider_class/medicalinsightprovider.dart'; +// import 'package:discover_module/ui_screen/view_insight.dart'; +// import 'package:flutter/cupertino.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter/widgets.dart'; +// import 'package:provider/provider.dart'; + +// class MedicalInsight extends StatefulWidget { +// const MedicalInsight({super.key}); + +// @override +// State createState() => _MedicalInsightState(); +// } + +// class _MedicalInsightState extends State { +// final List> cardData = [ +// {'id': 'ID ', 'number': 'MI1688128025', 'id1': "jjj", 'number1': '265'}, +// {'id': 'ID ', 'number': 20}, +// {'id': 'ID ', 'number': 30}, +// // Add more data entries as needed +// ]; + +// String selectedOption = 'None'; +// late GlobalKey actionKey; + +// var item; + +// @override +// void initState() { +// actionKey = GlobalKey(); +// super.initState(); +// getapicall(); +// } + +// void getapicall() async { +// await Provider.of(context, listen: false) +// .medicalinsightdata(); +// } + +// // GlobalKey actionKey; +// // final List> data = [ +// // {'id': 'Data ID 1', 'number': 10}, +// // {'id': 'Data ID 2', 'number': 20}, +// // {'id': 'Data ID 3', 'number': 30}, +// // // Add more data entries as needed +// // ]; +// @override +// Widget build(BuildContext context) { +// return Directionality( +// textDirection: TextDirection.ltr, +// child: SafeArea( +// child: Scaffold( +// backgroundColor: const Color.fromARGB(255, 222, 237, 247), +// appBar: AppBar( +// title: const Text('Medical Insight'), +// ), +// body: Consumer( +// builder: (context, value, child) { +// return Column( +// children: [ +// Padding( +// padding: const EdgeInsets.all(15.0), +// child: TextField( +// //controller: _searchController, +// onChanged: (value) { +// setState(() {}); +// }, +// decoration: InputDecoration( +// fillColor: Constants.k2color, +// contentPadding: const EdgeInsets.symmetric(vertical: 9.0), +// border: const OutlineInputBorder( +// borderRadius: BorderRadius.only( +// bottomRight: Radius.circular(0))), +// labelText: ' Search', +// prefixIcon: const Icon( +// Icons.search, +// ), +// ), +// ), +// ), +// Row( +// mainAxisAlignment: MainAxisAlignment.end, +// children: [ +// OutlinedButton( +// style: OutlinedButton.styleFrom( +// backgroundColor: Constants.k2color, +// foregroundColor: Colors.white), +// onPressed: () {}, +// child: Text("Create Medical Insight")) +// ], +// ), +// Expanded( +// child: ListView.builder( +// physics: const ScrollPhysics(), +// // scrollDirection: Axis.vertical, +// shrinkWrap: true, +// itemCount: value.med.length, +// itemBuilder: (context, index) { +// item = value.med[index]; + +// print( +// "Item_Medical_insight ${item['Therapeutic Area']}"); +// return GestureDetector( +// onTap: () { +// _showAlertDialog(context); +// }, +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: Card( +// surfaceTintColor: Colors.white, +// // shape: RoundedRectangleBorder( +// // side: BorderSide(color: Colors.black, width: 1), +// // borderRadius: BorderRadius.only( +// // bottomRight: Radius.circular(30)), +// // ), +// child: SizedBox( +// width: MediaQuery.sizeOf(context).width, +// child: ListTile( +// title: Column( +// // crossAxisAlignment: CrossAxisAlignment.center, +// children: [ +// Align( +// alignment: Alignment.centerLeft, +// child: Text( +// "ID", +// style: TextStyle( +// fontSize: 16, +// fontWeight: FontWeight.bold), +// ), +// ), +// Align( +// alignment: Alignment.centerLeft, +// child: Text( +// item['id'].toString(), +// textAlign: TextAlign.left, +// style: const TextStyle(fontSize: 16), +// ), +// ), +// // Row( +// // mainAxisAlignment: +// // MainAxisAlignment.spaceBetween, +// // children: [ +// // Text( +// // "Interaction Id", +// // style: TextStyle( +// // fontSize: 16, +// // fontWeight: FontWeight.bold), +// // ), +// // Text( +// // "pokn".toString(), +// // style: TextStyle(fontSize: 16), +// // ), +// // ], +// // ), + +// Row( +// mainAxisAlignment: +// MainAxisAlignment.spaceBetween, +// children: [ +// const Expanded( +// flex: 1, +// child: Align( +// alignment: Alignment.centerLeft, +// child: Text( +// "Therapeutic Area", +// style: TextStyle( +// fontSize: 16, +// fontWeight: +// FontWeight.bold), +// ), +// ), +// ), +// Expanded( +// flex: 1, +// child: Align( +// alignment: Alignment.centerLeft, +// child: Text( +// item['Therapeutic Area'] +// .toString(), +// style: const TextStyle( +// fontSize: 16), +// ), +// ), +// ) +// ], +// ), +// Row( +// mainAxisAlignment: +// MainAxisAlignment.spaceBetween, +// children: [ +// const Expanded( +// flex: 1, +// child: Align( +// alignment: Alignment.centerLeft, +// child: Text( +// "Product", +// style: TextStyle( +// fontSize: 16, +// fontWeight: +// FontWeight.bold), +// ), +// ), +// ), +// Expanded( +// flex: 1, +// child: Align( +// alignment: Alignment.centerLeft, +// child: Text( +// item['Product'].toString(), +// style: const TextStyle( +// fontSize: 16), +// ), +// ), +// ), +// ], +// ), +// Row( +// mainAxisAlignment: +// MainAxisAlignment.spaceBetween, +// children: [ +// const Expanded( +// flex: 1, +// child: Align( +// alignment: Alignment.centerLeft, +// child: Text( +// "Source Type", +// style: TextStyle( +// fontSize: 16, +// fontWeight: +// FontWeight.bold), +// ), +// )), +// Expanded( +// flex: 1, +// child: Align( +// alignment: Alignment.centerLeft, +// child: Text( +// item['Source Type'].toString(), +// style: const TextStyle( +// fontSize: 16), +// ), +// ), +// ) +// ], +// ), +// Row( +// mainAxisAlignment: +// MainAxisAlignment.spaceBetween, +// children: [ +// const Expanded( +// flex: 1, +// child: Align( +// alignment: Alignment.centerLeft, +// child: Text( +// "Topics", +// style: TextStyle( +// fontSize: 16, +// fontWeight: +// FontWeight.bold), +// ), +// ), +// ), +// Expanded( +// flex: 1, +// child: Align( +// alignment: Alignment.centerLeft, +// child: Text( +// item['Topics'].toString(), +// style: const TextStyle( +// fontSize: 16), +// ), +// ), +// ) +// ], +// ), +// Row( +// children: [ +// Expanded( +// flex: 1, +// child: Column( +// children: [ +// Row( +// children: [ +// Icon( +// Icons.person, +// size: 20, +// ), +// Text( +// "pooja", +// style: TextStyle( +// fontSize: 14.0), +// ) +// ], +// ), +// Row( +// children: [ +// Icon( +// Icons.calendar_today, +// size: 20, +// ), +// Text( +// "11/11/2022 ", +// style: TextStyle( +// fontSize: 14.0), +// ) +// ], +// ) +// ], +// ), +// ), +// Expanded( +// flex: 1, +// child: Align( +// alignment: +// Alignment.centerRight, +// child: OutlinedButton( +// style: +// OutlinedButton.styleFrom( +// shape: +// CircleBorder()), +// onPressed: () { +// // final RenderBox renderBox = +// // actionKey.currentContext! +// // .findRenderObject(); +// // final position = renderBox +// // .localToGlobal(Offset.zero); +// final RenderBox renderBox = +// actionKey +// .currentContext! +// .findRenderObject() +// as RenderBox; +// final position = +// renderBox.localToGlobal( +// Offset.zero); + +// showMenu( +// context: context, +// position: +// RelativeRect.fromLTRB( +// position.dx, +// position.dy + +// renderBox +// .size.height, +// position.dx + +// renderBox +// .size.width, +// position.dy + +// renderBox +// .size.height + +// 10, +// ), +// items: >[ +// PopupMenuItem( +// value: 'Option 1', +// child: +// Text('Option 1'), +// ), +// PopupMenuItem( +// value: 'Option 2', +// child: +// Text('Option 2'), +// ), +// PopupMenuItem( +// value: 'Option 3', +// child: +// Text('Option 3'), +// ), +// ], +// ).then((value) { +// if (value != null) { +// setState(() { +// selectedOption = +// value; +// }); +// } +// }); +// }, +// child: Icon( +// Icons.more_horiz_rounded, +// // color: Constants.k2color, +// ), +// )), +// ) +// ], +// ), +// ], +// ), +// ), +// ), +// // shape: BorderRadius.only(bottomRight: Radius.circular(50)), +// ), +// ), +// ); +// }), +// ) +// ], +// ); +// }), +// ), +// ), +// ); +// } + +// void _showAlertDialog(BuildContext context) { +// showDialog( +// context: context, +// builder: (BuildContext context) { +// return AlertDialog( +// // title: Text('Alert'), +// content: const MyWidget22(), +// actions: [ +// TextButton( +// child: const Text('Close'), +// onPressed: () { +// Navigator.of(context).pop(); +// }, +// ), +// ], +// ); +// }, +// ); +// } +// } + +import 'package:discover_module/constants.dart'; +import 'package:discover_module/provider_class/medicalinsightprovider.dart'; +import 'package:discover_module/ui_screen/view_insight.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:provider/provider.dart'; +import 'package:adoptive_calendar/adoptive_calendar.dart'; + +class MedicalInsight extends StatefulWidget { + const MedicalInsight({super.key}); + + @override + State createState() => _MedicalInsightState(); +} + +class _MedicalInsightState extends State { + final List> cardData = [ + {'id': 'ID ', 'number': 'MI1688128025', 'id1': "jjj", 'number1': '265'}, + {'id': 'ID ', 'number': 20}, + {'id': 'ID ', 'number': 30}, + // Add more data entries as needed + ]; + + String selectedOption = 'None'; + late GlobalKey actionKey; + // DateTime? pickedDate; + + var item; + final TextEditingController textController = TextEditingController(); + + DateTime? selectedDate; + + bool calview = false; + String? start, end; + @override + void initState() { + actionKey = GlobalKey(); + super.initState(); + getapicall(); + } + + void getapicall() async { + await Provider.of(context, listen: false) + .medicalinsightdata(); + } + + // GlobalKey actionKey; + // final List> data = [ + // {'id': 'Data ID 1', 'number': 10}, + // {'id': 'Data ID 2', 'number': 20}, + // {'id': 'Data ID 3', 'number': 30}, + // // Add more data entries as needed + // ]; + @override + Widget build(BuildContext context) { + return Directionality( + textDirection: TextDirection.ltr, + child: SafeArea( + child: Scaffold( + backgroundColor: const Color.fromARGB(255, 222, 237, 247), + appBar: AppBar( + title: const Text('Medical Insight'), + actions: [ + GestureDetector( + onTap: () { + setState(() { + calview = true; + }); + }, + child: Icon(Icons.calendar_month)) + ], + ), + body: Consumer( + builder: (context, value, child) { + return Column( + children: [ + // GestureDetector( + // onTap: () => _selectDate(context), + // child: AbsorbPointer( + // child: TextField( + // controller: textController, + // decoration: InputDecoration( + // focusedBorder: InputBorder.none, + // enabledBorder: InputBorder.none, + // contentPadding: EdgeInsets.all(10.0), + // labelText: "date", + // labelStyle: + // TextStyle(color: Colors.black, fontSize: 16), + // // pass the hint text parameter here + // hintStyle: TextStyle(color: Colors.black, fontSize: 16), + // suffixIcon: Icon(Icons.calendar_today), + // ), + // style: TextStyle(color: Colors.black, fontSize: 18), + // ), + // ), + // ), + Visibility( + visible: calview, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + OutlinedButton( + onPressed: () { + _selectDate(context); + }, + child: + start == null ? Text('Start Date') : Text(start!), + ), + OutlinedButton( + onPressed: () { + _selectDate1(context); + }, + child: end == null ? Text('Start Date') : Text(end!), + ), + ], + ), + ), + + Padding( + padding: const EdgeInsets.all(8.0), + child: TextField( + //controller: _searchController, + onChanged: (value) { + setState(() {}); + }, + decoration: InputDecoration( + fillColor: Constants.k2color, + contentPadding: const EdgeInsets.symmetric(vertical: 9.0), + border: const OutlineInputBorder( + borderRadius: BorderRadius.only( + bottomRight: Radius.circular(0))), + labelText: ' Search', + prefixIcon: const Icon( + Icons.search, + ), + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + OutlinedButton( + style: OutlinedButton.styleFrom( + backgroundColor: Constants.k2color, + foregroundColor: Colors.white), + onPressed: () {}, + child: Text("Create Medical Insight")) + ], + ), + Expanded( + child: ListView.builder( + physics: const ScrollPhysics(), + // scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: value.med.length, + itemBuilder: (context, index) { + item = value.med[index]; + + print( + "Item_Medical_insight ${item['Therapeutic Area']}"); + return GestureDetector( + onTap: () { + _showAlertDialog(context); + }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Card( + surfaceTintColor: Colors.white, + // shape: RoundedRectangleBorder( + // side: BorderSide(color: Colors.black, width: 1), + // borderRadius: BorderRadius.only( + // bottomRight: Radius.circular(30)), + // ), + child: SizedBox( + width: MediaQuery.sizeOf(context).width, + child: ListTile( + title: Column( + // crossAxisAlignment: CrossAxisAlignment.center, + children: [ + // Text( + // "Acute neurology is the therapeutic area of the medical insight for Product A. The age of treatment is the topic of interest for this source type publication."), + + RichText( + text: TextSpan( + text: 'Acute neurology is the', + style: DefaultTextStyle.of(context) + .style, + children: const [ + TextSpan( + text: ' therapeutic area ', + style: TextStyle( + fontWeight: + FontWeight.bold)), + TextSpan( + text: + 'of the medical insight for Product A.'), + TextSpan( + text: 'The age of treatment', + style: TextStyle( + fontWeight: + FontWeight.bold)), + TextSpan( + text: + ' is the topic of interest for this source type'), + TextSpan( + text: ' publication.', + style: TextStyle( + fontWeight: + FontWeight.bold)), + ], + ), + ), + + Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + Row( + children: [ + Icon( + Icons.person, + size: 20, + ), + Text( + "pooja", + style: + TextStyle(fontSize: 14.0), + ) + ], + ), + Row( + children: [ + Icon( + Icons.calendar_today, + size: 20, + ), + Text( + "11/11/2022 ", + style: + TextStyle(fontSize: 14.0), + ) + ], + ) + ], + ), + ), + // Align( + // alignment: Alignment.centerLeft, + // child: Text( + // "Therapeutic Area", + // style: TextStyle( + // fontSize: 12, + // fontWeight: FontWeight.normal), + // ), + // ), + // Align( + // alignment: Alignment.centerLeft, + // child: Text( + // item['Therapeutic Area'].toString(), + // style: const TextStyle(fontSize: 14), + // ), + // ), + // Align( + // alignment: Alignment.centerLeft, + // child: Text( + // "Product", + // style: TextStyle( + // fontSize: 12, + // fontWeight: FontWeight.normal), + // ), + // ), + // Align( + // alignment: Alignment.centerLeft, + // child: Text( + // item['Product'].toString(), + // style: const TextStyle(fontSize: 14), + // ), + // ), + // Align( + // alignment: Alignment.centerLeft, + // child: Text( + // "Source Type", + // style: TextStyle( + // fontSize: 12, + // fontWeight: FontWeight.normal), + // ), + // ), + // Align( + // alignment: Alignment.centerLeft, + // child: Text( + // item['Source Type'].toString(), + // style: const TextStyle(fontSize: 14), + // ), + // ), + // Align( + // alignment: Alignment.centerLeft, + // child: Text( + // "Topics", + // style: TextStyle( + // fontSize: 12, + // fontWeight: FontWeight.normal), + // ), + // ), + // Align( + // alignment: Alignment.centerLeft, + // child: Text( + // item['Topics'].toString(), + // style: const TextStyle(fontSize: 14), + // ), + // ), + // Row( + // children: [ + // Expanded( + // flex: 1, + // child: Column( + // children: [ + // Row( + // children: [ + // Icon( + // Icons.person, + // size: 20, + // ), + // Text( + // "pooja", + // style: TextStyle( + // fontSize: 14.0), + // ) + // ], + // ), + // Row( + // children: [ + // Icon( + // Icons.calendar_today, + // size: 20, + // ), + // Text( + // "11/11/2022 ", + // style: TextStyle( + // fontSize: 14.0), + // ) + // ], + // ) + // ], + // ), + // ), + // Expanded( + // flex: 1, + // child: Align( + // alignment: + // Alignment.centerRight, + // child: OutlinedButton( + // style: + // OutlinedButton.styleFrom( + // shape: + // CircleBorder()), + // onPressed: () { + // // final RenderBox renderBox = + // // actionKey.currentContext! + // // .findRenderObject(); + // // final position = renderBox + // // .localToGlobal(Offset.zero); + // final RenderBox renderBox = + // actionKey + // .currentContext! + // .findRenderObject() + // as RenderBox; + // final position = + // renderBox.localToGlobal( + // Offset.zero); + + // showMenu( + // context: context, + // position: + // RelativeRect.fromLTRB( + // position.dx, + // position.dy + + // renderBox + // .size.height, + // position.dx + + // renderBox + // .size.width, + // position.dy + + // renderBox + // .size.height + + // 10, + // ), + // items: >[ + // PopupMenuItem( + // value: 'Option 1', + // child: + // Text('Option 1'), + // ), + // PopupMenuItem( + // value: 'Option 2', + // child: + // Text('Option 2'), + // ), + // PopupMenuItem( + // value: 'Option 3', + // child: + // Text('Option 3'), + // ), + // ], + // ).then((value) { + // if (value != null) { + // setState(() { + // selectedOption = + // value; + // }); + // } + // }); + // }, + // child: Icon( + // Icons.more_horiz_rounded, + // // color: Constants.k2color, + // ), + // )), + // ) + // ], + // ), + ], + ), + ), + ), + // shape: BorderRadius.only(bottomRight: Radius.circular(50)), + ), + ), + ); + }), + ) + ], + ); + }), + ), + ), + ); + } + + void _showAlertDialog(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + // title: Text('Alert'), + content: const MyWidget22(), + actions: [ + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + + Future _selectDate(BuildContext context) async { + final DateTime? picked = await showDatePicker( + context: context, + initialDate: selectedDate, + firstDate: DateTime(1901, 1), + lastDate: DateTime(2100)); + if (picked != null && picked != selectedDate) + setState(() { + selectedDate = picked; + String convertedDateTime = + "${picked.year.toString()}-${picked.month.toString().padLeft(2, '0')}-${picked.day.toString().padLeft(2, '0')}"; + // widget.textController.value = TextEditingValue(text: picked.toString()); + textController.value = TextEditingValue(text: convertedDateTime); + + start = convertedDateTime; + ; + }); + } + + Future _selectDate1(BuildContext context) async { + final DateTime? picked = await showDatePicker( + context: context, + initialDate: selectedDate, + firstDate: DateTime(1901, 1), + lastDate: DateTime(2100)); + if (picked != null && picked != selectedDate) + setState(() { + selectedDate = picked; + String convertedDateTime = + "${picked.year.toString()}-${picked.month.toString().padLeft(2, '0')}-${picked.day.toString().padLeft(2, '0')}"; + // widget.textController.value = TextEditingValue(text: picked.toString()); + textController.value = TextEditingValue(text: convertedDateTime); + + end = convertedDateTime; + ; + }); + } +} diff --git a/lib/ui_screen/new_editinteraction.dart b/lib/ui_screen/new_editinteraction.dart new file mode 100644 index 0000000..3894a4e --- /dev/null +++ b/lib/ui_screen/new_editinteraction.dart @@ -0,0 +1,1720 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:discover_module/constants.dart'; +import 'package:discover_module/textScalar.dart'; +import 'package:discover_module/ui_screen/interactionform/model/interaction_data.dart'; +import 'package:discover_module/ui_screen/interactionform/model/save_interaction.dart'; +import 'package:discover_module/ui_screen/interactionform/util.dart'; +import 'package:discover_module/ui_screen/interactionform/viewinteractionprovider.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/services.dart'; +import 'package:flutter_carousel_widget/flutter_carousel_widget.dart'; +import 'package:intl/intl.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:provider/provider.dart'; +import 'package:dropdown_button2/dropdown_button2.dart'; + +import 'package:permission_handler/permission_handler.dart'; +// import 'package:pwa_ios/widgets/custombutton.dart'; +// import 'package:pwa_ios/widgets/customrangeslider.dart'; +// import 'package:pwa_ios/widgets/interatciontextfield.dart'; +import 'package:file_picker/file_picker.dart'; +// import 'package:pwa_ios/widgets/responsive_ext.dart'; +import 'package:path/path.dart' as p; + +class EditInteractionScreen1 extends StatefulWidget { + // int index; + // String form; + SaveInteraction saveInteraction; + EditInteractionScreen1( + {super.key, + // required this.index, + // required this.form, + required this.saveInteraction}); + + @override + State createState() => _EditInteractionScreenState(); +} + +class _EditInteractionScreenState extends State { + List interactionReponseList = []; + List sectionList = []; + List textEditingControllerList = []; + int textfieldIndex = 0; + String dropdownvalue = 'Select value'; + String? fileName; + final TextEditingController textEditingController = TextEditingController(); + + final CarouselController _controller = CarouselController(); + + int _currentPage = 0; + late int _totalPages = + Provider.of(context, listen: false) + .interactionReponseList + .length; + + @override + void dispose() { + super.dispose(); + + // WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + // Provider.of(context, listen: false).dispose(); + // }); + } + + @override + void initState() { + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + // initConfig(); + // if (mytimer!.isActive) { + // cancelTimer(); + // } + init(); + }); + + super.initState(); + } + + initConfig() async { + // await Provider.of(context, listen: false) + // .init(widget.index); + await Provider.of(context, listen: false) + .initConfigData(); + + // setState(() {}); + } + + init() async { + // await Provider.of(context, listen: false) + // .init(widget.index); + + await Provider.of(context, listen: false) + .initSavedForm(widget.saveInteraction); + setState(() {}); + } + + @override + Widget build(BuildContext context) { + return Consumer( + builder: (BuildContext context, provider, Widget? child) { + // print("build context"); + // print("Providerr_is: ${provider.multipletextEditingControllerList}"); + return GestureDetector( + onTap: () { + FocusScope.of(context).requestFocus(FocusNode()); + }, + child: OrientationBuilder(builder: (context, orientation) { + return SafeArea( + child: Scaffold( + appBar: AppBar( + title: Text( + widget.saveInteraction.id, + style: TextStyle( + fontSize: isTablet ? 22 : 14, color: Colors.white), + ), + // backgroundColor: const Color(0xFF2b9af3), + automaticallyImplyLeading: false, + actions: [saveActions(provider)], + leading: InkWell( + onTap: () async { + await provider.disposeValues().then((value) { + Navigator.pop(context); + }); + }, + child: const Icon( + Icons.arrow_back_ios, + color: Colors.white, + ), + ), + ), + body: Column( + mainAxisSize: MainAxisSize.min, + 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; + child: 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}"); + return ListView( + children: [ + Container( + //elevation: 4, + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(0.0), + // ), + color: Constants.k2color, + child: ExpansionTile( + maintainState: true, + // backgroundColor: Colors.white, + backgroundColor: Constants.k2color, + + // 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.bold, + fontSize: 18.0), + )), + item.multiple + ? Align( + alignment: + Alignment.centerRight, + child: IconButton( + onPressed: () { + provider.getSectionItem( + item.sectionName); + // print("index is $listIndex"); + setState(() { + // for (var item + }); + }, + icon: const Icon( + Icons.add_circle_outline, + size: 30, + color: Colors.white, + ), + ), + ) + : const SizedBox.shrink() + ]), + children: [ + Container( + color: Colors.white, + child: Padding( + padding: + const EdgeInsets.only(top: 8.0), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + GridView.count( + physics: + const NeverScrollableScrollPhysics(), + // crossAxisCount: + // context.responsive( + // 1, + // sm: 1, // small + // md: 1, // medium + // lg: sectionList.length == 1 + // ? 1 + // : 4, // large + // xl: 3, // extra large screen + // ), + crossAxisCount: + context.responsive( + 1, + sm: 1, // small + md: 2, // medium + lg: sectionList.length == 1 + ? 1 + : 3, // large + xl: 3, // extra large screen + ), + mainAxisSpacing: + sectionList.length == 1 || + !isTablet + ? 1 + : 3.5, + shrinkWrap: true, + padding: EdgeInsets.zero, + + childAspectRatio: + sectionList.length == 1 + ? orientation == + Orientation + .landscape + ? 10 + : 4.8 + : isTablet + ? 2.8 + : 3.5, + children: List.generate( + sectionList.length, + (i) { + // print(sectionList); + SectionList sectionItem = + sectionList[i]; + dropdownvalue = sectionItem + .widget == + InteractionWidget + .DROPDOWN + ? sectionItem.value ?? + "Select" + : ' '; + List< + InputClass> list = sectionItem + .widget == + InteractionWidget + .DROPDOWN || + sectionItem + .widget == + InteractionWidget + .AUTOCOMPLETE || + sectionItem + .widget == + InteractionWidget + .MULTISELECT + ? provider.getData2( + sectionItem) + : []; + provider.checkboxlist = + sectionItem.widget == + InteractionWidget + .CHECKBOX + ? provider.getData2( + sectionItem) + : []; + + return Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + sectionItem.widget == + InteractionWidget + .BUTTON && + sectionItem + .input == + 'add' + ? const SizedBox + .shrink() + : Padding( + padding: + const EdgeInsets + .only( + left: + 8.0, + right: + 8.0), + // child: Text( + // '${sectionItem.name}:*', + // style: TextStyle( + // color: Colors + // .orange + // .shade800, + // fontSize: + // isTablet + // ? 18 + // : 12, + // ), + // ), + child: Text( + sectionItem + .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: 0, + widgetData: + sectionItem + .widget!, + multiple: false), + // SizedBox( + // height: isTablet ? 15 : 5, + // ), + ], + ); + }, + ), + ), + // SizedBox( + // height: isTablet ? 15 : 5, + // ), + item.multiple + ? gridViewWidget( + provider, + item.sectionName, + item.multipleList ?? [], + orientation, + item, + 0) + : const SizedBox.shrink(), + provider.interactionReponseList + .length == + 0 - 1 + ? saveActions(provider) + : const SizedBox.shrink() + //const Spacer(), + ], + ), + ), + ), + ]), + ), + ], + ); + }).toList(), + ), + ), + // const Spacer(), + // saveActions(provider), + + 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, + ), + ), + ), + ), + ], + ), + ), + ), + ], + )), + ); + }), + ); + }); + } + + Widget returnWidget({ + required SectionList sectionItem, + required FormFieldData item, + required ViewInteractionProvider 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: + print("Radiiooooo"); + 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( + sliderPos: sectionItem.selectedValue!.isNotEmpty + ? double.parse(sectionItem.selectedValue!.last.toString()) + : 10.0, + 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 { + if (sectionItem.selectedValue!.isNotEmpty) { + showFilesAlertDialog(context, + sectionItem.fileName!.join(','), sectionItem); + } else { + sectionItem.selectedValue = []; + sectionItem.extension = []; + sectionItem.fileName = []; + await getEncodedFile(sectionItem); + } + + setState(() {}); + }, + width: 120, + height: 40, + fontsize: 12, + textColor: Colors.black, + title: sectionItem.name), + const SizedBox( + width: 5, + ), + Text( + sectionItem.selectedValue!.isNotEmpty + ? 'File Uploaded' + : 'No file uploaded', + style: TextStyle( + color: sectionItem.selectedValue!.isNotEmpty + ? Colors.green + : Colors.red), + ), + ], + ); + + 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.chars ?? "0"), + controller: sectionItem.controller!, + labelText: sectionItem.name, + // maxlines: 4, + // minlines: 3, + onChanged: (val) { + sectionItem.selectedValue = []; + setState(() {}); + + sectionItem.selectedValue!.add(val); + }, + ), + ), + ) + : Expanded( + child: Padding( + padding: const EdgeInsets.only(left: 8.0, right: 8.0), + child: SizedBox( + // width: isTablet ? 200 : MediaQuery.of(context).size.width, + width: MediaQuery.of(context).size.width, + + height: isTablet ? 50 : 40, + child: InteractionTextField( + maxchars: int.parse(sectionItem.chars ?? "0"), + controller: sectionItem.controller!, + inputType: sectionItem.input == "number" + ? TextInputType.number + : TextInputType.name, + labelText: sectionItem.name, + onChanged: (val) { + sectionItem.selectedValue = []; + provider.setTextValue(val, sectionItem, multiple); + }, + ), + ), + ), + ); + case InteractionWidget.DROPDOWN: + // return customdropdown(sectionItem, provider, list, multiple); + + return customAutoCompletedropdown( + sectionItem, provider, list, multiple); + } + } + + 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, + width: MediaQuery.of(context).size.width, + + // height: isTablet ? 50 : 40, + 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(ViewInteractionProvider 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.green.shade500, + onPressed: () async { + // if (textFieldsValidation(provider).isEmpty) { + await provider.saveJsonObject(context, + widget.saveInteraction.intId, widget.saveInteraction); + + // 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)); + // } + }, + textColor: Colors.white, + title: "Update", + // height: 40, + // width: isTablet ? 120 : 80, + height: MediaQuery.of(context).size.height * 0.2, + + fontsize: isTablet ? 16 : 12, + ), + ), + SizedBox( + width: isTablet ? 20 : 2, + ), + ], + ), + ); + } + + Widget buildRadio(SectionList sectionItem, ViewInteractionProvider 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, + ViewInteractionProvider 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: [ + CheckboxListTile( + dense: true, + 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, + ViewInteractionProvider provider, List list, bool multiple) { + // sectionItem.value = ''; + // print("%%%%${sectionItem.selectedValue!.last}"); + print("ItemList_is: $list"); + if (list.isEmpty) { + print("###list empty###"); + 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: isTablet ? 200 : MediaQuery.of(context).size.width, + // height: isTablet ? 60 : 40, + width: MediaQuery.of(context).size.width, + + child: DropdownButtonFormField2( + isExpanded: true, + decoration: InputDecoration( + isDense: true, + // Add Horizontal padding using menuItemStyleData.padding so it matches + // the menu padding when button's width is not specified. + contentPadding: const EdgeInsets.symmetric(vertical: 5), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(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.selectedValue!.isNotEmpty + ? list[list.indexWhere( + (element) => element.id == sectionItem.selectedValue!.last, + )] + : 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, value); + print("selected ${sectionItem.value}"); + // setState(() {}); + }, + onSaved: (value) { + sectionItem.selectedObject = value!; + sectionItem.value = value.id; + provider.setDropDownValue(value.id, sectionItem, multiple, value); + // setState(() {}); + }, + buttonStyleData: const ButtonStyleData( + padding: EdgeInsets.only(right: 8), + ), + iconStyleData: const IconStyleData( + icon: Icon( + Icons.arrow_drop_down, + color: Colors.black45, + ), + iconSize: 24, + ), + dropdownStyleData: DropdownStyleData( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + ), + ), + menuItemStyleData: const MenuItemStyleData( + padding: EdgeInsets.symmetric(horizontal: 16), + ), + ), + ), + ); + } + + Widget customAutoCompletedropdown(SectionList sectionItem, + ViewInteractionProvider provider, List list, bool multiple) { + // sectionItem.value = list[0].name; + 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, + + child: DropdownButtonHideUnderline( + child: DropdownButtonFormField2( + isExpanded: true, + decoration: InputDecoration( + // Add Horizontal padding using menuItemStyleData.padding so it matches + // the menu padding when button's width is not specified. + contentPadding: const EdgeInsets.symmetric(vertical: 5), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + ), + // 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), + ), + ), + ), + ), + 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, + ViewInteractionProvider 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, + + child: DropdownButtonHideUnderline( + child: DropdownButtonFormField2( + isExpanded: true, + decoration: InputDecoration( + isDense: true, + // Add Horizontal padding using menuItemStyleData.padding so it matches + // the menu padding when button's width is not specified. + contentPadding: const EdgeInsets.symmetric(vertical: 5), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + ), + // 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( + // ViewInteractionProvider provider, + // String sectionName, + // List sectionList, + // Orientation orientation, + // FormFieldData item, + // int listIndex) { + // print("SectionListtt:isss: $sectionList"); + // return Padding( + // padding: isTablet + // ? const EdgeInsets.only(left: 8.0) + // : const EdgeInsets.only(left: 12.0, right: 12.0), + // child: GridView.count( + // physics: const NeverScrollableScrollPhysics(), + // crossAxisCount: context.responsive( + // 1, // default + // sm: 1, // small + // md: 1, // medium + // lg: sectionList.length == 1 ? 1 : 4, // large + // xl: 5, // extra large screen + // ), + // mainAxisSpacing: sectionList.length == 1 || !isTablet ? 1 : 2, + // shrinkWrap: true, + // padding: EdgeInsets.zero, + // childAspectRatio: sectionList.length == 1 || !isTablet + // ? orientation == Orientation.landscape + // ? 10 + // : 4.2 + // : 1.8, + // children: List.generate( + // sectionList.length, + // (i) { + // // print(sectionList); + // SectionList sectionItem = sectionList[i]; + // dropdownvalue = sectionItem.widget == InteractionWidget.DROPDOWN + // ? sectionItem.value ?? "Select" + // : ' '; + // List list = + // sectionItem.widget == InteractionWidget.DROPDOWN || + // sectionItem.widget == InteractionWidget.AUTOCOMPLETE || + // sectionItem.widget == InteractionWidget.MULTISELECT + // ? provider.getData2(sectionItem) + // : []; + // provider.checkboxlist = + // sectionItem.widget == InteractionWidget.CHECKBOX + // ? provider.getData2(sectionItem) + // : []; + + // return Wrap(children: [ + // Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // sectionItem.widget == InteractionWidget.BUTTON && + // sectionItem.param == 'add' || + // sectionItem.param == 'deletebtn' + // ? const SizedBox.shrink() + // : Text( + // '${sectionItem.name}:*', + // style: TextStyle( + // color: Colors.orange.shade800, + // fontSize: isTablet ? 18 : 14, + // ), + // ), + // const SizedBox( + // height: 15, + // ), + // sectionItem.widget == InteractionWidget.BUTTON + // ? sectionItem.input == 'chooseFile' + // ? Row( + // children: [ + // CustomButton( + // backgroundColor: const Color.fromARGB( + // 255, 233, 229, 229), + // onPressed: () async { + // if (sectionItem + // .selectedValue!.isNotEmpty) { + // showFilesAlertDialog( + // context, + // sectionItem.fileName!.join(','), + // sectionItem); + // } else { + // sectionItem.selectedValue = []; + // sectionItem.extension = []; + // sectionItem.fileName = []; + // await getEncodedFile(sectionItem); + // } + // setState(() {}); + // }, + // width: 120, + // height: 40, + // fontsize: 12, + // textColor: Colors.black, + // title: sectionItem.name), + // const SizedBox( + // width: 5, + // ), + // Text( + // sectionItem.selectedValue!.isNotEmpty + // ? 'File uploaded' + // : 'No file uploaded', + // style: TextStyle( + // color: + // sectionItem.selectedValue!.isNotEmpty + // ? Colors.green + // : Colors.red), + // ), + // ], + // ) + // : isTablet + // ? IconButton( + // onPressed: () { + // provider.deleteMultipleRows( + // sectionItem.gid!, + // sectionList[i], + // sectionName); + + // setState(() {}); + // }, + // icon: const Icon( + // Icons.cancel, + // size: 30, + // color: Color.fromARGB(255, 8, 39, 92), + // ), + // ) + // : Padding( + // padding: + // const EdgeInsets.only(left: 3.0, top: 5), + // child: CustomButton( + // backgroundColor: const Color.fromARGB( + // 255, 233, 75, 75), + // onPressed: () { + // provider.deleteMultipleRows( + // sectionItem.gid!, + // sectionList[i], + // sectionName); + + // setState(() {}); + // }, + // width: 80, + // height: 30, + // fontsize: 12, + // textColor: Colors.white, + // title: "Delete"), + // ) + // : returnWidget( + // sectionItem: sectionItem, + // item: item, + // provider: provider, + // list: list, + // gridIndex: i, + // listIndex: listIndex, + // widgetData: sectionItem.widget!, + // multiple: true), + // ], + // ), + // ]); + // }, + // ), + // ), + // ); + // } + + Widget gridViewWidget( + ViewInteractionProvider provider, + String sectionName, + List sectionList, + Orientation orientation, + FormFieldData item, + int listIndex) { + print("SectionListtt:isss: $sectionList"); + + List pooja = sectionList; + + print("Pooja: $pooja"); + + List> convertedArray = []; + print("Provider Length: ${item.sectionList.length}"); + + for (int i = 0; i < sectionList.length; i += item.sectionList.length + 1) { + print("Section List11111: $sectionList"); + print("item.sectionList.length List11111: ${item.sectionList.length}"); + + convertedArray + .add(sectionList.sublist(i, i + item.sectionList.length + 1)); + } + print("ConvertedArrayEditMulti.leangth: $convertedArray"); + print("ConvertedArray.leangth: ${convertedArray.length}"); + return 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) + : []; + + 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, + ), + )), + const SizedBox( + height: 15, + ), + sectionItem.widget == InteractionWidget.BUTTON + ? sectionItem.input == 'chooseFile' + ? Row( + children: [ + CustomButton( + backgroundColor: + const Color.fromARGB( + 255, 233, 229, 229), + onPressed: () async { + if (sectionItem.selectedValue! + .isNotEmpty) { + showFilesAlertDialog( + context, + sectionItem.fileName! + .join(','), + sectionItem); + } else { + sectionItem.selectedValue = + []; + sectionItem.extension = []; + sectionItem.fileName = []; + await getEncodedFile( + sectionItem); + } + setState(() {}); + }, + width: 120, + height: 40, + fontsize: 12, + textColor: Colors.black, + title: sectionItem.name), + const SizedBox( + width: 5, + ), + Text( + sectionItem + .selectedValue!.isNotEmpty + ? 'File uploaded' + : 'No file uploaded', + style: TextStyle( + color: sectionItem + .selectedValue! + .isNotEmpty + ? Colors.green + : Colors.red), + ), + ], + ) + : isTablet + ? IconButton( + onPressed: () { + provider.deleteMultipleRows( + sectionItem.gid!, + sectionList[i], + sectionName); + + setState(() {}); + }, + icon: const Icon( + Icons.cancel, + size: 30, + color: Color.fromARGB( + 255, 8, 39, 92), + ), + ) + : Padding( + padding: const EdgeInsets.only( + left: 8.0, right: 8.0), + 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), + ], + ), + ); + }), + ], + ), + ), + ], + ); + } + + String textFieldsValidation(ViewInteractionProvider provider) { + if (provider.sectionList + .any((element) => element.controller!.text.isEmpty)) { + return 'Fields cannot be empty'; + } + if (provider.textEditingControllerList.isNotEmpty) { + if (provider.validateTextFields()) { + return 'Fields cannot be empty'; + } + } + if (provider.multipletextEditingControllerList.isNotEmpty) { + if (provider.validateMultipleRows()) { + return 'Fields cannot be empty'; + } + } + + return ''; + } + + _displaySnackBar(String msg) { + final snackBar = SnackBar( + content: Text( + msg, + style: const TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold), + )); + ScaffoldMessenger.of(context).showSnackBar(snackBar); + //scaffoldKeyLogin.currentState!.showSnackBar(snackBar); + } + + Future getEncodedFile(SectionList sectionItem) async { + String base64Image = ''; + var status = Platform.isAndroid + ? await Permission.manageExternalStorage.status + : await Permission.storage.status; + if (status.isGranted) { + FilePickerResult? result = + await FilePicker.platform.pickFiles(allowMultiple: true); + + if (result != null) { + print(result.files.first.path); + print(result.files.last.path); + for (var files in result.files) { + File file = File(files.path!); + print("check file path : ${file.path}"); + fileName = file.path.split('/').last; + // Get the application folder directory + Directory? directory = Platform.isAndroid + ? await getExternalStorageDirectory() //FOR ANDROID + : await getApplicationDocumentsDirectory(); + String newPath = ""; //FOR ios + String convertedDirectoryPath = (directory?.path).toString(); + + print("see the converted directory path $convertedDirectoryPath"); + + newPath = "$convertedDirectoryPath/konectar/files"; + print("new path :$newPath"); + directory = Directory(newPath); + if (!await directory.exists()) { + await directory.create(recursive: true); + } + File newFile = await file.copy('${directory.path}/$fileName'); + print("new path is ${newFile.path}"); + final extension = p.extension(newFile.path); + List imageBytes = await newFile.readAsBytes(); + Uint8List imageUint8List = Uint8List.fromList(imageBytes); + base64Image = base64Encode(imageUint8List); + sectionItem.selectedValue!.add(base64Image); + sectionItem.extension!.add(extension); + sectionItem.fileName!.add(fileName); + } + } + } else { + print("not permitted"); + await requestPermission(Platform.isAndroid + ? Permission.manageExternalStorage + : Permission.storage); + } + } + + Future requestPermission(Permission permission) async { + final status = await permission.request(); + + setState(() { + print(status); + }); + } + + showAlertDialog(BuildContext context, String record) { + // set up the buttons + // ViewInteractionProvider provider = + // Provider.of(context, listen: false); + Widget cancelButton = TextButton( + child: const Text("Ok"), + onPressed: () async { + Navigator.of(context).pop(); + Navigator.of(context).pop(); + }, + ); + + // set up the AlertDialog + AlertDialog alert = AlertDialog( + title: const Text(""), + content: Text("Form $record Updated Successfully!"), + actions: [ + cancelButton, + ], + ); + + // show the dialog + showDialog( + context: context, + builder: (BuildContext context) { + return alert; + }, + ); + } + + 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 + // ViewInteractionProvider provider = + // Provider.of(context, listen: false); + Widget cancelButton = TextButton( + child: const Text("Upload"), + onPressed: () async { + Navigator.of(context).pop(); + sectionItem.selectedValue = []; + sectionItem.extension = []; + sectionItem.fileName = []; + await getEncodedFile(sectionItem); + }, + ); + Widget okButton = TextButton( + child: const Text("Cancel"), + onPressed: () async { + Navigator.of(context).pop(); + }, + ); + // set up the AlertDialog + AlertDialog alert = AlertDialog( + title: const Text(""), + content: Text( + "Following File(s) $files uploaded .Do you still want to upload files ?", + style: const TextStyle(fontSize: 15), + ), + actions: [cancelButton, okButton], + ); + + // show the dialog + showDialog( + context: context, + builder: (BuildContext context) { + return alert; + }, + ); + } +} diff --git a/lib/ui_screen/new_profile.dart b/lib/ui_screen/new_profile.dart index 3de4d19..6362626 100644 --- a/lib/ui_screen/new_profile.dart +++ b/lib/ui_screen/new_profile.dart @@ -17,6 +17,7 @@ import 'package:discover_module/ui_screen/interactionform/model/save_interaction import 'package:discover_module/ui_screen/interactionform/view_forms_list.dart'; import 'package:discover_module/ui_screen/interactionform/view_interaction_screen.dart'; import 'package:discover_module/ui_screen/interactionform/viewinteractionprovider.dart'; +import 'package:discover_module/ui_screen/new_editinteraction.dart'; import 'package:discover_module/ui_screen/newformlist.dart'; import 'package:discover_module/ui_screen/publication_data.dart'; import 'package:expandable/expandable.dart'; @@ -1607,7 +1608,7 @@ class _NewProfileState extends State { Navigator.push( context, MaterialPageRoute( - builder: (BuildContext context) => EditInteractionScreen( + builder: (BuildContext context) => EditInteractionScreen1( saveInteraction: provider.savedList[index], ))) }); diff --git a/lib/ui_screen/newformlist.dart b/lib/ui_screen/newformlist.dart index 3dff141..02f0ed5 100644 --- a/lib/ui_screen/newformlist.dart +++ b/lib/ui_screen/newformlist.dart @@ -5,6 +5,7 @@ import 'package:discover_module/ui_screen/interactionform/interactionprovider.da 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:discover_module/ui_screen/medical_insight.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; @@ -160,25 +161,7 @@ class _FormListState extends State { }, 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( @@ -199,6 +182,26 @@ class _FormListState extends State { ), const Divider(), + + ListTile( + title: const Text( + "Medical Insight", + style: TextStyle(fontSize: 18.0), + ), + onTap: () async { + final ConfigDataProvider configDataProvider = + ConfigDataProvider(); + + await configDataProvider.initConfigUIDataMedical(); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + const MedicalInsight())); + }, + trailing: Icon(Icons.arrow_forward_ios), + ), + const Divider(), ], ); }) @@ -283,6 +286,23 @@ class _FormListState extends State { trailing: const Icon(Icons.arrow_forward_ios), ), Divider(), + ListTile( + title: const Text( + "Medical Insight", + style: TextStyle(fontSize: 18.0), + ), + onTap: () async { + final ConfigDataProvider configDataProvider = + ConfigDataProvider(); + await configDataProvider.initConfigUIDataEng(); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const MedicalInsight())); + }, + trailing: const Icon(Icons.arrow_forward_ios), + ), + Divider(), ], ), ), diff --git a/lib/ui_screen/view_insight.dart b/lib/ui_screen/view_insight.dart new file mode 100644 index 0000000..793e606 --- /dev/null +++ b/lib/ui_screen/view_insight.dart @@ -0,0 +1,94 @@ +import 'package:discover_module/constants.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class MyWidget22 extends StatefulWidget { + const MyWidget22({super.key}); + + @override + State createState() => _MyWidget22State(); +} + +class _MyWidget22State extends State { + final List> cardData = [ + {'id': 'ID ', 'number': 10, 'id1': "jjj", 'number1': '265'}, + {'id': 'ID ', 'number': 20}, + {'id': 'ID ', 'number': 30}, + // Add more data entries as needed + ]; + @override + Widget build(BuildContext context) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + ListTile( + title: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Icon( + Icons.edit, + color: Constants.k2color, + ) + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + cardData[0]['id'], + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + Text( + cardData[0]['number'].toString(), + style: TextStyle(fontSize: 16), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Interaction Id", + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + Text( + cardData[0]['number'].toString(), + style: TextStyle(fontSize: 16), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Therapeutic Area", + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + Text( + cardData[0]['number'].toString(), + style: TextStyle(fontSize: 16), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Product", + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + Text( + cardData[0]['number'].toString(), + style: TextStyle(fontSize: 16), + ), + ], + ), + ], + ), + ), + ], + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 3940f2c..6a56b0c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -9,6 +9,14 @@ packages: url: "https://pub.dev" source: hosted version: "67.0.0" + adoptive_calendar: + dependency: "direct main" + description: + name: adoptive_calendar + sha256: "504abaacaba8f433a9d829d74153bf365fe330b7b40760e525a3445f593181c3" + url: "https://pub.dev" + source: hosted + version: "0.1.8" analyzer: dependency: transitive description: @@ -816,6 +824,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.3.0+1" + popup_menu: + dependency: "direct main" + description: + name: popup_menu + sha256: a6d7f39669cd010818063233f287822d4fcfcdc1d872b4bae72d9f3caf848e3a + url: "https://pub.dev" + source: hosted + version: "2.0.0" provider: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 1e114e2..3b3b408 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -63,6 +63,8 @@ dependencies: expandable: ^5.0.1 flutter_carousel_widget: ^2.2.0 carousel_slider: ^4.2.1 + popup_menu: ^2.0.0 + adoptive_calendar: ^0.1.8