Further restructuring of chatBubble.dart, added chatMessage.dart
This commit is contained in:
@ -1,12 +1,8 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:marianum_mobile/api/marianumcloud/talk/chat/getChatResponse.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class RichObjectStringProcessor {
|
||||
static String parseTextPreview(String message, Map<String, RichObjectString>? data) {
|
||||
static String parseToString(String message, Map<String, RichObjectString>? data) {
|
||||
if(data == null) return message;
|
||||
|
||||
data.forEach((key, value) {
|
||||
@ -15,31 +11,4 @@ class RichObjectStringProcessor {
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
static Future<Widget> parseAnyToWidget(String message, Map<String, RichObjectString>? data) async {
|
||||
if(data == null) return SelectableText(message);
|
||||
if(!message.contains(RegExp("{file}"))) return Text(parseTextPreview(message, data));
|
||||
|
||||
SharedPreferences preferences = await SharedPreferences.getInstance();
|
||||
|
||||
Widget? back;
|
||||
data.forEach((key, value) {
|
||||
back = CachedNetworkImage(
|
||||
errorWidget: (context, url, error) {
|
||||
return Text("Datei: ${value.name}", style: const TextStyle(fontWeight: FontWeight.bold));
|
||||
},
|
||||
alignment: Alignment.center,
|
||||
placeholder: (context, url) {
|
||||
return const Padding(padding: EdgeInsets.all(10), child: CircularProgressIndicator());
|
||||
},
|
||||
fadeInDuration: const Duration(seconds: 1),
|
||||
imageUrl: "https://cloud.marianum-fulda.de/core/preview?fileId=${value.id}&x=100&y=-1&a=1",
|
||||
httpHeaders: {
|
||||
"Authorization": "Basic ${base64.encode(utf8.encode("${preferences.getString("username")}:${preferences.getString("password")}"))}"
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
return back ?? Text("NOPE");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user