mirror of
https://github.com/dstark5/Openlib.git
synced 2025-07-15 04:46:31 +08:00
initial release
This commit is contained in:
101
lib/ui/components/file_buttons_widget.dart
Normal file
101
lib/ui/components/file_buttons_widget.dart
Normal file
@ -0,0 +1,101 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:openlib/ui/components/delete_dialog_widget.dart';
|
||||
import 'package:openlib/ui/epub_viewer.dart';
|
||||
import 'package:openlib/ui/pdf_viewer.dart';
|
||||
|
||||
class FileOpenAndDeleteButtons extends StatelessWidget {
|
||||
final String id;
|
||||
final String format;
|
||||
final Function onDelete;
|
||||
|
||||
const FileOpenAndDeleteButtons(
|
||||
{Key? key,
|
||||
required this.id,
|
||||
required this.format,
|
||||
required this.onDelete})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 21, bottom: 21),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.secondary,
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: Colors.white,
|
||||
)),
|
||||
onPressed: () => {
|
||||
if (format == 'pdf')
|
||||
{
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (BuildContext context) {
|
||||
return PdfView(
|
||||
fileName: '$id.$format',
|
||||
);
|
||||
}))
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (BuildContext context) {
|
||||
return EpubViewerWidget(
|
||||
fileName: '$id.$format',
|
||||
);
|
||||
}))
|
||||
}
|
||||
},
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.fromLTRB(17, 8, 17, 8),
|
||||
child: Text('Open'),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
TextButton(
|
||||
style: ButtonStyle(
|
||||
shape: MaterialStateProperty.all(
|
||||
RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(50.0),
|
||||
side: BorderSide(
|
||||
width: 3, color: Theme.of(context).colorScheme.secondary),
|
||||
),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return ShowDeleteDialog(
|
||||
id: id,
|
||||
format: format,
|
||||
onDelete: onDelete,
|
||||
);
|
||||
});
|
||||
},
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(5.3),
|
||||
child: Text(
|
||||
'Delete',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user