import 'package:flutter/material.dart'; import 'package:spotiflac_android/l10n/l10n.dart'; /// Shared chrome for the multi-select bottom bar: rounded surface, drag /// handle, close button, "N selected" header and select-all toggle. /// The screen-specific action buttons go in [children]. class SelectionBottomBar extends StatelessWidget { const SelectionBottomBar({ super.key, required this.selectedCount, required this.allSelected, required this.onClose, required this.onToggleSelectAll, required this.bottomPadding, required this.children, this.allSelectedLabel, this.tapToSelectLabel, }); final int selectedCount; final bool allSelected; final VoidCallback onClose; final VoidCallback onToggleSelectAll; final double bottomPadding; final List children; /// Overrides the default "All tracks selected" subtitle. final String? allSelectedLabel; /// Overrides the default "Tap tracks to select" subtitle. final String? tapToSelectLabel; @override Widget build(BuildContext context) { final colorScheme = Theme.of(context).colorScheme; return Container( decoration: BoxDecoration( color: colorScheme.surfaceContainerHigh, borderRadius: const BorderRadius.vertical(top: Radius.circular(28)), boxShadow: [ BoxShadow( color: Colors.black.withValues(alpha: 0.15), blurRadius: 12, offset: const Offset(0, -4), ), ], ), child: SafeArea( top: false, child: Padding( padding: EdgeInsets.fromLTRB(16, 16, 16, bottomPadding > 0 ? 8 : 16), child: Column( mainAxisSize: MainAxisSize.min, children: [ Container( width: 32, height: 4, margin: const EdgeInsets.only(bottom: 16), decoration: BoxDecoration( color: colorScheme.outlineVariant, borderRadius: BorderRadius.circular(2), ), ), Row( children: [ IconButton.filledTonal( onPressed: onClose, tooltip: MaterialLocalizations.of( context, ).closeButtonTooltip, icon: const Icon(Icons.close), style: IconButton.styleFrom( backgroundColor: colorScheme.surfaceContainerHighest, ), ), const SizedBox(width: 12), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( context.l10n.selectionSelected(selectedCount), style: Theme.of(context).textTheme.titleMedium ?.copyWith(fontWeight: FontWeight.bold), ), Text( allSelected ? allSelectedLabel ?? context.l10n.selectionAllSelected : tapToSelectLabel ?? context.l10n.downloadedAlbumTapToSelect, style: Theme.of(context).textTheme.bodySmall ?.copyWith(color: colorScheme.onSurfaceVariant), ), ], ), ), TextButton.icon( onPressed: onToggleSelectAll, icon: Icon( allSelected ? Icons.deselect : Icons.select_all, size: 20, ), label: Text( allSelected ? context.l10n.actionDeselect : context.l10n.actionSelectAll, ), style: TextButton.styleFrom( foregroundColor: colorScheme.primary, ), ), ], ), const SizedBox(height: 12), ...children, ], ), ), ), ); } }