new changes

This commit is contained in:
saritabirare 2024-09-06 17:55:52 +05:30
parent 50b0828726
commit e1d96ee34e
6 changed files with 162 additions and 77 deletions

View File

@ -368,15 +368,31 @@ class _CheckoutScreenState extends State<CheckoutScreen> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Subtotal: \${_cartController.subtotal.value.toStringAsFixed(2)}'),
Text(
'GST: \${_cartController.gstTotal.value.toStringAsFixed(2)}'),
Text(
'Grand Total: \${_cartController.grandTotal.value.toStringAsFixed(2)}'),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Subtotal:'),
Text('${_cartController.subtotal.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)}'),
],
),
],
),
),
],
),
),

View File

@ -155,17 +155,33 @@ class _OrderConfermationScreenState extends State<OrderConfermationScreen> {
Padding(
padding: EdgeInsets.all(Get.width * 0.02),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Subtotal: \${_cartController.subtotal.value.toStringAsFixed(2)}'),
Text(
'GST: \${_cartController.gstTotal.value.toStringAsFixed(2)}'),
Text(
'Grand Total: \${_cartController.grandTotal.value.toStringAsFixed(2)}'),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Subtotal:'),
Text('${_cartController.subtotal.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: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Address :${widget.placedOrder!.shipTo}",
style: GoogleFonts.roboto(
child: TextField(
controller: TextEditingController(
text: widget.placedOrder!.shipTo,
),
decoration: InputDecoration(
hintText: "Address : ${widget.placedOrder!.shipTo}",
hintStyle: GoogleFonts.roboto(
fontSize: Get.width * 0.04,
fontWeight: FontWeight.w400,
),
border: OutlineInputBorder(),
),
),
),
// Padding(

View File

@ -110,13 +110,19 @@ class _CartScreenState extends State<CartScreen> {
height: 10,
),
Obx(() {
return Text(
"Subtotal Price: ₹ ${_cartController.subtotal.value}",
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Subtotal Price: ",
style: GoogleFonts.roboto(
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,
// ),
Obx(() {
return Text(
"gstTotal Price: ₹ ${_cartController.gstTotal.value}",
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"gstTotal Price: ",
style: GoogleFonts.roboto(
fontSize: 15,
fontWeight: FontWeight.w700,
color: Colors.white,
color: Colors.black,
),
),
Text("${_cartController.gstTotal.value}"),
],
);
}),
Obx(() {
return Text(
"grandTotal Price: ₹ ${_cartController.grandTotal.value}",
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"grandTotal Price:",
style: GoogleFonts.roboto(
fontSize: 15,
fontWeight: FontWeight.w700,
color: Colors.white,
color: Colors.black,
),
),
Text("${_cartController.grandTotal.value}"),
],
);
}),

View File

@ -7,7 +7,7 @@ import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import '../models/product_model1.dart';
import '../screens/product/cart_screen.dart';
import '../utils/show_snackbar.dart';
class ProductCard extends StatefulWidget {
@ -42,6 +42,11 @@ class _ProductCardState extends State<ProductCard> {
final CartController _cartController = Get.put(CartController());
bool showQuantity = widget.isInCart || widget.isCheckout || widget.isConfirmation;
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(
onTap: () => widget.isInCart || widget.isCheckout
? null
@ -96,7 +101,7 @@ class _ProductCardState extends State<ProductCard> {
),
showQuantity
? Text(
"Quantity: ${widget.productModel!.quantity.toString()}",
"Quantity: ${currentQuantity}",
style: GoogleFonts.roboto(
fontSize: 15,
fontWeight: FontWeight.w700,
@ -120,6 +125,45 @@ class _ProductCardState extends State<ProductCard> {
mainAxisAlignment:
MainAxisAlignment.spaceAround,
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(
height: 24,
width: 24,
@ -127,8 +171,13 @@ class _ProductCardState extends State<ProductCard> {
onPressed: () {
_cartController.increaseQuantity(widget.productModel!);
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(
@ -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(
onPressed: () {
_cartController.removeFromCart(widget.productModel!);
showSnackbar("Product removed successfully!");
setState(() {
// Update the local quantity
currentQuantity = 1;
});
},
icon: const Icon(
Icons.delete_outline_rounded,

View File

@ -144,6 +144,14 @@ packages:
url: "https://pub.dev"
source: hosted
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:
dependency: "direct main"
description:

View File

@ -42,6 +42,7 @@ dependencies:
http: ^1.2.2
shared_preferences: ^2.2.3
logger: ^2.4.0
get_storage: ^2.1.1
dev_dependencies:
flutter_test: