pparth602

Untitled

Oct 30th, 2020
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 3.07 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_svg/flutter_svg.dart';
  3.  
  4. class BookInfoTile extends StatelessWidget {
  5.   final String bookCoverImageURL;
  6.   final String bookTitle;
  7.   final String authorName;
  8.   final int bookLength;
  9.   final onClick;
  10.   final Function onStop;
  11.  
  12.   const BookInfoTile(
  13.       {Key key,
  14.       @required this.bookCoverImageURL,
  15.       @required this.bookTitle,
  16.       @required this.authorName,
  17.       @required this.bookLength,
  18.       @required this.onClick,
  19.       this.onStop})
  20.       : super(key: key);
  21.   @override
  22.   Widget build(BuildContext context) {
  23.     Size size = MediaQuery.of(context).size;
  24.     return GestureDetector(
  25.       onTap: onClick,
  26.       child: Expanded(
  27.         child: Row(
  28.           mainAxisAlignment: MainAxisAlignment.start,
  29.           crossAxisAlignment: CrossAxisAlignment.center,
  30.           children: [
  31.             ClipRRect(
  32.               borderRadius: BorderRadius.circular(25.0),
  33.               child: Image.asset(
  34.                 bookCoverImageURL,
  35.                 fit: BoxFit.fill,
  36.                 alignment: Alignment.centerLeft,
  37.                 height: size.height * 0.22,
  38.                 width: size.width * 0.40,
  39.               ),
  40.             ),
  41.             SizedBox(width: 16),
  42.             Expanded(
  43.               child: Column(
  44.                 crossAxisAlignment: CrossAxisAlignment.start,
  45.                 children: [
  46.                   Text(
  47.                     bookTitle,
  48.                     overflow: TextOverflow.visible,
  49.                     style: TextStyle(
  50.                       fontWeight: FontWeight.bold,
  51.                       color: Colors.black,
  52.                     ),
  53.                   ),
  54.                   const SizedBox(
  55.                     height: 10,
  56.                   ),
  57.                   Text(
  58.                     'by $authorName',
  59.                     style: TextStyle(
  60.                       fontSize: 15,
  61.                       fontWeight: FontWeight.normal,
  62.                       color: Color(0xFF767676),
  63.                     ),
  64.                   ),
  65.                   const SizedBox(
  66.                     height: 8,
  67.                   ),
  68.                   RichText(
  69.                     text: TextSpan(
  70.                       children: [
  71.                         WidgetSpan(
  72.                           alignment: PlaceholderAlignment.middle,
  73.                           child: SvgPicture.asset(
  74.                             'assets/svg/circle-fill.svg',
  75.                             color: Color(0xFFffe564),
  76.                             height: 10,
  77.                             alignment: Alignment.topCenter,
  78.                           ),
  79.                         ),
  80.                         TextSpan(
  81.                           text: " $bookLength",
  82.                         ),
  83.                       ],
  84.                     ),
  85.                   ),
  86.                   RaisedButton(
  87.                     onPressed: onStop,
  88.                     child: Text('Stop'),
  89.                   ),
  90.                 ],
  91.               ),
  92.             ),
  93.           ],
  94.         ),
  95.       ),
  96.     );
  97.   }
  98. }
  99.  
Advertisement
Add Comment
Please, Sign In to add comment