final after change app
This commit is contained in:
@@ -28,7 +28,9 @@ Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async
|
||||
await Firebase.initializeApp();
|
||||
print("💬 Background Message Received: ${message.notification?.title}");
|
||||
if (message.notification != null) {
|
||||
|
||||
NotificationService.flutterLocalNotificationsPlugin.show(
|
||||
|
||||
message.hashCode,
|
||||
message.notification!.title,
|
||||
message.notification!.body,
|
||||
@@ -39,6 +41,7 @@ Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async
|
||||
channelDescription: 'Used for important notifications.',
|
||||
importance: Importance.max,
|
||||
priority: Priority.high,
|
||||
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -68,8 +68,9 @@
|
||||
// };
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final couponResponse = couponResponseFromJson(jsonString);
|
||||
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
@@ -77,40 +78,41 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
CouponResponse couponResponseFromJson(String str) => CouponResponse.fromJson(json.decode(str));
|
||||
CouponResponse couponResponseFromJson(String str) =>
|
||||
CouponResponse.fromJson(json.decode(str));
|
||||
|
||||
String couponResponseToJson(CouponResponse data) => json.encode(data.toJson());
|
||||
|
||||
class CouponResponse {
|
||||
bool? isValid;
|
||||
int? originalPrice;
|
||||
int? eligibleSubtotal;
|
||||
int? discountAmount;
|
||||
int? finalPrice;
|
||||
String? message;
|
||||
CouponDetails? couponDetails;
|
||||
bool? isValid;
|
||||
double? originalPrice;
|
||||
double? eligibleSubtotal;
|
||||
dynamic? discountAmount;
|
||||
double? finalPrice;
|
||||
String? message;
|
||||
CouponDetails? couponDetails;
|
||||
|
||||
CouponResponse({
|
||||
this.isValid,
|
||||
this.originalPrice,
|
||||
this.eligibleSubtotal,
|
||||
this.discountAmount,
|
||||
this.finalPrice,
|
||||
this.message,
|
||||
this.couponDetails,
|
||||
});
|
||||
CouponResponse({
|
||||
this.isValid,
|
||||
this.originalPrice,
|
||||
this.eligibleSubtotal,
|
||||
this.discountAmount,
|
||||
this.finalPrice,
|
||||
this.message,
|
||||
this.couponDetails,
|
||||
});
|
||||
|
||||
factory CouponResponse.fromJson(Map<String, dynamic> json) => CouponResponse(
|
||||
factory CouponResponse.fromJson(Map<String, dynamic> json) => CouponResponse(
|
||||
isValid: json["isValid"],
|
||||
originalPrice: json["originalPrice"],
|
||||
eligibleSubtotal: json["eligibleSubtotal"],
|
||||
originalPrice: json["originalPrice"].toDouble(),
|
||||
eligibleSubtotal: json["eligibleSubtotal"].toDouble(),
|
||||
discountAmount: json["discountAmount"],
|
||||
finalPrice: json["finalPrice"],
|
||||
finalPrice: json["finalPrice"].toDouble(),
|
||||
message: json["message"],
|
||||
couponDetails: CouponDetails.fromJson(json["couponDetails"]),
|
||||
);
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
Map<String, dynamic> toJson() => {
|
||||
"isValid": isValid,
|
||||
"originalPrice": originalPrice,
|
||||
"eligibleSubtotal": eligibleSubtotal,
|
||||
@@ -118,30 +120,29 @@ class CouponResponse {
|
||||
"finalPrice": finalPrice,
|
||||
"message": message,
|
||||
"couponDetails": couponDetails!.toJson(),
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
class CouponDetails {
|
||||
String? code;
|
||||
String ?type;
|
||||
String ?discountValue;
|
||||
String? code;
|
||||
String? type;
|
||||
String? discountValue;
|
||||
|
||||
CouponDetails({
|
||||
this.code,
|
||||
this.type,
|
||||
this.discountValue,
|
||||
});
|
||||
CouponDetails({
|
||||
this.code,
|
||||
this.type,
|
||||
this.discountValue,
|
||||
});
|
||||
|
||||
factory CouponDetails.fromJson(Map<String, dynamic> json) => CouponDetails(
|
||||
factory CouponDetails.fromJson(Map<String, dynamic> json) => CouponDetails(
|
||||
code: json["code"],
|
||||
type: json["type"],
|
||||
discountValue: json["discountValue"],
|
||||
);
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
Map<String, dynamic> toJson() => {
|
||||
"code": code,
|
||||
"type": type,
|
||||
"discountValue": discountValue,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -256,7 +256,6 @@ class AddtocartProvider extends ChangeNotifier {
|
||||
print("ijdfhjhgjfgihj $data");
|
||||
try {
|
||||
var result = await _homeRepo.applyCoupon(data);
|
||||
|
||||
|
||||
return result.fold(
|
||||
(error) {
|
||||
@@ -273,8 +272,9 @@ class AddtocartProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
return false;
|
||||
},
|
||||
(response)
|
||||
{
|
||||
(response)
|
||||
{
|
||||
print("dfkhjkfgdkfkgh ");
|
||||
if (response != null) {
|
||||
couponResponse = response;
|
||||
_couponId = id;
|
||||
|
||||
@@ -144,7 +144,7 @@ class ProductProvider extends ChangeNotifier {
|
||||
"minPrice": "${minPrice}",
|
||||
"maxPrice": maxprice,
|
||||
"search": search,
|
||||
"sortBy": orderby,
|
||||
"sortBy": 'basePrice',
|
||||
"sortOrder": "asc"
|
||||
};
|
||||
} else {
|
||||
@@ -157,6 +157,8 @@ class ProductProvider extends ChangeNotifier {
|
||||
"sortOrder": "asc"
|
||||
};
|
||||
}
|
||||
|
||||
print("ljdkgkjdfghkj ${data}");
|
||||
var result = await _homeRepo.getAllProduct(data, context, id);
|
||||
|
||||
return result.fold(
|
||||
@@ -180,11 +182,14 @@ class ProductProvider extends ChangeNotifier {
|
||||
ProductDetailsData productDetails = ProductDetailsData();
|
||||
bool isProductLoading = true;
|
||||
|
||||
Future<void> getProduuctDetails(
|
||||
Future<bool> getProduuctDetails(
|
||||
BuildContext context, String id, int quantity, String price) async {
|
||||
var data = {};
|
||||
context.showLoader(show: true);
|
||||
productDetails = ProductDetailsData();
|
||||
|
||||
isProductLoading = true;
|
||||
|
||||
quantitys = quantity;
|
||||
_totalPrice = quantity * (double.parse(price));
|
||||
notifyListeners();
|
||||
@@ -192,13 +197,18 @@ class ProductProvider extends ChangeNotifier {
|
||||
var result = await _homeRepo.getProductDetails(data, context, id);
|
||||
return result.fold(
|
||||
(error) {
|
||||
context.showLoader(show: false);
|
||||
isProductLoading = false;
|
||||
notifyListeners();
|
||||
return false;
|
||||
},
|
||||
(response) {
|
||||
context.showLoader(show: false);
|
||||
productDetails = response!;
|
||||
isProductLoading = false;
|
||||
|
||||
notifyListeners();
|
||||
return true;
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -524,8 +534,10 @@ class ProductProvider extends ChangeNotifier {
|
||||
),
|
||||
);
|
||||
},
|
||||
(response) {
|
||||
cartItems.add(productId); // Add product to cart
|
||||
(response)
|
||||
async {
|
||||
cartItems.add(productId);
|
||||
|
||||
Fluttertoast.showToast(
|
||||
msg: "Added to cart successfully!",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
@@ -535,7 +547,7 @@ class ProductProvider extends ChangeNotifier {
|
||||
fontSize: 14.0,
|
||||
);
|
||||
iscardAdded = true;
|
||||
notifyListeners(); // Update UI after adding to cart
|
||||
notifyListeners();
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
|
||||
@@ -143,7 +143,6 @@ class ProductRepo {
|
||||
.map((item) => ProductCategoryModel.fromJson(item))
|
||||
.toList();
|
||||
if (response != null && response.data != null) {
|
||||
|
||||
final List<ProductCategoryModel> productModels = (response.data as List)
|
||||
.map((item) => ProductCategoryModel.fromJson(item))
|
||||
.toList();
|
||||
@@ -236,7 +235,7 @@ class ProductRepo {
|
||||
FutureResult<CouponResponse> applyCoupon(data) async {
|
||||
try {
|
||||
var response = await _productService.applyCoupon(data);
|
||||
|
||||
print("jdjkgdfjkhdfg ");
|
||||
CouponResponse couponresponse =
|
||||
couponResponseFromJson(response.toString());
|
||||
print("jdjkgdfjkhdfg $couponresponse");
|
||||
|
||||
@@ -2,14 +2,13 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
|
||||
|
||||
class NotificationService {
|
||||
static final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
|
||||
static Future<void> init() async {
|
||||
const AndroidInitializationSettings initializationSettingsAndroid =
|
||||
AndroidInitializationSettings('@mipmap/ic_launcher');
|
||||
AndroidInitializationSettings('logo');
|
||||
|
||||
const DarwinInitializationSettings initializationSettingsIOS =
|
||||
DarwinInitializationSettings(
|
||||
|
||||
@@ -297,15 +297,31 @@ class _BestDealScreenState extends State<BestDealScreen> {
|
||||
itemBuilder: (context, index) {
|
||||
var bestdealproduct = provider.bestdeal[index];
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": bestdealproduct.id,
|
||||
"quantity": 1,
|
||||
"price": bestdealproduct.discountPrice,
|
||||
},
|
||||
);
|
||||
onTap: () async {
|
||||
|
||||
var status = await provider.getProduuctDetails(
|
||||
context, bestdealproduct.id, 1, bestdealproduct.discountPrice);
|
||||
if (status) {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": bestdealproduct.id,
|
||||
"quantity": 1,
|
||||
"price": bestdealproduct.discountPrice,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// context.push(
|
||||
// MyRoutes.PRODUCTDETAILS,
|
||||
// extra: {
|
||||
// "id": bestdealproduct.id,
|
||||
// "quantity": 1,
|
||||
// "price": bestdealproduct.discountPrice,
|
||||
// },
|
||||
// );
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
|
||||
@@ -101,15 +101,28 @@ class _MycartState extends State<Mycart> {
|
||||
double cardWidth = MediaQuery.of(context).size.width * 0.4;
|
||||
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": bestdealproduct.id,
|
||||
"quantity": 1,
|
||||
"price": bestdealproduct.discountPrice,
|
||||
},
|
||||
);
|
||||
onTap: () async {
|
||||
var status = await provider.getProduuctDetails(context,
|
||||
bestdealproduct.id, 1, bestdealproduct.discountPrice);
|
||||
if (status) {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": bestdealproduct.id,
|
||||
"quantity": 1,
|
||||
"price": bestdealproduct.discountPrice,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// context.push(
|
||||
// MyRoutes.PRODUCTDETAILS,
|
||||
// extra: {
|
||||
// "id": bestdealproduct.id,
|
||||
// "quantity": 1,
|
||||
// "price": bestdealproduct.discountPrice,
|
||||
// },
|
||||
// );
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@@ -216,8 +229,11 @@ class _MycartState extends State<Mycart> {
|
||||
onTap: () async {
|
||||
if (await SharedPrefUtils.getToken() !=
|
||||
null) {
|
||||
await provider.addToCart(
|
||||
context, bestdealproduct.id!, 1);
|
||||
await Provider.of<AddtocartProvider>(
|
||||
context,
|
||||
listen: false)
|
||||
.addToCart(
|
||||
context, bestdealproduct.id!, 1);
|
||||
} else {
|
||||
context.push(MyRoutes.SIGNUP);
|
||||
}
|
||||
@@ -410,15 +426,30 @@ class _MycartState extends State<Mycart> {
|
||||
var items = provider.allitem.items![index];
|
||||
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": items.product!.id,
|
||||
"quantity": items.quantity,
|
||||
"price": items.product!.discountPrice,
|
||||
},
|
||||
);
|
||||
onTap: () async {
|
||||
var status =
|
||||
await Provider.of<ProductProvider>(context, listen: false)
|
||||
.getProduuctDetails(context, items.product!.id!,
|
||||
items.quantity!, items.product!.discountPrice!);
|
||||
if (status) {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": items.product!.id,
|
||||
"quantity": items.quantity,
|
||||
"price": items.product!.discountPrice,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// context.push(
|
||||
// MyRoutes.PRODUCTDETAILS,
|
||||
// extra: {
|
||||
// "id": items.product!.id,
|
||||
// "quantity": items.quantity,
|
||||
// "price": items.product!.discountPrice,
|
||||
// },
|
||||
// );
|
||||
},
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.w),
|
||||
|
||||
@@ -108,27 +108,21 @@ class CouponsScreen extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Stack(
|
||||
children: [
|
||||
// Background Image
|
||||
Positioned.fill(
|
||||
child: Image.network(
|
||||
coupon.imageUrl,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
|
||||
// Blur Effect
|
||||
Positioned.fill(
|
||||
child: BackdropFilter(
|
||||
filter:
|
||||
ImageFilter.blur(sigmaX: 5, sigmaY: 5),
|
||||
child: Container(
|
||||
color: Colors.black.withOpacity(
|
||||
0.3), // Dark overlay for readability
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Coupon Content
|
||||
Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
@@ -139,8 +133,7 @@ class CouponsScreen extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors
|
||||
.white, // Ensure contrast with background
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
@@ -151,8 +144,7 @@ class CouponsScreen extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors
|
||||
.white, // Ensure contrast with background
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
@@ -162,19 +154,20 @@ class CouponsScreen extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color:
|
||||
Colors.white, // Highlight price
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
Text(
|
||||
"₹${coupon.discountValue ?? ''}",
|
||||
coupon.type == "PERCENTAGE"
|
||||
? "${coupon.discountValue ?? ''}%"
|
||||
: "₹${coupon.discountValue ?? ''}",
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.amber, // Highlight price
|
||||
color: Colors.amber,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
@@ -183,13 +176,10 @@ class CouponsScreen extends StatelessWidget {
|
||||
style: TextStyle(color: Colors.white70),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
|
||||
// Coupon Code and Apply Button
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// Coupon Code Box
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 10, vertical: 5),
|
||||
@@ -209,18 +199,18 @@ class CouponsScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Apply Button
|
||||
ElevatedButton(
|
||||
onPressed: isCouponValid
|
||||
? () async {
|
||||
? () async
|
||||
{
|
||||
var status = await provider
|
||||
.applyCoupon(
|
||||
context,
|
||||
cartId,
|
||||
coupon.code,
|
||||
coupon.id);
|
||||
if (status) {
|
||||
if (status)
|
||||
{
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,17 +202,30 @@ class _FavouriteScreenState extends State<FavouriteScreen>
|
||||
_animationController.forward(from: 0);
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
// extra: productId
|
||||
onTap: () async {
|
||||
var status = await provider.getProduuctDetails(
|
||||
context, productId, 1, product.discountPrice);
|
||||
if (status) {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": productId,
|
||||
"quantity": 1,
|
||||
"price": product.discountPrice,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
extra: {
|
||||
"id": productId,
|
||||
"quantity": 1,
|
||||
"price": product.discountPrice,
|
||||
},
|
||||
);
|
||||
// context.push(
|
||||
// MyRoutes.PRODUCTDETAILS,
|
||||
// // extra: productId
|
||||
|
||||
// extra: {
|
||||
// "id": productId,
|
||||
// "quantity": 1,
|
||||
// "price": product.discountPrice,
|
||||
// },
|
||||
// );
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
|
||||
@@ -156,15 +156,28 @@ class _CtegoryProductState extends State<CtegoryProduct> {
|
||||
}
|
||||
var product = provider.products[index];
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": product.id,
|
||||
"quantity": 1,
|
||||
"price": product.discountPrice,
|
||||
},
|
||||
);
|
||||
onTap: () async {
|
||||
var status = await provider.getProduuctDetails(
|
||||
context, product.id, 1, product.discountPrice);
|
||||
if (status) {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": product.id,
|
||||
"quantity": 1,
|
||||
"price": product.discountPrice,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// context.push(
|
||||
// MyRoutes.PRODUCTDETAILS,
|
||||
// extra: {
|
||||
// "id": product.id,
|
||||
// "quantity": 1,
|
||||
// "price": product.discountPrice,
|
||||
// },
|
||||
// );
|
||||
},
|
||||
child: Container(
|
||||
height: itemHeight,
|
||||
|
||||
@@ -103,19 +103,19 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
Text(suggestion.name),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
// _searchController.text = suggestion.name;
|
||||
// searchProvider.getHomeProduct(
|
||||
// context, "", suggestion.name, '', '', '');
|
||||
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": suggestion.id,
|
||||
"quantity": 1,
|
||||
"price": suggestion.discountPrice,
|
||||
},
|
||||
);
|
||||
onTap: () async {
|
||||
var status = await searchProvider.getProduuctDetails(
|
||||
context, suggestion.id, 1, suggestion.discountPrice);
|
||||
if (status) {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": suggestion.id,
|
||||
"quantity": 1,
|
||||
"price": suggestion.discountPrice,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_clearOverlay();
|
||||
},
|
||||
@@ -393,15 +393,22 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
MediaQuery.of(context).size.width * 0.4;
|
||||
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": bestdealproduct.id,
|
||||
"quantity": 1,
|
||||
"price": bestdealproduct.discountPrice,
|
||||
},
|
||||
);
|
||||
onTap: () async {
|
||||
var status = await provider.getProduuctDetails(
|
||||
context,
|
||||
bestdealproduct.id,
|
||||
1,
|
||||
bestdealproduct.discountPrice);
|
||||
if (status) {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": bestdealproduct.id,
|
||||
"quantity": 1,
|
||||
"price": bestdealproduct.discountPrice,
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@@ -461,8 +468,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height *
|
||||
0.01),
|
||||
|
||||
|
||||
Text(
|
||||
bestdealproduct.name ?? "",
|
||||
textAlign: TextAlign.left,
|
||||
@@ -756,15 +761,19 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
itemBuilder: (context, index) {
|
||||
var product = provider.homeproducts[index];
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": product.id,
|
||||
"quantity": 1,
|
||||
"price": product.discountPrice,
|
||||
},
|
||||
);
|
||||
onTap: () async {
|
||||
var status = await provider.getProduuctDetails(
|
||||
context, product.id, 1, product.discountPrice);
|
||||
if (status) {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": product.id,
|
||||
"quantity": 1,
|
||||
"price": product.discountPrice,
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
child: SizedBox(
|
||||
child: Column(
|
||||
|
||||
@@ -46,8 +46,8 @@ class _ProductDetailsState extends State<ProductDetails> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Provider.of<ProductProvider>(context, listen: false)
|
||||
.getProduuctDetails(context, widget.id, widget.quantity, widget.price);
|
||||
// Provider.of<ProductProvider>(context, listen: false)
|
||||
// .getProduuctDetails(context, widget.id, widget.quantity, widget.price);
|
||||
}
|
||||
|
||||
double value = 3.5;
|
||||
@@ -962,11 +962,9 @@ class _ProductDetailsState extends State<ProductDetails> {
|
||||
}
|
||||
|
||||
String formatDate(String dateStr) {
|
||||
// Parse the date string to DateTime
|
||||
DateTime date = DateTime.parse(dateStr).toLocal();
|
||||
|
||||
// Format the date
|
||||
return DateFormat('MMMM d, yyyy').format(date); // "February 4, 2025"
|
||||
return DateFormat('MMMM d, yyyy').format(date);
|
||||
}
|
||||
|
||||
Widget bestDeal() {
|
||||
@@ -986,15 +984,28 @@ class _ProductDetailsState extends State<ProductDetails> {
|
||||
double cardWidth = MediaQuery.of(context).size.width * 0.4;
|
||||
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": bestdealproduct.id,
|
||||
"quantity": 1,
|
||||
"price": bestdealproduct.discountPrice,
|
||||
},
|
||||
);
|
||||
onTap: () async {
|
||||
var status = await provider.getProduuctDetails(context,
|
||||
bestdealproduct.id, 1, bestdealproduct.discountPrice);
|
||||
if (status) {
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": bestdealproduct.id,
|
||||
"quantity": 1,
|
||||
"price": bestdealproduct.discountPrice,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// context.push(
|
||||
// MyRoutes.PRODUCTDETAILS,
|
||||
// extra: {
|
||||
// "id": bestdealproduct.id,
|
||||
// "quantity": 1,
|
||||
// "price": bestdealproduct.discountPrice,
|
||||
// },
|
||||
// );
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@@ -1244,89 +1255,3 @@ class _ProductDetailsState extends State<ProductDetails> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Widget _slider(BuildContext context) {
|
||||
// double height = MediaQuery.of(context).size.height * .43;
|
||||
// double statusBarHeight = MediaQuery.of(context).padding.top;
|
||||
|
||||
// // Fetch product data from Provider
|
||||
// final productProvider = Provider.of<ProductProvider>(context);
|
||||
// Product? model = productProvider.selectedProduct; // Ensure you have a selected product
|
||||
|
||||
// if (model == null) {
|
||||
// return Center(child: CircularProgressIndicator()); // Show loading if no product data
|
||||
// }
|
||||
|
||||
// return GestureDetector(
|
||||
// onTap: () {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// PageRouteBuilder(
|
||||
// pageBuilder: (_, __, ___) => ProductPreview(
|
||||
// pos: _curSlider,
|
||||
// secPos: widget.secPos,
|
||||
// index: widget.index,
|
||||
// id: model.id,
|
||||
// imgList: sliderList,
|
||||
// list: widget.list,
|
||||
// video: model.video,
|
||||
// videoType: model.videType,
|
||||
// from: true,
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// child: Stack(
|
||||
// children: <Widget>[
|
||||
// Container(
|
||||
// alignment: Alignment.center,
|
||||
// padding: EdgeInsets.only(top: statusBarHeight + kToolbarHeight),
|
||||
// child: PageView.builder(
|
||||
// physics: const BouncingScrollPhysics(),
|
||||
// itemCount: sliderList.length,
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// controller: _pageController,
|
||||
// reverse: false,
|
||||
// onPageChanged: (index) {
|
||||
// setState(() {
|
||||
// _curSlider = index;
|
||||
// });
|
||||
// },
|
||||
// itemBuilder: (BuildContext context, int i) {
|
||||
// return sliderList[i] != "youtube"
|
||||
// ? networkImageCommon(sliderList[i]!, height, true)
|
||||
// : playIcon(model);
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// Positioned(
|
||||
// bottom: 30,
|
||||
// height: 20,
|
||||
// width: MediaQuery.of(context).size.width,
|
||||
// child: Row(
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: List.generate(
|
||||
// sliderList.length,
|
||||
// (index) => AnimatedContainer(
|
||||
// duration: const Duration(milliseconds: 500),
|
||||
// width: _curSlider == index ? 30.0 : 8.0,
|
||||
// height: 8.0,
|
||||
// margin: const EdgeInsets.symmetric(vertical: 2.0, horizontal: 4.0),
|
||||
// decoration: BoxDecoration(
|
||||
// border: Border.all(
|
||||
// color: Theme.of(context).colorScheme.primary),
|
||||
// borderRadius: BorderRadius.circular(20.0),
|
||||
// color: _curSlider == index
|
||||
// ? Theme.of(context).colorScheme.primary
|
||||
// : Colors.transparent,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// indicatorImage(model),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user