68 lines
1.6 KiB
Dart
68 lines
1.6 KiB
Dart
/// Widget: File Item
|
|
///
|
|
/// Displays a file attachment item with icon and name.
|
|
library;
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
/// File Item Widget
|
|
///
|
|
/// Shows a file attachment with:
|
|
/// - File type icon
|
|
/// - File name extracted from URL
|
|
/// - Theme-aware styling
|
|
class FileItem extends StatelessWidget {
|
|
const FileItem({
|
|
super.key,
|
|
required this.fileUrl,
|
|
required this.icon,
|
|
});
|
|
|
|
final String fileUrl;
|
|
final IconData icon;
|
|
|
|
String get fileName {
|
|
final uri = Uri.parse(fileUrl);
|
|
return uri.pathSegments.isNotEmpty ? uri.pathSegments.last : fileUrl;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
|
|
return Container(
|
|
margin: const EdgeInsets.only(bottom: 8),
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: colorScheme.surfaceContainerHighest,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
width: 32,
|
|
height: 32,
|
|
decoration: BoxDecoration(
|
|
color: colorScheme.primary,
|
|
borderRadius: BorderRadius.circular(6),
|
|
),
|
|
child: Icon(icon, color: colorScheme.onPrimary, size: 14),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Text(
|
|
fileName,
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: colorScheme.onSurface,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|