mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-28 07:19:32 +01:00
Merge branch 'krille/update-sdk' into 'master'
Update sdk See merge request ChristianPauly/fluffychat-flutter!32
This commit is contained in:
commit
ddf2eb3204
@ -7,7 +7,7 @@ import 'package:flutter_advanced_networkimage/provider.dart';
|
||||
import 'matrix.dart';
|
||||
|
||||
class Avatar extends StatelessWidget {
|
||||
final MxContent mxContent;
|
||||
final Uri mxContent;
|
||||
final String name;
|
||||
final double size;
|
||||
final Function onTap;
|
||||
@ -39,16 +39,16 @@ class Avatar extends StatelessWidget {
|
||||
onTap: onTap,
|
||||
child: CircleAvatar(
|
||||
radius: size / 2,
|
||||
backgroundImage: mxContent.mxc?.isNotEmpty ?? false
|
||||
backgroundImage: mxContent != null
|
||||
? AdvancedNetworkImage(
|
||||
src,
|
||||
useDiskCache: !kIsWeb,
|
||||
)
|
||||
: null,
|
||||
backgroundColor: mxContent.mxc.isEmpty
|
||||
backgroundColor: mxContent == null
|
||||
? name?.color ?? Theme.of(context).secondaryHeaderColor
|
||||
: Theme.of(context).secondaryHeaderColor,
|
||||
child: mxContent.mxc.isEmpty
|
||||
child: mxContent == null
|
||||
? Text(fallbackLetters, style: TextStyle(color: Colors.white))
|
||||
: null,
|
||||
),
|
||||
|
@ -6,7 +6,7 @@ import 'package:flutter_advanced_networkimage/provider.dart';
|
||||
import 'matrix.dart';
|
||||
|
||||
class ContentBanner extends StatelessWidget {
|
||||
final MxContent mxContent;
|
||||
final Uri mxContent;
|
||||
final double height;
|
||||
final IconData defaultIcon;
|
||||
final bool loading;
|
||||
@ -25,7 +25,7 @@ class ContentBanner extends StatelessWidget {
|
||||
final mediaQuery = MediaQuery.of(context);
|
||||
final int bannerSize =
|
||||
(mediaQuery.size.width * mediaQuery.devicePixelRatio).toInt();
|
||||
final String src = mxContent.getThumbnail(
|
||||
final String src = mxContent?.getThumbnail(
|
||||
Matrix.of(context).client,
|
||||
width: bannerSize,
|
||||
height: bannerSize,
|
||||
@ -47,7 +47,7 @@ class ContentBanner extends StatelessWidget {
|
||||
child: Opacity(
|
||||
opacity: 0.75,
|
||||
child: !loading
|
||||
? mxContent.mxc?.isNotEmpty ?? false
|
||||
? mxContent != null
|
||||
? Image(
|
||||
height: 300,
|
||||
fit: BoxFit.cover,
|
||||
|
@ -3,6 +3,8 @@ import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluffychat/utils/matrix_file_extension.dart';
|
||||
|
||||
import 'dialogs/simple_dialogs.dart';
|
||||
|
||||
class ImageBubble extends StatefulWidget {
|
||||
final Event event;
|
||||
|
||||
@ -23,7 +25,7 @@ class _ImageBubbleState extends State<ImageBubble> {
|
||||
|
||||
Future<MatrixFile> _getFile() async {
|
||||
if (_file != null) return _file;
|
||||
return widget.event.downloadAndDecryptAttachment();
|
||||
return widget.event.downloadAndDecryptAttachment(getThumbnail: true);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -47,7 +49,13 @@ class _ImageBubbleState extends State<ImageBubble> {
|
||||
}
|
||||
if (_file != null) {
|
||||
return InkWell(
|
||||
onTap: () => _file.open(),
|
||||
onTap: () async {
|
||||
final MatrixFile matrixFile =
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
widget.event.downloadAndDecryptAttachment(),
|
||||
);
|
||||
matrixFile.open();
|
||||
},
|
||||
child: Image.memory(
|
||||
_file.bytes,
|
||||
fit: BoxFit.cover,
|
||||
|
@ -19,7 +19,7 @@ class PresenceListItem extends StatelessWidget {
|
||||
return FutureBuilder<Profile>(
|
||||
future: Matrix.of(context).client.getProfileFromUserId(presence.sender),
|
||||
builder: (context, snapshot) {
|
||||
MxContent avatarUrl = MxContent('');
|
||||
Uri avatarUrl;
|
||||
String displayname = presence.sender.localpart;
|
||||
if (snapshot.hasData) {
|
||||
avatarUrl = snapshot.data.avatarUrl;
|
||||
|
@ -30,8 +30,11 @@ class PublicRoomListItem extends StatelessWidget {
|
||||
final bool hasTopic =
|
||||
publicRoomEntry.topic != null && publicRoomEntry.topic.isNotEmpty;
|
||||
return ListTile(
|
||||
leading:
|
||||
Avatar(MxContent(publicRoomEntry.avatarUrl), publicRoomEntry.name),
|
||||
leading: Avatar(
|
||||
publicRoomEntry.avatarUrl == null
|
||||
? null
|
||||
: Uri.parse(publicRoomEntry.avatarUrl),
|
||||
publicRoomEntry.name),
|
||||
title: Text(hasTopic
|
||||
? "${publicRoomEntry.name} (${publicRoomEntry.numJoinedMembers})"
|
||||
: publicRoomEntry.name),
|
||||
|
@ -77,12 +77,13 @@ class MatrixState extends State<Matrix> {
|
||||
await storage.deleteItem(widget.clientName);
|
||||
}
|
||||
|
||||
Future<String> downloadAndSaveContent(MxContent content,
|
||||
Future<String> downloadAndSaveContent(Uri content,
|
||||
{int width, int height, ThumbnailMethod method}) async {
|
||||
final bool thumbnail = width == null && height == null ? false : true;
|
||||
final String tempDirectory = (await getTemporaryDirectory()).path;
|
||||
final String prefix = thumbnail ? "thumbnail" : "";
|
||||
File file = File('$tempDirectory/${prefix}_${content.mxc.split("/").last}');
|
||||
File file =
|
||||
File('$tempDirectory/${prefix}_${content.toString().split("/").last}');
|
||||
|
||||
if (!file.existsSync()) {
|
||||
final url = thumbnail
|
||||
@ -214,7 +215,7 @@ class MatrixState extends State<Matrix> {
|
||||
// The person object for the android message style notification
|
||||
final person = Person(
|
||||
name: room.getLocalizedDisplayname(context),
|
||||
icon: room.avatar.mxc.isEmpty
|
||||
icon: room.avatar == null
|
||||
? null
|
||||
: await downloadAndSaveContent(
|
||||
room.avatar,
|
||||
|
@ -3,9 +3,7 @@ import 'package:fluffychat/components/audio_player.dart';
|
||||
import 'package:fluffychat/components/image_bubble.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:fluffychat/utils/event_extension.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||
import 'package:link_text/link_text.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:fluffychat/utils/matrix_file_extension.dart';
|
||||
@ -51,16 +49,6 @@ class MessageContent extends StatelessWidget {
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
onPressed: () async {
|
||||
if (kIsWeb) {
|
||||
if (event.room.encrypted) {
|
||||
showToast(I18n.of(context).notSupportedInWeb);
|
||||
}
|
||||
await launch(
|
||||
MxContent(event.content["url"])
|
||||
.getDownloadLink(event.room.client),
|
||||
);
|
||||
return;
|
||||
}
|
||||
final MatrixFile matrixFile =
|
||||
await SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(
|
||||
|
@ -623,4 +623,7 @@ class ExtendedStore extends Store implements ExtendedStoreAPI {
|
||||
'saved_at INTEGER, ' +
|
||||
'UNIQUE(mxc_uri))',
|
||||
};
|
||||
|
||||
@override
|
||||
int get maxFileSize => 1 * 1024 * 1024;
|
||||
}
|
||||
|
@ -159,7 +159,9 @@ class _InvitationSelectionState extends State<InvitationSelection> {
|
||||
itemCount: foundProfiles.length,
|
||||
itemBuilder: (BuildContext context, int i) => ListTile(
|
||||
leading: Avatar(
|
||||
MxContent(foundProfiles[i]["avatar_url"] ?? ""),
|
||||
foundProfiles[i]["avatar_url"] == null
|
||||
? null
|
||||
: Uri.parse(foundProfiles[i]["avatar_url"]),
|
||||
foundProfiles[i]["display_name"] ??
|
||||
foundProfiles[i]["user_id"],
|
||||
),
|
||||
|
@ -158,7 +158,9 @@ class _NewPrivateChatState extends State<_NewPrivateChat> {
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Avatar(
|
||||
MxContent(foundProfile["avatar_url"] ?? ""),
|
||||
foundProfile["avatar_url"] == null
|
||||
? null
|
||||
: Uri.parse(foundProfile["avatar_url"]),
|
||||
foundProfile["display_name"] ??
|
||||
foundProfile["user_id"],
|
||||
size: 12,
|
||||
@ -186,7 +188,9 @@ class _NewPrivateChatState extends State<_NewPrivateChat> {
|
||||
});
|
||||
},
|
||||
leading: Avatar(
|
||||
MxContent(foundProfile["avatar_url"] ?? ""),
|
||||
foundProfile["avatar_url"] == null
|
||||
? null
|
||||
: Uri.parse(foundProfile["avatar_url"]),
|
||||
foundProfile["display_name"] ?? foundProfile["user_id"],
|
||||
//size: 24,
|
||||
),
|
||||
|
@ -152,7 +152,7 @@ class _SettingsState extends State<Settings> {
|
||||
color: Theme.of(context).appBarTheme.textTheme.title.color),
|
||||
),
|
||||
background: ContentBanner(
|
||||
profile?.avatarUrl ?? MxContent(""),
|
||||
profile?.avatarUrl,
|
||||
height: 300,
|
||||
defaultIcon: Icons.account_circle,
|
||||
loading: profile == null,
|
||||
|
@ -117,8 +117,8 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: "28dee0e2e3dc2fdde64b29d0a65028b49b4c4dc7"
|
||||
resolved-ref: "28dee0e2e3dc2fdde64b29d0a65028b49b4c4dc7"
|
||||
ref: "1265ebf7da56440ead152bbf44502b941436dc1b"
|
||||
resolved-ref: "1265ebf7da56440ead152bbf44502b941436dc1b"
|
||||
url: "https://gitlab.com/famedly/famedlysdk.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
@ -27,7 +27,7 @@ dependencies:
|
||||
famedlysdk:
|
||||
git:
|
||||
url: https://gitlab.com/famedly/famedlysdk.git
|
||||
ref: 28dee0e2e3dc2fdde64b29d0a65028b49b4c4dc7
|
||||
ref: 1265ebf7da56440ead152bbf44502b941436dc1b
|
||||
|
||||
localstorage: ^3.0.1+4
|
||||
bubble: ^1.1.9+1
|
||||
|
Loading…
Reference in New Issue
Block a user