How to programmatically close an ActionSheetIOS in React Native? - react-native

I can't find a way to programmatically close an ActionSheetIOS. When the device orientation changes, if there is an action sheet open, I need to close it before reopening it (otherwise it is erroneously anchored to the wrong location). I haven't been able to find a way to trigger closing it without requiring user input. Is this possible programmatically?

The documentation does not mention this being possible in the current version (0.38.0). I also could not find any related issue, so the only ideas that comes to mind are either finding a package that implements the functionality JS.coach, or extending the implementation of ActionSheetIOS to include that functionality. Maybe this question might be helpful.

React Native version 0.69.0 has added the ActionSheetIOS.dismissActionSheet() method, which will dismiss the most upper action sheet.

Related

How to detect a screenshot in a RN application?

I'm having some problem about a screenshot-detector in an application.
I'm using EXPO, but I've no idea about how can I detect a screenshot.
Suppose that I've a profile screen. Each user has a profile page, I want to detect when another user does a screenshot on the screen.
My problem is: how can I detect this? I readed about the gesture here, but it didn't help me. With the gestures I can detect, instead, the scroll in a page, the location x and location y.
I readed also this answer, but about the event touchesCancelled:withEvent:touchesCancelled:withEvent: I have not found anything in React Native docs (and also EXPO docs).
So: which is the idea behind a screenshot detector? Thanks for your help!
You can't do it without detaching EXPO. There is already a feature request for that.
If you decide to detach EXPO, react-native-screenshot-detector might be helpful. The solution is very similar to the one from the linked question.
Currently with expo there is no way to do that, But if you detach you can use this package it supports android&ios screenshot detecting react-native-detector

React native DatePickerAndroid clear option

I'm using the native DatePickerAndroid for editing a date field in my react-native app.
I would like to know if there is any support for adding a 'clear' button to the native date picker that will close the datepicker and return an empty date - in order to be able to clear the date in the input field.
I've attached a screenshot of the native android date picker opened from a regular <input/> with type date in chrome. As you can see there is a 'clear' button - exactly what I'm looking for!
Actually this question was previously answered by ufxmeng, but his answer was lately deleted (I don't know why...).
His solution was to create a custom AndroidDatePicker module, mostly copied from the original DatePicker Module created by React Native, with slight changes for adding a CLEAR button.
He put together a github repo holding all files that need to be added/changed to accomplish this. Basically the changes you'll need are here and here.
But note that the original CLEAR button added in that repo doesn't fully match the needs pointed out in my question (see this issue).
So I've changed some of the code to make it work the way I expected. You could see the changes I made in this pull request
It works great for me!
In case anyone else needs this, I forked the original repo of ufxmeng and added Clear button functionality for TimePicker as well:
https://github.com/sladek-jan/CustomDatePicker

react-native-router-flux - Resetting navigation stack in tab

What we want
We use react-native-router-flux in our application and find ourself in a situation where we need to reset the navigation stack (at least) for one tab. This is our scene structure:
tabs
listTab
listView
recordingView
creationTab
recordView
descriptionView
publishView
Concretely, our application lets users create and view recordings. There's a listTab, with two sub-scenes (list of recordings and view a single recording) and a tab for creating (creationTab) recordings with several steps (recordView, descriptionView, publishView). After the last step, the recording is published and we redirect to the viewRecording scene for that recording in the listTab.
When pressing the creationTab again, we would like to get back to the first scene of the creation process again, but instead we of course land on the last step (publishView) again.
What we tried
After reading through the documentation and issues connected to this, we figured the option reset might help us. However, if we try to add type='reset' to the props of creationTab, when pressing the tab, all other tab icons disappear (as documented in this issue).
So instead, we then tried to set the type of our push from publishView to recordingView to reset, but that also did not work (although the right action is dispatched and the back button is removed on the new scene, when hitting the recordingTab icon again, we still get back to our old publishView).
We also though about using Switches, to unmount the components but it doesn't seem like this is how they were intended to be used...
Versions
react-native: 0.30.0
react-native-router-flux: 3.32.0
We're now getting a bit desperate after days spent on issues like this and similar ones and I am not sure how we should proceed. Has anybody experienced similar problems or found a solution?
I faced the same issue. As a temporary workaround, I do not use the reset option but instead follow the redirection immediately with a pop action.
In my case, my view is only one level deep so this is not too dirty. I'll look for a cleaner solution but I hope it can help in the meantime.
react-native: 0.35.0-rc
react-native-router-flux: 3.35.0

What is the best way to display and interact with a skill tree

I am trying to create an interface that is similar to the interface on this website for the skill tree: http://www.pathofexile.com/passive-skill-tree. What is the best way to go about doing this and have the same or similar user interaction. ie. you click on a node and it activate or deactivates it. The movement of the tree and zooming on it would be nice as well. Would like to try to stay away from webView as I am thinking about features I want to add. Thanks in advance just want to see what a good way to do this is.
you can use webView and have almost a copy-paste of the presented webpage html source and load it.
However with native components you can have better performance, but it will "not a copy"
Native componets:
IIViewDeckController for iOS
iHasApp for iOS
iHasApp for iOS
There are more on that side. Consider a combination of they,

Getting the screen position of a non-view based NSStatusItem

My application makes use of an NSStatusItem. I need to grab the screen coordinates for the status item, but since I have no need for the functionality offered by setting a custom view for the item I am using a standard icon-based one instead.
Is there a way to get the status item's position without having to resort to setting a custom view to it?
Unless you find a better way, you could use some undocumented API: - (id)_window of NSStatusItem probably returns the window enclosing the item itself. Maybe you can get some interesting information out of that?
Beware: Some fundamentalists might actually try to break your neck for using undocumented API. Just make sure you check regularly if this portion of your code works with newer OS versions (either by hand or using some unit tests).