DiscoverModule/lib/contacts_module/ui_screen/engagementtab.dart

1076 lines
53 KiB
Dart
Raw Permalink Normal View History

2024-10-07 12:41:28 +00:00
// import 'package:discover_module/constants.dart';
// import 'package:discover_module/custom_widget/text.dart';
// import 'package:discover_module/model_class/speaker.dart';
// import 'package:discover_module/provider_class/medicalinsightprovider.dart';
// import 'package:discover_module/provider_class/nih_provider.dart';
// import 'package:discover_module/provider_class/patent_provider.dart';
// import 'package:discover_module/provider_class/procedureprovider.dart';
// import 'package:discover_module/provider_class/speaker_provider.dart';
// import 'package:discover_module/provider_class/training_provider.dart';
// import 'package:discover_module/storage_hive/nih_grant_data/crud_nih.dart';
// import 'package:discover_module/storage_hive/patent_data/crud_patent.dart';
// import 'package:discover_module/storage_hive/procedure_data/crud_pro.dart';
// import 'package:discover_module/storage_hive/speaker_data/crud.speaker.dart';
// import 'package:discover_module/ui_screen/bottom_sheet.dart';
// import 'package:discover_module/ui_screen/interactionform/interactionprovider.dart';
// import 'package:discover_module/ui_screen/interactionform/model/save_interaction.dart';
// import 'package:discover_module/ui_screen/interactionform/view_forms_list.dart';
// import 'package:discover_module/ui_screen/interactionform/viewinteractionprovider.dart';
// import 'package:discover_module/ui_screen/medical_insight.dart';
// import 'package:discover_module/ui_screen/new_editinteraction.dart';
// import 'package:discover_module/ui_screen/new_viewinteraction.dart';
// import 'package:discover_module/ui_screen/nih_show_more.dart';
// import 'package:discover_module/ui_screen/patent_show_more.dart';
// import 'package:discover_module/ui_screen/pro_show_more.dart';
import 'package:discover_module/contacts_module/constants.dart';
import 'package:discover_module/contacts_module/custom_widget/text.dart';
import 'package:discover_module/contacts_module/provider_class/nih_provider.dart';
import 'package:discover_module/contacts_module/provider_class/patent_provider.dart';
import 'package:discover_module/contacts_module/provider_class/procedureprovider.dart';
import 'package:discover_module/contacts_module/provider_class/speaker_provider.dart';
import 'package:discover_module/contacts_module/storage_hive/nih_grant_data/crud_nih.dart';
import 'package:discover_module/contacts_module/storage_hive/patent_data/crud_patent.dart';
import 'package:discover_module/contacts_module/storage_hive/procedure_data/crud_pro.dart';
import 'package:discover_module/contacts_module/storage_hive/speaker_data/crud.speaker.dart';
import 'package:discover_module/contacts_module/ui_screen/bottom_sheet.dart';
import 'package:discover_module/contacts_module/ui_screen/interactionform/interactionprovider.dart';
import 'package:discover_module/contacts_module/ui_screen/interactionform/model/save_interaction.dart';
import 'package:discover_module/contacts_module/ui_screen/interactionform/view_forms_list.dart';
import 'package:discover_module/contacts_module/ui_screen/interactionform/viewinteractionprovider.dart';
import 'package:discover_module/contacts_module/ui_screen/new_editinteraction.dart';
import 'package:discover_module/contacts_module/ui_screen/new_viewinteraction.dart';
import 'package:discover_module/contacts_module/ui_screen/nih_show_more.dart';
import 'package:discover_module/contacts_module/ui_screen/patent_show_more.dart';
import 'package:discover_module/contacts_module/ui_screen/pro_show_more.dart';
2024-08-30 12:24:54 +00:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
2024-11-22 10:38:43 +00:00
import 'package:flutter/widgets.dart';
2024-08-30 12:24:54 +00:00
import 'package:provider/provider.dart';
class EngagementTab extends StatefulWidget {
2024-11-22 10:38:43 +00:00
EngagementTab({required this.text, this.offline, Key? key, this.offlineMode})
: super(key: key);
2024-08-30 12:24:54 +00:00
final int text;
2024-10-07 12:41:28 +00:00
int? offline;
2024-11-22 10:38:43 +00:00
bool? offlineMode;
2024-08-30 12:24:54 +00:00
@override
State<EngagementTab> createState() => _EngagementTabState();
}
class _EngagementTabState extends State<EngagementTab> {
bool _isExpanded = false;
List medinsightData = [];
List patent = [];
List nihgrants = [];
List procedure = [];
2024-10-07 12:41:28 +00:00
List speakerlistt = [];
// List training = [];
2024-08-30 12:24:54 +00:00
// List eng = [];
var item;
@override
void initState() {
// TODO: implement initState
2024-11-22 10:38:43 +00:00
print("Engagement_offlineModee: ${widget.offlineMode}");
2024-08-30 12:24:54 +00:00
super.initState();
getdata();
}
getdata() async {
var form = Provider.of<ViewInteractionProvider>(context, listen: false);
form.savedList;
2024-10-07 12:41:28 +00:00
final patentt1, nih1, pro1, tri1, speakerlist;
2024-08-30 12:24:54 +00:00
//var med = Provider.of<MediacalInsightProvider>(context, listen: false);
//await med.medicalinsightdata();
// final medlist = med.trialsinfo;
2024-10-07 12:41:28 +00:00
if (widget.offline == 1) {
patentt1 = await retrieveidpatent(widget.text);
print("Savedd_CheckingloclistEdu123: $patentt1");
} else {
var patentt = Provider.of<PatentProvider>(context, listen: false);
await patentt.patentinfo(widget.text);
patentt1 = patentt.patentlist;
}
if (widget.offline == 1) {
nih1 = await retrieveidnih(widget.text);
print("Savedd_CheckingloclistEdu123: $nih1");
} else {
var nih = Provider.of<NIHGrantsProvider>(context, listen: false);
await nih.nihinfo(widget.text);
nih1 = nih.nihgrantslist;
}
2024-08-30 12:24:54 +00:00
2024-10-07 12:41:28 +00:00
if (widget.offline == 1) {
pro1 = await retrieveidpro(widget.text);
print("Savedd_CheckingloclistEdupro1123: $pro1");
} else {
var pro = Provider.of<ProcedureProvider>(context, listen: false);
await pro.proinfo(widget.text);
pro1 = pro.prolist;
}
2024-08-30 12:24:54 +00:00
2024-10-07 12:41:28 +00:00
if (widget.offline == 1) {
speakerlist = await retrieveidspeaker(widget.text);
print("Savedd_CheckingloclistEdupro1123: $pro1");
} else {
var speaker1 =
Provider.of<SpekerEvalutionProvider>(context, listen: false);
await speaker1.getspeakerdata();
speakerlist = speaker1.speakerlist;
}
2024-08-30 12:24:54 +00:00
setState(() {
// medinsightData = medlist;
patent = patentt1;
nihgrants = nih1;
procedure = pro1;
2024-10-07 12:41:28 +00:00
// training = tri1;
speakerlistt = speakerlist;
2024-08-30 12:24:54 +00:00
// eng = engtypelist;
});
2024-10-07 12:41:28 +00:00
// print("CheckingPro: ${pro1.procedure}");
// print("Checkingnihgrants: $nihgrants");
2024-08-30 12:24:54 +00:00
}
@override
Widget build(BuildContext context) {
return Center(
child: ListView(
children: [
ListTileTheme(
dense: true,
child: Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Card(
margin: EdgeInsets.all(1.0),
// elevation: 5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0),
),
2024-11-22 10:38:43 +00:00
color: Constants.bgwhitecolor,
2024-08-30 12:24:54 +00:00
child: ExpansionTile(
initiallyExpanded: false,
maintainState: true,
onExpansionChanged: (bool expanded) {
setState(() {
_isExpanded = expanded;
});
},
2024-11-22 10:38:43 +00:00
backgroundColor: Constants.bgwhitecolor,
2024-08-30 12:24:54 +00:00
trailing: Icon(
_isExpanded
? Icons.keyboard_arrow_up
: Icons.keyboard_arrow_down,
color: Colors.black),
// collapsedBackgroundColor: Color(0xFF2b9af3),
title: Row(
//mainAxisSize: MainAxisSize.min,
children: [
GestureDetector(
onTap: () async {
final provider = Provider.of<InteractionProvider>(
context,
listen: false);
if (getCount(provider.intConfigDataList[0].name,
provider) !=
0) {
provider.savedList
.where((element) =>
element.form ==
provider.intConfigDataList[0].name)
.toList();
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
SavedFormListScreen(
formname: provider
.intConfigDataList[0].name,
)));
}
},
child: Text1(
title: "Interactions",
txtcolor: Colors.black,
fontweight: FontWeight.normal,
txtfont: 17.0),
),
const SizedBox(
width: 8.0,
),
],
),
children: [
Container(
height: MediaQuery.of(context).size.height / 5,
color: Colors.white,
child: Consumer<ViewInteractionProvider>(builder:
(BuildContext context, provider, Widget? child) {
print("P_leangth : ${provider.savedList.length}");
if (provider.savedList.length != 0) {
return ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: provider.savedList.take(2).length,
itemBuilder: (context, index) {
print("Indexxxxxx $index");
return Column(
children: [
ListTile(
subtitle: Text(
'Updated on ${provider.savedList[index].updatedTime}',
//style: TextStyle(fontStyle: FontStyle.italic),
),
title: Text(
provider.savedList[index].id,
),
trailing: SizedBox(
width: 150,
child: Row(children: [
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext
context) =>
ViewInteractionScreen1(
saveInteraction:
provider.savedList[
index],
)));
},
icon: const Icon(
Icons.info_outline,
size: 24,
color: Color.fromARGB(
255, 8, 39, 92),
),
),
IconButton(
onPressed: () async {
await provider
.initConfigData()
.then({
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext
context) =>
EditInteractionScreen1(
saveInteraction:
provider.savedList[
index],
)))
});
},
icon: const Icon(
Icons.edit,
size: 24,
color: Color.fromARGB(
255, 8, 39, 92),
),
),
IconButton(
onPressed: () {
showDeleteRecordAlertDialog(
context,
provider
.savedList[index].id,
provider.savedList[index]);
},
icon: const Icon(
Icons.delete,
size: 24,
color: Color.fromARGB(
255, 8, 39, 92),
),
),
]),
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext
context) =>
ViewInteractionScreen1(
saveInteraction:
provider.savedList[
index],
)));
},
),
const Divider(),
],
);
});
} else {
return Container(
color: Colors.white,
width: MediaQuery.of(context).size.width,
child: Column(
children: [
Text("No records"),
],
),
);
}
}),
),
Container(
color: Colors.white,
child: Align(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: OutlinedButton(
onPressed: () {
final provider =
Provider.of<InteractionProvider>(context,
listen: false);
if (getCount(provider.intConfigDataList[0].name,
provider) !=
0) {
provider.savedList
.where((element) =>
element.form ==
provider.intConfigDataList[0].name)
.toList();
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
SavedFormListScreen(
formname: provider
.intConfigDataList[0].name,
)));
}
},
child: Text('Show More'),
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
),
),
)
]),
),
),
),
2024-10-07 12:41:28 +00:00
speakerlistt.length != 0
2024-11-22 10:38:43 +00:00
? GestureDetector(
onTap: () {
// Do nothing to prevent expansion
},
child: ListTileTheme(
dense: true,
child: Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Card(
margin: EdgeInsets.all(1.0),
// elevation: 5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0),
),
color: Constants.bgwhitecolor,
child: ExpansionTile(
initiallyExpanded: false,
maintainState: true,
onExpansionChanged: (bool expanded) {
setState(() {
_isExpanded = expanded;
});
},
backgroundColor: Constants.bgwhitecolor,
trailing: Icon(
_isExpanded
? Icons.keyboard_arrow_up
: Icons.keyboard_arrow_down,
color: Colors.black),
title: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text1(
title: "Speaker Evalution",
txtcolor: Colors.black,
fontweight: FontWeight.normal,
txtfont: 17.0),
const SizedBox(
width: 8.0,
),
Text1(
title:
"(${speakerlistt.length.toString()})",
txtcolor: Colors.black,
fontweight: FontWeight.normal,
txtfont: 17.0),
],
),
2024-10-07 12:41:28 +00:00
children: [
2024-11-22 10:38:43 +00:00
Visibility(
visible: widget.offlineMode == null
? true
: widget.offlineMode!,
child: Scrollbar(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Container(
constraints: BoxConstraints(
minWidth: MediaQuery.of(context)
.size
.width),
color: Colors.white,
child: DataTable(
showCheckboxColumn: false,
columns: const [
DataColumn(
label: Expanded(
child: Text(
'Program Topic',
style: TextStyle(
fontWeight: FontWeight.w600),
2024-10-07 12:41:28 +00:00
),
2024-11-22 10:38:43 +00:00
)),
DataColumn(
label: Expanded(
child: Text('Speaker Name',
style: TextStyle(
fontWeight: FontWeight
.w600)))),
2024-10-07 12:41:28 +00:00
],
2024-11-22 10:38:43 +00:00
rows: List.generate(
speakerlistt.take(2).length,
(index) => DataRow(
onSelectChanged: (value) {
// =======> Use onSelectChanged for tab
print(
"message ${speakerlistt[index]}");
// bsheet(
// publication_data[
// index]);
showModalBottomSheet(
useRootNavigator: true,
isScrollControlled: false,
enableDrag: true,
useSafeArea: true,
constraints:
const BoxConstraints(
maxWidth: double.infinity,
),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.vertical(
top: Radius.circular(0),
),
),
clipBehavior:
Clip.antiAliasWithSaveLayer,
context: context,
builder: (context) {
return bsheet(
speakerlistt[index]);
},
);
},
color: MaterialStateProperty
.resolveWith<Color?>(
(Set<MaterialState>
states) {
if (index.isEven) {
return Colors.grey
.withOpacity(0.1);
}
return null;
}),
cells: [
DataCell(Text(
speakerlistt[index]
.programtopic
.toString(),
softWrap: true)),
DataCell(Text(
speakerlistt[index]
.speakername
.toString(),
softWrap: true)),
],
),
),
2024-10-07 12:41:28 +00:00
),
),
),
),
),
2024-11-22 10:38:43 +00:00
Visibility(
visible: widget.offlineMode == null
? true
: widget.offlineMode!,
child: Container(
color: Colors.white,
child: Align(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: OutlinedButton(
onPressed: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (_) =>
// AffiliationsData()));
},
child: Text(
'Show More',
style: TextStyle(
color: Constants.k2color),
),
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(12),
),
),
2024-10-07 12:41:28 +00:00
),
),
),
),
2024-11-22 10:38:43 +00:00
)
]),
),
2024-10-07 12:41:28 +00:00
),
),
)
: Container(), // adds spacing between the text and image
2024-08-30 12:24:54 +00:00
nihgrants.length != 0
? ListTileTheme(
dense: true,
child: Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Card(
margin: EdgeInsets.all(1.0),
//elevation: 5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0),
),
2024-11-22 10:38:43 +00:00
color: Constants.bgwhitecolor,
2024-08-30 12:24:54 +00:00
child: ExpansionTile(
initiallyExpanded: false,
maintainState: true,
// backgroundColor: Colors.white,
// collapsedBackgroundColor: Color(0xFF2b9af3),
onExpansionChanged: (bool expanded) {
setState(() {
_isExpanded = expanded;
});
},
2024-11-22 10:38:43 +00:00
backgroundColor: Constants.bgwhitecolor,
2024-08-30 12:24:54 +00:00
trailing: Icon(
_isExpanded
? Icons.keyboard_arrow_up
: Icons.keyboard_arrow_down,
color: Colors.black),
title: Row(
mainAxisAlignment: MainAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
children: [
Text1(
title: "NIH Grants",
txtcolor: Colors.black,
fontweight: FontWeight.normal,
txtfont: 17.0),
const SizedBox(
width: 8.0,
),
Text1(
title: "(${nihgrants.length.toString()})",
txtcolor: Colors.black,
fontweight: FontWeight.normal,
txtfont: 17.0),
],
),
children: [
Scrollbar(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Container(
constraints: BoxConstraints(
minWidth:
MediaQuery.of(context).size.width),
color: Colors.white,
child: DataTable(
showCheckboxColumn: false,
columns: const [
DataColumn(
label: Expanded(
child: Text('NIH Center',
style: TextStyle(
fontWeight: FontWeight.w600),
softWrap: true),
)),
DataColumn(
label: Expanded(
child: Text('Organization Name',
style: TextStyle(
fontWeight:
FontWeight.w600)))),
],
rows: List.generate(
nihgrants.take(2).length,
(index) => DataRow(
onSelectChanged: (value) {
print("message ${nihgrants[index]}");
showModalBottomSheet(
useRootNavigator: true,
isScrollControlled: false,
enableDrag: true,
useSafeArea: true,
constraints: const BoxConstraints(
maxWidth: double.infinity,
),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.vertical(
top: Radius.circular(0),
),
),
clipBehavior:
Clip.antiAliasWithSaveLayer,
context: context,
builder: (context) {
return bsheet(nihgrants[index]);
},
);
},
cells: [
DataCell(Text(
2024-10-07 12:41:28 +00:00
nihgrants[index]
.piNames
2024-08-30 12:24:54 +00:00
.toString(),
softWrap: true)),
DataCell(Text(
nihgrants[index]
2024-10-07 12:41:28 +00:00
.institute
2024-08-30 12:24:54 +00:00
.toString(),
softWrap: true)),
],
),
),
),
),
),
),
Container(
color: Colors.white,
child: Align(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: OutlinedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => NIHShowMore(
text: widget.text)));
},
child: Text(
'Show More',
style:
TextStyle(color: Constants.k2color),
),
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
),
),
)
]),
),
),
)
: Container(), // adds spacing between the text and image
procedure.length != 0
? ListTileTheme(
dense: true,
child: Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Card(
margin: EdgeInsets.all(1.0),
// elevation: 5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0),
),
2024-11-22 10:38:43 +00:00
color: Constants.bgwhitecolor,
2024-08-30 12:24:54 +00:00
child: ExpansionTile(
initiallyExpanded: false,
maintainState: true,
// backgroundColor: Colors.white,
// collapsedBackgroundColor: Color(0xFF2b9af3),
onExpansionChanged: (bool expanded) {
setState(() {
_isExpanded = expanded;
});
},
2024-11-22 10:38:43 +00:00
backgroundColor: Constants.bgwhitecolor,
2024-08-30 12:24:54 +00:00
trailing: Icon(
_isExpanded
? Icons.keyboard_arrow_up
: Icons.keyboard_arrow_down,
color: Colors.black),
title: Row(
mainAxisAlignment: MainAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
children: [
Text1(
title: "Procedures",
txtcolor: Colors.black,
fontweight: FontWeight.normal,
txtfont: 17.0),
const SizedBox(
width: 8.0,
),
Text1(
title: "(${procedure.length.toString()})",
txtcolor: Colors.black,
fontweight: FontWeight.normal,
txtfont: 17.0),
],
),
children: [
Scrollbar(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Container(
constraints: BoxConstraints(
minWidth:
MediaQuery.of(context).size.width),
color: Colors.white,
child: DataTable(
showCheckboxColumn: false,
columns: const [
DataColumn(
label: Expanded(
child: Text('Program Year',
style: TextStyle(
fontWeight: FontWeight.w600),
softWrap: true),
)),
DataColumn(
label: Expanded(
child: Text('Procedure',
style: TextStyle(
fontWeight:
FontWeight.w600)))),
],
rows: List.generate(
procedure.take(2).length,
(index) => DataRow(
onSelectChanged: (value) {
print("message ${procedure[index]}");
showModalBottomSheet(
useRootNavigator: true,
isScrollControlled: false,
enableDrag: true,
useSafeArea: true,
constraints: const BoxConstraints(
maxWidth: double.infinity,
),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.vertical(
top: Radius.circular(0),
),
),
clipBehavior:
Clip.antiAliasWithSaveLayer,
context: context,
builder: (context) {
return bsheet(procedure[index]);
},
);
},
cells: [
DataCell(Text(
2024-10-07 12:41:28 +00:00
procedure[index]
.procedure
2024-08-30 12:24:54 +00:00
.toString(),
softWrap: true)),
DataCell(Text(
procedure[index]
2024-10-07 12:41:28 +00:00
.placeOfService
2024-08-30 12:24:54 +00:00
.toString(),
softWrap: true)),
],
),
),
),
),
),
),
Container(
color: Colors.white,
child: Align(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: OutlinedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => ProShowMore(
text: widget.text)));
},
child: Text(
'Show More',
style:
TextStyle(color: Constants.k2color),
),
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
),
),
)
]),
),
),
)
: Container(), // adds spacing between the text and image
patent.length != 0
? ListTileTheme(
dense: true,
child: Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Card(
margin: EdgeInsets.all(1.0),
// elevation: 5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0),
),
2024-11-22 10:38:43 +00:00
color: Constants.bgwhitecolor,
2024-08-30 12:24:54 +00:00
child: ExpansionTile(
initiallyExpanded: false,
maintainState: true,
// backgroundColor: Colors.white,
// collapsedBackgroundColor: Color(0xFF2b9af3),
onExpansionChanged: (bool expanded) {
setState(() {
_isExpanded = expanded;
});
},
2024-11-22 10:38:43 +00:00
backgroundColor: Constants.bgwhitecolor,
2024-08-30 12:24:54 +00:00
trailing: Icon(
_isExpanded
? Icons.keyboard_arrow_up
: Icons.keyboard_arrow_down,
color: Colors.black),
title: Row(
mainAxisAlignment: MainAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
children: [
Text1(
title: "Patents",
txtcolor: Colors.black,
fontweight: FontWeight.normal,
txtfont: 17.0),
const SizedBox(
width: 8.0,
),
Text1(
title: "(${patent.length.toString()})",
txtcolor: Colors.black,
fontweight: FontWeight.normal,
txtfont: 17.0),
],
),
children: [
Scrollbar(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Container(
constraints: BoxConstraints(
minWidth:
MediaQuery.of(context).size.width),
color: Colors.white,
child: DataTable(
showCheckboxColumn: false,
columns: const [
DataColumn(
label: Expanded(
child: Text('Patent Title',
style: TextStyle(
fontWeight: FontWeight.w600),
softWrap: true),
)),
DataColumn(
label: Expanded(
child: Text('Status',
style: TextStyle(
fontWeight:
FontWeight.w600)))),
],
rows: List.generate(
patent.take(2).length,
(index) => DataRow(
onSelectChanged: (value) {
print("message ${patent[index]}");
showModalBottomSheet(
useRootNavigator: true,
isScrollControlled: false,
enableDrag: true,
useSafeArea: true,
constraints: const BoxConstraints(
maxWidth: double.infinity,
),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.vertical(
top: Radius.circular(0),
),
),
clipBehavior:
Clip.antiAliasWithSaveLayer,
context: context,
builder: (context) {
return bsheet(patent[index]);
},
);
},
cells: [
DataCell(Text(
2024-10-07 12:41:28 +00:00
patent[index]
.patentTitle
2024-08-30 12:24:54 +00:00
.toString(),
softWrap: true)),
DataCell(Text(
2024-10-07 12:41:28 +00:00
patent[index].status.toString(),
2024-08-30 12:24:54 +00:00
softWrap: true)),
],
),
),
),
),
),
),
Container(
color: Colors.white,
child: Align(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: OutlinedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => PatentShowMore(
text: widget.text)));
},
child: Text(
'Show More',
style:
TextStyle(color: Constants.k2color),
),
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
),
),
)
]),
),
),
)
: Container(),
],
),
);
}
Future<int> getCount(String form, InteractionProvider provider) async {
await provider.getRecords();
return provider.savedList.where((element) => element.form == form).length;
}
showDeleteRecordAlertDialog(
BuildContext context, String record, SaveInteraction saveInteraction) {
// set up the buttons
ViewInteractionProvider provider =
Provider.of<ViewInteractionProvider>(context, listen: false);
Widget cancelButton = TextButton(
child: const Text("YES"),
onPressed: () async {
await provider.deleteRecord(saveInteraction).then((value) {
_displaySnackBar("Deleted sucessfully!");
Navigator.of(context).pop();
});
},
);
Widget continueButton = TextButton(
child: const Text("NO"),
onPressed: () {
Navigator.of(context).pop();
},
);
// set up the AlertDialog
AlertDialog alert = AlertDialog(
title: const Text(""),
content: Text("Are you sure you want to delete the record $record ?"),
actions: [
cancelButton,
continueButton,
],
);
// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
_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);
}
}