This commit is contained in:
howard-stearns 2017-05-01 15:45:26 -07:00
parent 61b738e3cd
commit 545fd1355f

View file

@ -31,7 +31,7 @@ Item {
property bool drillDownToPlace: false; property bool drillDownToPlace: false;
property bool showPlace: isConcurrency; property bool showPlace: isConcurrency;
property string messageColor: lozenge.visible ? "white" : hifi.colors.blueAccent; property string messageColor: isAnnouncement ? "white" : hifi.colors.blueAccent;
property string timePhrase: pastTime(timestamp); property string timePhrase: pastTime(timestamp);
property int onlineUsers: 0; property int onlineUsers: 0;
property bool isConcurrency: action === 'concurrency'; property bool isConcurrency: action === 'concurrency';
@ -71,6 +71,10 @@ Item {
property bool hasGif: imageUrl.indexOf('.gif') === (imageUrl.length - 4); property bool hasGif: imageUrl.indexOf('.gif') === (imageUrl.length - 4);
function pluralize(count, singular, optionalPlural) {
return (count === 1) ? singular : (optionalPlural || (singular + "s"));
}
DropShadow { DropShadow {
visible: isStacked; visible: isStacked;
anchors.fill: shadow1; anchors.fill: shadow1;
@ -189,7 +193,7 @@ Item {
RalewayRegular { RalewayRegular {
id: message; id: message;
visible: !isAnnouncement; visible: !isAnnouncement;
text: isConcurrency ? ((onlineUsers === 1) ? "person" : "people") : (isAnnouncement ? "connections" : (drillDownToPlace ? "snapshots" : ("by " + userName))); text: isConcurrency ? pluralize(onlineUsers, "person", "people") : (drillDownToPlace ? "snapshots" : ("by " + userName));
size: textSizeSmall; size: textSizeSmall;
color: messageColor; color: messageColor;
elide: Text.ElideRight; // requires a width to be specified` elide: Text.ElideRight; // requires a width to be specified`
@ -205,14 +209,14 @@ Item {
Column { Column {
visible: isAnnouncement; visible: isAnnouncement;
RalewayRegular { RalewayRegular {
text: "connections" + " "; // fixme: pluralize text: pluralize(onlineUsers, "connection") + " "; // hack padding
size: textSizeSmall; size: textSizeSmall;
color: "white"; // fixme not needed? get rid of complication in messageColor? color: messageColor;
} }
RalewayRegular { RalewayRegular {
text: "are here now"; // fixme pluralize text: pluralize(onlineUsers, "is here now", "are here now");
size: textSizeSmall * 0.7; size: textSizeSmall * 0.7;
color: "white"; //' fixme not needed? get rid of complication in messageColor? color: messageColor;
} }
} }
spacing: textPadding; spacing: textPadding;