fix: Minor desktop fixes

This commit is contained in:
Christian Pauly 2021-01-20 20:27:09 +01:00
parent bb537141d7
commit c224993548
5 changed files with 21 additions and 7 deletions

View File

@ -12,19 +12,21 @@ class Avatar extends StatelessWidget {
final double size; final double size;
final Function onTap; final Function onTap;
static const double defaultSize = 44; static const double defaultSize = 44;
final Client client;
const Avatar( const Avatar(
this.mxContent, this.mxContent,
this.name, { this.name, {
this.size = defaultSize, this.size = defaultSize,
this.onTap, this.onTap,
this.client,
Key key, Key key,
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var thumbnail = mxContent?.getThumbnail( var thumbnail = mxContent?.getThumbnail(
Matrix.of(context).client, client ?? Matrix.of(context).client,
width: size * MediaQuery.of(context).devicePixelRatio, width: size * MediaQuery.of(context).devicePixelRatio,
height: size * MediaQuery.of(context).devicePixelRatio, height: size * MediaQuery.of(context).devicePixelRatio,
); );

View File

@ -11,12 +11,14 @@ class ContentBanner extends StatelessWidget {
final IconData defaultIcon; final IconData defaultIcon;
final bool loading; final bool loading;
final Function onEdit; final Function onEdit;
final Client client;
const ContentBanner(this.mxContent, const ContentBanner(this.mxContent,
{this.height = 400, {this.height = 400,
this.defaultIcon = Icons.people_outline, this.defaultIcon = Icons.people_outline,
this.loading = false, this.loading = false,
this.onEdit, this.onEdit,
this.client,
Key key}) Key key})
: super(key: key); : super(key: key);
@ -26,7 +28,7 @@ class ContentBanner extends StatelessWidget {
final bannerSize = final bannerSize =
(mediaQuery.size.width * mediaQuery.devicePixelRatio).toInt(); (mediaQuery.size.width * mediaQuery.devicePixelRatio).toInt();
final src = mxContent?.getThumbnail( final src = mxContent?.getThumbnail(
Matrix.of(context).client, client ?? Matrix.of(context).client,
width: bannerSize, width: bannerSize,
height: bannerSize, height: bannerSize,
method: ThumbnailMethod.scale, method: ThumbnailMethod.scale,

View File

@ -4,6 +4,7 @@ import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter_typeahead/flutter_typeahead.dart'; import 'package:flutter_typeahead/flutter_typeahead.dart';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'avatar.dart'; import 'avatar.dart';
import 'matrix.dart';
class InputBar extends StatelessWidget { class InputBar extends StatelessWidget {
final Room room; final Room room;
@ -138,7 +139,11 @@ class InputBar extends StatelessWidget {
return ret; return ret;
} }
Widget buildSuggestion(BuildContext context, Map<String, String> suggestion) { Widget buildSuggestion(
BuildContext context,
Map<String, String> suggestion,
Client client,
) {
if (suggestion['type'] == 'emote') { if (suggestion['type'] == 'emote') {
final size = 30.0; final size = 30.0;
final ratio = MediaQuery.of(context).devicePixelRatio; final ratio = MediaQuery.of(context).devicePixelRatio;
@ -182,8 +187,12 @@ class InputBar extends StatelessWidget {
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Avatar(url, suggestion['displayname'] ?? suggestion['mxid'], Avatar(
size: size), url,
suggestion['displayname'] ?? suggestion['mxid'],
size: size,
client: client,
),
SizedBox(width: 6), SizedBox(width: 6),
Text(suggestion['displayname'] ?? suggestion['mxid']), Text(suggestion['displayname'] ?? suggestion['mxid']),
], ],
@ -283,7 +292,7 @@ class InputBar extends StatelessWidget {
textCapitalization: TextCapitalization.sentences, textCapitalization: TextCapitalization.sentences,
), ),
suggestionsCallback: getSuggestions, suggestionsCallback: getSuggestions,
itemBuilder: buildSuggestion, itemBuilder: (c, s) => buildSuggestion(c, s, Matrix.of(context).client),
onSuggestionSelected: (Map<String, String> suggestion) => onSuggestionSelected: (Map<String, String> suggestion) =>
insertSuggestion(context, suggestion), insertSuggestion(context, suggestion),
errorBuilder: (BuildContext context, Object error) => Container(), errorBuilder: (BuildContext context, Object error) => Container(),

View File

@ -310,7 +310,7 @@ class MatrixState extends State<Matrix> {
final Set verificationMethods = <KeyVerificationMethod>{ final Set verificationMethods = <KeyVerificationMethod>{
KeyVerificationMethod.numbers KeyVerificationMethod.numbers
}; };
if (PlatformInfos.isMobile) { if (PlatformInfos.isMobile || (!kIsWeb && Platform.isLinux)) {
// emojis don't show in web somehow // emojis don't show in web somehow
verificationMethods.add(KeyVerificationMethod.emoji); verificationMethods.add(KeyVerificationMethod.emoji);
} }

View File

@ -208,6 +208,7 @@ class UserBottomSheet extends StatelessWidget {
child: ContentBanner( child: ContentBanner(
user.avatarUrl, user.avatarUrl,
defaultIcon: Icons.person_outline, defaultIcon: Icons.person_outline,
client: user.room.client,
), ),
), ),
ListTile( ListTile(