424 lines
14 KiB
Dart
424 lines
14 KiB
Dart
import 'package:flutter/cupertino.dart';
|
||
import 'package:flutter/material.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 SocialMediaDataTable extends StatelessWidget {
|
||
final bool isTweets;
|
||
|
||
const SocialMediaDataTable({super.key, required this.isTweets});
|
||
Widget build(BuildContext context) {
|
||
return ListView(
|
||
padding: const EdgeInsets.all(2),
|
||
children: [
|
||
PaginatedDataTable(
|
||
dataRowMaxHeight: isTablet ? 80.0 : 60.0,
|
||
showEmptyRows: false,
|
||
headingRowHeight: 60,
|
||
//dataRowMinHeight: 100.0,
|
||
columnSpacing: 44.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: Text(isTweets ? 'Top 10 Tweets' : 'Top 20 Profiles'),
|
||
headingRowColor: MaterialStateProperty.all(Colors.blueAccent),
|
||
rowsPerPage: isTablet ? 5 : 4,
|
||
showCheckboxColumn: false,
|
||
actions: [],
|
||
columns: isTweets
|
||
? [
|
||
DataColumn(
|
||
label: Center(
|
||
child: Text(
|
||
'SLNO.',
|
||
style: TextStyle(color: Colors.white),
|
||
))),
|
||
DataColumn(
|
||
label: Text('Handle',
|
||
style: TextStyle(color: Colors.white))),
|
||
DataColumn(
|
||
label:
|
||
Text('Tweet', style: TextStyle(color: Colors.white))),
|
||
DataColumn(
|
||
label: Text('Total Engagement',
|
||
style: TextStyle(color: Colors.white))),
|
||
]
|
||
: [
|
||
DataColumn(
|
||
label: Center(
|
||
child: Text(
|
||
'SLNO.',
|
||
style: TextStyle(color: Colors.white),
|
||
))),
|
||
DataColumn(
|
||
label: Text('Handle',
|
||
style: TextStyle(color: Colors.white))),
|
||
DataColumn(
|
||
label:
|
||
Text('Bio', style: TextStyle(color: Colors.white))),
|
||
DataColumn(
|
||
label: Text('Followers',
|
||
style: TextStyle(color: Colors.white))),
|
||
DataColumn(
|
||
label: Text('Tweets',
|
||
style: TextStyle(color: Colors.white))),
|
||
DataColumn(
|
||
label: Text('Tweet Sentiments',
|
||
style: TextStyle(color: Colors.white))),
|
||
],
|
||
source: _DataSource(context, isTweets),
|
||
),
|
||
],
|
||
);
|
||
}
|
||
}
|
||
|
||
class _Row {
|
||
_Row(this.name, this.bio, this.followers, this.tweets, this.tweetsentiments);
|
||
|
||
final String name;
|
||
final String bio;
|
||
final String followers;
|
||
final int tweets;
|
||
final int tweetsentiments;
|
||
|
||
bool selected = false;
|
||
}
|
||
|
||
class _DataSource extends DataTableSource {
|
||
final bool isTweets;
|
||
_DataSource(this.context, this.isTweets) {
|
||
_rows = <_Row>[
|
||
_Row(
|
||
'Hany Ragy',
|
||
'Cardiologist,Expert in Women & Heart Disease, Prevention, Author Saving Women\'s\n Hearts - Heals President of ASPC #earlyinterventionalist @CedarsSinai',
|
||
'63.8K',
|
||
10,
|
||
100),
|
||
_Row(
|
||
'Hany Ragy',
|
||
'Cardiologist,Expert in Women & Heart Disease, Prevention, Author Saving Women\'s\n Hearts- Heals President of ASPC #earlyinterventionalist @CedarsSinai',
|
||
'63.8K',
|
||
10,
|
||
100),
|
||
_Row(
|
||
'Hany Ragy',
|
||
'Cardiologist,Expert in Women & Heart Disease, Prevention, Author Saving Women\'s \n Hearts- Heals President of ASPC #earlyinterventionalist @CedarsSinai',
|
||
'63.8K',
|
||
10,
|
||
100),
|
||
_Row(
|
||
'Hany Ragy',
|
||
'Cardiologist,Expert in Women & Heart Disease, Prevention, Author Saving Women\'s \n Hearts- Heals President of ASPC #earlyinterventionalist @CedarsSinai',
|
||
'63.8K',
|
||
10,
|
||
100),
|
||
_Row(
|
||
'Hany Ragy',
|
||
'Cardiologist,Expert in Women & Heart Disease, Prevention, Author Saving Women\'s\n Hearts- Heals President of ASPC #earlyinterventionalist @CedarsSinai',
|
||
'63.8K',
|
||
10,
|
||
100),
|
||
_Row(
|
||
'Hany Ragy',
|
||
'Cardiologist,Expert in Women & Heart Disease, Prevention, Author Saving Women\'s\n Hearts- Heals President of ASPC #earlyinterventionalist @CedarsSinai',
|
||
'63.8K',
|
||
10,
|
||
100),
|
||
_Row(
|
||
'Hany Ragy',
|
||
'Cardiologist,Expert in Women & Heart Disease, Prevention, Author Saving Women\'s\n Hearts- Heals President of ASPC #earlyinterventionalist @CedarsSinai',
|
||
'63.8K',
|
||
10,
|
||
100),
|
||
_Row(
|
||
'Hany Ragy',
|
||
'Cardiologist,Expert in Women & Heart Disease, Prevention, Author Saving Women\'s\n Hearts- Heals President of ASPC #earlyinterventionalist @CedarsSinai',
|
||
'63.8K',
|
||
10,
|
||
100),
|
||
_Row(
|
||
'Hany Ragy',
|
||
'Cardiologist,Expert in Women & Heart Disease, Prevention, Author Saving Women\'s\n Hearts- Heals President of ASPC #earlyinterventionalist @CedarsSinai',
|
||
'63.8K',
|
||
10,
|
||
100),
|
||
_Row(
|
||
'Hany Ragy',
|
||
'Cardiologist,Expert in Women & Heart Disease, Prevention, Author Saving Women\'s\n Hearts- Heals President of ASPC #earlyinterventionalist @CedarsSinai',
|
||
'63.8K',
|
||
10,
|
||
1),
|
||
_Row(
|
||
'Hany Ragy',
|
||
'Cardiologist,Expert in Women & Heart Disease, Prevention, Author Saving Women\'s\n Hearts- Heals President of ASPC #earlyinterventionalist @CedarsSinai',
|
||
'63.8K',
|
||
10,
|
||
100),
|
||
_Row(
|
||
'Hany Ragy',
|
||
'Cardiologist,Expert in Women & Heart Disease, Prevention, Author Saving Women\'s\n Hearts- Heals President of ASPC #earlyinterventionalist @CedarsSinai',
|
||
'63.8K',
|
||
100,
|
||
1),
|
||
_Row(
|
||
'Hany Ragy',
|
||
'Cardiologist,Expert in Women & Heart Disease, Prevention, Author Saving Women\'s\n Hearts- Heals President of ASPC #earlyinterventionalist @CedarsSinai',
|
||
'63.8K',
|
||
10,
|
||
100),
|
||
_Row(
|
||
'Hany Ragy',
|
||
'Cardiologist,Expert in Women & Heart Disease, Prevention, Author Saving Women\'s\n Hearts- Heals President of ASPC #earlyinterventionalist @CedarsSinai',
|
||
'63.8K',
|
||
10,
|
||
100),
|
||
_Row(
|
||
'Hany Ragy',
|
||
'Cardiologist,Expert in Women & Heart Disease, Prevention, Author Saving Women\'s\n Hearts- Heals President of ASPC #earlyinterventionalist @CedarsSinai',
|
||
'63.8K',
|
||
10,
|
||
100),
|
||
];
|
||
}
|
||
|
||
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: isTweets
|
||
? [
|
||
DataCell(Text("${index + 1}")),
|
||
DataCell(Text(
|
||
row.name,
|
||
maxLines: 2,
|
||
)),
|
||
DataCell(Text(row.bio)),
|
||
DataCell(Text(row.tweets.toString())),
|
||
]
|
||
: [
|
||
DataCell(Text("${index + 1}")),
|
||
DataCell(Text(
|
||
row.name,
|
||
maxLines: 2,
|
||
)),
|
||
DataCell(Text(row.bio)),
|
||
DataCell(Text(row.followers)),
|
||
DataCell(Text(row.tweets.toString())),
|
||
DataCell(Row(
|
||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||
children: [
|
||
Container(
|
||
height: isTablet ? 40 : 34,
|
||
width: isTablet ? 40 : 34,
|
||
decoration: BoxDecoration(
|
||
shape: BoxShape.circle,
|
||
color: Colors.green,
|
||
),
|
||
child: Icon(
|
||
Icons.thumb_up,
|
||
color: Colors.white,
|
||
size: isTablet ? 24 : 18,
|
||
),
|
||
alignment: Alignment.center,
|
||
),
|
||
Text(" ${row.tweetsentiments.toString()} % "),
|
||
Container(
|
||
height: isTablet ? 40 : 34,
|
||
width: isTablet ? 40 : 34,
|
||
decoration: BoxDecoration(
|
||
shape: BoxShape.circle,
|
||
color: Colors.yellow,
|
||
),
|
||
child: Icon(
|
||
Icons.thumbs_up_down,
|
||
color: Colors.white,
|
||
size: isTablet ? 24 : 18,
|
||
),
|
||
alignment: Alignment.center,
|
||
),
|
||
Text(" ${row.tweetsentiments.toString()} % "),
|
||
Container(
|
||
height: isTablet ? 40 : 34,
|
||
width: isTablet ? 40 : 34,
|
||
decoration: BoxDecoration(
|
||
shape: BoxShape.circle,
|
||
color: Colors.red,
|
||
),
|
||
child: Icon(
|
||
Icons.thumb_down,
|
||
color: Colors.white,
|
||
size: isTablet ? 24 : 18,
|
||
),
|
||
alignment: Alignment.center,
|
||
),
|
||
Text(" 0 % "),
|
||
],
|
||
)),
|
||
],
|
||
);
|
||
}
|
||
|
||
@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: 17,
|
||
),
|
||
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.blue,
|
||
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.blue,
|
||
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,
|
||
),
|
||
);
|
||
}
|
||
}
|