pos changes

This commit is contained in:
2026-08-06 19:26:53 +05:30
parent cb065a0f69
commit eebd10da6d
42 changed files with 3451 additions and 2531 deletions

View File

@@ -14,14 +14,12 @@ class CartLineTile extends StatelessWidget {
required this.onIncrement,
required this.onDecrement,
required this.onRemove,
this.onDiscount,
});
final CartLine line;
final VoidCallback onIncrement;
final VoidCallback onDecrement;
final VoidCallback onRemove;
final VoidCallback? onDiscount;
@override
Widget build(BuildContext context) {
@@ -30,7 +28,16 @@ class CartLineTile extends StatelessWidget {
return Dismissible(
key: ValueKey('dismiss_${p.id}'),
direction: DismissDirection.endToStart,
onDismissed: (_) => onRemove(),
// Confirm rather than dismiss: [onRemove] opens the PIN dialog, and a
// refused PIN must leave the line exactly where it was. Dismissing first
// and asking after left the row gone from the screen but still in the
// cart — and Flutter asserting about a dismissed widget still in the
// tree. Returning false always is correct: when the PIN is accepted the
// line disappears because the cart changed, not because of the swipe.
confirmDismiss: (_) async {
onRemove();
return false;
},
background: Container(
alignment: Alignment.centerRight,
padding: const EdgeInsets.only(right: AppSpacing.xl),
@@ -119,7 +126,7 @@ class CartLineTile extends StatelessWidget {
color: AppColors.textTertiary,
constraints: const BoxConstraints(minWidth: 32, minHeight: 32),
padding: EdgeInsets.zero,
tooltip: 'Remove',
tooltip: 'Remove from bill (needs the removal PIN)',
),
],),
@@ -132,17 +139,6 @@ class CartLineTile extends StatelessWidget {
onIncrement: onIncrement,
onDecrement: onDecrement,
),
if (onDiscount != null) ...[
const SizedBox(width: AppSpacing.sm),
IconButton(
onPressed: onDiscount,
icon: const Icon(Icons.local_offer_outlined, size: 17),
color: AppColors.textSecondary,
constraints: const BoxConstraints(minWidth: 34, minHeight: 34),
padding: EdgeInsets.zero,
tooltip: 'Line discount',
),
],
const Spacer(),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
@@ -209,8 +205,12 @@ class _Stepper extends StatelessWidget {
borderRadius: AppRadius.brSm,
border: Border.all(color: AppColors.border),
),
// Minus stops at one rather than emptying the line. Dropping to zero
// was a silent removal that skipped the PIN the close button asks for —
// two taps of a stepper should not be a way around the till's only
// theft control.
child: Row(mainAxisSize: MainAxisSize.min, children: [
_btn(Icons.remove_rounded, onDecrement),
_btn(Icons.remove_rounded, quantity > 1 ? onDecrement : null),
Container(
constraints: const BoxConstraints(minWidth: 42),
alignment: Alignment.center,
@@ -226,7 +226,7 @@ class _Stepper extends StatelessWidget {
);
}
Widget _btn(IconData icon, VoidCallback onTap) => Material(
Widget _btn(IconData icon, VoidCallback? onTap) => Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
@@ -234,7 +234,13 @@ class _Stepper extends StatelessWidget {
child: SizedBox(
width: 34,
height: 34,
child: Icon(icon, size: 17, color: AppColors.primary),
child: Icon(
icon,
size: 17,
color: onTap == null
? AppColors.textTertiary.withValues(alpha: 0.5)
: AppColors.primary,
),
),
),
);