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,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,18 @@ import 'package:famedlysdk/famedlysdk.dart';
|
|||
extension ClientPresenceExtension on Client {
|
||||
List<Presence> get statusList {
|
||||
final statusList = presences.values.toList().reversed.toList();
|
||||
statusList.removeWhere((p) => p.presence.statusMsg?.isEmpty ?? true);
|
||||
final directRooms = rooms.where((r) => r.isDirectChat).toList();
|
||||
statusList.removeWhere((p) =>
|
||||
directRooms.indexWhere((r) => r.directChatMatrixID == p.senderId) ==
|
||||
-1);
|
||||
statusList.reversed.toList();
|
||||
return statusList;
|
||||
}
|
||||
|
||||
static final Map<String, Profile> presencesCache = {};
|
||||
|
||||
Future<Profile> requestProfileCached(String senderId) async {
|
||||
presencesCache[senderId] ??= await getProfileFromUserId(senderId);
|
||||
return presencesCache[senderId];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -358,7 +358,9 @@ class _ChatState extends State<_Chat> {
|
|||
}
|
||||
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Theme.of(context).appBarTheme.color.withOpacity(0.9),
|
||||
leading: selectMode
|
||||
? IconButton(
|
||||
icon: Icon(Icons.close),
|
||||
|
|
@ -462,337 +464,328 @@ class _ChatState extends State<_Chat> {
|
|||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
SafeArea(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
if (_loadingHistory) LinearProgressIndicator(),
|
||||
Expanded(
|
||||
child: FutureBuilder<bool>(
|
||||
future: getTimeline(),
|
||||
builder: (BuildContext context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
Column(
|
||||
children: <Widget>[
|
||||
if (_loadingHistory) LinearProgressIndicator(),
|
||||
Expanded(
|
||||
child: FutureBuilder<bool>(
|
||||
future: getTimeline(),
|
||||
builder: (BuildContext context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
if (room.notificationCount != null &&
|
||||
room.notificationCount > 0 &&
|
||||
timeline != null &&
|
||||
timeline.events.isNotEmpty) {
|
||||
room.sendReadReceipt(timeline.events.first.eventId);
|
||||
}
|
||||
if (room.notificationCount != null &&
|
||||
room.notificationCount > 0 &&
|
||||
timeline != null &&
|
||||
timeline.events.isNotEmpty) {
|
||||
room.sendReadReceipt(timeline.events.first.eventId);
|
||||
}
|
||||
|
||||
if (timeline.events.isEmpty) return Container();
|
||||
if (timeline.events.isEmpty) return Container();
|
||||
|
||||
return ListView.builder(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: max(
|
||||
0,
|
||||
(MediaQuery.of(context).size.width -
|
||||
AdaptivePageLayout.defaultMinWidth *
|
||||
3.5) /
|
||||
2),
|
||||
),
|
||||
reverse: true,
|
||||
itemCount: timeline.events.length + 2,
|
||||
controller: _scrollController,
|
||||
itemBuilder: (BuildContext context, int i) {
|
||||
return i == timeline.events.length + 1
|
||||
? _canLoadMore && !_loadingHistory
|
||||
? FlatButton(
|
||||
child: Text(
|
||||
L10n.of(context).loadMore,
|
||||
style: TextStyle(
|
||||
color:
|
||||
Theme.of(context).primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration:
|
||||
TextDecoration.underline,
|
||||
),
|
||||
return ListView.builder(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: max(
|
||||
0,
|
||||
(MediaQuery.of(context).size.width -
|
||||
AdaptivePageLayout.defaultMinWidth *
|
||||
3.5) /
|
||||
2),
|
||||
),
|
||||
reverse: true,
|
||||
itemCount: timeline.events.length + 2,
|
||||
controller: _scrollController,
|
||||
itemBuilder: (BuildContext context, int i) {
|
||||
return i == timeline.events.length + 1
|
||||
? _canLoadMore && !_loadingHistory
|
||||
? FlatButton(
|
||||
child: Text(
|
||||
L10n.of(context).loadMore,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
onPressed: requestHistory,
|
||||
)
|
||||
: Container()
|
||||
: i == 0
|
||||
? AnimatedContainer(
|
||||
height: seenByText.isEmpty ? 0 : 24,
|
||||
duration: seenByText.isEmpty
|
||||
? Duration(milliseconds: 0)
|
||||
: Duration(milliseconds: 500),
|
||||
alignment:
|
||||
timeline.events.first.senderId ==
|
||||
client.userID
|
||||
? Alignment.topRight
|
||||
: Alignment.topLeft,
|
||||
child: Text(
|
||||
seenByText,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color:
|
||||
Theme.of(context).primaryColor,
|
||||
),
|
||||
),
|
||||
onPressed: requestHistory,
|
||||
)
|
||||
: Container()
|
||||
: i == 0
|
||||
? AnimatedContainer(
|
||||
height: seenByText.isEmpty ? 0 : 24,
|
||||
duration: seenByText.isEmpty
|
||||
? Duration(milliseconds: 0)
|
||||
: Duration(milliseconds: 500),
|
||||
alignment:
|
||||
timeline.events.first.senderId ==
|
||||
client.userID
|
||||
? Alignment.topRight
|
||||
: Alignment.topLeft,
|
||||
child: Text(
|
||||
seenByText,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
padding: EdgeInsets.only(
|
||||
left: 8,
|
||||
right: 8,
|
||||
bottom: 8,
|
||||
),
|
||||
)
|
||||
: Message(timeline.events[i - 1],
|
||||
onAvatarTab: (Event event) {
|
||||
sendController.text +=
|
||||
' ${event.senderId}';
|
||||
}, onSelect: (Event event) {
|
||||
if (!event.redacted) {
|
||||
if (selectedEvents.contains(event)) {
|
||||
setState(
|
||||
() =>
|
||||
selectedEvents.remove(event),
|
||||
);
|
||||
} else {
|
||||
setState(
|
||||
() => selectedEvents.add(event),
|
||||
);
|
||||
}
|
||||
selectedEvents.sort(
|
||||
(a, b) => a.originServerTs
|
||||
.compareTo(b.originServerTs),
|
||||
),
|
||||
padding: EdgeInsets.only(
|
||||
left: 8,
|
||||
right: 8,
|
||||
bottom: 8,
|
||||
),
|
||||
)
|
||||
: Message(timeline.events[i - 1],
|
||||
onAvatarTab: (Event event) {
|
||||
sendController.text +=
|
||||
' ${event.senderId}';
|
||||
}, onSelect: (Event event) {
|
||||
if (!event.redacted) {
|
||||
if (selectedEvents.contains(event)) {
|
||||
setState(
|
||||
() => selectedEvents.remove(event),
|
||||
);
|
||||
} else {
|
||||
setState(
|
||||
() => selectedEvents.add(event),
|
||||
);
|
||||
}
|
||||
},
|
||||
longPressSelect: selectedEvents.isEmpty,
|
||||
selected: selectedEvents
|
||||
.contains(timeline.events[i - 1]),
|
||||
timeline: timeline,
|
||||
nextEvent: i >= 2
|
||||
? timeline.events[i - 2]
|
||||
: null);
|
||||
});
|
||||
},
|
||||
),
|
||||
selectedEvents.sort(
|
||||
(a, b) => a.originServerTs
|
||||
.compareTo(b.originServerTs),
|
||||
);
|
||||
}
|
||||
},
|
||||
longPressSelect: selectedEvents.isEmpty,
|
||||
selected: selectedEvents
|
||||
.contains(timeline.events[i - 1]),
|
||||
timeline: timeline,
|
||||
nextEvent: i >= 2
|
||||
? timeline.events[i - 2]
|
||||
: null);
|
||||
});
|
||||
},
|
||||
),
|
||||
AnimatedContainer(
|
||||
duration: Duration(milliseconds: 300),
|
||||
height: replyEvent != null ? 56 : 0,
|
||||
child: Material(
|
||||
color: Theme.of(context).secondaryHeaderColor,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(Icons.close),
|
||||
onPressed: () => setState(() => replyEvent = null),
|
||||
),
|
||||
Expanded(
|
||||
child: ReplyContent(replyEvent),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
height: 1,
|
||||
),
|
||||
AnimatedContainer(
|
||||
duration: Duration(milliseconds: 300),
|
||||
height: replyEvent != null ? 56 : 0,
|
||||
child: Material(
|
||||
color: Theme.of(context).secondaryHeaderColor,
|
||||
thickness: 1,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(Icons.close),
|
||||
onPressed: () => setState(() => replyEvent = null),
|
||||
),
|
||||
Expanded(
|
||||
child: ReplyContent(replyEvent),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
room.canSendDefaultMessages &&
|
||||
room.membership == Membership.join
|
||||
? Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.backgroundColor
|
||||
.withOpacity(0.8),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: selectMode
|
||||
? <Widget>[
|
||||
Container(
|
||||
height: 56,
|
||||
child: FlatButton(
|
||||
onPressed: () =>
|
||||
forwardEventsAction(context),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Icon(Icons.keyboard_arrow_left),
|
||||
Text(L10n.of(context).forward),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
selectedEvents.length == 1
|
||||
? selectedEvents.first.status > 0
|
||||
? Container(
|
||||
height: 56,
|
||||
child: FlatButton(
|
||||
onPressed: () => replyAction(),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
L10n.of(context).reply),
|
||||
Icon(Icons
|
||||
.keyboard_arrow_right),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
height: 56,
|
||||
child: FlatButton(
|
||||
onPressed: () =>
|
||||
sendAgainAction(),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(L10n.of(context)
|
||||
.tryToSendAgain),
|
||||
SizedBox(width: 4),
|
||||
Icon(Icons.send, size: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
]
|
||||
: <Widget>[
|
||||
if (!kIsWeb && inputText.isEmpty)
|
||||
PopupMenuButton<String>(
|
||||
icon: Icon(Icons.add),
|
||||
onSelected: (String choice) async {
|
||||
if (choice == 'file') {
|
||||
sendFileAction(context);
|
||||
} else if (choice == 'image') {
|
||||
sendImageAction(context);
|
||||
}
|
||||
if (choice == 'camera') {
|
||||
openCameraAction(context);
|
||||
}
|
||||
if (choice == 'voice') {
|
||||
voiceMessageAction(context);
|
||||
}
|
||||
},
|
||||
itemBuilder: (BuildContext context) =>
|
||||
<PopupMenuEntry<String>>[
|
||||
PopupMenuItem<String>(
|
||||
value: 'file',
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.green,
|
||||
foregroundColor: Colors.white,
|
||||
child: Icon(Icons.attachment),
|
||||
),
|
||||
title:
|
||||
Text(L10n.of(context).sendFile),
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
),
|
||||
),
|
||||
PopupMenuItem<String>(
|
||||
value: 'image',
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.blue,
|
||||
foregroundColor: Colors.white,
|
||||
child: Icon(Icons.image),
|
||||
),
|
||||
title: Text(
|
||||
L10n.of(context).sendImage),
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
),
|
||||
),
|
||||
PopupMenuItem<String>(
|
||||
value: 'camera',
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.purple,
|
||||
foregroundColor: Colors.white,
|
||||
child: Icon(Icons.camera_alt),
|
||||
),
|
||||
title: Text(
|
||||
L10n.of(context).openCamera),
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
),
|
||||
),
|
||||
PopupMenuItem<String>(
|
||||
value: 'voice',
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
child: Icon(Icons.mic),
|
||||
),
|
||||
title: Text(
|
||||
L10n.of(context).voiceMessage),
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
height: 1,
|
||||
color: Theme.of(context).secondaryHeaderColor,
|
||||
thickness: 1,
|
||||
),
|
||||
room.canSendDefaultMessages && room.membership == Membership.join
|
||||
? Container(
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
Theme.of(context).backgroundColor.withOpacity(0.8),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: selectMode
|
||||
? <Widget>[
|
||||
Container(
|
||||
height: 56,
|
||||
child: FlatButton(
|
||||
onPressed: () =>
|
||||
forwardEventsAction(context),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Icon(Icons.keyboard_arrow_left),
|
||||
Text(L10n.of(context).forward),
|
||||
],
|
||||
),
|
||||
EncryptionButton(room),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 4.0),
|
||||
child: InputBar(
|
||||
room: room,
|
||||
minLines: 1,
|
||||
maxLines: kIsWeb ? 1 : 8,
|
||||
keyboardType: kIsWeb
|
||||
? TextInputType.text
|
||||
: TextInputType.multiline,
|
||||
onSubmitted: (String text) {
|
||||
send();
|
||||
FocusScope.of(context)
|
||||
.requestFocus(inputFocus);
|
||||
},
|
||||
focusNode: inputFocus,
|
||||
controller: sendController,
|
||||
decoration: InputDecoration(
|
||||
hintText:
|
||||
L10n.of(context).writeAMessage,
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
selectedEvents.length == 1
|
||||
? selectedEvents.first.status > 0
|
||||
? Container(
|
||||
height: 56,
|
||||
child: FlatButton(
|
||||
onPressed: () => replyAction(),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(L10n.of(context).reply),
|
||||
Icon(Icons
|
||||
.keyboard_arrow_right),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
height: 56,
|
||||
child: FlatButton(
|
||||
onPressed: () =>
|
||||
sendAgainAction(),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(L10n.of(context)
|
||||
.tryToSendAgain),
|
||||
SizedBox(width: 4),
|
||||
Icon(Icons.send, size: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
]
|
||||
: <Widget>[
|
||||
if (!kIsWeb && inputText.isEmpty)
|
||||
PopupMenuButton<String>(
|
||||
icon: Icon(Icons.add),
|
||||
onSelected: (String choice) async {
|
||||
if (choice == 'file') {
|
||||
sendFileAction(context);
|
||||
} else if (choice == 'image') {
|
||||
sendImageAction(context);
|
||||
}
|
||||
if (choice == 'camera') {
|
||||
openCameraAction(context);
|
||||
}
|
||||
if (choice == 'voice') {
|
||||
voiceMessageAction(context);
|
||||
}
|
||||
},
|
||||
itemBuilder: (BuildContext context) =>
|
||||
<PopupMenuEntry<String>>[
|
||||
PopupMenuItem<String>(
|
||||
value: 'file',
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.green,
|
||||
foregroundColor: Colors.white,
|
||||
child: Icon(Icons.attachment),
|
||||
),
|
||||
title:
|
||||
Text(L10n.of(context).sendFile),
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
),
|
||||
onChanged: (String text) {
|
||||
typingCoolDown?.cancel();
|
||||
typingCoolDown =
|
||||
Timer(Duration(seconds: 2), () {
|
||||
typingCoolDown = null;
|
||||
currentlyTyping = false;
|
||||
room.sendTypingInfo(false);
|
||||
});
|
||||
typingTimeout ??=
|
||||
Timer(Duration(seconds: 30), () {
|
||||
typingTimeout = null;
|
||||
currentlyTyping = false;
|
||||
});
|
||||
if (!currentlyTyping) {
|
||||
currentlyTyping = true;
|
||||
room.sendTypingInfo(true,
|
||||
timeout: Duration(seconds: 30)
|
||||
.inMilliseconds);
|
||||
}
|
||||
setState(() => inputText = text);
|
||||
},
|
||||
),
|
||||
PopupMenuItem<String>(
|
||||
value: 'image',
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.blue,
|
||||
foregroundColor: Colors.white,
|
||||
child: Icon(Icons.image),
|
||||
),
|
||||
title:
|
||||
Text(L10n.of(context).sendImage),
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
),
|
||||
),
|
||||
PopupMenuItem<String>(
|
||||
value: 'camera',
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.purple,
|
||||
foregroundColor: Colors.white,
|
||||
child: Icon(Icons.camera_alt),
|
||||
),
|
||||
title:
|
||||
Text(L10n.of(context).openCamera),
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
),
|
||||
),
|
||||
PopupMenuItem<String>(
|
||||
value: 'voice',
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
child: Icon(Icons.mic),
|
||||
),
|
||||
title: Text(
|
||||
L10n.of(context).voiceMessage),
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
EncryptionButton(room),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 4.0),
|
||||
child: InputBar(
|
||||
room: room,
|
||||
minLines: 1,
|
||||
maxLines: kIsWeb ? 1 : 8,
|
||||
keyboardType: kIsWeb
|
||||
? TextInputType.text
|
||||
: TextInputType.multiline,
|
||||
onSubmitted: (String text) {
|
||||
send();
|
||||
FocusScope.of(context)
|
||||
.requestFocus(inputFocus);
|
||||
},
|
||||
focusNode: inputFocus,
|
||||
controller: sendController,
|
||||
decoration: InputDecoration(
|
||||
hintText:
|
||||
L10n.of(context).writeAMessage,
|
||||
border: InputBorder.none,
|
||||
),
|
||||
onChanged: (String text) {
|
||||
typingCoolDown?.cancel();
|
||||
typingCoolDown =
|
||||
Timer(Duration(seconds: 2), () {
|
||||
typingCoolDown = null;
|
||||
currentlyTyping = false;
|
||||
room.sendTypingInfo(false);
|
||||
});
|
||||
typingTimeout ??=
|
||||
Timer(Duration(seconds: 30), () {
|
||||
typingTimeout = null;
|
||||
currentlyTyping = false;
|
||||
});
|
||||
if (!currentlyTyping) {
|
||||
currentlyTyping = true;
|
||||
room.sendTypingInfo(true,
|
||||
timeout: Duration(seconds: 30)
|
||||
.inMilliseconds);
|
||||
}
|
||||
setState(() => inputText = text);
|
||||
},
|
||||
),
|
||||
),
|
||||
if (!kIsWeb && inputText.isEmpty)
|
||||
IconButton(
|
||||
icon: Icon(Icons.mic),
|
||||
onPressed: () =>
|
||||
voiceMessageAction(context),
|
||||
),
|
||||
if (kIsWeb || inputText.isNotEmpty)
|
||||
IconButton(
|
||||
icon: Icon(Icons.send),
|
||||
onPressed: () => send(),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (!kIsWeb && inputText.isEmpty)
|
||||
IconButton(
|
||||
icon: Icon(Icons.mic),
|
||||
onPressed: () =>
|
||||
voiceMessageAction(context),
|
||||
),
|
||||
if (kIsWeb || inputText.isNotEmpty)
|
||||
IconButton(
|
||||
icon: Icon(Icons.send),
|
||||
onPressed: () => send(),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -298,34 +298,61 @@ class _ChatListState extends State<ChatList> {
|
|||
onPressed: () =>
|
||||
Matrix.of(context).shareContent = null,
|
||||
),
|
||||
automaticallyImplyLeading: false,
|
||||
titleSpacing: 0,
|
||||
title: selectMode == SelectMode.share
|
||||
? Text(L10n.of(context).share)
|
||||
: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
height: 42,
|
||||
margin: EdgeInsets.only(right: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).secondaryHeaderColor,
|
||||
borderRadius: BorderRadius.circular(90),
|
||||
),
|
||||
child: TextField(
|
||||
autocorrect: false,
|
||||
controller: searchController,
|
||||
decoration: InputDecoration(
|
||||
suffixIcon: loadingPublicRooms
|
||||
? Container(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(),
|
||||
margin: EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Material(
|
||||
elevation: 5,
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Row(
|
||||
children: [
|
||||
Builder(
|
||||
builder: (context) => IconButton(
|
||||
padding: EdgeInsets.zero,
|
||||
icon: Icon(Icons.menu),
|
||||
onPressed: () =>
|
||||
Scaffold.of(context).openDrawer(),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
autocorrect: false,
|
||||
controller: searchController,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.all(9),
|
||||
border: InputBorder.none,
|
||||
hintText:
|
||||
L10n.of(context).searchForAChat,
|
||||
),
|
||||
)
|
||||
: Icon(Icons.search),
|
||||
contentPadding: EdgeInsets.all(9),
|
||||
border: InputBorder.none,
|
||||
hintText: L10n.of(context).searchForAChat,
|
||||
),
|
||||
),
|
||||
loadingPublicRooms
|
||||
? Container(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child:
|
||||
CircularProgressIndicator(),
|
||||
),
|
||||
)
|
||||
: IconButton(
|
||||
padding: EdgeInsets.zero,
|
||||
icon: Icon(Icons.account_circle),
|
||||
onPressed: () =>
|
||||
Navigator.of(context).push(
|
||||
AppRoute.defaultRoute(
|
||||
context,
|
||||
SettingsView())),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -433,9 +460,9 @@ class _ChatListState extends State<ChatList> {
|
|||
? Container()
|
||||
: PreferredSize(
|
||||
preferredSize:
|
||||
Size.fromHeight(89),
|
||||
Size.fromHeight(90),
|
||||
child: Container(
|
||||
height: 81,
|
||||
height: 82,
|
||||
child: ListView.builder(
|
||||
scrollDirection:
|
||||
Axis.horizontal,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue