53 lines
1.4 KiB
Dart
53 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
class HistoryItem extends StatelessWidget {
|
|
final DateTime timestamp;
|
|
final String imageUrl;
|
|
|
|
const HistoryItem({
|
|
super.key,
|
|
required this.timestamp,
|
|
required this.imageUrl,
|
|
});
|
|
|
|
void _showImageDialog(BuildContext context) {
|
|
showDialog(
|
|
context: context,
|
|
builder:
|
|
(_) => GestureDetector(
|
|
onTap: () => Navigator.of(context).pop(), // tutup saat tap di luar
|
|
child: Scaffold(
|
|
backgroundColor: Colors.black.withOpacity(0.8),
|
|
body: Center(
|
|
child: Hero(tag: imageUrl, child: Image.network(imageUrl)),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final formattedTime = DateFormat('dd MMM yyyy - HH:mm').format(timestamp);
|
|
return Card(
|
|
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
|
child: ListTile(
|
|
leading: Text(formattedTime, style: const TextStyle(fontSize: 14)),
|
|
trailing: GestureDetector(
|
|
onTap: () => _showImageDialog(context),
|
|
child: Hero(
|
|
tag: imageUrl,
|
|
child: Image.network(
|
|
imageUrl,
|
|
width: 60,
|
|
height: 60,
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|