import 'package:flutter/material.dart'; import 'package:cashumit/widgets/dotted_line.dart'; class CashierStatusBar extends StatelessWidget { final bool isPrinterConnected; final VoidCallback onPrinterTap; final int unsubmittedReceiptsCount; final VoidCallback onOfflineQueueTap; final String? destinationAccountName; final VoidCallback onDestinationTap; final VoidCallback onNewTransaction; final bool hasItems; const CashierStatusBar({ super.key, required this.isPrinterConnected, required this.onPrinterTap, required this.unsubmittedReceiptsCount, required this.onOfflineQueueTap, this.destinationAccountName, required this.onDestinationTap, required this.onNewTransaction, this.hasItems = false, }); @override Widget build(BuildContext context) { return Container( width: double.infinity, color: Colors.white, padding: const EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 2), child: Column( mainAxisSize: MainAxisSize.min, children: [ Row( children: [ // Status Printer InkWell( onTap: onPrinterTap, borderRadius: BorderRadius.circular(4), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2), child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( Icons.print, size: 14, color: isPrinterConnected ? Colors.green[700] : Colors.grey[500], ), const SizedBox(width: 4), Text( isPrinterConnected ? 'Printer Siap' : 'Printer Offline', style: TextStyle( fontSize: 11, fontWeight: FontWeight.w600, color: isPrinterConnected ? Colors.green[800] : Colors.grey[600], ), ), ], ), ), ), const SizedBox(width: 6), Text('|', style: TextStyle(color: Colors.grey[300])), const SizedBox(width: 6), // Status Sinkronisasi / Antrean Nota Expanded( child: InkWell( onTap: onOfflineQueueTap, borderRadius: BorderRadius.circular(4), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2), child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( unsubmittedReceiptsCount > 0 ? Icons.cloud_upload_outlined : Icons.cloud_done_outlined, size: 14, color: unsubmittedReceiptsCount > 0 ? Colors.orange[800] : Colors.blue[700], ), const SizedBox(width: 4), Flexible( child: Text( unsubmittedReceiptsCount > 0 ? '$unsubmittedReceiptsCount Antre' : 'Sinkron', style: TextStyle( fontSize: 11, fontWeight: FontWeight.w600, color: unsubmittedReceiptsCount > 0 ? Colors.orange[900] : Colors.blue[800], ), overflow: TextOverflow.ellipsis, ), ), ], ), ), ), ), // Akun Tujuan InkWell( onTap: onDestinationTap, borderRadius: BorderRadius.circular(4), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2), child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( Icons.account_balance_wallet_outlined, size: 14, color: Colors.grey[700], ), const SizedBox(width: 4), ConstrainedBox( constraints: const BoxConstraints(maxWidth: 140), child: Text( destinationAccountName != null && destinationAccountName!.isNotEmpty ? destinationAccountName! : 'Pilih Akun', style: TextStyle( fontSize: 11, color: Colors.grey[800], ), overflow: TextOverflow.ellipsis, ), ), ], ), ), ), // Tombol Reset / Transaksi Baru if (hasItems) ...[ const SizedBox(width: 4), InkWell( onTap: onNewTransaction, borderRadius: BorderRadius.circular(4), child: Tooltip( message: 'Transaksi Baru (Bersihkan)', child: Padding( padding: const EdgeInsets.all(2.0), child: Icon( Icons.refresh, size: 16, color: Colors.red[400], ), ), ), ), ], ], ), const SizedBox(height: 4), const DottedLine(), ], ), ); } }