Surface/lib/widgets/attachment/attachment_item.dart

26 lines
786 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':
return AspectRatio(
aspectRatio: data.metadata['ratio']?.toDouble(),
child: UniversalImage(sn.getAttachmentUrl(data.rid)),
);
default:
return const Placeholder();
}
}
}