fixed ui changes

This commit is contained in:
2025-05-05 02:09:28 +05:30
parent ce9bb33bdd
commit f863a81bb1
13 changed files with 412 additions and 404 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -1118,7 +1118,7 @@
"languageVersion": "3.4"
}
],
"generated": "2025-05-04T18:54:05.217340Z",
"generated": "2025-05-04T20:38:53.504097Z",
"generator": "pub",
"generatorVersion": "3.5.3",
"flutterRoot": "file:///Users/apple/Documents/development/flutter",

File diff suppressed because one or more lines are too long

View File

@@ -23,7 +23,8 @@ import 'package:provider/provider.dart';
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async
{
await Firebase.initializeApp();
print("💬 Background Message Received: ${message.notification?.title}");
if (message.notification != null) {

View File

@@ -22,7 +22,6 @@ import 'package:grocery_app/utils/extensions/extensions.dart';
import 'package:http/http.dart' as http;
class ProductProvider extends ChangeNotifier {
final _homeRepo = getIt<ProductRepo>();
@@ -109,7 +108,6 @@ class ProductProvider extends ChangeNotifier {
);
}
Future<bool> updateDeviceToken(BuildContext context) async {
var fcm = await FirebaseMessaging.instance.getToken();
var data = {"deviceToken": fcm, "deviceTpe": "android"};
@@ -119,7 +117,6 @@ class ProductProvider extends ChangeNotifier {
var result = await _homeRepo.updateDeviceToken(data, context);
return result.fold(
(error) {
return true;
},
(response) {
@@ -142,13 +139,23 @@ class ProductProvider extends ChangeNotifier {
if (maxprice.isNotEmpty) {
data = {
"page": 1,
"limit": 12,
"minPrice": "${minPrice}",
"maxPrice": maxprice,
"search": search,
"sortBy": orderby
"sortBy": orderby,
"sortOrder": "asc"
};
} else {
data = {"minPrice": "${minPrice}", "search": search, "sortBy": orderby};
data = {
"page": 1,
"limit": 12,
"minPrice": "${minPrice}",
"search": search,
"sortBy": orderby,
"sortOrder": "asc"
};
}
var result = await _homeRepo.getAllProduct(data, context, id);
@@ -160,6 +167,8 @@ class ProductProvider extends ChangeNotifier {
(response) {
homeproducts = response.data!;
print("kdsjfjklghjdkf ${homeproducts.length}");
isHomeLoadingg = false;
notifyListeners();
},

View File

@@ -373,7 +373,7 @@ class _BestDealScreenState extends State<BestDealScreen> {
Text(
bestdealproduct.name ?? "",
textAlign: TextAlign.left,
maxLines: 2,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.customMedium(
APPCOLOR.balck1A1A1A, 16),

View File

@@ -30,7 +30,8 @@ class _MycartState extends State<Mycart> {
@override
void initState() {
Future.microtask(() {
final addToCartProvider = Provider.of<AddtocartProvider>(context, listen: false);
final addToCartProvider =
Provider.of<AddtocartProvider>(context, listen: false);
addToCartProvider.getItemCards(context);
addToCartProvider.offerCoupon(context);
addToCartProvider.getCurrentLocation(context);
@@ -91,10 +92,10 @@ class _MycartState extends State<Mycart> {
return const Center(child: Text(''));
} else {
return SizedBox(
height: MediaQuery.of(context).size.height * 0.28,
height: MediaQuery.of(context).size.height * 0.3,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: provider.bestdeal.length,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
var bestdealproduct = provider.bestdeal[index];
double cardWidth = MediaQuery.of(context).size.width * 0.4;
@@ -111,58 +112,50 @@ class _MycartState extends State<Mycart> {
);
},
child: Padding(
padding: const EdgeInsets.only(right: 5, bottom: 5, top: 5),
padding: const EdgeInsets.all(8.0),
child: Container(
width: cardWidth,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
blurRadius: 1,
offset: const Offset(5, 5),
),
],
),
child: Padding(
padding: const EdgeInsets.all(5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Container(
height: MediaQuery.of(context).size.height * 0.12,
width: cardWidth * 0.9,
height: MediaQuery.of(context).size.height * 0.17,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(15),
),
child: Stack(
alignment: Alignment.center,
children: [
AppNetworkImage(
imageUrl: bestdealproduct
.productImages?.first?.url ??
"",
radius: 10,
backGroundColor: Colors.transparent,
radius: 10),
),
Positioned(
right: 1,
right: 0,
bottom: 0,
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 10, vertical: 10),
width: 40,
height: 40,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(5),
borderRadius: BorderRadius.circular(100),
),
child: Center(
child: Text(
"${calculateDiscountPercentage(double.parse(bestdealproduct!.basePrice), double.parse(bestdealproduct!.discountPrice))}% OFF",
style: TextStyle(
"${calculateDiscountPercentage(double.parse(bestdealproduct.basePrice), double.parse(bestdealproduct.discountPrice))}% \nOFF",
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.white,
fontSize: 15)),
fontWeight: FontWeight.bold,
fontSize: 10)),
),
),
)
@@ -171,31 +164,23 @@ class _MycartState extends State<Mycart> {
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.01,
),
height: MediaQuery.of(context).size.height * 0.01),
Text(
bestdealproduct.name ?? "",
textAlign: TextAlign.left,
maxLines: 2,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style:
context.customMedium(APPCOLOR.balck1A1A1A, 14),
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.005,
),
height: MediaQuery.of(context).size.height * 0.005),
Text(
bestdealproduct.unit ?? "",
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.customMedium(
Colors.grey.withOpacity(0.8),
12,
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.005,
Colors.grey.withOpacity(0.8), 12),
),
const Spacer(),
Row(
@@ -207,22 +192,20 @@ class _MycartState extends State<Mycart> {
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.customSemiBold(
Colors.black, 15),
style:
context.customSemiBold(Colors.black, 15),
),
Text(
"${bestdealproduct.basePrice ?? ""}",
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context
.customMedium(
Colors.grey.withOpacity(0.8),
15,
)
Colors.grey.withOpacity(0.8), 15)
.copyWith(
decoration:
TextDecoration.lineThrough,
),
TextDecoration.lineThrough),
),
],
),
@@ -235,19 +218,15 @@ class _MycartState extends State<Mycart> {
null) {
await provider.addToCart(
context, bestdealproduct.id!, 1);
context
.read<AddtocartProvider>()
.getItemCards(context);
} else {
context.push(MyRoutes.SIGNUP);
}
},
child: Container(
height: MediaQuery.of(context).size.height *
0.028,
// width:
// MediaQuery.of(context).size.width * 0.1,
0.035,
width:
MediaQuery.of(context).size.width * 0.1,
decoration: BoxDecoration(
color: APPCOLOR.lightGreen,
borderRadius: BorderRadius.circular(5),
@@ -256,14 +235,12 @@ class _MycartState extends State<Mycart> {
child: provider.isLoading[
bestdealproduct.id] ??
false
? Padding(
padding:
const EdgeInsets.all(8.0),
child: Container(
? const Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
height: 10,
width: 10,
child:
CircularProgressIndicator(
child: CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2),
),
@@ -283,11 +260,11 @@ class _MycartState extends State<Mycart> {
),
),
),
),
);
},
),
);
;
}
});
}

View File

@@ -31,7 +31,7 @@ class DataNotFound extends StatelessWidget {
const SizedBox(height: 5),
Text(
message,
style: const TextStyle(fontSize: 10, fontWeight: FontWeight.w500),
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500),
textAlign: TextAlign.center,
),
],

View File

@@ -146,12 +146,47 @@ class _FavouriteScreenState extends State<FavouriteScreen>
return Expanded(
child: _buildSkeletonLoader()); // Show Skeleton while loading
} else if (provider.wishListItem.isEmpty) {
return Expanded(
child: DataNotFound(
return Center(
child: Column(
children: [
SizedBox(
height: 150.h,
),
DataNotFound(
imagePath: 'assets/images/wishlist.jpg',
message: "Data Not Found",
width: 250.w,
height: 200.h,
message: "Your Order is empty",
),
InkWell(
onTap: () {
context.push(MyRoutes.FRUITVEGGIEDETAIL);
},
child: Container(
margin: const EdgeInsets.only(top: 30, bottom: 10),
height: 40,
width: MediaQuery.sizeOf(context).width / 2.8,
decoration: BoxDecoration(
color: APPCOLOR.lightGreen,
borderRadius: BorderRadius.circular(10)),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
Icons.search,
color: Colors.white,
),
const SizedBox(
width: 10,
),
Text(
"Shoping",
style: context.customMedium(Colors.white, 16),
),
],
),
),
),
],
));
} else {
return Expanded(

View File

@@ -104,9 +104,19 @@ class _HomeScreenState extends State<HomeScreen> {
],
),
onTap: () {
_searchController.text = suggestion.name;
searchProvider.getHomeProduct(
context, "", suggestion.name, '', '', '');
// _searchController.text = suggestion.name;
// searchProvider.getHomeProduct(
// context, "", suggestion.name, '', '', '');
context.push(
MyRoutes.PRODUCTDETAILS,
extra: {
"id": suggestion.id,
"quantity": 1,
"price": suggestion.discountPrice,
},
);
_clearOverlay();
},
);
@@ -143,8 +153,7 @@ class _HomeScreenState extends State<HomeScreen> {
children: [
Expanded(
child: Consumer<ProductProvider>(
builder: (context, provider, child)
{
builder: (context, provider, child) {
return CompositedTransformTarget(
link: _layerLink,
child: Container(
@@ -452,10 +461,12 @@ class _HomeScreenState extends State<HomeScreen> {
SizedBox(
height: MediaQuery.of(context).size.height *
0.01),
Text(
bestdealproduct.name ?? "",
textAlign: TextAlign.left,
maxLines: 2,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.customMedium(
APPCOLOR.balck1A1A1A, 14),

View File

@@ -1,14 +1,18 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
import 'package:grocery_app/src/common_widget/network_image.dart';
import 'package:grocery_app/src/core/routes/routes.dart';
import 'package:grocery_app/src/logic/provider/home_provider.dart';
import 'package:grocery_app/src/logic/provider/order_provider.dart';
import 'package:grocery_app/src/ui/data_notfound.dart';
import 'package:grocery_app/utils/constants/assets_constant.dart';
import 'package:grocery_app/utils/constants/color_constant.dart';
import 'package:grocery_app/utils/extensions/extensions.dart';
import 'package:grocery_app/utils/extensions/uicontext.dart';
import 'package:intl/intl.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
@@ -81,10 +85,47 @@ class _MyOrderScreenState extends State<MyOrderScreen> {
}
if (orderProvider.orderList.isEmpty) {
return const Center(
child: DataNotFound(
return Center(
child: Column(
children: [
SizedBox(
height: 150.h,
),
DataNotFound(
imagePath: 'assets/images/wishlist.jpg',
message: "No Order!",
message: "Your Order is empty",
),
InkWell(
onTap: () {
context.push(MyRoutes.FRUITVEGGIEDETAIL);
},
child: Container(
margin: const EdgeInsets.only(top: 30, bottom: 10),
height: 40,
width: MediaQuery.sizeOf(context).width / 2.8,
decoration: BoxDecoration(
color: APPCOLOR.lightGreen,
borderRadius: BorderRadius.circular(10)),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
Icons.search,
color: Colors.white,
),
const SizedBox(
width: 10,
),
Text(
"Shoping",
style: context.customMedium(Colors.white, 16),
),
],
),
),
),
],
));
}
@@ -142,7 +183,6 @@ class _MyOrderScreenState extends State<MyOrderScreen> {
Text(order.orderNumber,
style: TextStyle(
fontWeight: FontWeight.bold)),
Text(
order.totalItems.toString() +
" items",
@@ -151,8 +191,6 @@ class _MyOrderScreenState extends State<MyOrderScreen> {
],
),
Spacer(),
],
),
SizedBox(height: 10),

View File

@@ -148,7 +148,6 @@ class _ProductDetailsState extends State<ProductDetails> {
var productImage =
provider.productDetails.data!.productImages![index];
return AppNetworkImage(
imageUrl: productImage.url,
backGroundColor: Colors.transparent,
radius: 10,
@@ -952,7 +951,6 @@ class _ProductDetailsState extends State<ProductDetails> {
borderRadius: BorderRadius.circular(15),
),
child: AppNetworkImage(
imageUrl: "",
backGroundColor: Colors.transparent,
),
@@ -980,75 +978,70 @@ class _ProductDetailsState extends State<ProductDetails> {
return Center(child: Text('No products available'));
} else {
return 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,
itemBuilder: (context, index) {
var bestdealproduct = provider.bestdeal[index];
double cardWidth =
MediaQuery.of(context).size.width * 0.4; // Dynamic width
double cardWidth = MediaQuery.of(context).size.width * 0.4;
return InkWell(
onTap: () {
provider.getProduuctDetails(
context, bestdealproduct.id, 0, "0");
context.push(
MyRoutes.PRODUCTDETAILS,
extra: {
"id": bestdealproduct.id,
"quantity": 1,
"price": bestdealproduct.discountPrice,
},
);
},
child: Padding(
padding: const EdgeInsets.only(right: 10, bottom: 5, top: 5),
padding: const EdgeInsets.all(8.0),
child: Container(
width: cardWidth,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
blurRadius: 1,
offset: const Offset(5, 5),
),
],
),
child: Padding(
padding: const EdgeInsets.all(5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Container(
height: MediaQuery.of(context).size.height * 0.12,
width: cardWidth * 0.9,
height: MediaQuery.of(context).size.height * 0.17,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(15),
),
child: Stack(
alignment: Alignment.center,
children: [
AppNetworkImage(
imageUrl: bestdealproduct
.productImages?.first?.url ??
"",
backGroundColor: Colors.transparent,
radius: 10,
backGroundColor: Colors.transparent,
),
Positioned(
right: 1,
right: 0,
bottom: 0,
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 10, vertical: 10),
width: 40,
height: 40,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(5),
borderRadius: BorderRadius.circular(100),
),
child: Center(
child: Text(
"${calculateDiscountPercentage(double.parse(bestdealproduct.basePrice), double.parse(bestdealproduct!.discountPrice))}% OFF",
style: TextStyle(
"${calculateDiscountPercentage(double.parse(bestdealproduct.basePrice), double.parse(bestdealproduct.discountPrice))}% \nOFF",
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.white,
fontSize: 15)),
fontWeight: FontWeight.bold,
fontSize: 10)),
),
),
)
@@ -1057,31 +1050,23 @@ class _ProductDetailsState extends State<ProductDetails> {
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.01,
),
height: MediaQuery.of(context).size.height * 0.01),
Text(
bestdealproduct.name ?? "",
textAlign: TextAlign.left,
maxLines: 2,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style:
context.customMedium(APPCOLOR.balck1A1A1A, 14),
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.005,
),
height: MediaQuery.of(context).size.height * 0.005),
Text(
bestdealproduct.unit ?? "",
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.customMedium(
Colors.grey.withOpacity(0.8),
12,
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.005,
Colors.grey.withOpacity(0.8), 12),
),
const Spacer(),
Row(
@@ -1093,8 +1078,8 @@ class _ProductDetailsState extends State<ProductDetails> {
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.customSemiBold(
Colors.black, 15),
style:
context.customSemiBold(Colors.black, 15),
),
Text(
"${bestdealproduct.basePrice ?? ""}",
@@ -1103,52 +1088,13 @@ class _ProductDetailsState extends State<ProductDetails> {
overflow: TextOverflow.ellipsis,
style: context
.customMedium(
Colors.grey.withOpacity(0.8),
15,
)
Colors.grey.withOpacity(0.8), 15)
.copyWith(
decoration:
TextDecoration.lineThrough,
),
TextDecoration.lineThrough),
),
],
),
// Align(
// alignment: Alignment.centerRight,
// child: InkWell(
// onTap: () async {
// bool success = await provider.addToCart(context, bestdealproduct.id!);
// if (success) {
// Fluttertoast.showToast(
// msg: "Product added to cart!",
// toastLength: Toast.LENGTH_SHORT,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.green,
// textColor: Colors.white,
// fontSize: 14.0,
// );
// }
// },
// 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: Text(
// 'Add',
// style:
// context.customRegular(Colors.white, 12),
// ),
// ),
// ),
// ),
// ),
const Spacer(),
Align(
alignment: Alignment.centerRight,
@@ -1156,10 +1102,7 @@ class _ProductDetailsState extends State<ProductDetails> {
onTap: () async {
if (await SharedPrefUtils.getToken() !=
null) {
provider.isLoading[bestdealproduct.id] ??
false
? null
: () => provider.addToCart(
await provider.addToCart(
context, bestdealproduct.id!, 1);
} else {
context.push(MyRoutes.SIGNUP);
@@ -1171,24 +1114,25 @@ class _ProductDetailsState extends State<ProductDetails> {
width:
MediaQuery.of(context).size.width * 0.1,
decoration: BoxDecoration(
color: provider.cartItems
.contains(bestdealproduct.id)
? Colors.grey
: APPCOLOR.lightGreen,
color: APPCOLOR.lightGreen,
borderRadius: BorderRadius.circular(5),
),
child: Center(
child: provider.isLoading[
bestdealproduct.id] ??
false
? CircularProgressIndicator(
? const Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
height: 10,
width: 10,
child: CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2)
strokeWidth: 2),
),
)
: Text(
provider.cartItems.contains(
bestdealproduct.id)
? 'Added'
: 'Add',
'Add',
style: context.customRegular(
Colors.white, 12),
),
@@ -1202,7 +1146,6 @@ class _ProductDetailsState extends State<ProductDetails> {
),
),
),
),
);
},
),

View File

@@ -65,8 +65,8 @@ class _ProfileScreenState extends State<ProfileScreen> {
}
@override
Widget build(BuildContext context)
{
Widget build(BuildContext context) {
print("lkdjflkjhjkg ${APPSTRING.isToken}");
return Scaffold(
body: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
@@ -113,7 +113,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
imageUrl: provider.profile ?? "",
radius: 90,
backGroundColor: Colors.white,
boxFit: BoxFit.fill,
boxFit: BoxFit.cover,
),
),
],
@@ -228,9 +228,13 @@ class _ProfileScreenState extends State<ProfileScreen> {
),
),
InkWell(
onTap: () {
onTap: () async {
if (await SharedPrefUtils.getToken() != null) {
Provider.of<ProductProvider>(context, listen: false)
.customerLogOut(context);
} else {
context.push(MyRoutes.SIGNUP);
}
},
child: Container(
margin: const EdgeInsets.only(
@@ -251,18 +255,10 @@ class _ProfileScreenState extends State<ProfileScreen> {
const SizedBox(
width: 10,
),
if (APPSTRING.isToken == null ||
APPSTRING.isToken == "") ...{
Text(
"login",
style: context.customMedium(Colors.white, 16),
),
} else ...{
Text(
"Logout",
style: context.customMedium(Colors.white, 16),
),
}
],
),
),
@@ -399,6 +395,4 @@ class _ProfileScreenState extends State<ProfileScreen> {
},
);
}
}