|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | + |
| 3 | +/// Shows toast once after the selected text is copied to the Clipboard. |
| 4 | +Widget showToast(bool canShowToast, Alignment alignment, String toastText) { |
| 5 | + return Visibility( |
| 6 | + visible: canShowToast, |
| 7 | + child: Positioned.fill( |
| 8 | + bottom: 25.0, |
| 9 | + child: Align( |
| 10 | + alignment: alignment, |
| 11 | + child: Flex( |
| 12 | + direction: Axis.horizontal, |
| 13 | + mainAxisAlignment: MainAxisAlignment.center, |
| 14 | + children: <Widget>[ |
| 15 | + Container( |
| 16 | + padding: const EdgeInsets.only( |
| 17 | + left: 16, top: 6, right: 16, bottom: 6), |
| 18 | + decoration: BoxDecoration( |
| 19 | + color: Colors.grey[600], |
| 20 | + borderRadius: const BorderRadius.all( |
| 21 | + Radius.circular(16.0), |
| 22 | + ), |
| 23 | + ), |
| 24 | + child: Text( |
| 25 | + toastText, |
| 26 | + textAlign: TextAlign.center, |
| 27 | + style: const TextStyle( |
| 28 | + fontFamily: 'Roboto', fontSize: 16, color: Colors.white), |
| 29 | + ), |
| 30 | + ), |
| 31 | + ], |
| 32 | + ), |
| 33 | + ), |
| 34 | + )); |
| 35 | +} |
| 36 | + |
| 37 | +/// Displays the error message |
| 38 | +void showErrorDialog(BuildContext context, String error, String description) { |
| 39 | + showDialog<dynamic>( |
| 40 | + context: context, |
| 41 | + builder: (BuildContext context) { |
| 42 | + return AlertDialog( |
| 43 | + insetPadding: const EdgeInsets.all(0), |
| 44 | + title: Row( |
| 45 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 46 | + children: <Widget>[ |
| 47 | + Text(error), |
| 48 | + Container( |
| 49 | + height: 36, // height of close search menu button |
| 50 | + width: 36, // width of close search menu button |
| 51 | + child: RawMaterialButton( |
| 52 | + onPressed: () { |
| 53 | + Navigator.of(context).pop(); |
| 54 | + }, |
| 55 | + child: const Icon( |
| 56 | + Icons.clear, |
| 57 | + size: 20, |
| 58 | + ), |
| 59 | + ), |
| 60 | + ), |
| 61 | + ], |
| 62 | + ), |
| 63 | + content: Container(width: 328.0, child: Text(description)), |
| 64 | + actions: <Widget>[ |
| 65 | + TextButton( |
| 66 | + onPressed: () { |
| 67 | + Navigator.of(context, rootNavigator: true).pop(); |
| 68 | + }, |
| 69 | + child: const Text('OK'), |
| 70 | + ) |
| 71 | + ], |
| 72 | + actionsPadding: const EdgeInsets.only(bottom: 10), |
| 73 | + ); |
| 74 | + }, |
| 75 | + ); |
| 76 | +} |
| 77 | + |
| 78 | +/// Represents PDF document. |
| 79 | +class Document { |
| 80 | + /// Constructs Document instance. |
| 81 | + Document(this.name, this.path); |
| 82 | + |
| 83 | + /// Name of the PDF document. |
| 84 | + final String name; |
| 85 | + |
| 86 | + /// Path of the PDF document. |
| 87 | + final String path; |
| 88 | +} |
0 commit comments