[UI-Kit] Pop attachment download dialog in case of any error.
Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
@@ -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,38 +232,46 @@ class AttachmentActionsModal extends StatelessWidget {
|
|||||||
color: theme.colorTheme.white,
|
color: theme.colorTheme.white,
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: downloadComplete
|
child: progress == null
|
||||||
? Container(
|
? Container(
|
||||||
height: 160,
|
height: 100,
|
||||||
width: 160,
|
width: 100,
|
||||||
child: StreamSvgIcon.check(
|
child: StreamSvgIcon.error(
|
||||||
color: theme.colorTheme.greyGainsboro,
|
color: theme.colorTheme.greyGainsboro,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Container(
|
: progress.toProgressIndicatorValue == 1.0
|
||||||
height: 100,
|
? Container(
|
||||||
width: 100,
|
height: 160,
|
||||||
child: Stack(
|
width: 160,
|
||||||
fit: StackFit.expand,
|
child: StreamSvgIcon.check(
|
||||||
children: [
|
color: theme.colorTheme.greyGainsboro,
|
||||||
CircularProgressIndicator(
|
|
||||||
value: value,
|
|
||||||
strokeWidth: 8.0,
|
|
||||||
valueColor: AlwaysStoppedAnimation(
|
|
||||||
theme.colorTheme.accentBlue,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Center(
|
)
|
||||||
child: Text(
|
: Container(
|
||||||
'${progress.toPercentage}%',
|
height: 100,
|
||||||
style: theme.textTheme.headline.copyWith(
|
width: 100,
|
||||||
color: theme.colorTheme.grey,
|
child: Stack(
|
||||||
|
fit: StackFit.expand,
|
||||||
|
children: [
|
||||||
|
CircularProgressIndicator(
|
||||||
|
value: progress.toProgressIndicatorValue,
|
||||||
|
strokeWidth: 8.0,
|
||||||
|
valueColor: AlwaysStoppedAnimation(
|
||||||
|
theme.colorTheme.accentBlue,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Center(
|
||||||
|
child: Text(
|
||||||
|
'${progress.toPercentage}%',
|
||||||
|
style: theme.textTheme.headline.copyWith(
|
||||||
|
color: theme.colorTheme.grey,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user