import 'package:desktopapp/classes/stream_element.dart'; import 'package:desktopapp/utils/requests.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; class StreamElementCard extends StatelessWidget { const StreamElementCard({Key? key, required this.streamElement}) : super(key: key); final StreamElement streamElement; @override Widget build(BuildContext context) { IconData icon; switch (streamElement.type) { case StreamElementType.log: icon = Icons.info; break; case StreamElementType.alert: icon = Icons.notifications_active; break; } return Card( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Text( DateFormat.jms().format(streamElement.date), style: const TextStyle(fontSize: 16), ), const SizedBox(width: 8), Icon( icon, size: 30, ), const SizedBox(width: 8), Expanded( child: Text( streamElement.message, style: const TextStyle(fontSize: 16), ), ), if (streamElement.type == StreamElementType.alert) IconButton( icon: const Icon(Icons.send), onPressed: () async { await Requests.sendAlert(streamElement.message, type: AlertType.host); }, ), ], ) ], ), ), ); } }