diff --git a/lib/screens/bookmarks/ui/bookmark_item.dart b/lib/screens/bookmarks/ui/bookmark_item.dart index c12760c..72585cb 100644 --- a/lib/screens/bookmarks/ui/bookmark_item.dart +++ b/lib/screens/bookmarks/ui/bookmark_item.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:favicon/favicon.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:linkdy/models/data/bookmarks.dart'; import 'package:linkdy/providers/app_status_provider.dart'; @@ -35,16 +37,45 @@ class BookmarkItem extends ConsumerWidget { isThreeLine: true, title: Padding( padding: const EdgeInsets.only(bottom: 4), - child: Text( - validateStrings(bookmark.title, bookmark.websiteTitle), - maxLines: 2, - overflow: TextOverflow.ellipsis, - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Theme.of(context).colorScheme.onSurface, - ), + child: Row( + children: [ + FutureBuilder( + future: FaviconFinder.getBest(bookmark.url!), + builder: (context, snapshot) { + if (snapshot.data == null) return const SizedBox(); + return Row( + children: [ + if (snapshot.data!.url.contains("svg")) + SvgPicture.network( + snapshot.data!.url, + width: 16, + height: 16, + ), + if (!snapshot.data!.url.contains("svg")) + Image.network( + snapshot.data!.url, + width: 16, + height: 16, + ), + const SizedBox(width: 8), + ], + ); + }, + ), + Expanded( + child: Text( + validateStrings(bookmark.title, bookmark.websiteTitle), + maxLines: 1, + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.left, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Theme.of(context).colorScheme.onSurface, + ), + ), + ), + ], ), ), subtitle: Column( diff --git a/pubspec.lock b/pubspec.lock index 9a3283c..84d9b57 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -313,6 +313,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + favicon: + dependency: "direct main" + description: + name: favicon + sha256: ebb7423ba7ccc87d3cce9b60de1b5f72004de3cddeedd88d98463fc7f66faf0c + url: "https://pub.dev" + source: hosted + version: "1.1.2" ffi: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index f3eac39..1fd7ef2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,6 +54,7 @@ dependencies: easy_autocomplete: ^1.6.0 sentry_flutter: ^7.16.1 flutter_dotenv: ^5.1.0 + favicon: ^1.1.2 dev_dependencies: build_runner: ^2.4.8