-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from mahmoodhamdi:feature/add-shimmer-loading-…
…effects Add Shimmer Loading Effects for Better User Experience
- Loading branch information
Showing
8 changed files
with
330 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:shimmer/shimmer.dart'; | ||
import 'package:t_store/core/utils/constants/colors.dart'; | ||
import 'package:t_store/core/utils/constants/sizes.dart'; | ||
import 'package:t_store/core/utils/helpers/helper_functions.dart'; | ||
|
||
class ProductShimmer extends StatelessWidget { | ||
const ProductShimmer({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final dark = THelperFunctions.isDarkMode(context); | ||
return GridView.builder( | ||
shrinkWrap: true, | ||
physics: const NeverScrollableScrollPhysics(), | ||
padding: EdgeInsets.zero, | ||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( | ||
crossAxisCount: 2, | ||
mainAxisSpacing: TSizes.gridViewSpacing, | ||
crossAxisSpacing: TSizes.gridViewSpacing, | ||
mainAxisExtent: 288, | ||
), | ||
itemCount: 4, // Show 4 shimmer items while loading | ||
itemBuilder: (_, __) => Container( | ||
width: 180, | ||
padding: const EdgeInsets.all(1), | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular(TSizes.productImageRadius), | ||
color: dark ? TColors.darkerGrey : TColors.white, | ||
), | ||
child: Shimmer.fromColors( | ||
baseColor: dark ? Colors.grey[850]! : Colors.grey[300]!, | ||
highlightColor: dark ? Colors.grey[700]! : Colors.grey[100]!, | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
// Image container shimmer | ||
Container( | ||
width: double.infinity, | ||
height: 180, | ||
decoration: BoxDecoration( | ||
color: Colors.white, | ||
borderRadius: | ||
BorderRadius.circular(TSizes.productImageRadius), | ||
), | ||
), | ||
const SizedBox(height: TSizes.spaceBtwItems), | ||
// Title shimmer | ||
Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: TSizes.sm), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Container( | ||
width: double.infinity, | ||
height: 12, | ||
color: Colors.white, | ||
), | ||
const SizedBox(height: TSizes.spaceBtwItems / 2), | ||
// Brand shimmer | ||
Container( | ||
width: 100, | ||
height: 10, | ||
color: Colors.white, | ||
), | ||
const SizedBox(height: TSizes.spaceBtwItems), | ||
// Price and cart button shimmer | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: [ | ||
Container( | ||
width: 60, | ||
height: 15, | ||
color: Colors.white, | ||
), | ||
Container( | ||
width: 40, | ||
height: 40, | ||
decoration: const BoxDecoration( | ||
color: Colors.white, | ||
shape: BoxShape.circle, | ||
), | ||
), | ||
], | ||
), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.