DiscoverModule/lib/ui_screen/newformlist.dart

437 lines
17 KiB
Dart
Raw Normal View History

2024-05-20 10:29:02 +00:00
import 'package:discover_module/ui_screen/interactionform/configprovider.dart';
2024-07-08 04:58:57 +00:00
import 'package:discover_module/ui_screen/interactionform/interaction_screen.dart';
2024-05-20 10:29:02 +00:00
import 'package:discover_module/ui_screen/interactionform/interactionlistscreen.dart';
2024-07-05 08:48:29 +00:00
import 'package:discover_module/ui_screen/interactionform/interactionprovider.dart';
2024-07-08 04:58:57 +00:00
import 'package:discover_module/ui_screen/interactionform/model/save_interaction.dart';
import 'package:discover_module/ui_screen/interactionform/view_forms_list.dart';
2024-05-20 10:29:02 +00:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
2024-07-05 08:48:29 +00:00
import 'package:provider/provider.dart';
2024-05-20 10:29:02 +00:00
class FormList extends StatefulWidget {
const FormList({super.key});
@override
State<FormList> createState() => _FormListState();
}
class _FormListState extends State<FormList> {
2024-07-08 04:58:57 +00:00
List<SaveInteraction> savedList = [];
2024-07-05 08:48:29 +00:00
@override
void initState() {
2024-07-08 04:58:57 +00:00
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
// if (!mytimer!.isActive) {
// activateTimer();
// }
print("interactionListt");
init();
});
2024-07-05 08:48:29 +00:00
super.initState();
2024-07-08 04:58:57 +00:00
}
2024-07-05 08:48:29 +00:00
2024-07-08 04:58:57 +00:00
init() async {
print("init");
await Provider.of<InteractionProvider>(context, listen: false)
.initConfigData();
print("init1");
await Provider.of<InteractionProvider>(context, listen: false).getRecords();
print("init2");
//setState(() {});
2024-07-05 08:48:29 +00:00
}
2024-07-08 04:58:57 +00:00
Future<int> getCount(String form, InteractionProvider provider) async {
await provider.getRecords();
2024-07-05 08:48:29 +00:00
2024-07-08 04:58:57 +00:00
return provider.savedList.where((element) => element.form == form).length;
2024-07-05 08:48:29 +00:00
}
2024-05-20 10:29:02 +00:00
@override
Widget build(BuildContext context) {
2024-07-08 04:58:57 +00:00
return Consumer<InteractionProvider>(
builder: (BuildContext context, provider, Widget? child) {
return SafeArea(
child: Scaffold(
appBar: AppBar(
title: Text("Form List"),
),
body: provider.intConfigDataList.length == 1
? ListView.builder(
itemCount: provider.intConfigDataList.length,
cacheExtent: double.parse(
provider.intConfigDataList.length.toString()),
itemBuilder: (context, index) {
print("checkkkk");
return Column(
children: [
ListTile(
title: const Text(
"Add My Event",
style: TextStyle(fontSize: 18.0),
),
onTap: () async {
final ConfigDataProvider configDataProvider =
ConfigDataProvider();
await configDataProvider.initConfigUIData123();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const InteractionListScreen()));
// Navigator.push(context,
// MaterialPageRoute(builder: (context) => AddEventScreen()));
},
trailing: const Icon(Icons.arrow_forward_ios),
),
Divider(),
// ListTile(
// title: const Text(
// "Interaction",
// style: TextStyle(fontSize: 18.0),
// ),
// onTap: () async {
// print("I am Interaction");
// final ConfigDataProvider configDataProvider =
// ConfigDataProvider();
// await configDataProvider.initConfigUIData();
// // Navigator.push(context, MaterialPageRoute(builder: (context)))=> InteractionScreen();
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => InteractionListScreen()));
// },
// trailing: const Icon(Icons.arrow_forward_ios),
// ),
ListTile(
title: const Text(
"Interaction",
style: TextStyle(fontSize: 18.0),
),
onTap: () async {
print(
"I am Interaction:${index}, ${provider.intConfigDataList[index].name}");
// final ConfigDataProvider configDataProvider =
// ConfigDataProvider();
// await configDataProvider.initConfigUIData();
// // Navigator.push(context, MaterialPageRoute(builder: (context)))=> InteractionScreen();
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => InteractionListScreen()));
if (provider.intConfigDataList.length == 1) {
setState(() {});
final ConfigDataProvider configDataProvider =
ConfigDataProvider();
await configDataProvider.initConfigUIData();
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
InteractionScreen(
index: index,
form: provider
.intConfigDataList[index].name,
)));
} else {
final ConfigDataProvider configDataProvider =
ConfigDataProvider();
await configDataProvider.initConfigUIData();
// Navigator.push(context, MaterialPageRoute(builder: (context)))=> InteractionScreen();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
InteractionListScreen()));
}
},
trailing: const Icon(Icons.arrow_forward_ios),
),
const Divider(),
ListTile(
title: const Text(
"New Medical Insight",
style: TextStyle(fontSize: 18.0),
),
onTap: () async {
final ConfigDataProvider configDataProvider =
ConfigDataProvider();
await configDataProvider.initConfigUIDataMedical();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const InteractionListScreen()));
},
trailing: Icon(Icons.arrow_forward_ios),
),
Divider(),
ListTile(
title: const Text(
"Engagement",
style: TextStyle(fontSize: 18.0),
),
onTap: () async {
final ConfigDataProvider configDataProvider =
ConfigDataProvider();
await configDataProvider.initConfigUIDataEng();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const InteractionListScreen()));
},
trailing: const Icon(Icons.arrow_forward_ios),
),
const Divider(),
],
);
})
: ListView(
children: [
ListTile(
title: const Text(
"Add My Event",
style: TextStyle(fontSize: 18.0),
),
onTap: () async {
final ConfigDataProvider configDataProvider =
ConfigDataProvider();
await configDataProvider.initConfigUIData123();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const InteractionListScreen()));
// Navigator.push(context,
// MaterialPageRoute(builder: (context) => AddEventScreen()));
},
trailing: const Icon(Icons.arrow_forward_ios),
),
Divider(),
ListTile(
title: const Text(
"Interaction",
style: TextStyle(fontSize: 18.0),
),
onTap: () async {
print("I am Interaction");
final ConfigDataProvider configDataProvider =
ConfigDataProvider();
await configDataProvider.initConfigUIData();
// Navigator.push(context, MaterialPageRoute(builder: (context)))=> InteractionScreen();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => InteractionListScreen()));
},
trailing: const Icon(Icons.arrow_forward_ios),
),
const Divider(),
ListTile(
title: const Text(
"New Medical Insight",
style: TextStyle(fontSize: 18.0),
),
onTap: () async {
final ConfigDataProvider configDataProvider =
ConfigDataProvider();
await configDataProvider.initConfigUIDataMedical();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const InteractionListScreen()));
},
trailing: Icon(Icons.arrow_forward_ios),
),
Divider(),
ListTile(
title: const Text(
"Engagement",
style: TextStyle(fontSize: 18.0),
),
onTap: () async {
final ConfigDataProvider configDataProvider =
ConfigDataProvider();
await configDataProvider.initConfigUIDataEng();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const InteractionListScreen()));
},
trailing: const Icon(Icons.arrow_forward_ios),
),
Divider(),
],
),
2024-06-10 11:11:00 +00:00
),
2024-07-08 04:58:57 +00:00
);
});
2024-05-20 10:29:02 +00:00
}
}
2024-07-08 04:58:57 +00:00
// import 'package:discover_module/ui_screen/interactionform/configprovider.dart';
// import 'package:discover_module/ui_screen/interactionform/interactionlistscreen.dart';
// import 'package:discover_module/ui_screen/interactionform/interactionprovider.dart';
// import 'package:flutter/cupertino.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter/widgets.dart';
// import 'package:provider/provider.dart';
// class FormList extends StatefulWidget {
// const FormList({super.key});
// @override
// State<FormList> createState() => _FormListState();
// }
// class _FormListState extends State<FormList> {
// var formdata;
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// idata();
// }
// idata() {
// var iprovider = Provider.of<InteractionProvider>(context, listen: false);
// setState(() {
// formdata = iprovider.intConfigDataList;
// });
// }
// @override
// Widget build(BuildContext context) {
// return SafeArea(
// child: Scaffold(
// appBar: AppBar(
// title: Text("Form List"),
// ),
// body: ListView(
// children: [
// ListTile(
// title: const Text(
// "Add My Event",
// style: TextStyle(fontSize: 18.0),
// ),
// onTap: () async {
// final ConfigDataProvider configDataProvider =
// ConfigDataProvider();
// await configDataProvider.initConfigUIData123();
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => const InteractionListScreen()));
// // Navigator.push(context,
// // MaterialPageRoute(builder: (context) => AddEventScreen()));
// },
// trailing: const Icon(Icons.arrow_forward_ios),
// ),
// Divider(),
// // ListTile(
// // title: const Text(
// // "Interaction",
// // style: TextStyle(fontSize: 18.0),
// // ),
// // onTap: () async {
// // print("I am Interaction");
// // final ConfigDataProvider configDataProvider =
// // ConfigDataProvider();
// // await configDataProvider.initConfigUIData();
// // // Navigator.push(context, MaterialPageRoute(builder: (context)))=> InteractionScreen();
// // Navigator.push(
// // context,
// // MaterialPageRoute(
// // builder: (context) => InteractionListScreen()));
// // },
// // trailing: const Icon(Icons.arrow_forward_ios),
// // ),
// ListTile(
// title: const Text(
// "Interaction",
// style: TextStyle(fontSize: 18.0),
// ),
// onTap: () async {
// print("I am Interaction");
// final ConfigDataProvider configDataProvider =
// ConfigDataProvider();
// await configDataProvider.initConfigUIData();
// // Navigator.push(context, MaterialPageRoute(builder: (context)))=> InteractionScreen();
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => InteractionListScreen()));
// },
// trailing: const Icon(Icons.arrow_forward_ios),
// ),
// const Divider(),
// ListTile(
// title: const Text(
// "New Medical Insight",
// style: TextStyle(fontSize: 18.0),
// ),
// onTap: () async {
// final ConfigDataProvider configDataProvider =
// ConfigDataProvider();
// await configDataProvider.initConfigUIDataMedical();
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => const InteractionListScreen()));
// },
// trailing: Icon(Icons.arrow_forward_ios),
// ),
// Divider(),
// ListTile(
// title: const Text(
// "Engagement",
// style: TextStyle(fontSize: 18.0),
// ),
// onTap: () async {
// final ConfigDataProvider configDataProvider =
// ConfigDataProvider();
// await configDataProvider.initConfigUIDataEng();
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => const InteractionListScreen()));
// },
// trailing: const Icon(Icons.arrow_forward_ios),
// ),
// Divider(),
// ],
// ),
// ),
// );
// }
// }