35 lines
1.1 KiB
Dart
35 lines
1.1 KiB
Dart
// lib/remote/remote_image_tile.dart
|
|
import 'package:flutter/material.dart';
|
|
import 'remote_http.dart';
|
|
import 'package:aves/model/entry/entry.dart';
|
|
|
|
class RemoteImageTile extends StatelessWidget {
|
|
final AvesEntry entry;
|
|
const RemoteImageTile({super.key, required this.entry});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// Usa SOLO campi remoti, mai entry.path
|
|
final rel = entry.remoteThumb2 ?? entry.remoteThumb1 ?? entry.remotePath;
|
|
if (rel == null || rel.isEmpty) {
|
|
return const ColoredBox(color: Colors.black12);
|
|
}
|
|
final url = RemoteHttp.absUrl(rel);
|
|
|
|
return FutureBuilder<Map<String, String>>(
|
|
future: RemoteHttp.headers(),
|
|
builder: (context, snap) {
|
|
if (snap.connectionState != ConnectionState.done) {
|
|
return const ColoredBox(color: Colors.black12);
|
|
}
|
|
final hdrs = snap.data ?? const {};
|
|
return Image.network(
|
|
url,
|
|
fit: BoxFit.cover,
|
|
headers: hdrs.isEmpty ? null : hdrs,
|
|
errorBuilder: (_, __, ___) => const Icon(Icons.broken_image),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|