Splash color on select

This commit is contained in:
Christian Pauly 2020-02-09 16:26:24 +01:00
parent 955c2376ea
commit 5451216695
3 changed files with 66 additions and 116 deletions

View file

@ -48,106 +48,51 @@ class Message extends StatelessWidget {
? Colors.redAccent
: Theme.of(context).primaryColor;
}
List<PopupMenuEntry<String>> popupMenuList = [];
if (event.canRedact && !event.redacted && event.status > 1) {
popupMenuList.add(
PopupMenuItem<String>(
value: "remove",
child: Text(I18n.of(context).removeMessage),
),
);
}
if (!event.redacted &&
[
MessageTypes.Text,
MessageTypes.Reply,
MessageTypes.Location,
MessageTypes.Notice,
MessageTypes.Emote,
MessageTypes.None,
].contains(event.messageType) &&
event.body.isNotEmpty) {
popupMenuList.add(
PopupMenuItem<String>(
value: "copy",
child: Text(I18n.of(context).copy),
),
);
}
if (!event.redacted) {
popupMenuList.add(
PopupMenuItem<String>(
value: "forward",
child: Text(I18n.of(context).forward),
),
);
}
if (ownMessage && event.status == -1) {
popupMenuList.add(
PopupMenuItem<String>(
value: "resend",
child: Text(I18n.of(context).tryToSendAgain),
),
);
popupMenuList.add(
PopupMenuItem<String>(
value: "delete",
child: Text(I18n.of(context).deleteMessage),
),
);
}
List<Widget> rowChildren = [
Expanded(
child: InkWell(
onTap: longPressSelect ? null : () => onSelect(event),
onLongPress: !longPressSelect ? null : () => onSelect(event),
child: AnimatedOpacity(
duration: Duration(milliseconds: 500),
opacity: (event.status == 0 || event.redacted) ? 0.5 : 1,
child: Bubble(
elevation: 0,
radius: Radius.circular(8),
alignment: alignment,
margin: BubbleEdges.symmetric(horizontal: 4),
color: color,
nip: nip,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
ownMessage
? I18n.of(context).you
: event.sender.calcDisplayname(),
style: TextStyle(
color: ownMessage
? textColor
: event.sender.calcDisplayname().color,
fontWeight: FontWeight.bold,
),
child: AnimatedOpacity(
duration: Duration(milliseconds: 500),
opacity: (event.status == 0 || event.redacted) ? 0.5 : 1,
child: Bubble(
elevation: 0,
radius: Radius.circular(8),
alignment: alignment,
margin: BubbleEdges.symmetric(horizontal: 4),
color: color,
nip: nip,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
ownMessage
? I18n.of(context).you
: event.sender.calcDisplayname(),
style: TextStyle(
color: ownMessage
? textColor
: event.sender.calcDisplayname().color,
fontWeight: FontWeight.bold,
),
SizedBox(width: 4),
Text(
event.time.localizedTime(context),
style: TextStyle(
color: textColor.withAlpha(180),
),
),
SizedBox(width: 4),
Text(
event.time.localizedTime(context),
style: TextStyle(
color: textColor.withAlpha(180),
),
],
),
MessageContent(
event,
textColor: textColor,
),
],
),
),
],
),
MessageContent(
event,
textColor: textColor,
),
],
),
),
),
@ -171,18 +116,23 @@ class Message extends StatelessWidget {
rowChildren.insert(0, avatarOrSizedBox);
}
return AnimatedContainer(
duration: Duration(milliseconds: 300),
curve: Curves.fastOutSlowIn,
color: selected
? Theme.of(context).primaryColor.withAlpha(100)
: Theme.of(context).backgroundColor,
padding: EdgeInsets.only(
left: 8.0, right: 8.0, bottom: sameSender ? 4.0 : 8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: rowMainAxisAlignment,
children: rowChildren,
return InkWell(
onTap: longPressSelect ? () => null : () => onSelect(event),
splashColor: Theme.of(context).primaryColor.withAlpha(100),
onLongPress: !longPressSelect ? null : () => onSelect(event),
child: AnimatedContainer(
duration: Duration(milliseconds: 300),
curve: Curves.fastOutSlowIn,
color: selected
? Theme.of(context).primaryColor.withAlpha(100)
: Theme.of(context).primaryColor.withAlpha(0),
padding: EdgeInsets.only(
left: 8.0, right: 8.0, bottom: sameSender ? 4.0 : 8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: rowMainAxisAlignment,
children: rowChildren,
),
),
);
}

View file

@ -44,7 +44,7 @@ class App extends StatelessWidget {
appBarTheme: AppBarTheme(
brightness: Brightness.light,
color: Colors.white,
elevation: 1,
//elevation: 1,
textTheme: TextTheme(
title: TextStyle(
color: Colors.black,

View file

@ -12,7 +12,7 @@ extension LocalizedBody on Event {
MessageTypes.None,
};
getLocalizedBody(BuildContext context,
String getLocalizedBody(BuildContext context,
{bool withSenderNamePrefix = false, bool hideQuotes = false}) {
if (this.redacted) {
return I18n.of(context)
@ -204,6 +204,13 @@ extension LocalizedBody on Event {
localizedBody = I18n.of(context).unknownEvent(this.typeKey);
}
// Hide quotes
if (hideQuotes) {
List<String> lines = localizedBody.split("\n");
lines.removeWhere((s) => s.startsWith("> ") || s.isEmpty);
localizedBody = lines.join("\n");
}
// Add the sender name prefix
if (withSenderNamePrefix &&
this.type == EventTypes.Message &&
@ -214,13 +221,6 @@ extension LocalizedBody on Event {
localizedBody = "$senderNameOrYou: $localizedBody";
}
// Hide quotes
if (hideQuotes) {
List<String> lines = localizedBody.split("\n");
lines.removeWhere((s) => s.startsWith("> "));
localizedBody = lines.join("\n");
}
return localizedBody;
}
}