Splash color on select
This commit is contained in:
parent
955c2376ea
commit
5451216695
|
@ -48,106 +48,51 @@ class Message extends StatelessWidget {
|
||||||
? Colors.redAccent
|
? Colors.redAccent
|
||||||
: Theme.of(context).primaryColor;
|
: 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 = [
|
List<Widget> rowChildren = [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: InkWell(
|
child: AnimatedOpacity(
|
||||||
onTap: longPressSelect ? null : () => onSelect(event),
|
duration: Duration(milliseconds: 500),
|
||||||
onLongPress: !longPressSelect ? null : () => onSelect(event),
|
opacity: (event.status == 0 || event.redacted) ? 0.5 : 1,
|
||||||
child: AnimatedOpacity(
|
child: Bubble(
|
||||||
duration: Duration(milliseconds: 500),
|
elevation: 0,
|
||||||
opacity: (event.status == 0 || event.redacted) ? 0.5 : 1,
|
radius: Radius.circular(8),
|
||||||
child: Bubble(
|
alignment: alignment,
|
||||||
elevation: 0,
|
margin: BubbleEdges.symmetric(horizontal: 4),
|
||||||
radius: Radius.circular(8),
|
color: color,
|
||||||
alignment: alignment,
|
nip: nip,
|
||||||
margin: BubbleEdges.symmetric(horizontal: 4),
|
child: Column(
|
||||||
color: color,
|
mainAxisSize: MainAxisSize.min,
|
||||||
nip: nip,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: Column(
|
children: <Widget>[
|
||||||
mainAxisSize: MainAxisSize.min,
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Row(
|
Text(
|
||||||
mainAxisSize: MainAxisSize.min,
|
ownMessage
|
||||||
children: <Widget>[
|
? I18n.of(context).you
|
||||||
Text(
|
: event.sender.calcDisplayname(),
|
||||||
ownMessage
|
style: TextStyle(
|
||||||
? I18n.of(context).you
|
color: ownMessage
|
||||||
: event.sender.calcDisplayname(),
|
? textColor
|
||||||
style: TextStyle(
|
: event.sender.calcDisplayname().color,
|
||||||
color: ownMessage
|
fontWeight: FontWeight.bold,
|
||||||
? textColor
|
|
||||||
: event.sender.calcDisplayname().color,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
SizedBox(width: 4),
|
),
|
||||||
Text(
|
SizedBox(width: 4),
|
||||||
event.time.localizedTime(context),
|
Text(
|
||||||
style: TextStyle(
|
event.time.localizedTime(context),
|
||||||
color: textColor.withAlpha(180),
|
style: TextStyle(
|
||||||
),
|
color: textColor.withAlpha(180),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
MessageContent(
|
),
|
||||||
event,
|
MessageContent(
|
||||||
textColor: textColor,
|
event,
|
||||||
),
|
textColor: textColor,
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -171,18 +116,23 @@ class Message extends StatelessWidget {
|
||||||
rowChildren.insert(0, avatarOrSizedBox);
|
rowChildren.insert(0, avatarOrSizedBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
return AnimatedContainer(
|
return InkWell(
|
||||||
duration: Duration(milliseconds: 300),
|
onTap: longPressSelect ? () => null : () => onSelect(event),
|
||||||
curve: Curves.fastOutSlowIn,
|
splashColor: Theme.of(context).primaryColor.withAlpha(100),
|
||||||
color: selected
|
onLongPress: !longPressSelect ? null : () => onSelect(event),
|
||||||
? Theme.of(context).primaryColor.withAlpha(100)
|
child: AnimatedContainer(
|
||||||
: Theme.of(context).backgroundColor,
|
duration: Duration(milliseconds: 300),
|
||||||
padding: EdgeInsets.only(
|
curve: Curves.fastOutSlowIn,
|
||||||
left: 8.0, right: 8.0, bottom: sameSender ? 4.0 : 8.0),
|
color: selected
|
||||||
child: Row(
|
? Theme.of(context).primaryColor.withAlpha(100)
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
: Theme.of(context).primaryColor.withAlpha(0),
|
||||||
mainAxisAlignment: rowMainAxisAlignment,
|
padding: EdgeInsets.only(
|
||||||
children: rowChildren,
|
left: 8.0, right: 8.0, bottom: sameSender ? 4.0 : 8.0),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
mainAxisAlignment: rowMainAxisAlignment,
|
||||||
|
children: rowChildren,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class App extends StatelessWidget {
|
||||||
appBarTheme: AppBarTheme(
|
appBarTheme: AppBarTheme(
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
elevation: 1,
|
//elevation: 1,
|
||||||
textTheme: TextTheme(
|
textTheme: TextTheme(
|
||||||
title: TextStyle(
|
title: TextStyle(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
|
|
|
@ -12,7 +12,7 @@ extension LocalizedBody on Event {
|
||||||
MessageTypes.None,
|
MessageTypes.None,
|
||||||
};
|
};
|
||||||
|
|
||||||
getLocalizedBody(BuildContext context,
|
String getLocalizedBody(BuildContext context,
|
||||||
{bool withSenderNamePrefix = false, bool hideQuotes = false}) {
|
{bool withSenderNamePrefix = false, bool hideQuotes = false}) {
|
||||||
if (this.redacted) {
|
if (this.redacted) {
|
||||||
return I18n.of(context)
|
return I18n.of(context)
|
||||||
|
@ -204,6 +204,13 @@ extension LocalizedBody on Event {
|
||||||
localizedBody = I18n.of(context).unknownEvent(this.typeKey);
|
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
|
// Add the sender name prefix
|
||||||
if (withSenderNamePrefix &&
|
if (withSenderNamePrefix &&
|
||||||
this.type == EventTypes.Message &&
|
this.type == EventTypes.Message &&
|
||||||
|
@ -214,13 +221,6 @@ extension LocalizedBody on Event {
|
||||||
localizedBody = "$senderNameOrYou: $localizedBody";
|
localizedBody = "$senderNameOrYou: $localizedBody";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide quotes
|
|
||||||
if (hideQuotes) {
|
|
||||||
List<String> lines = localizedBody.split("\n");
|
|
||||||
lines.removeWhere((s) => s.startsWith("> "));
|
|
||||||
localizedBody = lines.join("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return localizedBody;
|
return localizedBody;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue