Big refactoring
This commit is contained in:
parent
d9d5ab2703
commit
af0696a4ac
11 changed files with 516 additions and 454 deletions
|
|
@ -167,7 +167,12 @@ class SimpleDialogs {
|
|||
children: <Widget>[
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(width: 16),
|
||||
Text(L10n.of(context).loadingPleaseWait),
|
||||
Expanded(
|
||||
child: Text(
|
||||
L10n.of(context).loadingPleaseWait,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/dialogs/presence_dialog.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/views/chat.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../utils/client_presence_extension.dart';
|
||||
import '../avatar.dart';
|
||||
import '../matrix.dart';
|
||||
|
||||
|
|
@ -10,50 +11,48 @@ class PresenceListItem extends StatelessWidget {
|
|||
|
||||
const PresenceListItem(this.presence);
|
||||
|
||||
static final Map<String, Profile> _presences = {};
|
||||
|
||||
Future<Profile> _requestProfile(BuildContext context) async {
|
||||
_presences[presence.senderId] ??=
|
||||
await Matrix.of(context).client.getProfileFromUserId(presence.senderId);
|
||||
return _presences[presence.senderId];
|
||||
void _startChatAction(BuildContext context, String userId) async {
|
||||
final roomId = await User(userId,
|
||||
room: Room(client: Matrix.of(context).client, id: ''))
|
||||
.startDirectChat();
|
||||
await Navigator.of(context).pushAndRemoveUntil(
|
||||
AppRoute.defaultRoute(
|
||||
context,
|
||||
ChatView(roomId),
|
||||
),
|
||||
(Route r) => r.isFirst);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<Profile>(
|
||||
future: _requestProfile(context),
|
||||
future:
|
||||
Matrix.of(context).client.requestProfileCached(presence.senderId),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) return Container();
|
||||
Uri avatarUrl;
|
||||
var displayname = presence.senderId.localpart;
|
||||
if (snapshot.hasData) {
|
||||
avatarUrl = snapshot.data.avatarUrl;
|
||||
displayname = snapshot.data.displayname;
|
||||
displayname =
|
||||
snapshot.data.displayname ?? presence.senderId.localpart;
|
||||
}
|
||||
return InkWell(
|
||||
onTap: () => showDialog(
|
||||
context: context,
|
||||
builder: (c) => PresenceDialog(
|
||||
presence,
|
||||
avatarUrl: avatarUrl,
|
||||
displayname: displayname,
|
||||
),
|
||||
child: Container(
|
||||
width: 80,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
SizedBox(height: 9),
|
||||
Avatar(avatarUrl, displayname),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(6.0),
|
||||
child: Text(
|
||||
displayname,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
onTap: () => _startChatAction(context, presence.senderId),
|
||||
child: Container(
|
||||
width: 80,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
SizedBox(height: 9),
|
||||
Avatar(avatarUrl, displayname),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(6.0),
|
||||
child: Text(
|
||||
displayname,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue