From 7f7601b1ed4ad76f2729e8dca18c0dedd856c604 Mon Sep 17 00:00:00 2001 From: meylis98 Date: Thu, 9 Mar 2023 03:35:53 +0500 Subject: [PATCH] glove effect removed on scroll in homeScreen --- lib/features/screens/home/home_screen.dart | 329 +++++++++++---------- 1 file changed, 166 insertions(+), 163 deletions(-) diff --git a/lib/features/screens/home/home_screen.dart b/lib/features/screens/home/home_screen.dart index 97bd43a..0cf5035 100644 --- a/lib/features/screens/home/home_screen.dart +++ b/lib/features/screens/home/home_screen.dart @@ -97,180 +97,183 @@ class _HomeScreenState extends State with TickerProviderStateMixin { vertical: GlobalVariables.verticalPadding(context) / 2, horizontal: GlobalVariables.horizontalPadding(context), ), - child: NestedScrollView( - physics: const BouncingScrollPhysics(), - scrollBehavior: CustomScrollBehavior(), - headerSliverBuilder: (context, innerBoxIsScrolled) => [ - SliverToBoxAdapter( - child: Column( - children: [ - Container( - height: 50.adaptedPx(), - width: MediaQuery.of(context).size.width, - decoration: BoxDecoration( - color: AppTheme.whiteColor, - borderRadius: BorderRadius.circular(30.adaptedPx()), - ), - child: TextButton( - onPressed: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const SearchScreen(), - ), - ); - }, - style: TextButton.styleFrom( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(30.adaptedPx()), - ), + child: ScrollConfiguration( + behavior: CustomScrollBehavior(), + child: NestedScrollView( + physics: const BouncingScrollPhysics(), + headerSliverBuilder: (context, innerBoxIsScrolled) => [ + SliverToBoxAdapter( + child: Column( + children: [ + Container( + height: 50.adaptedPx(), + width: MediaQuery.of(context).size.width, + decoration: BoxDecoration( + color: AppTheme.whiteColor, + borderRadius: + BorderRadius.circular(30.adaptedPx()), ), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.symmetric( - horizontal: 15.adaptedPx()), - child: SvgPicture.asset( - 'assets/icons/search.svg'), - ), - Text( - 'searchHint'.translation, - style: GoogleFonts.poppins( - textStyle: Theme.of(context) - .primaryTextTheme - .bodyMedium - ?.copyWith( - fontSize: 16.adaptedPx(), - color: AppTheme.lightTextColor, - ), + child: TextButton( + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const SearchScreen(), ), + ); + }, + style: TextButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(30.adaptedPx()), ), - ], - ), - ), - ), - CarouselSlider( - items: (sliders != null) - ? [ - for (int i = 0; i < sliders.length; i++) - CachedNetworkImage( - imageUrl: sliders[i].img, - width: - GlobalVariables.deviceWidth(context), - fit: BoxFit.contain, - progressIndicatorBuilder: - (context, url, progress) => - const Center( - child: CircularProgressIndicator(), - ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.symmetric( + horizontal: 15.adaptedPx()), + child: SvgPicture.asset( + 'assets/icons/search.svg'), + ), + Text( + 'searchHint'.translation, + style: GoogleFonts.poppins( + textStyle: Theme.of(context) + .primaryTextTheme + .bodyMedium + ?.copyWith( + fontSize: 16.adaptedPx(), + color: AppTheme.lightTextColor, + ), ), - ] - : [ - SizedBox( - height: 150.adaptedPx(), - child: const Center( - child: CircularProgressIndicator()), ), ], - options: CarouselOptions( - initialPage: 0, - padEnds: true, - scrollPhysics: const BouncingScrollPhysics(), - viewportFraction: 1, - autoPlay: true, - onPageChanged: (index, reason) { - setState(() { - currentPage = index; - }); - }, - autoPlayAnimationDuration: - const Duration(seconds: 2), - autoPlayInterval: const Duration(seconds: 5), - ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: List.generate( - sliders.length, - (index) => buildDot( - index: index, + ), ), ), - ), - Padding( - padding: EdgeInsets.only( - top: 20.adaptedPx(), bottom: 10.adaptedPx()), - child: Align( - alignment: Alignment.centerLeft, - child: Text( - 'categories'.translation, - style: Theme.of(context) - .primaryTextTheme - .bodyMedium - ?.copyWith( - color: AppTheme.blackColor, - fontSize: 18.adaptedPx(), - fontWeight: FontWeight.w600, - ), - ), - ), - ), - categories.isEmpty - ? Padding( - padding: EdgeInsets.symmetric( - vertical: 10.adaptedPx()), - child: const Center( - child: CircularProgressIndicator()), - ) - : Padding( - padding: EdgeInsets.symmetric( - vertical: 10.adaptedPx()), - child: ButtonsTabBar( - controller: tabController, - contentPadding: EdgeInsets.symmetric( - horizontal: 20.adaptedPx()), - splashColor: AppTheme.lightPrimaryColor, - radius: 10.adaptedPx(), - backgroundColor: AppTheme.lightPrimaryColor, - buttonMargin: EdgeInsets.only( - left: 0, - right: 15.adaptedPx(), - ), - onTap: (value) { - setState(() { - categoryId = categories[value].id; - debugPrint(categoryId.toString()); - }); - }, - unselectedBackgroundColor: - AppTheme.whiteColor, - physics: const BouncingScrollPhysics(), - tabs: [ - for (var category in categories) - Tab(text: category.name) + CarouselSlider( + items: (sliders != null) + ? [ + for (int i = 0; i < sliders.length; i++) + CachedNetworkImage( + imageUrl: sliders[i].img, + width: GlobalVariables.deviceWidth( + context), + fit: BoxFit.contain, + progressIndicatorBuilder: + (context, url, progress) => + const Center( + child: CircularProgressIndicator(), + ), + ), + ] + : [ + SizedBox( + height: 150.adaptedPx(), + child: const Center( + child: CircularProgressIndicator()), + ), ], + options: CarouselOptions( + initialPage: 0, + padEnds: true, + scrollPhysics: const BouncingScrollPhysics(), + viewportFraction: 1, + autoPlay: true, + onPageChanged: (index, reason) { + setState(() { + currentPage = index; + }); + }, + autoPlayAnimationDuration: + const Duration(seconds: 2), + autoPlayInterval: const Duration(seconds: 5), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: List.generate( + sliders.length, + (index) => buildDot( + index: index, + ), + ), + ), + Padding( + padding: EdgeInsets.only( + top: 20.adaptedPx(), bottom: 10.adaptedPx()), + child: Align( + alignment: Alignment.centerLeft, + child: Text( + 'categories'.translation, + style: Theme.of(context) + .primaryTextTheme + .bodyMedium + ?.copyWith( + color: AppTheme.blackColor, + fontSize: 18.adaptedPx(), + fontWeight: FontWeight.w600, + ), + ), + ), + ), + categories.isEmpty + ? Padding( + padding: EdgeInsets.symmetric( + vertical: 10.adaptedPx()), + child: const Center( + child: CircularProgressIndicator()), + ) + : Padding( + padding: EdgeInsets.symmetric( + vertical: 10.adaptedPx()), + child: ButtonsTabBar( + controller: tabController, + contentPadding: EdgeInsets.symmetric( + horizontal: 20.adaptedPx()), + splashColor: AppTheme.lightPrimaryColor, + radius: 10.adaptedPx(), + backgroundColor: AppTheme.lightPrimaryColor, + buttonMargin: EdgeInsets.only( + left: 0, + right: 15.adaptedPx(), + ), + onTap: (value) { + setState(() { + categoryId = categories[value].id; + debugPrint(categoryId.toString()); + }); + }, + unselectedBackgroundColor: + AppTheme.whiteColor, + physics: const BouncingScrollPhysics(), + tabs: [ + for (var category in categories) + Tab(text: category.name) + ], + ), ), - ), - SizedBox(height: 15.adaptedPx()), - ], + SizedBox(height: 15.adaptedPx()), + ], + ), ), - ), - ], - body: tabController != null - ? TabBarView( - controller: tabController, - children: categories.isNotEmpty - ? categories - .map( - (category) => Products( - id: category.id, - ), - ) - .toList() - : [], - ) - : Container()), + ], + body: tabController != null + ? TabBarView( + controller: tabController, + children: categories.isNotEmpty + ? categories + .map( + (category) => Products( + id: category.id, + ), + ) + .toList() + : [], + ) + : Container()), + ), ), ); }