import 'package:flutter/material.dart'; import 'package:openlib/ui/extensions.dart'; import 'package:cached_network_image/cached_network_image.dart'; // TODO: Redesign this widget class BookInfoCard extends StatelessWidget { const BookInfoCard( {Key? key, required this.title, required this.author, required this.publisher, required this.thumbnail, required this.link, required this.onClick}) : super(key: key); final String title; final String author; final String publisher; final String? thumbnail; final String link; final VoidCallback onClick; @override Widget build(BuildContext context) { return Card( shadowColor: Colors.black.withOpacity(0), margin: const EdgeInsets.only(bottom: 20), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15), side: BorderSide( color: Theme.of(context).colorScheme.surfaceVariant, width: 1, ), ), child: InkWell( onTap: onClick, borderRadius: BorderRadius.circular(15), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ CachedNetworkImage( height: 140, width: 105, imageUrl: thumbnail ?? "", imageBuilder: (context, imageProvider) => Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), image: DecorationImage( image: imageProvider, fit: BoxFit.fill, ), ), ), placeholder: (context, url) => Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), color: Theme.of(context).colorScheme.surfaceVariant, ), height: 120, width: 90, ), errorWidget: (context, url, error) { return Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), color: Theme.of(context).colorScheme.surfaceVariant, ), height: 120, width: 90, child: const Center( child: Icon(Icons.image_rounded), ), ); }, ), Expanded( child: Padding( padding: const EdgeInsets.all(18), child: SizedBox( width: double.infinity, child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( title, style: const TextStyle( fontSize: 18, fontWeight: FontWeight.bold, // color: Colors.black, ), overflow: TextOverflow.ellipsis, maxLines: 2, ), Padding( padding: const EdgeInsets.symmetric(vertical: 4), child: Text( publisher, style: const TextStyle( fontSize: 12, fontWeight: FontWeight.w500, // color: "#4D4D4D".toColor(), ), overflow: TextOverflow.ellipsis, maxLines: 1, ), ), Text( author, style: TextStyle( fontSize: 14, fontWeight: FontWeight.w500, // color: "#7B7B7B".toColor(), color: Theme.of(context).colorScheme.onSurfaceVariant, ), overflow: TextOverflow.ellipsis, maxLines: 1, ), ], ), ), )) ], ), ), ); } }