Surface/lib/widgets/attachment/attachment_item.dart

26 lines
736 B
Dart
Raw Normal View History

2024-11-09 04:04:03 +00:00
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:surface/providers/sn_network.dart';
import 'package:surface/types/attachment.dart';
import 'package:surface/widgets/universal_image.dart';
class AttachmentItem extends StatelessWidget {
final SnAttachment data;
const AttachmentItem({super.key, required this.data});
@override
Widget build(BuildContext context) {
final tp = data.mimetype.split('/').firstOrNull;
final sn = context.read<SnNetworkProvider>();
switch (tp) {
case 'image':
2024-11-10 08:41:11 +00:00
return UniversalImage(
sn.getAttachmentUrl(data.rid),
fit: BoxFit.cover,
2024-11-09 04:04:03 +00:00
);
default:
return const Placeholder();
}
}
}