Added favicons bookmarks list

This commit is contained in:
Juan Gilsanz Polo
2024-02-24 16:05:36 +01:00
parent 01e2732b69
commit 93f74b1eef
3 changed files with 50 additions and 10 deletions

View File

@@ -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,9 +37,35 @@ class BookmarkItem extends ConsumerWidget {
isThreeLine: true,
title: Padding(
padding: const EdgeInsets.only(bottom: 4),
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: 2,
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.left,
style: TextStyle(
@@ -47,6 +75,9 @@ class BookmarkItem extends ConsumerWidget {
),
),
),
],
),
),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [

View File

@@ -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:

View File

@@ -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