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