Fixed bugs
This commit is contained in:
@@ -163,7 +163,7 @@ class _AddCustomerSheetState extends ConsumerState<AddCustomerSheet> {
|
||||
bottom: MediaQuery.of(context).viewInsets.bottom,
|
||||
left: 24,
|
||||
right: 24,
|
||||
top: 24,
|
||||
top: 48,
|
||||
),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
@@ -173,8 +173,14 @@ class _AddCustomerSheetState extends ConsumerState<AddCustomerSheet> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(LucideIcons.chevronLeft, size: 28),
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(widget.customer == null ? "New Customer" : "Edit Customer", style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
@@ -305,8 +311,10 @@ class _AddCustomerSheetState extends ConsumerState<AddCustomerSheet> {
|
||||
return statesState.when(
|
||||
data: (states) {
|
||||
return SmartSearchDropdown<int>(
|
||||
labelText: 'State',
|
||||
hintText: 'Select State',
|
||||
value: _selectedStateId,
|
||||
fillColor: Colors.grey[100],
|
||||
items: states.map((s) => s.id).toList(),
|
||||
itemAsString: (id) {
|
||||
final s = states.firstWhere((st) => st.id == id);
|
||||
|
||||
@@ -450,6 +450,34 @@ class _InvoiceBuilderScreenState extends ConsumerState<InvoiceBuilderScreen> {
|
||||
const Text('Line Items', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
|
||||
Row(
|
||||
children: [
|
||||
Consumer(
|
||||
builder: (context, ref, child) {
|
||||
final feature = ref.watch(businessFeatureProvider).value;
|
||||
final isBarcode = feature?.barcodeSource == 'BARCODE';
|
||||
return Row(
|
||||
children: [
|
||||
Text('Scan by:', style: TextStyle(fontSize: 12, color: Colors.grey.shade600)),
|
||||
const SizedBox(width: 4),
|
||||
Text('SKU', style: TextStyle(fontSize: 10, fontWeight: !isBarcode ? FontWeight.bold : FontWeight.normal, color: !isBarcode ? Colors.blue : Colors.grey)),
|
||||
Transform.scale(
|
||||
scale: 0.7,
|
||||
child: Switch(
|
||||
value: isBarcode,
|
||||
activeColor: Colors.blue,
|
||||
onChanged: (val) {
|
||||
if (feature != null) {
|
||||
ref.read(businessFeatureProvider.notifier).updateFeatures(
|
||||
feature.copyWith(barcodeSource: val ? 'BARCODE' : 'SKU')
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
Text('EAN', style: TextStyle(fontSize: 10, fontWeight: isBarcode ? FontWeight.bold : FontWeight.normal, color: isBarcode ? Colors.blue : Colors.grey)),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(LucideIcons.scanLine, color: Colors.blue),
|
||||
onPressed: _scanAndAddBarcode,
|
||||
@@ -595,10 +623,25 @@ class _InvoiceBuilderScreenState extends ConsumerState<InvoiceBuilderScreen> {
|
||||
child: Consumer(
|
||||
builder: (context, consumerRef, _) {
|
||||
final walletsState = consumerRef.watch(walletProvider);
|
||||
final wallets = walletsState.value ?? [];
|
||||
final allWallets = walletsState.value ?? [];
|
||||
|
||||
final wallets = allWallets.where((w) {
|
||||
if (_paymentMethod == 'Cash') {
|
||||
return w.nature == 'CASH';
|
||||
} else {
|
||||
return w.nature == 'INCOME' || w.nature == 'SAVINGS';
|
||||
}
|
||||
}).toList();
|
||||
|
||||
if (wallets.isNotEmpty && (_selectedWalletId == null || !wallets.any((w) => w.id == _selectedWalletId))) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) setState(() => _selectedWalletId = wallets.first.id);
|
||||
});
|
||||
}
|
||||
|
||||
return DropdownButtonHideUnderline(
|
||||
child: DropdownButton<int>(
|
||||
value: _selectedWalletId ?? wallets.firstOrNull?.id,
|
||||
value: _selectedWalletId,
|
||||
isDense: true,
|
||||
hint: const Text('Wallet'),
|
||||
items: wallets
|
||||
@@ -626,7 +669,14 @@ class _InvoiceBuilderScreenState extends ConsumerState<InvoiceBuilderScreen> {
|
||||
items: ['Cash', 'UPI', 'Bank Transfer', 'Card']
|
||||
.map((m) => DropdownMenuItem(value: m, child: Text(m)))
|
||||
.toList(),
|
||||
onChanged: (val) => setState(() => _paymentMethod = val!),
|
||||
onChanged: (val) {
|
||||
if (val != null) {
|
||||
setState(() {
|
||||
_paymentMethod = val;
|
||||
_selectedWalletId = null;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -31,9 +31,17 @@ class _ReceivePaymentSheetState extends ConsumerState<ReceivePaymentSheet> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final walletsState = ref.watch(walletProvider);
|
||||
final wallets = walletsState.value ?? [];
|
||||
final allWallets = walletsState.value ?? [];
|
||||
|
||||
if (wallets.isNotEmpty && _selectedWalletId == null) {
|
||||
final wallets = allWallets.where((w) {
|
||||
if (_paymentMethod == 'Cash') {
|
||||
return w.nature == 'CASH';
|
||||
} else {
|
||||
return w.nature == 'INCOME' || w.nature == 'SAVINGS';
|
||||
}
|
||||
}).toList();
|
||||
|
||||
if (wallets.isNotEmpty && (_selectedWalletId == null || !wallets.any((w) => w.id == _selectedWalletId))) {
|
||||
_selectedWalletId = wallets.first.id;
|
||||
}
|
||||
|
||||
@@ -102,7 +110,14 @@ class _ReceivePaymentSheetState extends ConsumerState<ReceivePaymentSheet> {
|
||||
items: ['Cash', 'UPI', 'Bank Transfer', 'Card']
|
||||
.map((m) => DropdownMenuItem(value: m, child: Text(m)))
|
||||
.toList(),
|
||||
onChanged: (val) => setState(() => _paymentMethod = val!),
|
||||
onChanged: (val) {
|
||||
if (val != null) {
|
||||
setState(() {
|
||||
_paymentMethod = val;
|
||||
_selectedWalletId = null;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user