92 lines
3.2 KiB
Dart
92 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_animate/flutter_animate.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../../../core/theme/app_colors.dart';
|
|
import '../../../core/theme/app_dimens.dart';
|
|
import '../../../core/theme/app_typography.dart';
|
|
import '../../../core/utils/formatters.dart';
|
|
import '../providers/cart_controller.dart';
|
|
|
|
/// Floating bill summary shown when the billing panel is collapsed into a
|
|
/// sheet. Gives the cashier the running total without opening anything.
|
|
class CartFab extends ConsumerWidget {
|
|
const CartFab({super.key, required this.onTap});
|
|
|
|
final VoidCallback onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final cart = ref.watch(cartControllerProvider);
|
|
if (cart.isEmpty) return const SizedBox.shrink();
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.all(AppSpacing.lg),
|
|
child: ConstrainedBox(
|
|
constraints: BoxConstraints(
|
|
maxWidth: MediaQuery.sizeOf(context).width - AppSpacing.xxxl,
|
|
),
|
|
child: Material(
|
|
color: AppColors.primary,
|
|
borderRadius: AppRadius.brLg,
|
|
elevation: 0,
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
borderRadius: AppRadius.brLg,
|
|
child: Container(
|
|
height: AppSizes.buttonHeightLarge,
|
|
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.xl),
|
|
decoration: BoxDecoration(
|
|
borderRadius: AppRadius.brLg,
|
|
boxShadow: AppColors.shadowLg,
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
width: 28,
|
|
height: 28,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withValues(alpha: 0.22),
|
|
borderRadius: AppRadius.brXs,
|
|
),
|
|
alignment: Alignment.center,
|
|
child: Text(
|
|
'${cart.lineCount}',
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 13,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: AppSpacing.md),
|
|
const Flexible(
|
|
child: Text(
|
|
'View bill',
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 15,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: AppSpacing.lg),
|
|
Text(
|
|
Formatters.money(cart.grandTotal),
|
|
style: AppTypography.money(19, color: Colors.white),
|
|
),
|
|
const SizedBox(width: AppSpacing.sm),
|
|
const Icon(Icons.keyboard_arrow_up_rounded,
|
|
color: Colors.white, size: 20),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
).animate().fadeIn(duration: 180.ms).slideY(begin: 0.3, end: 0);
|
|
}
|
|
}
|