Vaani/lib/shared/widgets/shelves/author_shelf.dart
Dr.Blank e23c0b6c5f
Some checks are pending
Flutter CI & Release / Test (push) Waiting to run
Flutter CI & Release / Build Android APKs (push) Blocked by required conditions
Flutter CI & Release / build_linux (push) Blocked by required conditions
Flutter CI & Release / Create GitHub Release (push) Blocked by required conditions
chore: run dart format
2026-01-10 16:51:05 +05:30

73 lines
2.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:shelfsdk/audiobookshelf_api.dart';
import 'package:vaani/shared/extensions/model_conversions.dart';
import 'package:vaani/shared/widgets/shelves/home_shelf.dart';
/// A shelf that displays Authors on the home page
class AuthorHomeShelf extends HookConsumerWidget {
const AuthorHomeShelf({super.key, required this.shelf, required this.title});
final String title;
final AuthorShelf shelf;
@override
Widget build(BuildContext context, WidgetRef ref) {
return SimpleHomeShelf(
title: title,
children: shelf.entities
.map((item) => AuthorOnShelf(item: item))
.toList(),
);
}
}
// a widget to display a item on the shelf
class AuthorOnShelf extends HookConsumerWidget {
const AuthorOnShelf({super.key, required this.item});
final Author item;
@override
Widget build(BuildContext context, WidgetRef ref) {
final author = item.asMinified;
// final coverImage = ref.watch(coverImageProvider(item));
return Container(
margin: const EdgeInsets.only(right: 10, bottom: 10),
constraints: const BoxConstraints(maxWidth: 100),
child: Column(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(50),
child: AspectRatio(
aspectRatio: 1,
child: Container(
constraints: const BoxConstraints(maxWidth: 50),
// child: coverImage.when(
// data: (image) {
// return Image.memory(image, fit: BoxFit.cover);
// },
// loading: () {
// return const Center(child: CircularProgressIndicator());
// },
// error: (error, stack) {
// return const Icon(Icons.error);
// },
// ),
),
),
),
Container(
margin: const EdgeInsets.all(5),
child: Text(
author.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
),
);
}
}