DiscoverModule/lib/ui_screen/events_data.dart

116 lines
3.9 KiB
Dart
Raw Normal View History

2024-07-05 08:48:29 +00:00
import 'package:discover_module/provider_class/affiliationsprovider.dart';
import 'package:discover_module/provider_class/events_provider.dart';
import 'package:discover_module/provider_class/publications_provider.dart';
2024-08-30 12:24:54 +00:00
import 'package:discover_module/ui_screen/bottom_sheet.dart';
2024-07-05 08:48:29 +00:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class EventsData extends StatefulWidget {
2024-08-30 12:24:54 +00:00
// const EventsData({super.key});
EventsData({required this.text, Key? key}) : super(key: key);
final int text;
2024-07-05 08:48:29 +00:00
@override
State<EventsData> createState() => _EventsDataState();
}
class _EventsDataState extends State<EventsData> {
2024-08-30 12:24:54 +00:00
List event_data = [];
2024-07-05 08:48:29 +00:00
@override
void initState() {
// TODO: implement initState
super.initState();
affdata();
}
affdata() async {
2024-08-30 12:24:54 +00:00
var events = Provider.of<EventProvider>(context, listen: false);
await events.geteventdata(widget.text);
final eventlist = events.EventsList;
2024-07-05 08:48:29 +00:00
setState(() {
2024-08-30 12:24:54 +00:00
event_data = eventlist;
2024-07-05 08:48:29 +00:00
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
2024-08-30 12:24:54 +00:00
title: Text('Events'),
2024-07-05 08:48:29 +00:00
),
body: Scrollbar(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
2024-08-30 12:24:54 +00:00
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Container(
constraints:
BoxConstraints(minWidth: MediaQuery.of(context).size.width),
child: DataTable(
showCheckboxColumn: false,
columns: const [
DataColumn(
label: Expanded(
child: Text('Event Name',
softWrap: true,
style: TextStyle(fontWeight: FontWeight.w600)),
)),
DataColumn(
label: Expanded(
child: Text('Role',
softWrap: true,
style:
TextStyle(fontWeight: FontWeight.w600)))),
// Add more columns as needed
],
rows: List.generate(
event_data.length,
(index) => DataRow(
onSelectChanged: (value) {
// =======> Use onSelectChanged for tab
print("message ${event_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(event_data[index]);
},
);
},
cells: [
DataCell(Text(
event_data[index]['event_name'].toString(),
softWrap: true)),
2024-07-05 08:48:29 +00:00
2024-08-30 12:24:54 +00:00
DataCell(Text(event_data[index]['role'].toString(),
softWrap: true)),
2024-07-05 08:48:29 +00:00
2024-08-30 12:24:54 +00:00
// Add more DataCells as needed
],
),
2024-07-05 08:48:29 +00:00
),
),
),
),
),
));
}
}