More features
This commit is contained in:
parent
614eb7077c
commit
f1079e5c70
13 changed files with 503 additions and 156 deletions
|
|
@ -23,7 +23,10 @@ class RedactMessageDialog extends StatelessWidget {
|
|||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
FlatButton(
|
||||
child: Text("Remove".toUpperCase()),
|
||||
child: Text(
|
||||
"Remove".toUpperCase(),
|
||||
style: TextStyle(color: Colors.red),
|
||||
),
|
||||
onPressed: () => removeAction(context),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -4,14 +4,76 @@ import 'package:fluffychat/utils/chat_time.dart';
|
|||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/views/chat.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
|
||||
import '../avatar.dart';
|
||||
import '../matrix.dart';
|
||||
|
||||
class ChatListItem extends StatelessWidget {
|
||||
final Room room;
|
||||
final bool activeChat;
|
||||
final Function onForget;
|
||||
|
||||
const ChatListItem(this.room, {this.activeChat = false});
|
||||
const ChatListItem(this.room, {this.activeChat = false, this.onForget});
|
||||
|
||||
void clickAction(BuildContext context) async {
|
||||
if (!activeChat) {
|
||||
if (room.membership == Membership.invite &&
|
||||
await Matrix.of(context).tryRequestWithLoadingDialog(room.join()) ==
|
||||
false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (room.membership == Membership.ban) {
|
||||
Toast.show("You have been banned from this chat", context, duration: 5);
|
||||
return;
|
||||
}
|
||||
|
||||
if (room.membership == Membership.leave) {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: Text("Archived Room"),
|
||||
content: Text("This room has been archived."),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text("Close".toUpperCase(),
|
||||
style: TextStyle(color: Colors.blueGrey)),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
FlatButton(
|
||||
child: Text("Forget".toUpperCase(),
|
||||
style: TextStyle(color: Colors.red)),
|
||||
onPressed: () async {
|
||||
await Matrix.of(context)
|
||||
.tryRequestWithLoadingDialog(room.forget());
|
||||
await Navigator.of(context).pop();
|
||||
if (this.onForget != null) this.onForget();
|
||||
},
|
||||
),
|
||||
FlatButton(
|
||||
child: Text("Rejoin".toUpperCase(),
|
||||
style: TextStyle(color: Colors.blue)),
|
||||
onPressed: () async {
|
||||
await Matrix.of(context)
|
||||
.tryRequestWithLoadingDialog(room.join());
|
||||
await Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (room.membership == Membership.join) {
|
||||
await Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
AppRoute.defaultRoute(context, Chat(room.id)),
|
||||
(r) => r.isFirst,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
@ -41,7 +103,19 @@ class ChatListItem extends StatelessWidget {
|
|||
subtitle: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Expanded(child: MessageContent(room.lastEvent, textOnly: true)),
|
||||
Expanded(
|
||||
child: room.membership == Membership.invite
|
||||
? Text(
|
||||
"You are invited to this chat",
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
)
|
||||
: MessageContent(
|
||||
room.lastEvent,
|
||||
textOnly: true,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
room.pushRuleState == PushRuleState.notify
|
||||
? Container()
|
||||
|
|
@ -70,48 +144,7 @@ class ChatListItem extends StatelessWidget {
|
|||
: Text(" "),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
if (activeChat) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
AppRoute.defaultRoute(context, Chat(room.id)),
|
||||
);
|
||||
} else {
|
||||
Navigator.push(
|
||||
context,
|
||||
AppRoute.defaultRoute(context, Chat(room.id)),
|
||||
);
|
||||
}
|
||||
},
|
||||
onLongPress: () {},
|
||||
/*trailing: Container(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Text(ChatTime(room.timeCreated).toEventTimeString()),
|
||||
room.notificationCount > 0
|
||||
? Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
margin: EdgeInsets.only(top: 3),
|
||||
decoration: BoxDecoration(
|
||||
color: room.highlightCount > 0
|
||||
? Colors.red
|
||||
: Theme.of(context).primaryColor,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
room.notificationCount.toString(),
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
)
|
||||
: Text(" "),
|
||||
],
|
||||
),
|
||||
),*/
|
||||
onTap: () => clickAction(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,9 @@ class Message extends StatelessWidget {
|
|||
SizedBox(width: 4),
|
||||
Text(
|
||||
ChatTime(event.time).toEventTimeString(),
|
||||
style: TextStyle(color: textColor, fontSize: 12),
|
||||
style: TextStyle(
|
||||
color: textColor.withAlpha(200),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ class StateMessage extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (event.type == EventTypes.Redaction) return Container();
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Opacity(
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class MessageContent extends StatelessWidget {
|
|||
case MessageTypes.Sticker:
|
||||
if (textOnly) {
|
||||
return Text(
|
||||
"${event.sender.calcDisplayname()} has sent an image",
|
||||
"${event.sender.calcDisplayname()} sent a picture",
|
||||
maxLines: maxLines,
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
|
|
@ -75,6 +75,17 @@ class MessageContent extends StatelessWidget {
|
|||
case MessageTypes.Audio:
|
||||
case MessageTypes.File:
|
||||
case MessageTypes.Video:
|
||||
if (textOnly) {
|
||||
return Text(
|
||||
"${event.sender.calcDisplayname()} sent a file",
|
||||
maxLines: maxLines,
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
decoration:
|
||||
event.redacted ? TextDecoration.lineThrough : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
return Container(
|
||||
width: 200,
|
||||
child: RaisedButton(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue