fixed ui after feedback
This commit is contained in:
@@ -15,8 +15,7 @@ import 'package:material_design_icons_flutter/material_design_icons_flutter.dart
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
class BestDealScreen extends StatefulWidget
|
||||
{
|
||||
class BestDealScreen extends StatefulWidget {
|
||||
const BestDealScreen({super.key});
|
||||
@override
|
||||
State<BestDealScreen> createState() => _BestDealScreenState();
|
||||
@@ -26,8 +25,7 @@ class _BestDealScreenState extends State<BestDealScreen> {
|
||||
bool _isSearching = false;
|
||||
TextEditingController _searchController = TextEditingController();
|
||||
@override
|
||||
void initState()
|
||||
{
|
||||
void initState() {
|
||||
Provider.of<ProductProvider>(context, listen: false)
|
||||
.getBestDealProduct(context, '');
|
||||
super.initState();
|
||||
@@ -56,6 +54,8 @@ class _BestDealScreenState extends State<BestDealScreen> {
|
||||
width: 20,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Provider.of<ProductProvider>(context, listen: false)
|
||||
.getBestDealProduct(context, '');
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
@@ -69,15 +69,13 @@ class _BestDealScreenState extends State<BestDealScreen> {
|
||||
title: _isSearching
|
||||
? TextField(
|
||||
controller: _searchController,
|
||||
autofocus: true, // Focus on search field when opened
|
||||
decoration: InputDecoration(
|
||||
autofocus: true,
|
||||
decoration: const InputDecoration(
|
||||
hintText: "Search...",
|
||||
border: InputBorder.none,
|
||||
),
|
||||
style: TextStyle(fontSize: 18),
|
||||
onChanged: (query) {
|
||||
// You can call a search function here
|
||||
},
|
||||
onChanged: (query) {},
|
||||
)
|
||||
: const Text(
|
||||
"Best Deal",
|
||||
@@ -87,7 +85,7 @@ class _BestDealScreenState extends State<BestDealScreen> {
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
if (_isSearching) // Show search icon only when searching
|
||||
if (_isSearching)
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Provider.of<ProductProvider>(context, listen: false)
|
||||
@@ -106,6 +104,8 @@ class _BestDealScreenState extends State<BestDealScreen> {
|
||||
setState(() {
|
||||
_isSearching = !_isSearching;
|
||||
if (!_isSearching) {
|
||||
Provider.of<ProductProvider>(context, listen: false)
|
||||
.getBestDealProduct(context, '');
|
||||
_searchController.clear(); // Clear search when closed
|
||||
}
|
||||
});
|
||||
@@ -290,7 +290,7 @@ class _BestDealScreenState extends State<BestDealScreen> {
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
childAspectRatio: MediaQuery.of(context).size.width /
|
||||
(MediaQuery.of(context).size.height / 1.5),
|
||||
(MediaQuery.of(context).size.height / 1.3),
|
||||
crossAxisSpacing: 10,
|
||||
mainAxisSpacing: 10,
|
||||
),
|
||||
@@ -319,78 +319,89 @@ class _BestDealScreenState extends State<BestDealScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height * 0.15,
|
||||
// width: MediaQuery.of(context).size.width *
|
||||
// 0.4, // Dynamic width
|
||||
decoration: BoxDecoration(
|
||||
color: APPCOLOR.bgGrey,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Stack(
|
||||
//alignment: Alignment.center,
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: AppNetworkImage(
|
||||
imageUrl:
|
||||
bestdealproduct.productImages?.first.url ??
|
||||
"",
|
||||
backGroundColor: Colors.transparent,
|
||||
radius: 10,
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height * 0.19,
|
||||
decoration: BoxDecoration(
|
||||
color: APPCOLOR.bgGrey,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
Center(
|
||||
child: AppNetworkImage(
|
||||
imageUrl: bestdealproduct
|
||||
.productImages?.first.url ??
|
||||
"",
|
||||
backGroundColor: Colors.transparent,
|
||||
radius: 10,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 1,
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
borderRadius:
|
||||
BorderRadius.circular(100),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${calculateDiscountPercentage(double.parse(bestdealproduct.basePrice), double.parse(bestdealproduct.discountPrice))}% \nOFF",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 1,
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${calculateDiscountPercentage(double.parse(bestdealproduct.basePrice), double.parse(bestdealproduct.discountPrice))}% \nOFF",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 12)),
|
||||
),
|
||||
Text(
|
||||
bestdealproduct.name ?? "",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context.customMedium(
|
||||
APPCOLOR.balck1A1A1A, 16),
|
||||
),
|
||||
Text(
|
||||
bestdealproduct.unit ?? "",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context.customMedium(
|
||||
Colors.grey.withOpacity(0.8),
|
||||
12,
|
||||
),
|
||||
),
|
||||
if (bestdealproduct.quantity > 0)
|
||||
Text(
|
||||
"In Stock",
|
||||
style: TextStyle(
|
||||
color: Colors.green, fontSize: 14),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.005),
|
||||
Text(
|
||||
bestdealproduct.name ?? "",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context.customMedium(APPCOLOR.balck1A1A1A, 16),
|
||||
),
|
||||
Text(
|
||||
bestdealproduct.unit ?? "",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context.customMedium(
|
||||
Colors.grey.withOpacity(0.8),
|
||||
12,
|
||||
),
|
||||
),
|
||||
if (bestdealproduct!.quantity > 0)
|
||||
Text("In Stock ",
|
||||
style:
|
||||
TextStyle(color: Colors.green, fontSize: 14)),
|
||||
Spacer(),
|
||||
SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"₹${bestdealproduct.discountPrice ?? ""} ",
|
||||
@@ -416,52 +427,46 @@ class _BestDealScreenState extends State<BestDealScreen> {
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: GestureDetector(
|
||||
onTap: () async {
|
||||
if (await SharedPrefUtils.getToken() != null) {
|
||||
await provider.addToWithCart(
|
||||
context,
|
||||
bestdealproduct.id!,
|
||||
bestdealproduct,
|
||||
bestdealproduct.productImages?.first.url);
|
||||
} else {
|
||||
context.push(MyRoutes.SIGNUP);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
height:
|
||||
MediaQuery.of(context).size.height * 0.035,
|
||||
width: MediaQuery.of(context).size.width * 0.1,
|
||||
decoration: BoxDecoration(
|
||||
color: APPCOLOR.lightGreen,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Center(
|
||||
child: provider
|
||||
.isLoading[bestdealproduct.id] ??
|
||||
false
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
height: 10,
|
||||
width: 10,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 2),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
if (await SharedPrefUtils.getToken() != null) {
|
||||
await provider.addToWithCart(
|
||||
context,
|
||||
bestdealproduct.id!,
|
||||
bestdealproduct,
|
||||
bestdealproduct.productImages?.first.url,
|
||||
);
|
||||
} else {
|
||||
context.push(MyRoutes.SIGNUP);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
height:
|
||||
MediaQuery.of(context).size.height * 0.035,
|
||||
width: MediaQuery.of(context).size.width * 0.1,
|
||||
decoration: BoxDecoration(
|
||||
color: APPCOLOR.lightGreen,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Center(
|
||||
child: provider.isLoading[bestdealproduct.id] ??
|
||||
false
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: SizedBox(
|
||||
height: 10,
|
||||
width: 10,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
// provider.cartItems
|
||||
// .contains(bestdealproduct.id)
|
||||
// ? 'Added'
|
||||
// :
|
||||
'Add',
|
||||
style: context.customRegular(
|
||||
Colors.white, 12),
|
||||
),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
'Add',
|
||||
style: context.customRegular(
|
||||
Colors.white, 12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -474,75 +479,6 @@ class _BestDealScreenState extends State<BestDealScreen> {
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(15),
|
||||
// child: GridView.builder(
|
||||
// itemCount: provider.bestdeal.length,
|
||||
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
// crossAxisCount: 2,
|
||||
// childAspectRatio: MediaQuery.of(context).size.width /
|
||||
// (MediaQuery.of(context).size.height / 1.5),
|
||||
// crossAxisSpacing: 10,
|
||||
// mainAxisSpacing: 10,
|
||||
// ),
|
||||
// itemBuilder: (context, index) {
|
||||
// var bestdealproduct = provider.bestdeal[index];
|
||||
// return InkWell(
|
||||
// onTap: () {
|
||||
// context.push(MyRoutes.PRODUCTDETAILS,
|
||||
// extra: bestdealproduct.id);
|
||||
// },
|
||||
// child: Container(
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// borderRadius: BorderRadius.circular(15),
|
||||
// ),
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(5),
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Container(
|
||||
// height: MediaQuery.of(context).size.height * 0.15,
|
||||
// width: MediaQuery.of(context).size.width * 0.4,
|
||||
// decoration: BoxDecoration(
|
||||
// color: APPCOLOR.bgGrey,
|
||||
// borderRadius: BorderRadius.circular(15),
|
||||
// ),
|
||||
// child: AppNetworkImage(
|
||||
// height: MediaQuery.of(context).size.height * 0.13,
|
||||
// width: MediaQuery.of(context).size.width * 0.35,
|
||||
// imageUrl:
|
||||
// bestdealproduct.productImages?.first.url ?? "",
|
||||
// backGroundColor: Colors.transparent,
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(height: 8),
|
||||
// Text(bestdealproduct.name ?? ""),
|
||||
// Text(bestdealproduct.unit ?? ""),
|
||||
// Text(bestdealproduct.quantity > 0
|
||||
// ? "In Stock"
|
||||
// : "Out of Stock"),
|
||||
// Row(
|
||||
// children: [
|
||||
// Text("₹${bestdealproduct.discountPrice ?? ""}"),
|
||||
// Text(
|
||||
// "₹${bestdealproduct.basePrice ?? ""}",
|
||||
// style: TextStyle(
|
||||
// decoration: TextDecoration.lineThrough,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
padding: const EdgeInsets.only(left: 40),
|
||||
child: DataNotFound(
|
||||
imagePath: 'assets/images/cart.jpg',
|
||||
message: "Product not abailable ",
|
||||
message: "",
|
||||
width: 220.w,
|
||||
height: 250.h,
|
||||
),
|
||||
@@ -175,7 +175,7 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final itemWidth = (constraints.maxWidth - 20) / 2;
|
||||
final itemHeight = itemWidth * 1.5;
|
||||
final itemHeight = itemWidth * 1.7;
|
||||
|
||||
return GridView.builder(
|
||||
controller: _scrollController,
|
||||
@@ -221,7 +221,7 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
children: [
|
||||
Container(
|
||||
height: itemWidth *
|
||||
0.7, // Adjust height for image container
|
||||
0.9, // Adjust height for image container
|
||||
// width: itemWidth,
|
||||
decoration: BoxDecoration(
|
||||
color: APPCOLOR.bgGrey,
|
||||
@@ -236,15 +236,17 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
"https://5.imimg.com/data5/SELLER/Default/2024/2/385126988/OL/DA/VW/8627346/1l-fortune-sunflower-oil.jpg",
|
||||
backGroundColor: Colors.transparent,
|
||||
radius: 10,
|
||||
boxFit:BoxFit.fill
|
||||
|
||||
),
|
||||
Positioned(
|
||||
right: 1,
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
height: 50,
|
||||
width: 50,
|
||||
height: 35,
|
||||
width: 35,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 10, vertical: 10),
|
||||
horizontal: 1, vertical: 1),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
borderRadius:
|
||||
@@ -252,75 +254,16 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${calculateDiscountPercentage(double.parse(product.basePrice), double.parse(product!.discountPrice))}% \nOFF",
|
||||
"${calculateDiscountPercentage(double.parse(product.basePrice), double.parse(product!.discountPrice))}%\nOFF",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12)),
|
||||
fontWeight:FontWeight.bold,
|
||||
fontSize: 10)),
|
||||
),
|
||||
),
|
||||
)
|
||||
// Positioned(
|
||||
// right: 5,
|
||||
// top: 5,
|
||||
// child: InkWell(
|
||||
// onTap: () async {
|
||||
// if (await SharedPrefUtils.getToken() !=
|
||||
// null) {
|
||||
// if (product.isInWishlist) {
|
||||
// Fluttertoast.showToast(
|
||||
// msg: "Item already added!",
|
||||
// toastLength: Toast.LENGTH_SHORT,
|
||||
// gravity: ToastGravity.BOTTOM,
|
||||
// backgroundColor: Colors.green,
|
||||
// textColor: Colors.white,
|
||||
// fontSize: 14.0,
|
||||
// );
|
||||
// } else {
|
||||
// //product.isInWishlist=ture;
|
||||
// provider
|
||||
// .toggleWishlist1(product.id!);
|
||||
// }
|
||||
// } else {
|
||||
// context.push(MyRoutes.LOGIN);
|
||||
// }
|
||||
// },
|
||||
// child: Icon(
|
||||
// product.isInWishlist
|
||||
// ? Icons.favorite
|
||||
// : Icons.favorite_border,
|
||||
// color: product.isInWishlist
|
||||
// ? Colors.red
|
||||
// : Colors.grey,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
// Positioned(
|
||||
// right: 5,
|
||||
// top: 5,
|
||||
// child: InkWell(
|
||||
// onTap: () async {
|
||||
// if (await SharedPrefUtils
|
||||
// .getToken() !=
|
||||
// null) {
|
||||
// provider.toggleWishlist(
|
||||
// context, product.id!);
|
||||
// } else {
|
||||
// context.push(MyRoutes.SIGNUP);
|
||||
// }
|
||||
// },
|
||||
// child: Icon(
|
||||
// provider.wishlist.contains(product.id)
|
||||
// ? Icons.favorite
|
||||
// : Icons.favorite_border,
|
||||
// color: provider.wishlist
|
||||
// .contains(product.id)
|
||||
// ? Colors.red
|
||||
// : Colors.grey,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -368,7 +368,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
height: 300.h,
|
||||
))
|
||||
: SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.28,
|
||||
height: MediaQuery.of(context).size.height * 0.3,
|
||||
child: ListView.builder(
|
||||
itemCount: provider.bestdeal.length,
|
||||
scrollDirection: Axis.horizontal,
|
||||
@@ -402,7 +402,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
Center(
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height *
|
||||
0.12,
|
||||
0.17,
|
||||
decoration: BoxDecoration(
|
||||
color: APPCOLOR.bgGrey,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
@@ -418,10 +418,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
bottom: 5,
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
borderRadius:
|
||||
@@ -618,7 +618,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
top: 15,
|
||||
left: 15,
|
||||
child: SizedBox(
|
||||
width: 170,
|
||||
width: 150,
|
||||
child: Text(
|
||||
banner.altText ?? "Special Event",
|
||||
style: context.customExtraBold(
|
||||
@@ -662,7 +662,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
imageUrl: banner.imageUrl ??
|
||||
'https://e7.pngegg.com/pngimages/742/816/png-clipart-coca-cola-can-illustration-coca-cola-soft-drink-surge-pepsi-coke-sweetness-cola-thumbnail.png',
|
||||
backGroundColor: Colors.transparent,
|
||||
// boxFit: BoxFit.contain,
|
||||
//boxFit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -65,7 +65,8 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget build(BuildContext context)
|
||||
{
|
||||
return Scaffold(
|
||||
body: NestedScrollView(
|
||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||
@@ -398,4 +399,6 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user