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:flutter/material.dart';
import 'package:favicon/favicon.dart';
import 'package:flutter_riverpod/flutter_riverpod.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/models/data/bookmarks.dart';
import 'package:linkdy/providers/app_status_provider.dart'; import 'package:linkdy/providers/app_status_provider.dart';
@@ -35,16 +37,45 @@ class BookmarkItem extends ConsumerWidget {
isThreeLine: true, isThreeLine: true,
title: Padding( title: Padding(
padding: const EdgeInsets.only(bottom: 4), padding: const EdgeInsets.only(bottom: 4),
child: Text( child: Row(
validateStrings(bookmark.title, bookmark.websiteTitle), children: [
maxLines: 2, FutureBuilder(
overflow: TextOverflow.ellipsis, future: FaviconFinder.getBest(bookmark.url!),
textAlign: TextAlign.left, builder: (context, snapshot) {
style: TextStyle( if (snapshot.data == null) return const SizedBox();
fontSize: 16, return Row(
fontWeight: FontWeight.w500, children: [
color: Theme.of(context).colorScheme.onSurface, 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( subtitle: Column(

View File

@@ -313,6 +313,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.3.1" version: "1.3.1"
favicon:
dependency: "direct main"
description:
name: favicon
sha256: ebb7423ba7ccc87d3cce9b60de1b5f72004de3cddeedd88d98463fc7f66faf0c
url: "https://pub.dev"
source: hosted
version: "1.1.2"
ffi: ffi:
dependency: transitive dependency: transitive
description: description:

View File

@@ -54,6 +54,7 @@ dependencies:
easy_autocomplete: ^1.6.0 easy_autocomplete: ^1.6.0
sentry_flutter: ^7.16.1 sentry_flutter: ^7.16.1
flutter_dotenv: ^5.1.0 flutter_dotenv: ^5.1.0
favicon: ^1.1.2
dev_dependencies: dev_dependencies:
build_runner: ^2.4.8 build_runner: ^2.4.8