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,63 +48,9 @@ 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,
@ -151,7 +97,6 @@ class Message extends StatelessWidget {
),
),
),
),
];
final Widget avatarOrSizedBox = sameSender
? SizedBox(width: 40)
@ -171,12 +116,16 @@ class Message extends StatelessWidget {
rowChildren.insert(0, avatarOrSizedBox);
}
return AnimatedContainer(
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).backgroundColor,
: Theme.of(context).primaryColor.withAlpha(0),
padding: EdgeInsets.only(
left: 8.0, right: 8.0, bottom: sameSender ? 4.0 : 8.0),
child: Row(
@ -184,6 +133,7 @@ class Message extends StatelessWidget {
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;
}
}