feat(ui): la carte reprend l'image importée en fond (voile pour lisibilité)
Build APK / build (push) Successful in 2m49s
Build APK / build (push) Successful in 2m49s
- ServerCard: fond = image (MemoryImage) + scrim dégradé si présente, sinon dégradé thématique ; vignette d'icône masquée quand image de fond. - servers_screen: fetch des bytes image (cache par id, vidé au refresh) → passe à la carte ; plus de FutureBuilder iconUrl inutile. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
2862fdd408
commit
fb4ab95f13
@@ -1,3 +1,5 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../models.dart';
|
||||
@@ -27,6 +29,15 @@ class _ServersScreenState extends State<ServersScreen> {
|
||||
List<GameServer>? _servers;
|
||||
String? _error;
|
||||
final _busy = <String>{};
|
||||
final _imgCache = <String, Uint8List?>{};
|
||||
|
||||
Future<Uint8List?> _image(GameServer s) async {
|
||||
if (!s.hasImage) return null;
|
||||
if (_imgCache.containsKey(s.id)) return _imgCache[s.id];
|
||||
final b = await widget.api.imageBytes(s.id).catchError((_) => null);
|
||||
_imgCache[s.id] = b;
|
||||
return b;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -41,6 +52,7 @@ class _ServersScreenState extends State<ServersScreen> {
|
||||
if (mounted) setState(() {
|
||||
_servers = servers;
|
||||
_error = null;
|
||||
_imgCache.clear(); // recharge les images (elles ont pu changer)
|
||||
});
|
||||
} on UnauthorizedException {
|
||||
await widget.auth.logout();
|
||||
@@ -191,11 +203,12 @@ class _ServersScreenState extends State<ServersScreen> {
|
||||
|
||||
Widget _card(GameServer s) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 14),
|
||||
child: FutureBuilder<String>(
|
||||
future: widget.api.iconUrl(s.id),
|
||||
child: FutureBuilder<Uint8List?>(
|
||||
future: _image(s),
|
||||
builder: (_, snap) => ServerCard(
|
||||
server: s,
|
||||
iconUrl: snap.data ?? '',
|
||||
iconUrl: '',
|
||||
imageBytes: snap.data,
|
||||
busy: _busy.contains(s.id),
|
||||
onToggle: () => _toggle(s),
|
||||
onTap: () => _openDetail(s),
|
||||
|
||||
Reference in New Issue
Block a user