FahimHoque

appbar

Dec 15th, 2021 (edited)
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 5.48 KB | None | 0 0
  1. class SingleMerchantAppBar extends StatefulWidget {
  2.   final Merchant? merchant;
  3.   final double? scrollPosition;
  4.   const SingleMerchantAppBar({
  5.     Key? key,
  6.     this.merchant,
  7.     this.scrollPosition,
  8.   }) : super(key: key);
  9.  
  10.   @override
  11.   _SingleMerchantAppBarState createState() => _SingleMerchantAppBarState();
  12. }
  13.  
  14. class _SingleMerchantAppBarState extends State<SingleMerchantAppBar> {
  15.   @override
  16.   Widget build(BuildContext context) {
  17.     return Column(
  18.       children: [
  19.         Container(
  20.           height: 175,
  21.           child: Stack(
  22.             children: [
  23.               widget.scrollPosition == 0 || widget.scrollPosition! < 100
  24.                   ? _buildBackgroundImage(context)
  25.                   : Container(),
  26.               Container(
  27.                 padding: EdgeInsets.all(20),
  28.                 child: Column(
  29.                   crossAxisAlignment: CrossAxisAlignment.start,
  30.                   children: [
  31.                     Row(
  32.                       mainAxisAlignment: MainAxisAlignment.spaceBetween,
  33.                       children: <Widget>[
  34.                         CustomBackButton(
  35.                           greyBackground: true,
  36.                         ),
  37.                         CustomSearchButton(
  38.                           greyBackground: true,
  39.                           onPressed: () {},
  40.                         ),
  41.                       ],
  42.                     ),
  43.                     SizedBox(
  44.                       height: 30,
  45.                     ),
  46.                     Row(
  47.                       crossAxisAlignment: CrossAxisAlignment.start,
  48.                       children: <Widget>[
  49.                         MerchantThumbnailCard(
  50.                           imageUrl: "assets/images/aarong_logo_small.png",
  51.                         ),
  52.                         SizedBox(width: 15),
  53.                         Column(
  54.                           crossAxisAlignment: CrossAxisAlignment.start,
  55.                           children: [
  56.                             _buildNameAndRating(),
  57.                             SizedBox(
  58.                               height: 15,
  59.                             ),
  60.                             _buildFollowRow(context),
  61.                           ],
  62.                         ),
  63.                       ],
  64.                     ),
  65.                   ],
  66.                 ),
  67.               ),
  68.             ],
  69.           ),
  70.         ),
  71.         SizedBox(
  72.           height: 5,
  73.         ),
  74.         CategoryBar(),
  75.       ],
  76.     );
  77.   }
  78.  
  79.   Widget _buildFollowRow(BuildContext context) {
  80.     return Row(
  81.       children: <Widget>[
  82.         FollowButton(
  83.           isFollowing: true,
  84.           blackBackground:
  85.               widget.scrollPosition == 0 || widget.scrollPosition! < 100
  86.                   ? false
  87.                   : true,
  88.           onPressed: () {},
  89.         ),
  90.         SizedBox(width: 20),
  91.         FollowerCountIcon(
  92.           isBlack: widget.scrollPosition == 0 || widget.scrollPosition! < 100
  93.               ? false
  94.               : true,
  95.           followerCount: 4900,
  96.         ),
  97.         SizedBox(width: 20),
  98.         AboutMerchantButton(
  99.           isBlack: widget.scrollPosition == 0 || widget.scrollPosition! < 100
  100.               ? false
  101.               : true,
  102.           onPressed: () {
  103.             openMerchantProfilePage(context);
  104.           },
  105.         ),
  106.       ],
  107.     );
  108.   }
  109.  
  110.   Widget _buildBackgroundImage(BuildContext context) {
  111.     return ClipRRect(
  112.       borderRadius: BorderRadius.only(
  113.         bottomLeft: Radius.circular(20),
  114.         bottomRight: Radius.circular(20),
  115.       ),
  116.       child: AnimatedOpacity(
  117.         opacity: widget.scrollPosition == 0 ? 1 : 0,
  118.         duration: const Duration(milliseconds: 100),
  119.         child: Container(
  120.           decoration: BoxDecoration(
  121.             borderRadius: BorderRadius.only(
  122.               bottomRight: Radius.circular(20.0),
  123.               bottomLeft: Radius.circular(20.0),
  124.             ),
  125.             /*
  126.               TO DO: BEFORE PROD CHANGE THIS TO NETWORK IMAGE
  127.             */
  128.             image: DecorationImage(
  129.               image: AssetImage('assets/images/mock_aarong_background.png'),
  130.               fit: BoxFit.cover,
  131.             ),
  132.           ),
  133.           // child: FittedBox(
  134.           //   child: Image.asset(
  135.           //     'assets/images/mock_aarong_background.png',
  136.           //     fit: BoxFit.fill,
  137.           //   ),
  138.           // ),
  139.         ),
  140.       ),
  141.     );
  142.   }
  143.  
  144.   Widget _buildNameAndRating() {
  145.     return Row(
  146.       children: <Widget>[
  147.         Text(
  148.           widget.merchant!.merchantName!,
  149.           style: TextStyle(
  150.             color: widget.scrollPosition == 0 || widget.scrollPosition! < 100
  151.                 ? CustomColors.white
  152.                 : CustomColors.primary,
  153.             fontSize: 18,
  154.             fontWeight: FontWeight.w600,
  155.           ),
  156.         ),
  157.         SizedBox(width: 30),
  158.         _buildRating(context),
  159.       ],
  160.     );
  161.   }
  162.  
  163.   Widget _buildRating(BuildContext context) {
  164.     return Row(
  165.       children: <Widget>[
  166.         Icon(
  167.           Icons.star,
  168.           color: Colors.amber,
  169.           size: 20,
  170.         ),
  171.         SizedBox(width: 5),
  172.         Text(
  173.           widget.merchant!.merchantRating!.toString(),
  174.           style: TextStyle(
  175.             color: widget.scrollPosition == 0 || widget.scrollPosition! < 100
  176.                 ? CustomColors.white
  177.                 : CustomColors.primary,
  178.             fontSize: 18,
  179.             fontWeight: FontWeight.w600,
  180.           ),
  181.         )
  182.       ],
  183.     );
  184.   }
  185. }
  186.  
  187.  
Add Comment
Please, Sign In to add comment