[UI-Kit] Pop attachment download dialog in case of any error.

Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
Sahil Kumar
2021-03-02 15:22:09 +05:30
parent d2e270e356
commit 35d0ca4baf
@@ -109,7 +109,9 @@ class AttachmentActionsModal extends StatelessWidget {
received, received,
); );
}, },
); ).catchError((_) {
progressNotifier.value = null;
});
// Closing attachment actions modal before opening // Closing attachment actions modal before opening
// attachment download dialog // attachment download dialog
@@ -212,9 +214,8 @@ class AttachmentActionsModal extends StatelessWidget {
child: ValueListenableBuilder( child: ValueListenableBuilder(
valueListenable: progressNotifier, valueListenable: progressNotifier,
builder: (_, _DownloadProgress progress, __) { builder: (_, _DownloadProgress progress, __) {
final value = progress.toProgressIndicatorValue; // Pop the dialog in case the progress is null or it's completed.
final downloadComplete = value == 1.0; if (progress == null || progress?.toProgressIndicatorValue == 1.0) {
if (value == 1.0) {
Future.delayed( Future.delayed(
const Duration(milliseconds: 500), const Duration(milliseconds: 500),
Navigator.of(context).pop, Navigator.of(context).pop,
@@ -231,7 +232,15 @@ class AttachmentActionsModal extends StatelessWidget {
color: theme.colorTheme.white, color: theme.colorTheme.white,
), ),
child: Center( child: Center(
child: downloadComplete child: progress == null
? Container(
height: 100,
width: 100,
child: StreamSvgIcon.error(
color: theme.colorTheme.greyGainsboro,
),
)
: progress.toProgressIndicatorValue == 1.0
? Container( ? Container(
height: 160, height: 160,
width: 160, width: 160,
@@ -246,7 +255,7 @@ class AttachmentActionsModal extends StatelessWidget {
fit: StackFit.expand, fit: StackFit.expand,
children: [ children: [
CircularProgressIndicator( CircularProgressIndicator(
value: value, value: progress.toProgressIndicatorValue,
strokeWidth: 8.0, strokeWidth: 8.0,
valueColor: AlwaysStoppedAnimation( valueColor: AlwaysStoppedAnimation(
theme.colorTheme.accentBlue, theme.colorTheme.accentBlue,