Files
SpotiFLAC-Mobile/lib/widgets/destructive_selection_button.dart
T
zarzet 962e582acc chore(flutter): move to Flutter 3.50.0 and the material_ui packages
Flutter 3.50 deprecates its built-in Material and Cupertino libraries in
favour of the material_ui and cupertino_ui packages. The imports move
with the official fix (dart fix, migrate_design_widgets); the app's old
two-library theme bridge collapses into one Theme type.

- MaterialExpressiveScope keeps the complete host theme nearest its
  child. The reduced copy made for the expressive widgets now shares the
  app's Theme type and would hide component themes and extensions.
- LegacyThemeBrightness hands the brightness to the glass package, which
  still reads Flutter's built-in theme.
- appLocalizationsDelegates lists the material_ui localization delegates;
  the generated list still names the built-in ones.
- Tests: findByTooltip and pageBack replace the flutter_test helpers that
  only know the built-in widgets, and several tests that had gone stale
  against earlier app changes are repaired.
2026-11-15 23:33:29 +07:00

54 lines
1.6 KiB
Dart

import 'package:material_ui/material_ui.dart';
import 'package:mornye/l10n/l10n.dart';
import 'package:mornye/widgets/app_action_button.dart';
/// Full-width delete action for selection-mode bottom bars: destructive
/// (error) styling once at least one item is selected, disabled/neutral
/// otherwise.
class DestructiveSelectionButton extends StatelessWidget {
const DestructiveSelectionButton({
super.key,
required this.count,
required this.colorScheme,
required this.onPressed,
this.label,
});
final int count;
final ColorScheme colorScheme;
final VoidCallback onPressed;
/// Replaces the downloaded album delete label.
final String? label;
@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
child: AppActionButton(
isDestructive: true,
onPressed: count > 0 ? onPressed : null,
icon: const Icon(Icons.delete_outline),
label: Text(
label ??
(count > 0
? context.l10n.downloadedAlbumDeleteCount(count)
: context.l10n.downloadedAlbumSelectToDelete),
),
style: FilledButton.styleFrom(
backgroundColor: count > 0
? colorScheme.error
: colorScheme.surfaceContainerHighest,
foregroundColor: count > 0
? colorScheme.onError
: colorScheme.onSurfaceVariant,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
),
),
);
}
}