DiscoverModule/lib/ui_screen/interactionform/interactionlistscreen.dart

178 lines
7.7 KiB
Dart
Raw Normal View History

2024-05-20 10:29:02 +00:00
import 'package:discover_module/ui_screen/interactionform/interaction_screen.dart';
import 'package:discover_module/ui_screen/interactionform/interactionprovider.dart';
import 'package:discover_module/ui_screen/interactionform/model/save_interaction.dart';
2024-07-19 08:45:14 +00:00
import 'package:discover_module/ui_screen/interactionform/new_dynamicform.dart';
2024-05-20 10:29:02 +00:00
import 'package:discover_module/ui_screen/interactionform/view_forms_list.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class InteractionListScreen extends StatefulWidget {
const InteractionListScreen({super.key});
@override
State<InteractionListScreen> createState() => _InteractionListScreenState();
}
class _InteractionListScreenState extends State<InteractionListScreen> {
List<SaveInteraction> savedList = [];
@override
void initState() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
// if (!mytimer!.isActive) {
// activateTimer();
// }
print("interactionListt");
init();
});
super.initState();
}
init() async {
print("init");
await Provider.of<InteractionProvider>(context, listen: false)
.initConfigData();
await Provider.of<InteractionProvider>(context, listen: false).getRecords();
setState(() {});
}
Future<int> getCount(String form, InteractionProvider provider) async {
await provider.getRecords();
return provider.savedList.where((element) => element.form == form).length;
}
@override
Widget build(BuildContext context) {
return Consumer<InteractionProvider>(
builder: (BuildContext context, provider, Widget? child) {
2024-06-10 11:11:00 +00:00
return SafeArea(
child: Scaffold(
appBar: AppBar(
title: Text(
'Interaction Forms',
//style: TextStyle(fontSize: isTablet ? 22 : 14, color: Colors.white),
),
automaticallyImplyLeading: false,
// backgroundColor: const Color(0xFF2b9af3),
leading: InkWell(
onTap: () {
Navigator.pop(context);
},
child: const Icon(
Icons.arrow_back_ios,
color: Colors.white,
),
2024-05-21 08:40:44 +00:00
),
),
2024-06-10 11:11:00 +00:00
body: Container(
child: Center(
child: ListView.builder(
itemCount: provider.intConfigDataList.length,
cacheExtent: double.parse(
provider.intConfigDataList.length.toString()),
itemBuilder: (context, index) {
2024-06-28 08:14:42 +00:00
print("ism Screenindex $index");
2024-06-10 11:11:00 +00:00
return Column(
children: [
ListTile(
title: Row(
children: [
Text(
provider.intConfigDataList[index].name,
2024-05-20 10:29:02 +00:00
),
2024-06-10 11:11:00 +00:00
const SizedBox(
width: 20,
),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
2024-07-19 08:45:14 +00:00
InteractionScreen1(
2024-06-10 11:11:00 +00:00
index: index,
form: provider
.intConfigDataList[index]
.name,
)));
2024-05-20 10:29:02 +00:00
},
2024-06-10 11:11:00 +00:00
icon: const Icon(
Icons.arrow_circle_right_outlined,
size: 30,
color: Color.fromARGB(255, 8, 39, 92),
2024-05-20 10:29:02 +00:00
),
2024-06-10 11:11:00 +00:00
),
],
),
trailing: provider.savedList.indexWhere((element) =>
element.form ==
provider
.intConfigDataList[index].name) !=
-1
? InkWell(
onTap: () {
2024-06-28 08:14:42 +00:00
print("inwesm Screenindex $index");
2024-06-10 11:11:00 +00:00
if (getCount(
provider.intConfigDataList[index]
.name,
provider) !=
0) {
provider.savedList
.where((element) =>
element.form ==
provider
.intConfigDataList[index]
.name)
.toList();
Navigator.push(
context,
MaterialPageRoute(
builder:
(BuildContext context) =>
SavedFormListScreen(
formname: provider
.intConfigDataList[
index]
.name,
)));
}
},
child: FittedBox(
fit: BoxFit.scaleDown,
child: Text(
"${provider.savedList.where((element) => element.form == provider.intConfigDataList[index].name).length} record(s) saved",
style: TextStyle(
// fontSize: isTablet ? 18.0 : 14,
fontSize: 18.0,
color: Colors.blue.shade900),
),
),
)
: const SizedBox.shrink(),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
2024-07-19 08:45:14 +00:00
InteractionScreen1(
2024-06-10 11:11:00 +00:00
index: index,
form: provider
.intConfigDataList[index].name,
)));
},
),
const Divider(),
],
);
})),
),
2024-05-20 10:29:02 +00:00
),
);
});
}
}