add box selected product
This commit is contained in:
@@ -117,7 +117,12 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
title: Text(lang.S.of(context).posSale),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
body: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: productsList.when(
|
||||
data: (products) {
|
||||
@@ -809,54 +814,226 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
},
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: providerData.cartItemList.isNotEmpty
|
||||
? Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Divider(thickness: 0.2, color: kBorderColorTextField),
|
||||
Padding(
|
||||
padding: EdgeInsetsGeometry.symmetric(horizontal: 16, vertical: 8),
|
||||
child: ElevatedButton(
|
||||
onPressed: () async {
|
||||
if (!permissionService.hasPermission(Permit.saleReturnsRead.value)) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
backgroundColor: kMainColor,
|
||||
content: Text(lang.S.of(context).inventoryPermission),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.05),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 5,
|
||||
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;
|
||||
}
|
||||
bool branchResult = await checkActionWhenNoBranch(context: context, ref: ref);
|
||||
if (!branchResult) {
|
||||
return;
|
||||
}
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(top: BorderSide(color: kBorderColorTextField)),
|
||||
),
|
||||
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
|
||||
bool result = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AddSalesScreen(
|
||||
customerModel: selectedCustomer,
|
||||
isFromPos: true,
|
||||
// Navigate to the next screen if permission is granted
|
||||
bool result = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AddSalesScreen(
|
||||
customerModel: selectedCustomer,
|
||||
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