I would like to change the display color of an inline list item or its background, based on a condition. Is that possible?
A use case is in a chat screen where the a message list is displayed. Messages from the sender are one color, and messages from the receiver are another color.
On each line item, I have the person’s profile picture and a message. It would be more user-friendly, though, if the background or the text itself were a different color to easily distinguish between the message I have sent and the ones I have received.
In your Messages table, make sure you have a column that stores an ID of the “chat” so you can know which messages belongs to which chat. Add a relation from that column to itself, make it a multiple relation.
Add a rowID column to that table.
Add a lookup column on top of the relation in the first step, return all rowIDs.
Add a “find element index” column, pointing to the array of rowIDs above, and return the index of the current row’s rowID. We do this to get the index of the message that is shown on the screen.
Add an If-Then-Else column. If the sender of the message is the signed-in user (depends on whether you use the user’s email or rowID, configure the correct condition here), return this value:
Add a template column, point to the if-then-else column above, replace {X} by the index we calculated two steps above.
Go back to the Chats table, assuming you already have a relation to the Messages table, create a joined list column and join all template values above, separated by a new line character. Basically it would look like this (I had more settings so mine would look longer).