Skip to content

Commit

Permalink
Merge pull request #109 from atsign-foundation/feat/596
Browse files Browse the repository at this point in the history
Feat/596
  • Loading branch information
sarika01 authored May 9, 2022
2 parents 65cb2d4 + ef8481c commit 6d258cb
Showing 1 changed file with 93 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class _DesktopReceivedFilesListTileState
Uint8List? videoThumbnail, firstContactImage;
String? contactName;
List<bool> fileResending = [];
bool isResendingToFirstContact = false;
bool isResendingToFirstContact = false, showDownloadIndicator = false;

@override
void initState() {
Expand Down Expand Up @@ -90,6 +90,58 @@ class _DesktopReceivedFilesListTileState
return videoThumbnail;
}

checkIfDownloadAvailable() async {
bool isExpired = true;
var expiryDate = widget.receivedHistory!.date!.add(Duration(days: 6));
if (expiryDate.difference(DateTime.now()) > Duration(seconds: 0)) {
isExpired = false;
}

if (isExpired) {
if (mounted) {
setState(() {
showDownloadIndicator = false;
});
}
return;
}

widget.receivedHistory!.files!.forEach((element) async {
String path = MixedConstants.RECEIVED_FILE_DIRECTORY +
Platform.pathSeparator +
(widget.receivedHistory!.sender ?? '') +
Platform.pathSeparator +
(element.name ?? '');
File test = File(path);
bool fileExists = await test.exists();
if (fileExists == false) {
showDownloadIndicator = true;
} else {
showDownloadIndicator = false;
}
});

if (mounted) {
setState(() {});
}
}

@override
void didUpdateWidget(covariant DesktopReceivedFilesListTile oldWidget) {
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) async {
await checkIfDownloadAvailable();
});
super.didUpdateWidget(oldWidget);
}

@override
void didChangeDependencies() {
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) async {
await checkIfDownloadAvailable();
});
super.didChangeDependencies();
}

@override
Widget build(BuildContext context) {
double deviceTextFactor = MediaQuery.of(context).textScaleFactor;
Expand All @@ -102,32 +154,45 @@ class _DesktopReceivedFilesListTileState
: null,
child: ListTile(
leading: contactList.isNotEmpty
? firstContactImage != null
? CustomCircleAvatar(
byteImage: firstContactImage, nonAsset: true)
: isResendingToFirstContact
? TypingIndicator(
showIndicator: true,
flashingCircleBrightColor: ColorConstants.dullText,
flashingCircleDarkColor: ColorConstants.fadedText,
)
: Stack(
children: [
Container(
width: 50,
height: 50,
child: firstContactImage != null
? CustomCircleAvatar(
byteImage: firstContactImage,
nonAsset: true,
)
: ContactInitial(
initials: contactList[0],
size: 50,
),
),
],
)
? isResendingToFirstContact
? TypingIndicator(
showIndicator: true,
flashingCircleBrightColor: ColorConstants.dullText,
flashingCircleDarkColor: ColorConstants.fadedText,
)
: Stack(
children: [
Container(
width: 50,
height: 50,
child: firstContactImage != null
? CustomCircleAvatar(
byteImage: firstContactImage,
nonAsset: true)
: ContactInitial(
initials: contactList[0],
size: 50,
),
),
showDownloadIndicator
? Positioned(
right: 0,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
padding: EdgeInsets.all(1.toHeight),
child: CircleAvatar(
backgroundColor:
ColorConstants.orangeColor,
radius: 5.toWidth,
),
),
)
: SizedBox()
],
)
: SizedBox(),
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down Expand Up @@ -156,10 +221,7 @@ class _DesktopReceivedFilesListTileState
)),
],
),
SizedBox(height: 5.toHeight),
SizedBox(
height: 8.toHeight,
),
SizedBox(height: 13.toHeight),
Container(
child: Column(
children: [
Expand Down

0 comments on commit 6d258cb

Please sign in to comment.