diff --git a/lib/configuration.dart b/lib/configuration.dart index ce64eca9c024ddaad6863358211ea3145e18ff38..482e404c30c6f908cb52fc9bc3d91f8754524815 100644 --- a/lib/configuration.dart +++ b/lib/configuration.dart @@ -26,7 +26,7 @@ class _MyHomePageState extends State<Configuration> { String _status = ''; TextStyle _statusStyle = const TextStyle(color: Colors.black); - Future<void> dumpToFile() async{ + Future<void> dumpToFile(BuildContext context) async{ var date = DateTime.now().toUtc(); var isoDate = date.toIso8601String(); @@ -53,10 +53,60 @@ class _MyHomePageState extends State<Configuration> { _statusStyle = const TextStyle(color: Colors.green); setState(() {}); HapticFeedback.vibrate(); + _showResultPopup(context, _status); } } + void _showResultPopup(BuildContext context, String text) async { + // Declaring and Initializing OverlayState + // and OverlayEntry objects + OverlayState? overlayState = Overlay.of(context); + OverlayEntry overlayEntry; + overlayEntry = OverlayEntry(builder: (context) { + + // You can return any widget you like + // here to be displayed on the Overlay + return Stack( + alignment: Alignment.center, + children: [ + Positioned( + // Position at 10% of height from bottom + bottom: MediaQuery.of(context).size.height * 0.1, + child: Material( + borderRadius: BorderRadius.circular(8.0), + color: Colors.blue, + child: Container( + padding: const EdgeInsets.all(5.0), // Space between Text and Bubble + width: MediaQuery.of(context).size.width * 0.95, + child: TextFormField( + minLines: 1, + maxLines: 5, + readOnly: true, + autofocus: false, + enabled: false, + //style: _statusStyle, + controller: TextEditingController( + text: _status, + ), + ), + ), + ), + ), + ], + ); + }); + + // Inserting the OverlayEntry into the Overlay + overlayState?.insert(overlayEntry); + + // Awaiting for 5 seconds + await Future.delayed(const Duration(seconds: 5)); + + // Removing the OverlayEntry from the Overlay + overlayEntry.remove(); + } + Future<void> updateConfiguration() async { final EventStoreInstance event = EventStoreInstance(); String token = ''; @@ -246,7 +296,7 @@ class _MyHomePageState extends State<Configuration> { icon: const Icon(Icons.download), label: const Text('Dump Events'), onPressed: () { - dumpToFile(); + dumpToFile(context); //Reset for debug testing only. //Remove in RELEASE Version: //database.delete();