new-dawn / new_dawn_ios_playground

iOS repository for project New Dawn
0 stars 1 forks source link

[9/n] Parse taken_by from ios and hide other people's chat entry #266

Open tangziyi001 opened 5 years ago

tangziyi001 commented 5 years ago
  1. Parse the server profile response and extract the taken_by field from iOS just like how you parsed the taken_info. By default the taken_by can be -1 indicating the the user is not taken by anyone.
  2. When the current user opens chat page, we should check if the user has been taken by checking if the taken_by != -1. If so, we should make all chat entries un-clickable and grey them out, unless that chat entry is from a user that 专属于 the current user. You can add that user ID check and make the cell unclickable starting from here: https://github.com/new-dawn/new_dawn_ios_playground/blob/master/NewDawn/NewDawn/ViewControllers/ChatPageViewControllers/ChatPageViewController.swift#L90

Notice that the functionfunc tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell will get called multiple times to render each individual cell in order. You can learn more about tableView online. In general, allMessages contains all messages from all users. You can use indexPath to get the cell index and use that to get the information for the ith user that the current user is chatting with.

You might also need to do some research on how to make a table cell unclickable programmically, and how to grey-out a specific cell. Let me know if you have any question.

Here is an example (but you don't need to follow strictly to the UI layout, just make sure that we can distinguish out the taken user):

Screen Shot 2019-06-19 at 10 39 11 PM

At this moment, the taken user might not be on the top of the chat list, but you don't need to concern about that now.

tangziyi001 commented 5 years ago

fetchLoginUserProfile: https://github.com/new-dawn/new_dawn_ios_playground/blob/master/NewDawn/NewDawn/ViewControllers/ChatPageViewControllers/ChatRoomViewController.swift#L381-L391