From 5dbdd52d4cbbfbcdce99e6cd15441c104a32f0a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20M=C3=BCller?= Date: Sat, 6 May 2023 19:24:07 +0200 Subject: [PATCH] Added loading indicator while file picking --- .idea/libraries/Dart_Packages.xml | 16 +++++++++++++ lib/screen/pages/talk/chatTextfield.dart | 30 ++++++++++++++++++++++++ lib/screen/pages/talk/chatView.dart | 23 ++++++++++-------- pubspec.yaml | 1 + 4 files changed, 60 insertions(+), 10 deletions(-) diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml index ff98d4f..c584ba9 100644 --- a/.idea/libraries/Dart_Packages.xml +++ b/.idea/libraries/Dart_Packages.xml @@ -58,6 +58,13 @@ + + + + + + @@ -548,6 +555,13 @@ + + + + + + @@ -1093,6 +1107,7 @@ + @@ -1159,6 +1174,7 @@ + diff --git a/lib/screen/pages/talk/chatTextfield.dart b/lib/screen/pages/talk/chatTextfield.dart index 83b50f9..80820d1 100644 --- a/lib/screen/pages/talk/chatTextfield.dart +++ b/lib/screen/pages/talk/chatTextfield.dart @@ -1,6 +1,8 @@ import 'dart:developer'; +import 'dart:io'; import 'package:flutter/material.dart'; +import 'package:loader_overlay/loader_overlay.dart'; import 'package:marianum_mobile/widget/filePick.dart'; import 'package:provider/provider.dart'; @@ -19,6 +21,30 @@ class ChatTextfield extends StatefulWidget { class _ChatTextfieldState extends State { final TextEditingController _textBoxController = TextEditingController(); bool sending = false; + bool isLoading = false; + + void mediaUpload(String? path) { + if(path == null) { + context.loaderOverlay.hide(); + return; + } + + showDialog(context: context, builder: (context) { + return AlertDialog( + title: const Text("Datei senden"), + content: Image.file(File(path)), + actions: [ + TextButton(onPressed: () { + Navigator.of(context).pop(); + context.loaderOverlay.hide(); + }, child: const Text("Abbrechen")), + TextButton(onPressed: () { + context.loaderOverlay.hide(); + }, child: const Text("Senden")), + ], + ); + }); + } @override Widget build(BuildContext context) { @@ -42,8 +68,10 @@ class _ChatTextfieldState extends State { leading: const Icon(Icons.file_open), title: const Text("Aus Dateien auswählen"), onTap: () { + context.loaderOverlay.show(); FilePick.documentPick().then((value) { log(value ?? "?"); + mediaUpload(value); }); Navigator.of(context).pop(); }, @@ -52,8 +80,10 @@ class _ChatTextfieldState extends State { leading: const Icon(Icons.image), title: const Text("Aus Gallerie auswählen"), onTap: () { + context.loaderOverlay.show(); FilePick.galleryPick().then((value) { log(value?.path ?? "?"); + mediaUpload(value?.path); }); Navigator.of(context).pop(); }, diff --git a/lib/screen/pages/talk/chatView.dart b/lib/screen/pages/talk/chatView.dart index 905e044..b4203fc 100644 --- a/lib/screen/pages/talk/chatView.dart +++ b/lib/screen/pages/talk/chatView.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:jiffy/jiffy.dart'; +import 'package:loader_overlay/loader_overlay.dart'; import 'package:marianum_mobile/api/marianumcloud/talk/chat/getChatResponse.dart'; import 'package:marianum_mobile/api/marianumcloud/talk/room/getRoomResponse.dart'; import 'package:marianum_mobile/data/chatList/chatProps.dart'; @@ -92,17 +93,19 @@ class _ChatViewState extends State { colorFilter: ColorFilter.linearToSrgbGamma() ) ), - child: data.primaryLoading() ? const Center(child: CircularProgressIndicator()) : Column( - children: [ - Expanded( - child: ListView( - reverse: true, - controller: _listController, - children: messages.reversed.toList(), + child: LoaderOverlay( + child: data.primaryLoading() ? const Center(child: CircularProgressIndicator()) : Column( + children: [ + Expanded( + child: ListView( + reverse: true, + controller: _listController, + children: messages.reversed.toList(), + ), ), - ), - ChatTextfield(widget.room.token), - ], + ChatTextfield(widget.room.token), + ], + ), ) ), ); diff --git a/pubspec.yaml b/pubspec.yaml index 99cc9a0..763fc0b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -66,6 +66,7 @@ dependencies: badges: ^3.0.2 image_picker: ^0.8.7+4 file_picker: ^5.2.11 + loader_overlay: ^2.2.0 dependency_overrides: xml: ^6.2.2