add box selected product
This commit is contained in:
29
journey/001_Adjust_Product_Padding_Walkthrough.md
Normal file
29
journey/001_Adjust_Product_Padding_Walkthrough.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Walkthrough - Moved Save Button to Bottom Navigation Bar
|
||||||
|
|
||||||
|
I have updated the `AddProduct` screen to improve user experience by making the "Save & Publish" / "Update" button always visible.
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
### 1. Moved Button to Bottom Navigation Bar
|
||||||
|
|
||||||
|
The `ElevatedButton` for saving or updating the product has been moved from the end of the scrollable form to the `Scaffold`'s `bottomNavigationBar`.
|
||||||
|
|
||||||
|
- **File**: `lib/Screens/Products/add product/add_product.dart`
|
||||||
|
- **Change**: Wrapped the button in a `Container` with shadow and padding, and assigned it to `bottomNavigationBar`.
|
||||||
|
- **Benefit**: The button is now fixed at the bottom of the screen, making it accessible at any scroll position.
|
||||||
|
|
||||||
|
### 2. Adjusted Scroll Padding
|
||||||
|
|
||||||
|
Added bottom padding to the `SingleChildScrollView` to ensure the last form fields (like Warranty/Guarantee) are not obscured by the new bottom bar.
|
||||||
|
|
||||||
|
- **File**: `lib/Screens/Products/add product/add_product.dart`
|
||||||
|
- **Change**: Updated `padding` to `EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 80)`.
|
||||||
|
|
||||||
|
## Verification Results
|
||||||
|
|
||||||
|
### Automated Tests
|
||||||
|
- Not applicable for this UI change.
|
||||||
|
|
||||||
|
### Manual Verification
|
||||||
|
- Verified that the code structure correctly places the button outside the scroll view.
|
||||||
|
- Verified that the `onPressed` logic utilizes the correct `ref` and `context`.
|
||||||
@@ -493,9 +493,12 @@ class AddProductState extends ConsumerState<AddProduct> {
|
|||||||
|
|
||||||
// --- END INITIALIZE DROPDOWN SELECTIONS ---
|
// --- END INITIALIZE DROPDOWN SELECTIONS ---
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: SingleChildScrollView(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Form(
|
child: Form(
|
||||||
key: key,
|
key: key,
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -961,127 +964,145 @@ class AddProductState extends ConsumerState<AddProduct> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () async {
|
|
||||||
print('${selectedVariation.map((e) => e.toString()).toList()}');
|
|
||||||
if ((key.currentState?.validate() ?? false)) {
|
|
||||||
ProductRepo productRepo = ProductRepo();
|
|
||||||
bool success;
|
|
||||||
|
|
||||||
// 1. Prepare Stocks List based on Type
|
|
||||||
List<StockDataModel> finalStocks = [];
|
|
||||||
|
|
||||||
if (_selectedType == ProductType.single) {
|
|
||||||
// Create a single stock entry from the Single Product Form controllers
|
|
||||||
finalStocks.add(StockDataModel(
|
|
||||||
stockId: widget.productModel?.stocks?.firstOrNull?.id
|
|
||||||
.toString(), // Preserve ID if updating
|
|
||||||
|
|
||||||
warehouseId: selectedWarehouse?.id.toString(),
|
|
||||||
// Using stockAlertController as per your UI logic for stock quantity
|
|
||||||
productStock: productStockController.text,
|
|
||||||
exclusivePrice: purchaseExclusivePriceController.text,
|
|
||||||
inclusivePrice: purchaseInclusivePriceController.text,
|
|
||||||
profitPercent: profitMarginController.text,
|
|
||||||
productSalePrice: salePriceController.text,
|
|
||||||
productWholeSalePrice: wholeSalePriceController.text,
|
|
||||||
productDealerPrice: dealerPriceController.text,
|
|
||||||
mfgDate: selectedManufactureDate,
|
|
||||||
expireDate: selectedExpireDate,
|
|
||||||
));
|
|
||||||
} else if (_selectedType == ProductType.variant) {
|
|
||||||
if (variantStocks.isEmpty) {
|
|
||||||
EasyLoading.showError("Please generate variations");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
finalStocks = variantStocks;
|
|
||||||
}
|
|
||||||
print('Variation ids $variationIds');
|
|
||||||
// 2. Construct the NEW Model
|
|
||||||
CreateProductModel submitData = CreateProductModel(
|
|
||||||
productId: widget.productModel?.id.toString(),
|
|
||||||
name: nameController.text,
|
|
||||||
categoryId: selectedCategory?.id.toString(),
|
|
||||||
brandId: selectedBrand?.id.toString(),
|
|
||||||
unitId: selectedUnit?.id.toString(),
|
|
||||||
modelId: selectedModel?.id.toString(),
|
|
||||||
productCode: productCodeController.text,
|
|
||||||
alertQty: stockAlertController.text,
|
|
||||||
rackId: selectedRack?.id.toString(),
|
|
||||||
shelfId: selectedShelf?.id.toString(),
|
|
||||||
productType: _selectedType.name,
|
|
||||||
vatType: selectedTaxType,
|
|
||||||
vatId: selectedTax?.id.toString(),
|
|
||||||
vatAmount: ((num.tryParse(purchaseInclusivePriceController.text) ?? 0) -
|
|
||||||
(num.tryParse(purchaseExclusivePriceController.text) ?? 0))
|
|
||||||
.toString(),
|
|
||||||
|
|
||||||
// New structure: Pass the list of StockDataModel
|
|
||||||
stocks: finalStocks,
|
|
||||||
|
|
||||||
// Variant IDs (only needed for variant type)
|
|
||||||
variationIds: _selectedType == ProductType.variant ? variationIds : null,
|
|
||||||
|
|
||||||
// Extra Fields
|
|
||||||
productManufacturer: manufacturerController.text,
|
|
||||||
productDiscount: discountPriceController.text,
|
|
||||||
image: pickedImage != null ? File(pickedImage!.path) : null,
|
|
||||||
|
|
||||||
// Warranty
|
|
||||||
warrantyDuration: warrantyController.text,
|
|
||||||
warrantyPeriod: selectedTimeWarranty,
|
|
||||||
guaranteeDuration: guaranteeController.text,
|
|
||||||
guaranteePeriod: selectedTimeGuarantee,
|
|
||||||
);
|
|
||||||
// --- TYPE: COMBO ---
|
|
||||||
if (_selectedType == ProductType.combo) {
|
|
||||||
if (comboList.isEmpty) {
|
|
||||||
EasyLoading.showError("Please add products to combo");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
submitData.comboProducts = comboList;
|
|
||||||
submitData.comboProfitPercent = comboProfitMarginController.text;
|
|
||||||
submitData.comboProductSalePrice = comboSalePriceController.text;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Call API
|
|
||||||
if (widget.productModel != null) {
|
|
||||||
if (!permissionService.hasPermission(Permit.productsUpdate.value)) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
content: Text(lang.S.of(context).updateProductWarn)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
success =
|
|
||||||
await productRepo.updateProduct(data: submitData, ref: ref, context: context);
|
|
||||||
} else {
|
|
||||||
if (!permissionService.hasPermission(Permit.productsCreate.value)) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
||||||
backgroundColor: Colors.red, content: Text(lang.S.of(context).addProductWarn)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
success =
|
|
||||||
await productRepo.createProduct(data: submitData, ref: ref, context: context);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (success) {
|
|
||||||
if (widget.productModel != null) {
|
|
||||||
ref.refresh(fetchProductDetails(widget.productModel?.id.toString() ?? ''));
|
|
||||||
}
|
|
||||||
ref.refresh(productProvider);
|
|
||||||
Navigator.pop(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(widget.productModel != null
|
|
||||||
? lang.S.of(context).update
|
|
||||||
: lang.S.of(context).saveNPublish),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
blurRadius: 5,
|
||||||
|
color: Colors.black.withOpacity(0.05),
|
||||||
|
offset: const Offset(0, -3),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: kMainColor,
|
||||||
|
minimumSize: const Size(double.infinity, 50),
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
print('${selectedVariation.map((e) => e.toString()).toList()}');
|
||||||
|
if ((key.currentState?.validate() ?? false)) {
|
||||||
|
ProductRepo productRepo = ProductRepo();
|
||||||
|
bool success;
|
||||||
|
|
||||||
|
// 1. Prepare Stocks List based on Type
|
||||||
|
List<StockDataModel> finalStocks = [];
|
||||||
|
|
||||||
|
if (_selectedType == ProductType.single) {
|
||||||
|
// Create a single stock entry from the Single Product Form controllers
|
||||||
|
finalStocks.add(StockDataModel(
|
||||||
|
stockId: widget.productModel?.stocks?.firstOrNull?.id.toString(), // Preserve ID if updating
|
||||||
|
|
||||||
|
warehouseId: selectedWarehouse?.id.toString(),
|
||||||
|
// Using stockAlertController as per your UI logic for stock quantity
|
||||||
|
productStock: productStockController.text,
|
||||||
|
exclusivePrice: purchaseExclusivePriceController.text,
|
||||||
|
inclusivePrice: purchaseInclusivePriceController.text,
|
||||||
|
profitPercent: profitMarginController.text,
|
||||||
|
productSalePrice: salePriceController.text,
|
||||||
|
productWholeSalePrice: wholeSalePriceController.text,
|
||||||
|
productDealerPrice: dealerPriceController.text,
|
||||||
|
mfgDate: selectedManufactureDate,
|
||||||
|
expireDate: selectedExpireDate,
|
||||||
|
));
|
||||||
|
} else if (_selectedType == ProductType.variant) {
|
||||||
|
if (variantStocks.isEmpty) {
|
||||||
|
EasyLoading.showError("Please generate variations");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
finalStocks = variantStocks;
|
||||||
|
}
|
||||||
|
print('Variation ids $variationIds');
|
||||||
|
// 2. Construct the NEW Model
|
||||||
|
CreateProductModel submitData = CreateProductModel(
|
||||||
|
productId: widget.productModel?.id.toString(),
|
||||||
|
name: nameController.text,
|
||||||
|
categoryId: selectedCategory?.id.toString(),
|
||||||
|
brandId: selectedBrand?.id.toString(),
|
||||||
|
unitId: selectedUnit?.id.toString(),
|
||||||
|
modelId: selectedModel?.id.toString(),
|
||||||
|
productCode: productCodeController.text,
|
||||||
|
alertQty: stockAlertController.text,
|
||||||
|
rackId: selectedRack?.id.toString(),
|
||||||
|
shelfId: selectedShelf?.id.toString(),
|
||||||
|
productType: _selectedType.name,
|
||||||
|
vatType: selectedTaxType,
|
||||||
|
vatId: selectedTax?.id.toString(),
|
||||||
|
vatAmount: ((num.tryParse(purchaseInclusivePriceController.text) ?? 0) -
|
||||||
|
(num.tryParse(purchaseExclusivePriceController.text) ?? 0))
|
||||||
|
.toString(),
|
||||||
|
|
||||||
|
// New structure: Pass the list of StockDataModel
|
||||||
|
stocks: finalStocks,
|
||||||
|
|
||||||
|
// Variant IDs (only needed for variant type)
|
||||||
|
variationIds: _selectedType == ProductType.variant ? variationIds : null,
|
||||||
|
|
||||||
|
// Extra Fields
|
||||||
|
productManufacturer: manufacturerController.text,
|
||||||
|
productDiscount: discountPriceController.text,
|
||||||
|
image: pickedImage != null ? File(pickedImage!.path) : null,
|
||||||
|
|
||||||
|
// Warranty
|
||||||
|
warrantyDuration: warrantyController.text,
|
||||||
|
warrantyPeriod: selectedTimeWarranty,
|
||||||
|
guaranteeDuration: guaranteeController.text,
|
||||||
|
guaranteePeriod: selectedTimeGuarantee,
|
||||||
|
);
|
||||||
|
// --- TYPE: COMBO ---
|
||||||
|
if (_selectedType == ProductType.combo) {
|
||||||
|
if (comboList.isEmpty) {
|
||||||
|
EasyLoading.showError("Please add products to combo");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
submitData.comboProducts = comboList;
|
||||||
|
submitData.comboProfitPercent = comboProfitMarginController.text;
|
||||||
|
submitData.comboProductSalePrice = comboSalePriceController.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Call API
|
||||||
|
if (widget.productModel != null) {
|
||||||
|
if (!permissionService.hasPermission(Permit.productsUpdate.value)) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
|
backgroundColor: Colors.red, content: Text(lang.S.of(context).updateProductWarn)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
success = await productRepo.updateProduct(data: submitData, ref: ref, context: context);
|
||||||
|
} else {
|
||||||
|
if (!permissionService.hasPermission(Permit.productsCreate.value)) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
|
backgroundColor: Colors.red, content: Text(lang.S.of(context).addProductWarn)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
success = await productRepo.createProduct(data: submitData, ref: ref, context: context);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
if (widget.productModel != null) {
|
||||||
|
ref.refresh(fetchProductDetails(widget.productModel?.id.toString() ?? ''));
|
||||||
|
}
|
||||||
|
ref.refresh(productProvider);
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
widget.productModel != null ? lang.S.of(context).update : lang.S.of(context).saveNPublish,
|
||||||
|
style: const TextStyle(fontSize: 16, color: Colors.white)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ class AddSalesScreenState extends ConsumerState<AddSalesScreen> {
|
|||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(20.0),
|
padding: const EdgeInsets.fromLTRB(20.0, 20.0, 20.0, 100.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
///_______Invoice_And_Date_____________________________________________________
|
///_______Invoice_And_Date_____________________________________________________
|
||||||
|
|||||||
@@ -222,4 +222,8 @@ class CartNotifier extends ChangeNotifier {
|
|||||||
);
|
);
|
||||||
calculatePrice();
|
calculatePrice();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
num getTotalAmount() {
|
||||||
|
return totalPayableAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -117,7 +117,12 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
|||||||
title: Text(lang.S.of(context).posSale),
|
title: Text(lang.S.of(context).posSale),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
body: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: SingleChildScrollView(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: productsList.when(
|
child: productsList.when(
|
||||||
data: (products) {
|
data: (products) {
|
||||||
@@ -809,54 +814,226 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
|||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
bottomNavigationBar: providerData.cartItemList.isNotEmpty
|
),
|
||||||
? Column(
|
Expanded(
|
||||||
mainAxisSize: MainAxisSize.min,
|
flex: 1,
|
||||||
children: [
|
child: Container(
|
||||||
Divider(thickness: 0.2, color: kBorderColorTextField),
|
margin: const EdgeInsets.all(16),
|
||||||
Padding(
|
decoration: BoxDecoration(
|
||||||
padding: EdgeInsetsGeometry.symmetric(horizontal: 16, vertical: 8),
|
color: Colors.white,
|
||||||
child: ElevatedButton(
|
borderRadius: BorderRadius.circular(10),
|
||||||
onPressed: () async {
|
boxShadow: [
|
||||||
if (!permissionService.hasPermission(Permit.saleReturnsRead.value)) {
|
BoxShadow(
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
color: Colors.black.withOpacity(0.05),
|
||||||
SnackBar(
|
spreadRadius: 1,
|
||||||
backgroundColor: kMainColor,
|
blurRadius: 5,
|
||||||
content: Text(lang.S.of(context).inventoryPermission),
|
offset: const Offset(0, 3),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
border: Border.all(color: kBorderColorTextField),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: kMainColor,
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(10),
|
||||||
|
topRight: Radius.circular(10),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const Text(
|
||||||
|
'Overview Item Added',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: providerData.cartItemList.isEmpty
|
||||||
|
? Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.shopping_cart_outlined,
|
||||||
|
size: 50, color: kSubPeraColor.withOpacity(0.5)),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
Text(
|
||||||
|
'Cart is Empty',
|
||||||
|
style: TextStyle(color: kSubPeraColor),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: ListView.separated(
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
itemCount: providerData.cartItemList.length,
|
||||||
|
separatorBuilder: (context, index) =>
|
||||||
|
Divider(color: kBorderColorTextField),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final item = providerData.cartItemList[index];
|
||||||
|
return Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
item.productName ?? '',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
'$currency${item.unitPrice} x ${item.quantity}',
|
||||||
|
style: TextStyle(
|
||||||
|
color: kSubPeraColor,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'$currency${(item.unitPrice ?? 0) * (item.quantity ?? 0)}',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: kMainColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
providerData.deleteToCart(index);
|
||||||
|
},
|
||||||
|
child: const Icon(
|
||||||
|
Icons.delete_outline,
|
||||||
|
color: Colors.red,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
return;
|
Container(
|
||||||
}
|
padding: const EdgeInsets.all(16),
|
||||||
bool branchResult = await checkActionWhenNoBranch(context: context, ref: ref);
|
decoration: BoxDecoration(
|
||||||
if (!branchResult) {
|
border: Border(top: BorderSide(color: kBorderColorTextField)),
|
||||||
return;
|
),
|
||||||
}
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Total Items:',
|
||||||
|
style: TextStyle(color: kSubPeraColor),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'${providerData.cartItemList.length}',
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 8),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Total Amount:',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: FittedBox(
|
||||||
|
fit: BoxFit.scaleDown,
|
||||||
|
child: Text(
|
||||||
|
'$currency${providerData.getTotalAmount()}',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: kMainColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 16),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: kMainColor,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
),
|
||||||
|
onPressed: providerData.cartItemList.isEmpty
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
if (!permissionService.hasPermission(Permit.saleReturnsRead.value)) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
backgroundColor: kMainColor,
|
||||||
|
content: Text(lang.S.of(context).inventoryPermission),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool branchResult = await checkActionWhenNoBranch(context: context, ref: ref);
|
||||||
|
if (!branchResult) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Navigate to the next screen if permission is granted
|
// Navigate to the next screen if permission is granted
|
||||||
bool result = await Navigator.push(
|
bool result = await Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => AddSalesScreen(
|
builder: (context) => AddSalesScreen(
|
||||||
customerModel: selectedCustomer,
|
customerModel: selectedCustomer,
|
||||||
isFromPos: true,
|
isFromPos: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Handle result after returning from AddSalesScreen
|
||||||
|
if (result) {
|
||||||
|
_searchController.clear();
|
||||||
|
selectedCustomer = null;
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: const Text(
|
||||||
|
'Continue',
|
||||||
|
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
],
|
||||||
|
),
|
||||||
// Handle result after returning from AddSalesScreen
|
|
||||||
if (result) {
|
|
||||||
_searchController.clear();
|
|
||||||
selectedCustomer = null;
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(lang.S.of(context).continueE),
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
)
|
),
|
||||||
: null,
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user