Skip to content

Commit

Permalink
fix: render icon when no cover image available
Browse files Browse the repository at this point in the history
  • Loading branch information
nesquikm committed Nov 14, 2023
1 parent c83876a commit 421b667
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
13 changes: 9 additions & 4 deletions lib/features/library/view/tome_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@ class TomeCard extends StatelessWidget {

@override
Widget build(BuildContext context) {
final coverImagePath = tome.coverImagePath ?? '';

return Card(
clipBehavior: Clip.antiAlias,
child: Stack(
fit: StackFit.expand,
children: [
Image.file(
File(tome.coverImagePath ?? ''),
fit: BoxFit.cover,
),
if (coverImagePath.isNotEmpty)
Image.file(
File(coverImagePath),
fit: BoxFit.cover,
)
else
const Icon(Icons.book),
Positioned.fill(
child: Material(
color: Colors.transparent,
Expand Down
11 changes: 7 additions & 4 deletions lib/features/library/view/tome_list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ class TomeListTile extends StatelessWidget {
Widget build(BuildContext context) {
final l10n = context.l10n;
final tomeInfo = tome.tomeInfo;
final coverImagePath = tome.coverImagePath ?? '';

final leading = withCover
? ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 56),
child: Image.file(
File(tome.coverImagePath ?? ''),
fit: BoxFit.contain,
),
child: coverImagePath.isNotEmpty
? Image.file(
File(coverImagePath),
fit: BoxFit.contain,
)
: const Icon(Icons.book),
)
: null;

Expand Down

0 comments on commit 421b667

Please sign in to comment.