// Flutter imports: import 'package:flutter/material.dart'; // Package imports: import 'package:flutter_riverpod/flutter_riverpod.dart'; // Project imports: import 'package:openlib/state/state.dart' show FileName, deleteFileFromMyLib; import 'package:openlib/ui/components/snack_bar_widget.dart'; class ShowDeleteDialog extends ConsumerWidget { final String id; final String format; final Function onDelete; const ShowDeleteDialog( {super.key, required this.id, required this.format, required this.onDelete}); @override Widget build(BuildContext context, WidgetRef ref) { return Stack( alignment: Alignment.center, children: [ Padding( padding: const EdgeInsets.all(15.0), child: Container( width: double.infinity, height: 219, decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), color: Theme.of(context).colorScheme.tertiaryContainer, ), padding: const EdgeInsets.fromLTRB(20, 50, 20, 20), child: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.all(8), child: Text( "Delete Book", style: TextStyle( fontSize: 19, fontWeight: FontWeight.bold, color: Theme.of(context).colorScheme.tertiary, decoration: TextDecoration.none), ), ), Padding( padding: const EdgeInsets.all(8), child: Text( "This is permanent and cannot be undone", style: TextStyle( fontSize: 13, fontWeight: FontWeight.bold, color: Theme.of(context) .colorScheme .tertiary .withAlpha(170), decoration: TextDecoration.none), overflow: TextOverflow.ellipsis, maxLines: 2, textAlign: TextAlign.start, ), ), Padding( padding: const EdgeInsets.all(10.0), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ TextButton( style: ButtonStyle( shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(50.0), side: BorderSide( width: 3, color: Theme.of(context) .colorScheme .secondary), ), ), ), onPressed: () { ref.read(deleteFileFromMyLib( FileName(md5: id, format: format))); Navigator.of(context).pop(); showSnackBar( context: context, message: 'Book has been Deleted!'); onDelete(); }, child: Padding( padding: const EdgeInsets.all(5.0), child: Text( 'Delete', style: TextStyle( fontSize: 11, fontWeight: FontWeight.bold, color: Theme.of(context).colorScheme.tertiary, ), ), ), ), const SizedBox( width: 10, ), TextButton( style: TextButton.styleFrom( backgroundColor: Theme.of(context).colorScheme.secondary, textStyle: const TextStyle( fontSize: 11, fontWeight: FontWeight.w900, color: Colors.white, )), onPressed: () { Navigator.of(context).pop(); }, child: const Padding( padding: EdgeInsets.all(5.0), child: Text('Cancel'), ), ) ], ), ) ], ), ), ), ), ], ); } }