improve weblibre search

This commit is contained in:
Fabian Freund
2026-06-01 07:17:37 +02:00
parent 88f128621f
commit 453e1a6c30
23 changed files with 1095 additions and 796 deletions
@@ -32,6 +32,13 @@ import 'package:weblibre/features/user/domain/providers.dart';
import 'package:weblibre/presentation/hooks/cached_future.dart';
import 'package:weblibre/presentation/widgets/safe_raw_image.dart';
/// Origins served by a bundled asset instead of a network-fetched favicon.
/// Lets first-party properties (e.g. the WebLibre search bang) show their
/// brand mark rather than a generic globe or a remotely fetched icon.
const _bundledIconByOrigin = {
'https://weblibre.eu': 'assets/icon/bang_icon.png',
};
Uint8List? selectFirstCachedIconBytes(Iterable<Uint8List?> cachedBytesByUrl) {
for (final cachedBytes in cachedBytesByUrl) {
if (cachedBytes != null) {
@@ -60,6 +67,20 @@ class UrlIcon extends HookConsumerWidget {
.where((u) => u.isScheme('http') || u.isScheme('https'))
.toList();
for (final url in eligibleUrls) {
final asset = _bundledIconByOrigin[url.origin];
if (asset != null) {
return RepaintBoundary(
child: Image.asset(
asset,
height: iconSize,
width: iconSize,
fit: BoxFit.contain,
),
);
}
}
final cachedBytesByUrl = [
for (final url in eligibleUrls)
ref.watch(watchCachedIconBytesProvider(url.origin)).value,