249 lines
7.5 KiB
Dart
249 lines
7.5 KiB
Dart
|
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/custominfopopup.dart';
|
||
|
|
||
|
class DataTableDemo extends StatelessWidget {
|
||
|
Widget build(BuildContext context) {
|
||
|
return Expanded(
|
||
|
child: ListView(
|
||
|
padding: const EdgeInsets.all(2),
|
||
|
children: [
|
||
|
PaginatedDataTable(
|
||
|
dataRowMaxHeight: isTablet ? 150.0 : 150.0,
|
||
|
//dataRowMinHeight: 100.0,
|
||
|
columnSpacing: 32.0,
|
||
|
// header: Row(
|
||
|
// children: [
|
||
|
// Text('Events'),
|
||
|
// const SizedBox(
|
||
|
// width: 20,
|
||
|
// ),
|
||
|
// SizedBox(
|
||
|
// width: double.minPositive,
|
||
|
// child: SearchBar(
|
||
|
// hintText: 'Search',
|
||
|
// shape: MaterialStateProperty.all(RoundedRectangleBorder(
|
||
|
// borderRadius: BorderRadius.circular(10))),
|
||
|
// ),
|
||
|
// ),
|
||
|
// ],
|
||
|
// ),
|
||
|
header: SizedBox.shrink(),
|
||
|
rowsPerPage: 6,
|
||
|
actions: [],
|
||
|
columns: [
|
||
|
DataColumn(label: Center(child: Text(' Event Name'))),
|
||
|
DataColumn(label: Text('Start Date')),
|
||
|
DataColumn(label: Text('End Date')),
|
||
|
DataColumn(label: Text('Number of Attendees')),
|
||
|
DataColumn(label: Text('Client Attendees')),
|
||
|
],
|
||
|
source: _DataSource(context),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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-09-2024', '12-11-2024', 10, 1),
|
||
|
_Row('Cell A2', '12-09-2024', '12-11-2024', 10, 2),
|
||
|
_Row('Cell A3', '12-09-2024', '12-11-2024', 20, 3),
|
||
|
_Row('Cell A4', '12-09-2024', '12-11-2024', 30, 4),
|
||
|
_Row('Cell A1', '12-09-2024', '12-11-2024', 40, 5),
|
||
|
_Row('Cell A2', '12-09-2024', '12-11-2024', 10, 6),
|
||
|
_Row('Cell A3', '12-09-2024', '12-11-2024', 10, 7),
|
||
|
_Row('Cell A4', '12-09-2024', '12-11-2024', 90, 8),
|
||
|
];
|
||
|
}
|
||
|
|
||
|
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(InkWell(
|
||
|
// onTap: () =>
|
||
|
|
||
|
// Navigator.of(context).push(
|
||
|
// MaterialPageRoute(
|
||
|
// builder: (context) => EventsTab(),
|
||
|
// ),
|
||
|
// ),
|
||
|
child: 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(
|
||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||
|
children: [
|
||
|
// IconButton(
|
||
|
// onPressed: () {
|
||
|
// MaterialPageRoute<void>(
|
||
|
// builder: (_) {
|
||
|
// return const CustomInfoPopup();
|
||
|
// },
|
||
|
// );
|
||
|
// },
|
||
|
// icon: const Icon(
|
||
|
// Icons.info,
|
||
|
// size: 20,
|
||
|
// )),
|
||
|
_infopopup(context),
|
||
|
Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
children: [
|
||
|
SizedBox(
|
||
|
width: isTablet
|
||
|
? MediaQuery.of(context).size.width * 0.50
|
||
|
: MediaQuery.of(context).size.width * 0.65,
|
||
|
child: Text(
|
||
|
'2024 Hematology/Oncology Pharmacy Association Annual Conference (HOPA)',
|
||
|
style: TextStyle(
|
||
|
// decoration: TextDecoration.underline,
|
||
|
// decorationColor: Colors.blue,
|
||
|
color: Colors.blue,
|
||
|
fontWeight: FontWeight.bold,
|
||
|
fontSize: 16,
|
||
|
),
|
||
|
maxLines: 2,
|
||
|
softWrap: true,
|
||
|
overflow: TextOverflow.ellipsis,
|
||
|
),
|
||
|
),
|
||
|
SizedBox(
|
||
|
width: isTablet
|
||
|
? MediaQuery.of(context).size.width * 0.25
|
||
|
: MediaQuery.of(context).size.width * 0.5,
|
||
|
child: Text(
|
||
|
'Tampa,Florida,United States',
|
||
|
style: TextStyle(
|
||
|
color: Colors.black,
|
||
|
fontStyle: FontStyle.italic,
|
||
|
fontSize: 14),
|
||
|
),
|
||
|
),
|
||
|
SizedBox(
|
||
|
width: isTablet
|
||
|
? MediaQuery.of(context).size.width * 0.25
|
||
|
: MediaQuery.of(context).size.width * 0.35,
|
||
|
child: Text(
|
||
|
'Organizer: Hematology/Oncology Pharmacy Association (HOPA)',
|
||
|
style: TextStyle(
|
||
|
color: Colors.black,
|
||
|
fontStyle: FontStyle.italic,
|
||
|
fontSize: 14),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
_infopopup(BuildContext context) {
|
||
|
return InfoPopupWidget(
|
||
|
customContent: Container(
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
borderRadius: BorderRadius.circular(10),
|
||
|
),
|
||
|
padding: const EdgeInsets.all(10),
|
||
|
child: Column(
|
||
|
children: const <Widget>[
|
||
|
Text(
|
||
|
' Speaker Count : 1 \n Session Notes : 0 \n Surveys : 0 \n Program: Completed',
|
||
|
style: TextStyle(
|
||
|
fontSize: 16.0,
|
||
|
color: Colors.black,
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
arrowTheme: const InfoPopupArrowTheme(
|
||
|
color: Color.fromARGB(255, 248, 238, 238),
|
||
|
arrowDirection: ArrowDirection.up,
|
||
|
),
|
||
|
dismissTriggerBehavior: PopupDismissTriggerBehavior.anyWhere,
|
||
|
areaBackgroundColor: Colors.transparent,
|
||
|
indicatorOffset: Offset.zero,
|
||
|
contentOffset: Offset.zero,
|
||
|
onControllerCreated: (controller) {
|
||
|
print('Info Popup Controller Created');
|
||
|
},
|
||
|
onAreaPressed: (InfoPopupController controller) {
|
||
|
print('Area Pressed');
|
||
|
},
|
||
|
infoPopupDismissed: () {
|
||
|
// Navigator.pop(context);
|
||
|
print('Info Popup Dismissed');
|
||
|
},
|
||
|
onLayoutMounted: (Size size) {
|
||
|
print('Info Popup Layout Mounted');
|
||
|
},
|
||
|
child: Icon(
|
||
|
Icons.info,
|
||
|
color: Colors.blue,
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|