-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Expensify.cash to iOS and Android native share menus #1414
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
Hey @marcaaron |
src/pages/SharePage.js
Outdated
<CreateMenu | ||
onClose={this.toggleCreateMenu} | ||
isVisible={this.state.isCreateMenuActive} | ||
onItemSelected={this.onCreateMenuItemSelected} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't need the
CreateMenu
here?
Same with theFAB
?
@marcaaron
CreateMenu
and FAB
would allow user to share not only to the chat from the list, but also to create a new chat and share there.
Of course a new chat can be created also with a search functionality of ChatSwitcherView
, but that's probably less intuitive for the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I see that new Search view has been merged to the master, so most of this doesn't make sense anymore and should be reworked anyway :)
@r8 sorry for missing a few of these replies please let us know if you are still working on this, thanks! |
Hey @marcaaron |
Sounds good! Thanks for the update. |
@marcaaron Could you please take a look? What do you think about this approach? I tried to reuse new Search components, then I tried to extend Home Page components to implement the sharing directly there, but had to revert both times and go the simper way. |
Can you explain what sorts of problems you ran into here? I'm not sure if I completely understand what kind of refactoring you are suggesting we need. But I think the approach you have here that relies on |
I'm not actually suggesting, I'm more like thinking out loud. The biggest challenge of this task for me is that almost each component I tried to reuse was a Smart one. I couldn't just reuse SidebarLinks, for example, because it's talking to the Onyx and calling redirect actions directly. Anyway, I should probably use |
Ah, my apologies. Yes, I think using |
I've updated the code according to comments. |
I think the Slack/WhatsApp design would be ideal @r8, thanks for the latest changes. Let's get our design team in here to confirm, too. cc @Expensify/design |
Sorry, can you clarify what you mean by this exactly? |
@marcaaron
|
@r8 Sorry I don't have the answer to that. Maybe @shawnborton or @sakluger can weigh in on how this should work? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna leave this review for @chiragsalian and @nickmurray47 to complete.
One comment I will reiterate here is that we do not have any async actions so I think if we can avoid making getOrCreateChatReport()
return a Promise
that would be ideal. It breaks some things about the philosophy of how Onyx should work.
See: https://github.com/Expensify/Expensify.cash/blob/master/README.md#philosophy
This case seems a benign, but I think it's a practice we are trying to completely avoid since once the flood gates are open it is much more likely that we will have lots of synchronous code. I also don't really have a clean solution other than try a version of this where we:
redirect()
to the report screen- once there check for the
sharedItem
and perform the logic to save a draft or upload the attachment
* @returns {Object} Prepared shared item structure | ||
*/ | ||
function prepareSharedItem(sharedItem) { | ||
if (sharedItem.mimeType.match(TEXT_MIME_TYPE)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 seems fine to me
I was actually considering this approach. But I didn't like it. |
That's not what I see in iOS. If I click Share from a page in Safari (my default browser) and then select WhatsApp or Slack, it pulls up a modal from the actual WhatsApp or Slack app. Here's what WhatsApp looks like: And here's what Slack looks like: So I think that the issue description is still a good way to implement this. When they select to share to Expensify.Cash, we open up the homepage of the ECash app, which lets them choose who to share with. |
@marcaaron |
Yep, I understand and agree. But perhaps, we could make it a pure function that lives inside the componentDidMount() {
if (props.sharedItem) {
processSharedItem(reportID, sharedItem);
}
} I'll admit, there are some things that make this a bit convoluted at the moment like the way we are loading several reports in the background here (so it would require another check in That particular problem will be solved by the addition of
That all makes sense to me. I know we have decided as a team to pursue something novel and learning as we go so we appreciate your patience. It's more important to us to try and stick to doing things one way for now. If that way ends up being wrong then we'll switch things up. Even this decision is not 100% mine to make in this case :) |
Just chatted with @chiragsalian separately and I wanted to add another comment with the desired flow. In the screenshots I posted above from the WhatsApp and Slack share modals, the user selects who to send it to (either an individual or a group). We'd like to see similar behavior. So my thinking was that when you select to share something, it would pop up with a modal that looks something like this: You could choose from one of the recent chats, or you could search or start a new chat or group. As soon as you select a chat, it would send your content to that chat. @marcaaron @chiragsalian does that sound like what you two were thinking of too? |
Of course, this change can be done and would be easier to pull off once the change I suggested above (i.e. to make the act of navigating to a report screen with a share item upload to the report). But I also think we should do this in a follow up PR. I'm going to advocate for @r8 here a bit and say that it's a little unreasonable to ask for this change at this point. If we wanted this change we should have asked for it 20+ days ago when this PR was created. This is the proposal we agreed to move forward with so we should merge this and create a new issue to allow for what you're asking. |
Also, I will take some responsibility for that since looking at the original issue I'm not sure I understand clearly what you were asking for @sakluger 😅 |
That's totally fair @marcaaron! I reviewed the demo video again and the only concern I have is that the button on the first step says "Post", which makes me think that it would post the content immediately, before getting a chance to select the chat. Could we change that "Post" to say "Next" instead? That would make it clear that there's another step (i.e. selecting the chat) before posting. If we made this small change, then I'd feel totally comfortable merging. |
I've done a bit of investigation, and here is what I know so far: This 'Cancel' and 'Post' buttons are defined in iOS core library for the share functionality ( So I'm in the big dilemma. The controller for the share functionality is provided by the package I'm using - Second option is to build a custom share view. But that's a bit of a windy and scary road with modification of build phases for the extension and with export of the share component from Expensify.chat app. And yet another option (to make it a trilemma) is to follow the second approach, but export the dummy component, Could you please advise what would be the preferable solution in this case? |
I think we can rule out hacks as an option
This does look scary. But maybe not completely off the table.
This also seems reasonable. Probably if we go this way we should still proceed with what we have and maybe follow up with this improvement in another issue. It looks fairly involved and I think there are some good building blocks laid out here. Thoughts @sakluger ? I might also propose another option which would be to submit a fix to the main library so that a custom share view isn't necessary and iOS can optionally behave like Android. But not sure if this is what we want at the end of the day. |
Not sure if there is any update here. This PR has got some pretty bad conflicts now. The good news is we have updated to |
@marcaaron oh, you're right. Sorry. |
…h into sergey-share-menu-fixes � Conflicts: � src/ONYXKEYS.js
Let us know how you want to proceed @r8. Thanks! |
@marcaaron To be honest, now I have much less time and energy than I had when it all started. |
Ah no worries. Yep I think maybe if we try to do this again we will move forward in smaller increments.
I think it's understandable to run out of steam or know when to cut losses on a PR. I wouldn't exactly call this a failure since we've learned some interesting things about this feature. Anyways, feel free to pick up smaller jobs if you have the time. We have enjoyed working with you. |
Details
Uses react-native-share-menu to add Expensify.cash to the native share menu on mobile platforms and enables sharing to the app.
Chat selection is made on separate page, which reuses components from Home page. To achieve this I had to modify some sidebar related components and functions, mainly to add callbacks for getting selected chat id.
Fixed Issues
Fixes #1294
Tests
Tested On
Screenshots
iOS
ShareMenu-iOS.mp4
Android
ShareMenu-Android.mp4