Adding fancy stuff to events list

This commit is contained in:
rzuasti
2026-02-11 18:31:12 -05:00
parent f927294194
commit 9c5755a2d9
2 changed files with 94 additions and 62 deletions
+38 -8
View File
@@ -3,9 +3,15 @@ import 'package:frontend/utils/friendly_date_formatter.dart';
import '../model/event.dart'; import '../model/event.dart';
import '../model/device_type.dart'; import '../model/device_type.dart';
// Dummy events to display class EventsList extends StatefulWidget {
// TODO : Replace with API call @override
final List<Event> events = <Event>[ _EventListState createState() => _EventListState();
}
class _EventListState extends State<EventsList> {
// Dummy events to display
// TODO : Replace with API call
List<Event> events = <Event>[
Event( Event(
id: 5, id: 5,
title: 'New device found', title: 'New device found',
@@ -46,24 +52,48 @@ final List<Event> events = <Event>[
deviceType: DeviceType.phone, deviceType: DeviceType.phone,
dateTime: DateTime(2026, 01, 17, 14, 47), dateTime: DateTime(2026, 01, 17, 14, 47),
), ),
]; ];
class EventsList extends StatelessWidget {
const EventsList({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListView.separated( return Scaffold(
appBar: AppBar(title: const Text('Events')),
body: ListView.separated(
itemCount: events.length, itemCount: events.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return ListTile( return Dismissible(
key: UniqueKey(),
onDismissed: (direction) {
setState(() {
events.removeAt(index);
});
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Event marked as read'),
behavior: SnackBarBehavior.floating,
showCloseIcon: true,
),
);
},
background: Container(
color: Theme.of(context).colorScheme.primaryContainer,
alignment: Alignment.center,
child: Icon(Icons.done),
),
child: ListTile(
leading: Icon(events[index].deviceType.icon), leading: Icon(events[index].deviceType.icon),
title: Text( title: Text(
'${FriendlyDateFormatter().format(events[index].dateTime)} - ${events[index].title}', '${FriendlyDateFormatter().format(events[index].dateTime)} - ${events[index].title}',
), ),
subtitle: Text(events[index].description), subtitle: Text(events[index].description),
trailing: Icon(Icons.more_vert),
onTap: () {},
),
); );
}, },
separatorBuilder: (context, index) => Divider(), separatorBuilder: (context, index) => Divider(),
),
); );
} }
} }
+6 -4
View File
@@ -14,7 +14,7 @@ final GoRouter router = GoRouter(
GoRoute( GoRoute(
path: '/events', path: '/events',
name: 'events', name: 'events',
builder: (context, state) => const EventsList(), builder: (context, state) => EventsList(),
), ),
GoRoute( GoRoute(
path: '/devices', path: '/devices',
@@ -49,7 +49,9 @@ class MainShell extends StatelessWidget {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('OOTT'), title: const Text('OOTT'),
backgroundColor: Theme.of(context).colorScheme.surfaceBright, backgroundColor: Theme.of(
context,
).colorScheme.surfaceContainerLowest,
), ),
body: Row( body: Row(
children: [ children: [
@@ -57,7 +59,7 @@ class MainShell extends StatelessWidget {
child: NavigationRail( child: NavigationRail(
backgroundColor: Theme.of( backgroundColor: Theme.of(
context, context,
).colorScheme.primaryContainer, ).colorScheme.surfaceContainerLow,
extended: constraints.maxWidth >= 600, extended: constraints.maxWidth >= 600,
destinations: [ destinations: [
NavigationRailDestination( NavigationRailDestination(
@@ -89,7 +91,7 @@ class MainShell extends StatelessWidget {
Expanded( Expanded(
child: Container( child: Container(
padding: const EdgeInsets.all(20), padding: const EdgeInsets.all(20),
color: Theme.of(context).colorScheme.surfaceDim, color: Theme.of(context).colorScheme.surface,
child: child, child: child,
), ),
), ),