1
0
Fork 0
mrtiboute/lib/widgets/components/stream_element_card.dart

62 lines
1.7 KiB
Dart
Raw Normal View History

2022-04-14 21:57:32 +02:00
import 'package:desktopapp/classes/stream_element.dart';
2022-04-14 22:48:15 +02:00
import 'package:desktopapp/utils/requests.dart';
2022-04-14 21:57:32 +02:00
import 'package:flutter/material.dart';
2022-04-14 22:48:15 +02:00
import 'package:intl/intl.dart';
2022-04-14 21:57:32 +02:00
class StreamElementCard extends StatelessWidget {
2022-04-14 22:48:15 +02:00
const StreamElementCard({Key? key, required this.streamElement})
: super(key: key);
2022-04-14 21:57:32 +02:00
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: [
2022-04-14 22:48:15 +02:00
Text(
DateFormat.jms().format(streamElement.date),
style: const TextStyle(fontSize: 16),
),
const SizedBox(width: 8),
2022-04-14 21:57:32 +02:00
Icon(
icon,
size: 30,
),
2022-04-14 22:48:15 +02:00
const SizedBox(width: 8),
Expanded(
child: Text(
streamElement.message,
style: const TextStyle(fontSize: 16),
),
2022-04-14 21:57:32 +02:00
),
2022-04-14 22:48:15 +02:00
if (streamElement.type == StreamElementType.alert)
IconButton(
icon: const Icon(Icons.send),
onPressed: () async {
await Requests.sendAlert(streamElement.message);
},
),
2022-04-14 21:57:32 +02:00
],
)
],
),
),
);
}
}