Skip to content

Commit

Permalink
TW-1702: handle download error on file tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Te-Z committed Jul 9, 2024
1 parent b9c3544 commit b95f8f2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class ChatDetailsFilesView extends StatelessWidget {
return ValueListenableBuilder(
valueListenable: controller.downloadFileStateNotifier,
builder: (context, DownloadPresentationState state, child) {
if (state is DownloadingPresentationState) {
if (state is DownloadingPresentationState ||
state is DownloadErrorPresentationState) {
return ChatDetailsDownloadingFileTile(
mimeType: controller.event.mimeType,
fileType: filetype,
Expand All @@ -37,6 +38,7 @@ class ChatDetailsFilesView extends StatelessWidget {
controller.downloadManager
.cancelDownload(controller.event.eventId);
},
hasError: state is DownloadErrorPresentationState,
);
} else if (state is DownloadedPresentationState) {
return ChatDetailsDownloadedFileTile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class ChatDetailsFilesViewWeb extends StatelessWidget {
return ValueListenableBuilder(
valueListenable: controller.downloadFileStateNotifier,
builder: (context, DownloadPresentationState state, child) {
if (state is DownloadingPresentationState) {
if (state is DownloadingPresentationState ||
state is DownloadErrorPresentationState) {
return ChatDetailsFileTileRowDownloadingWeb(
mimeType: controller.event.mimeType,
fileType: filetype,
Expand All @@ -36,6 +37,7 @@ class ChatDetailsFilesViewWeb extends StatelessWidget {
controller.downloadManager
.cancelDownload(controller.event.eventId);
},
hasError: state is DownloadErrorPresentationState,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ChatDetailsDownloadingFileTile extends StatelessWidget {
required this.fileType,
required this.sizeString,
required this.downloadFileStateNotifier,
this.hasError = false,
});

final GestureTapCallback onTap;
Expand All @@ -22,13 +23,15 @@ class ChatDetailsDownloadingFileTile extends StatelessWidget {
final String? fileType;
final String? sizeString;
final ValueNotifier<DownloadPresentationState> downloadFileStateNotifier;
final bool hasError;

@override
Widget build(BuildContext context) {
return InkWell(
hoverColor: LinagoraSysColors.material().surfaceVariant,
onTap: onTap,
child: ChatDetailsFileRowDownloadingWrapper(
hasError: hasError,
mimeType: mimeType,
fileType: fileType,
downloadFileStateNotifier: downloadFileStateNotifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ChatDetailsFileTileRowDownloadingWeb extends StatelessWidget {
required this.sizeString,
required this.onTap,
required this.downloadFileStateNotifier,
this.hasError = false,
});

final GestureTapCallback onTap;
Expand All @@ -26,13 +27,15 @@ class ChatDetailsFileTileRowDownloadingWeb extends StatelessWidget {
final String? fileType;
final DateTime sentDate;
final ValueNotifier<DownloadPresentationState> downloadFileStateNotifier;
final bool hasError;

@override
Widget build(BuildContext context) {
return InkWell(
hoverColor: LinagoraSysColors.material().surfaceVariant,
onTap: onTap,
child: ChatDetailsFileRowDownloadingWrapper(
hasError: hasError,
mimeType: mimeType,
fileType: fileType,
downloadFileStateNotifier: downloadFileStateNotifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ class ChatDetailsFileRowDownloadingWrapper extends StatelessWidget {
final String? mimeType;
final String? fileType;
final ValueNotifier<DownloadPresentationState> downloadFileStateNotifier;
final bool hasError;

const ChatDetailsFileRowDownloadingWrapper({
super.key,
required this.child,
required this.mimeType,
required this.fileType,
required this.downloadFileStateNotifier,
this.hasError = false,
});

final style = const MessageFileTileStyle();
Expand Down Expand Up @@ -50,11 +52,14 @@ class ChatDetailsFileRowDownloadingWrapper extends StatelessWidget {
width: style.iconSize,
height: style.iconSize,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary,
color: style.iconBackgroundColor(
hasError: hasError,
context: context,
),
shape: BoxShape.circle,
),
),
if (downloadProgress != 0)
if (downloadProgress != 0 && !hasError)
SizedBox(
width: style.circularProgressLoadingSize,
height: style.circularProgressLoadingSize,
Expand All @@ -66,11 +71,18 @@ class ChatDetailsFileRowDownloadingWrapper extends StatelessWidget {
Container(
width: style.downloadIconSize,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary,
color: style.iconBackgroundColor(
hasError: hasError,
context: context,
),
shape: BoxShape.circle,
),
child: Icon(
downloadProgress == 0 ? Icons.arrow_downward : Icons.close,
hasError
? Icons.error_outline
: downloadProgress == 0
? Icons.arrow_downward
: Icons.close,
key: ValueKey(downloadProgress),
color: Theme.of(context).colorScheme.surface,
size: style.downloadIconSize,
Expand Down

0 comments on commit b95f8f2

Please sign in to comment.