KonectarApp/lib/widgets/eventdetailslistview.dart

250 lines
8.3 KiB
Dart
Raw Normal View History

2024-09-06 06:30:31 +00:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:info_popup/info_popup.dart';
import 'package:konectar_events/utils/util.dart';
import 'package:konectar_events/view/eventstab.dart';
import 'package:konectar_events/widgets/custombutton.dart';
import 'package:konectar_events/widgets/customhcpcard.dart';
import 'package:konectar_events/widgets/custominfopopup.dart';
import 'package:konectar_events/widgets/customtopicscard.dart';
import 'package:konectar_events/widgets/eventdetailscontainer.dart';
class EventsDetailsDataTable extends StatelessWidget {
TextEditingController selecttextEditingController = TextEditingController();
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, constraints) {
return SizedBox(
height: isTablet
? MediaQuery.of(context).size.height * 0.75
: MediaQuery.of(context).size.height * 0.80,
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 2),
children: [
PaginatedDataTable(
dataRowMaxHeight: isTablet ? 120.0 : 120.0,
showCheckboxColumn: true,
showEmptyRows: false,
sortColumnIndex: 1,
//dataRowMinHeight: 100.0,
showFirstLastButtons: true,
columnSpacing: 32.0,
headingRowHeight: 44,
// header: SizedBox(
// height: 150,
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Text('Events Speakers'),
// CustomButton(
// backgroundColor: Colors.green,
// onPressed: () {},
// textColor: Colors.black,
// title: "Add To My Contacts",
// fontsize: 16,
// )
// // const SizedBox(
// // width: 10,
// // ),
// //
// ],
// ),
// ),
header: buildTextFieldWidget(context),
rowsPerPage: isTablet ? 4 : 3,
actions: [],
columns: [
DataColumn(
label: Center(child: Text(' HCP \n Topics')),
onSort: (columnIndex, ascending) {},
),
DataColumn(label: Text('Session Notes')),
DataColumn(label: Text('Medical Insights')),
DataColumn(label: Text('Survey')),
DataColumn(label: Text('Actions')),
],
source: _DataSource(context),
),
],
),
);
});
}
Widget buildTextFieldWidget(BuildContext context) {
return SizedBox(
width: isTablet ? 150 : MediaQuery.of(context).size.width,
height: isTablet ? 40 : 35,
child: TextField(
textAlignVertical: TextAlignVertical.center,
cursorHeight: 16.0,
maxLines: 1,
controller:
selecttextEditingController, //editing controller of this TextField
decoration: InputDecoration(
// border: OutlineInputBorder(),
hintText: 'Search',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
),
hintStyle: const TextStyle(fontSize: 16),
),
),
);
}
}
class _Row {
_Row(this.name, this.startDate, this.endDate, this.noOfAttendees,
this.clientAttendees);
final String name;
final String startDate;
final String endDate;
final int noOfAttendees;
final int clientAttendees;
bool selected = false;
}
class _DataSource extends DataTableSource {
_DataSource(this.context) {
_rows = <_Row>[
_Row('Cell A1', '12', '10', 10, 1),
_Row('Cell A1', '12', '10', 10, 1),
_Row('Cell A1', '12', '10', 10, 1),
_Row('Cell A1', '12', '10', 10, 1),
_Row('Cell A1', '12', '10', 10, 1),
_Row('Cell A1', '12', '10', 10, 1),
_Row('Cell A1', '12', '10', 10, 1),
];
}
final BuildContext context;
late List<_Row> _rows;
int _selectedCount = 0;
@override
DataRow? getRow(int index) {
assert(index >= 0);
if (index >= _rows.length) return null;
final row = _rows[index];
return DataRow.byIndex(
index: index,
selected: row.selected,
onSelectChanged: (value) {
if (row.selected != value) {
_selectedCount += value! ? 1 : -1;
assert(_selectedCount >= 0);
row.selected = value;
notifyListeners();
}
},
cells: [
DataCell(eventNameContainer()),
DataCell(Text(row.startDate)),
DataCell(Text(row.endDate)),
DataCell(Text(row.noOfAttendees.toString())),
DataCell(Text(row.clientAttendees.toString())),
],
);
}
@override
int get rowCount => _rows.length;
@override
bool get isRowCountApproximate => false;
@override
int get selectedRowCount => _selectedCount;
Widget eventNameContainer() {
return Container(
height: 300,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
FittedBox(child: CustomInfoPopup()),
SizedBox(
width: 5,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: isTablet
? MediaQuery.of(context).size.width * 0.50
: MediaQuery.of(context).size.width * 0.40,
child: Text(
'Husain Hatim',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 17,
),
maxLines: 2,
softWrap: true,
overflow: TextOverflow.ellipsis,
),
),
FittedBox(
child: InfoPopupWidget(
customContent: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
padding: EdgeInsets.all(isTablet ? 10 : 5),
child: CustomEventTopicsCard(),
),
arrowTheme: const InfoPopupArrowTheme(
color: Colors.white,
arrowDirection: ArrowDirection.down,
),
dismissTriggerBehavior: PopupDismissTriggerBehavior.onTapArea,
areaBackgroundColor: Colors.transparent,
indicatorOffset: Offset.zero,
// contentOffset: isTablet ? Offset(100, 100) : Offset(0, 100),
onControllerCreated: (controller) {
print('Info Popup Controller Created');
},
onAreaPressed: (InfoPopupController controller) {
controller.dismissInfoPopup();
print('Area Pressed');
},
infoPopupDismissed: () {
// Navigator.pop(context);
print('Info Popup Dismissed');
},
onLayoutMounted: (Size size) {
print('Info Popup Layout Mounted');
},
child: SizedBox(
width: isTablet
? MediaQuery.of(context).size.width * 0.25
: MediaQuery.of(context).size.width * 0.5,
child: Text(
'Programmed Cell Death 1 Receptor | Human Epidermal Growth Factor Receptor 2 +6more',
style: TextStyle(
decoration: TextDecoration.underline,
decorationColor: Colors.blue,
color: Colors.blue,
//fontStyle: FontStyle.italic,
fontSize: 14),
),
),
),
),
],
),
],
),
);
}
}