fix download image
This commit is contained in:
@@ -120,7 +120,7 @@ class AttachmentActionsModal extends StatelessWidget {
|
|||||||
received,
|
received,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
).catchError((_) {
|
).catchError((e, stk) {
|
||||||
progressNotifier.value = null;
|
progressNotifier.value = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -225,76 +225,73 @@ class AttachmentActionsModal extends StatelessWidget {
|
|||||||
ValueNotifier<_DownloadProgress?> progressNotifier,
|
ValueNotifier<_DownloadProgress?> progressNotifier,
|
||||||
) {
|
) {
|
||||||
final theme = StreamChatTheme.of(context);
|
final theme = StreamChatTheme.of(context);
|
||||||
return WillPopScope(
|
return ValueListenableBuilder(
|
||||||
onWillPop: () => Future.value(false),
|
valueListenable: progressNotifier,
|
||||||
child: ValueListenableBuilder(
|
builder: (_, _DownloadProgress? progress, __) {
|
||||||
valueListenable: progressNotifier,
|
// Pop the dialog in case the progress is null or it's completed.
|
||||||
builder: (_, _DownloadProgress? progress, __) {
|
if (progress == null || progress.toProgressIndicatorValue == 1.0) {
|
||||||
// Pop the dialog in case the progress is null or it's completed.
|
Future.delayed(
|
||||||
if (progress == null || progress.toProgressIndicatorValue == 1.0) {
|
const Duration(milliseconds: 500),
|
||||||
Future.delayed(
|
() => Navigator.of(context).maybePop(),
|
||||||
const Duration(milliseconds: 500),
|
);
|
||||||
Navigator.of(context).maybePop,
|
}
|
||||||
);
|
return Material(
|
||||||
}
|
type: MaterialType.transparency,
|
||||||
return Material(
|
child: Center(
|
||||||
type: MaterialType.transparency,
|
child: Container(
|
||||||
child: Center(
|
height: 182,
|
||||||
child: Container(
|
width: 182,
|
||||||
height: 182,
|
decoration: BoxDecoration(
|
||||||
width: 182,
|
borderRadius: BorderRadius.circular(16),
|
||||||
decoration: BoxDecoration(
|
color: theme.colorTheme.white,
|
||||||
borderRadius: BorderRadius.circular(16),
|
),
|
||||||
color: theme.colorTheme.white,
|
child: Center(
|
||||||
),
|
child: progress == null
|
||||||
child: Center(
|
? Container(
|
||||||
child: progress == null
|
height: 100,
|
||||||
? Container(
|
width: 100,
|
||||||
height: 100,
|
child: StreamSvgIcon.error(
|
||||||
width: 100,
|
color: theme.colorTheme.greyGainsboro,
|
||||||
child: StreamSvgIcon.error(
|
),
|
||||||
color: theme.colorTheme.greyGainsboro,
|
)
|
||||||
),
|
: progress.toProgressIndicatorValue == 1.0
|
||||||
)
|
? Container(
|
||||||
: progress.toProgressIndicatorValue == 1.0
|
key: Key('completedIcon'),
|
||||||
? Container(
|
height: 160,
|
||||||
key: Key('completedIcon'),
|
width: 160,
|
||||||
height: 160,
|
child: StreamSvgIcon.check(
|
||||||
width: 160,
|
color: theme.colorTheme.greyGainsboro,
|
||||||
child: StreamSvgIcon.check(
|
|
||||||
color: theme.colorTheme.greyGainsboro,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Container(
|
|
||||||
height: 100,
|
|
||||||
width: 100,
|
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
|
: Container(
|
||||||
|
height: 100,
|
||||||
|
width: 100,
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
);
|
||||||
),
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +307,7 @@ class AttachmentActionsModal extends StatelessWidget {
|
|||||||
final contentType = responseHeaders[Headers.contentTypeHeader]!;
|
final contentType = responseHeaders[Headers.contentTypeHeader]!;
|
||||||
final mimeType = contentType.first.split('/').last;
|
final mimeType = contentType.first.split('/').last;
|
||||||
filePath ??= '${appDocDir.path}/${attachment.id}.$mimeType';
|
filePath ??= '${appDocDir.path}/${attachment.id}.$mimeType';
|
||||||
return filePath;
|
return filePath!;
|
||||||
},
|
},
|
||||||
onReceiveProgress: progressCallback,
|
onReceiveProgress: progressCallback,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user