Auto hide bottom sheet when value changes from Firestore stream - flutter

I have a modal bottom sheet open waiting for a player to join a game via a code. I have a stream set up in my controller. When the player joins, I get the name of the other player. Once I get this name, I want to programmatically dismiss the bottom sheet so that the game can begin.
How can I do this, please?

If the modal is on top, you can simply call the following to close it:
Navigator.of(context).pop();
So, call this whenever you receive your data.

Related

How to close Slidable automatically in 1 second?

I am using flutter_slidable and it works well, but I would like to make that when you slide a item, automatically it returns at the original position (close) after 1 second.
And only keep opened when a bool change.
Is there any option or a way to do ir programatically?
Thanks.
Please try to read the documentation, last section is talking about your need:
How can I open the Slidable programmatically?
You can open or close the Slidable programmatically by calling the open or close method of the SlidableState. The easiest way get the SlidableState from a child is to call Slidable.of(context).
The open method has an optional parameter called actionType that let you choose which action pane to open.
How can I dismiss the Slidable programmatically?
Similar to opening or closing, you can dismiss the Slidable programmatically by calling the dismiss method of the SlidableState.
If you want to use the dismiss method without allowing your user to slide to dismiss, you can set the dragDismissible parameter of the SlidableDismissal constructor to false.
You can use this with await Future.delayed(Duration(seconds: 1),(){ //open or close });

Hide back button

I'm working on my 1st real game. I have 2 view controllers. The 1st one has an animated picture, and the player can enter there names. The 2nd one is displaying the game. After the game is over the player can play again or reset. The reset takes them back to the 1st VC so they can give new names. My question is how do I hide the reset until I need it. To put it there I made a button and command dragged it to the 1st VC and selected show.
Thanks for any information you might be able to give me.
If you are using iOS predefined back button then try like this:-
navigationItem.hidesBackButton = true
or if you have just dragged and drop the UIBarbutton then create the outlet and hide/show it accordingly.
If you have an outlet variable to your reset button, you can change the isHidden property of it to true or false appropriately.

What is the view or thing called that pops up in the photos app when you click the leftmost button at the bottom of the screen on the iPhone?

I want to implement this on my app. I want to search for tutorials on this topic but I don't know what its called. Can someone please tell me what its called? Eg. In the photos app in iPhone, when u click on the left most button at the bottom, a screen pops up from the bottom giving you options to either email image, set as wallpaper etc.. So, once again, what is this called? Thanks
That is a UIActionSheet. Check out the UIActionSheet Class Reference.
Basically you create one with the designated initializer -initWithTitle:delegate:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles: then send the -showInView: message to display it. You'll have to set yourself as it's delegate in order to handle selections made by the user.
The button is the 'action' barButtonItem type.
The button then opens a modal sheet. Opened with something like:
[self presentModalViewController:menuViewController animated:YES];

Is it possible to show two alert views on screen at the same time?

When I click a button on an alert view I would like to show another alert view while at the same time keeping the original alert view on screen. At the moment, the original alert view is closed.
Is this possible?
As Vladimir, put it you better don't try working in this direction. This is not certainly going to be good for the users.

Change UIActionSheet after doing it's job

I have to import some XML data into my app.
Now I open a UIActionSheet and add as a subview a UIActivityIndicatorView. Initially I show a progress wheel and a button with 'Cancel'.
When the XML has been imported, I want to hide the progress wheel (this it's easy) and change the button into a 'Done' button, all in the same UIActionSheet.
What I'm doing now is closing the UIActionSheet with the option dismissWithClickedButtonIndex, but I don't like this way because it's the same as pressing 'Cancel', and then I show an UIAlertView displaying "All data has been imported".
Is this possible ?
You shouldn't be doing that, when it loads correctly just dismiss the ActionSheet. On the other hand if an error occurs then display an alert.
Think about the user who will use the app multiple times a day, a Done message each time will be a waste of time.
UPDATE
As i understand your goal is to use the ActionSheet just as a popup (with Cancel ability), if so, just call dismissWithClickedButtonIndex:animated: when your XML loading is done.
If its successful then just call the dismiss method, if its unsuccessful then call the dismiss and popup an alert
This is a bit of a hack but should work. Note that there is a good chance that this will result in your app not being accepted into the app store as you're messing around with the action sheet in ways Apple didn't intend.
Initially display the action sheet with both the 'Done' and 'Cancel' buttons. Before displaying the sheet hide the 'Done' button using its hidden property. To see how to access the 'Done' button see this question.
Then when you're hiding the UIActivityIndicatorView, also change the hidden property of both the 'Cancel' and 'Done' buttons, so that the 'Done' button becomes visible. If the 'Done' button appears in the wrong position move it by modifying its centre property.