Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:app/router.dart';
- import 'package:app/src/components/buttons/about_merchant_button.dart';
- import 'package:app/src/components/buttons/back_button.dart';
- import 'package:app/src/components/buttons/follow_button.dart';
- import 'package:app/src/components/buttons/search_button.dart';
- import 'package:app/src/components/cards/merchant_thumbnail_card.dart';
- import 'package:app/src/components/icons/follower_count_icon.dart';
- import 'package:app/src/constants/custom_colors.dart';
- import 'package:app/src/models/merchant_model.dart';
- import 'package:flutter/material.dart';
- class MerchantSliverAppbar extends StatefulWidget {
- final Merchant merchant;
- const MerchantSliverAppbar({
- Key? key,
- required this.merchant,
- }) : super(key: key);
- @override
- _MerchantSliverAppbarState createState() => _MerchantSliverAppbarState();
- }
- class _MerchantSliverAppbarState extends State<MerchantSliverAppbar> {
- @override
- Widget build(BuildContext context) {
- final size = MediaQuery.of(context).size;
- // final maxHeightAppbar = 80;
- return SliverAppBar(
- expandedHeight: 200.0,
- pinned: true,
- floating: false,
- snap: false,
- backgroundColor: CustomColors.white,
- leading: CustomBackButton(greyBackground: false),
- flexibleSpace: merchantExpandedView(size),
- actions: [
- CustomSearchButton(
- greyBackground: false,
- onPressed: () {
- openSearchPage(context);
- },
- ),
- ],
- );
- }
- Widget merchantExpandedView(size) {
- return Container(
- child: LayoutBuilder(
- builder: (BuildContext context, BoxConstraints constraints) {
- double scrollPosition = constraints.biggest.height;
- return FlexibleSpaceBar(
- centerTitle: true,
- title: scrollPosition < 80
- ? buildTitle(scrollPosition, CustomColors.primary)
- : null,
- background: Stack(
- children: <Widget>[
- _buildBackgroundImage(),
- Positioned(
- bottom: 30.0,
- left: 15.0,
- child: _buildMerchantInfo(scrollPosition),
- ),
- ],
- ),
- );
- },
- ),
- );
- }
- Widget _buildBackgroundImage() {
- return ClipRRect(
- borderRadius: BorderRadius.only(
- bottomLeft: Radius.circular(20),
- bottomRight: Radius.circular(20),
- ),
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.only(
- bottomRight: Radius.circular(20.0),
- bottomLeft: Radius.circular(20.0),
- ),
- image: DecorationImage(
- image: AssetImage('assets/images/mock_background.png'),
- fit: BoxFit.cover,
- ),
- ),
- ),
- );
- }
- Widget _buildMerchantInfo(double scrollPosition) {
- return Container(
- padding: EdgeInsets.all(20),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- MerchantThumbnailCard(
- imageUrl: "assets/images/aarong_logo_small.png",
- ),
- SizedBox(width: 15),
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- buildTitle(scrollPosition, CustomColors.white),
- SizedBox(width: 40),
- _buildRadting(),
- ],
- ),
- SizedBox(
- height: 15,
- ),
- _buildButtonRow(),
- ],
- ),
- ],
- ),
- ],
- ),
- );
- }
- Widget buildTitle(double scrollPosition, Color color) {
- return Text(
- widget.merchant.merchantName!.toUpperCase(),
- maxLines: 1,
- style: TextStyle(
- color: color,
- fontSize: 20.0,
- fontWeight: FontWeight.w500,
- ),
- );
- }
- Widget _buildRadting() {
- return Container(
- child: Row(
- children: [
- Icon(
- Icons.star,
- color: Colors.amber,
- size: 18,
- ),
- Text(
- "4.5",
- style: TextStyle(
- color: CustomColors.primary,
- fontSize: 18,
- ),
- ),
- ],
- ),
- );
- }
- Widget _buildButtonRow() {
- return Row(
- children: [
- FollowButton(
- isFollowing: false,
- blackBackground: false,
- onPressed: () {},
- ),
- SizedBox(width: 20),
- FollowerCountIcon(
- followerCount: widget.merchant.merchantFollowers!.toInt(),
- ),
- SizedBox(width: 20),
- AboutMerchantButton(
- onPressed: () {
- openMerchantProfilePage(context);
- },
- ),
- ],
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement