8000
Skip to content

Add indicator for selected conversation in conversation list#86

Merged
gluonfield merged 3 commits intogluonfield:mainfrom
wzulfikar:add-current-convo-indicator
Apr 29, 2024
Merged

Add indicator for selected conversation in conversation list#86
gluonfield merged 3 commits intogluonfield:mainfrom
wzulfikar:add-current-convo-indicator

Conversation

@wzulfikar
Copy link
Copy Markdown
Contributor
@wzulfikar wzulfikar commented Apr 27, 2024

What
Add selectedConversation to ConversationHistoryListView to determine when to show the indicator.

Before (no indicator for selected conversation):

Screen.Recording.2024-04-28.at.1.01.08.AM.mov

After (selected conversation has blue indicator):

enchanted-convo-indicator.mov.mp4

Why
When selecting other conversation from the list, I noticed I had difficulty figuring out what's the currently selected conversation. This PR adds a little indicator to the selected conversation.

ForEach(conversationGroup.conversations, id:\.self) { dailyConversation in
HStack {
Button(action: {onTap(dailyConversation)}) {
let isSelected = selectedConversation?.name == dailyConversation.name && selectedConversation?.createdAt == dailyConversation.createdAt
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conversation doesn't have a unique ID so I'm using combination of name and createdAt. Not sure if having this conditional logic in view is acceptable here, but since it's quite simple (IMO) I think it's fine to put here.

@wzulfikar
Copy link
Copy Markdown
Contributor Author
wzulfikar commented Apr 27, 2024

Wanted to open an issue to ask about this but looks like it might be straightforward changes. So I went ahead and created this PR to illustrate my question. Happy to address any feedbacks (or close if you have other plan).

@gluonfield
Copy link
Copy Markdown
Owner

Hi @wzulfikar great idea!

I have adjusted style a bit to match the vision of the app.

ConversationSD type has id and since it conforms to Identifiable protocol comparison can be made as simple as selectedConversation == dailyConversation.

LGTM!

@gluonfield gluonfield merged commit ebed97c into gluonfield:main Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0