Minor fixes for file download handling
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
import 'package:better_open_file/better_open_file.dart';
|
||||
import 'package:bubble/bubble.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:jiffy/jiffy.dart';
|
||||
import 'package:marianum_mobile/api/marianumcloud/talk/chat/getChatResponse.dart';
|
||||
import 'package:marianum_mobile/screen/pages/files/fileElement.dart';
|
||||
import 'package:marianum_mobile/screen/pages/talk/chatMessage.dart';
|
||||
|
||||
import '../../../api/marianumcloud/talk/room/getRoomResponse.dart';
|
||||
@ -43,6 +45,7 @@ class ChatBubble {
|
||||
bool isSender;
|
||||
GetChatResponseObject bubbleData;
|
||||
GetRoomResponseObject chatData;
|
||||
double downloadProgress = 0;
|
||||
late ChatMessage message;
|
||||
|
||||
ChatBubble({
|
||||
@ -109,11 +112,19 @@ class ChatBubble {
|
||||
child: Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: Text(
|
||||
Jiffy.unixFromSecondsSinceEpoch(bubbleData.timestamp).format("HH:mm"),
|
||||
textAlign: TextAlign.end,
|
||||
style: const TextStyle(color: Colors.grey, fontSize: 12),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Visibility(
|
||||
visible: downloadProgress > 0,
|
||||
child: LinearProgressIndicator(value: downloadProgress),
|
||||
),
|
||||
Text(
|
||||
Jiffy.unixFromSecondsSinceEpoch(bubbleData.timestamp).format("HH:mm"),
|
||||
textAlign: TextAlign.end,
|
||||
style: const TextStyle(color: Colors.grey, fontSize: 12),
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -135,10 +146,13 @@ class ChatBubble {
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.person),
|
||||
title: Text("Zu '${bubbleData.actorDisplayName}' wechseln"),
|
||||
onTap: () => {},
|
||||
Visibility(
|
||||
visible: !isSender && chatData.type != GetRoomResponseObjectConversationType.oneToOne,
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.person),
|
||||
title: Text("Private Nachricht an '${bubbleData.actorDisplayName}'"),
|
||||
onTap: () => {},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.bug_report_outlined),
|
||||
@ -149,10 +163,24 @@ class ChatBubble {
|
||||
);
|
||||
});
|
||||
},
|
||||
onTap: () {
|
||||
FileElement.download(message.file!.path!, message.file?.name ?? "Datei", (progress) => {
|
||||
downloadProgress = progress,
|
||||
}, (result) => {
|
||||
downloadProgress = 0,
|
||||
if(result.type != ResultType.done) {
|
||||
showDialog(context: context, builder: (context) {
|
||||
return AlertDialog(
|
||||
content: Text(result.message),
|
||||
);
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Size _textSize(String text, TextStyle style) {
|
||||
final TextPainter textPainter = TextPainter(
|
||||
text: TextSpan(text: text, style: style),
|
||||
|
@ -53,7 +53,7 @@ class ChatMessage {
|
||||
fadeInDuration: const Duration(seconds: 1),
|
||||
imageUrl: "https://cloud.marianum-fulda.de/core/preview?fileId=${file!.id}&x=100&y=-1&a=1",
|
||||
httpHeaders: {
|
||||
"Authorization": "Basic ${base64.encode(utf8.encode("${preferences.getString("username")}:${preferences.getString("password")}"))}"
|
||||
"Authorization": "Basic ${base64.encode(utf8.encode("${preferences.getString("username")}:${preferences.getString("password")}"))}" // TODO move authentication
|
||||
},
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user