new changes
This commit is contained in:
parent
50b0828726
commit
e1d96ee34e
@ -368,15 +368,31 @@ class _CheckoutScreenState extends State<CheckoutScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Row(
|
||||||
'Subtotal: \₹${_cartController.subtotal.value.toStringAsFixed(2)}'),
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
Text(
|
children: [
|
||||||
'GST: \₹${_cartController.gstTotal.value.toStringAsFixed(2)}'),
|
Text('Subtotal:'),
|
||||||
Text(
|
Text('₹${_cartController.subtotal.value.toStringAsFixed(2)}'),
|
||||||
'Grand Total: \₹${_cartController.grandTotal.value.toStringAsFixed(2)}'),
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text('GST:'),
|
||||||
|
Text('₹${_cartController.gstTotal.value.toStringAsFixed(2)}'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text('Grand Total:'),
|
||||||
|
Text('₹${_cartController.grandTotal.value.toStringAsFixed(2)}'),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -155,17 +155,33 @@ class _OrderConfermationScreenState extends State<OrderConfermationScreen> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.all(Get.width * 0.02),
|
padding: EdgeInsets.all(Get.width * 0.02),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Row(
|
||||||
'Subtotal: \₹${_cartController.subtotal.value.toStringAsFixed(2)}'),
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
Text(
|
children: [
|
||||||
'GST: \₹${_cartController.gstTotal.value.toStringAsFixed(2)}'),
|
Text('Subtotal:'),
|
||||||
Text(
|
Text('₹${_cartController.subtotal.value.toStringAsFixed(2)}'),
|
||||||
'Grand Total: \₹${_cartController.grandTotal.value.toStringAsFixed(2)}'),
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text('GST:'),
|
||||||
|
Text('₹${_cartController.gstTotal.value.toStringAsFixed(2)}'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text('Grand Total:'),
|
||||||
|
Text('₹${_cartController.grandTotal.value.toStringAsFixed(2)}'),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -189,12 +205,18 @@ class _OrderConfermationScreenState extends State<OrderConfermationScreen> {
|
|||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Text(
|
child: TextField(
|
||||||
"Address :${widget.placedOrder!.shipTo}",
|
controller: TextEditingController(
|
||||||
style: GoogleFonts.roboto(
|
text: widget.placedOrder!.shipTo,
|
||||||
|
),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "Address : ${widget.placedOrder!.shipTo}",
|
||||||
|
hintStyle: GoogleFonts.roboto(
|
||||||
fontSize: Get.width * 0.04,
|
fontSize: Get.width * 0.04,
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
),
|
),
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Padding(
|
// Padding(
|
||||||
|
@ -110,13 +110,19 @@ class _CartScreenState extends State<CartScreen> {
|
|||||||
height: 10,
|
height: 10,
|
||||||
),
|
),
|
||||||
Obx(() {
|
Obx(() {
|
||||||
return Text(
|
return Row(
|
||||||
"Subtotal Price: ₹ ${_cartController.subtotal.value}",
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Subtotal Price: ",
|
||||||
style: GoogleFonts.roboto(
|
style: GoogleFonts.roboto(
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
color: Colors.white,
|
color: Colors.black,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
Text("₹ ${_cartController.subtotal.value}"),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
}),
|
}),
|
||||||
@ -126,24 +132,36 @@ class _CartScreenState extends State<CartScreen> {
|
|||||||
// height: 16,
|
// height: 16,
|
||||||
// ),
|
// ),
|
||||||
Obx(() {
|
Obx(() {
|
||||||
return Text(
|
return Row(
|
||||||
"gstTotal Price: ₹ ${_cartController.gstTotal.value}",
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"gstTotal Price: ",
|
||||||
style: GoogleFonts.roboto(
|
style: GoogleFonts.roboto(
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
color: Colors.white,
|
color: Colors.black,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
Text("₹ ${_cartController.gstTotal.value}"),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
}),
|
}),
|
||||||
Obx(() {
|
Obx(() {
|
||||||
return Text(
|
return Row(
|
||||||
"grandTotal Price: ₹ ${_cartController.grandTotal.value}",
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"grandTotal Price:",
|
||||||
style: GoogleFonts.roboto(
|
style: GoogleFonts.roboto(
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
color: Colors.white,
|
color: Colors.black,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
Text(" ₹ ${_cartController.grandTotal.value}"),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
}),
|
}),
|
||||||
|
@ -7,7 +7,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
|
||||||
import '../models/product_model1.dart';
|
import '../models/product_model1.dart';
|
||||||
import '../screens/product/cart_screen.dart';
|
|
||||||
import '../utils/show_snackbar.dart';
|
import '../utils/show_snackbar.dart';
|
||||||
|
|
||||||
class ProductCard extends StatefulWidget {
|
class ProductCard extends StatefulWidget {
|
||||||
@ -42,6 +42,11 @@ class _ProductCardState extends State<ProductCard> {
|
|||||||
final CartController _cartController = Get.put(CartController());
|
final CartController _cartController = Get.put(CartController());
|
||||||
bool showQuantity = widget.isInCart || widget.isCheckout || widget.isConfirmation;
|
bool showQuantity = widget.isInCart || widget.isCheckout || widget.isConfirmation;
|
||||||
bool isProductInCart = _cartController.cartList.contains(widget.productModel);
|
bool isProductInCart = _cartController.cartList.contains(widget.productModel);
|
||||||
|
|
||||||
|
|
||||||
|
int currentQuantity = isProductInCart
|
||||||
|
? _cartController.cartList.firstWhere((p) => p.id == widget.productModel!.id).quantity
|
||||||
|
: widget.productModel!.quantity;
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => widget.isInCart || widget.isCheckout
|
onTap: () => widget.isInCart || widget.isCheckout
|
||||||
? null
|
? null
|
||||||
@ -96,7 +101,7 @@ class _ProductCardState extends State<ProductCard> {
|
|||||||
),
|
),
|
||||||
showQuantity
|
showQuantity
|
||||||
? Text(
|
? Text(
|
||||||
"Quantity: ${widget.productModel!.quantity.toString()}",
|
"Quantity: ${currentQuantity}",
|
||||||
style: GoogleFonts.roboto(
|
style: GoogleFonts.roboto(
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
@ -120,6 +125,45 @@ class _ProductCardState extends State<ProductCard> {
|
|||||||
mainAxisAlignment:
|
mainAxisAlignment:
|
||||||
MainAxisAlignment.spaceAround,
|
MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 24,
|
||||||
|
width: 24,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
_cartController.decreaseQuantity(widget.productModel!);
|
||||||
|
setState(() {
|
||||||
|
// Update the local quantity to reflect the change
|
||||||
|
currentQuantity = _cartController
|
||||||
|
.cartList
|
||||||
|
.firstWhere((p) =>
|
||||||
|
p.id ==
|
||||||
|
widget.productModel!.id)
|
||||||
|
.quantity;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.circular(8.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'-',
|
||||||
|
style: GoogleFonts.roboto(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w800,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"${currentQuantity}",
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 24,
|
height: 24,
|
||||||
width: 24,
|
width: 24,
|
||||||
@ -127,8 +171,13 @@ class _ProductCardState extends State<ProductCard> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
_cartController.increaseQuantity(widget.productModel!);
|
_cartController.increaseQuantity(widget.productModel!);
|
||||||
setState(() {
|
setState(() {
|
||||||
widget.quantity = widget.productModel!.quantity;
|
// Update the local quantity to reflect the change
|
||||||
|
currentQuantity = _cartController
|
||||||
|
.cartList
|
||||||
|
.firstWhere((p) =>
|
||||||
|
p.id ==
|
||||||
|
widget.productModel!.id)
|
||||||
|
.quantity;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
@ -147,40 +196,6 @@ class _ProductCardState extends State<ProductCard> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
|
||||||
"${widget.quantity}",
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 24,
|
|
||||||
width: 24,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
_cartController.decreaseQuantity(widget.productModel!);
|
|
||||||
setState(() {
|
|
||||||
widget.quantity = widget.productModel!.quantity;
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(8.0),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
'-',
|
|
||||||
style: GoogleFonts.roboto(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w800,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -188,6 +203,11 @@ class _ProductCardState extends State<ProductCard> {
|
|||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_cartController.removeFromCart(widget.productModel!);
|
_cartController.removeFromCart(widget.productModel!);
|
||||||
|
showSnackbar("Product removed successfully!");
|
||||||
|
setState(() {
|
||||||
|
// Update the local quantity
|
||||||
|
currentQuantity = 1;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.delete_outline_rounded,
|
Icons.delete_outline_rounded,
|
||||||
|
@ -144,6 +144,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.6.6"
|
version: "4.6.6"
|
||||||
|
get_storage:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: get_storage
|
||||||
|
sha256: "39db1fffe779d0c22b3a744376e86febe4ade43bf65e06eab5af707dc84185a2"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.1"
|
||||||
google_fonts:
|
google_fonts:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -42,6 +42,7 @@ dependencies:
|
|||||||
http: ^1.2.2
|
http: ^1.2.2
|
||||||
shared_preferences: ^2.2.3
|
shared_preferences: ^2.2.3
|
||||||
logger: ^2.4.0
|
logger: ^2.4.0
|
||||||
|
get_storage: ^2.1.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Loading…
Reference in New Issue
Block a user