Skip to content
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

Request one controller or method that use to close dialog box or dropdown dialog #94

Closed
krButani opened this issue Dec 5, 2022 · 9 comments

Comments

@krButani
Copy link

krButani commented Dec 5, 2022

hi,

We need a controller or method which is used to close the dialog box or dropdown dialog. For example, as per attachment screen a short dropdown dialog is open when I click on a floating button, we want to close the dropdown dialog.

change

@lcuis
Copy link
Owner

lcuis commented Dec 5, 2022

Hi @krButani ,

Thanks for your request.

As there are some menu mode examples on the readme with close and done buttons, I assume you need the button to be outside the Widget. Is this correct?

@krButani
Copy link
Author

krButani commented Dec 5, 2022

you are right but this is example we are working on big application and clients wants to close automatically. real application we are not using any close button. for example, first control is search_choise that user open like attachment to select country and then next control is TextFormField. When user click On TextFormField that time we need to close search_choise if its open. so, that why need a controller or method to close

@lcuis
Copy link
Owner

lcuis commented Dec 5, 2022

Oh, I see.
Then, I prepared an example that will probably not really help you as it relies on a button:

Column(
        children: [
          closeButton,
          SearchChoices.single(
            items: items,
            value: selectedValueSingleMenu,
            hint: "Select one",
            searchHint: null,
            onChanged: (value) {
              setState(() {
                selectedValueSingleMenu = value;
              });
            },
            dialogBox: false,
            isExpanded: true,
            menuConstraints: BoxConstraints.tight(const Size.fromHeight(350)),
            buildDropDownDialog: (
                Widget titleBar,
                Widget searchBar,
                Widget list,
                Widget closeButton,
                BuildContext dropDownContext,
                ) {
              Future.delayed(Duration(milliseconds: 400)).whenComplete((){
                setState(() {
                  this.closeButton=closeButton;
                });
              });
              return (AnimatedContainer(
                padding: MediaQuery.of(dropDownContext).viewInsets,
                duration: const Duration(milliseconds: 300),
                child: SizedBox(
                  height: 400,
                  child: Card(
                    margin: const EdgeInsets.symmetric(vertical: 30, horizontal: 40),
                    child: Container(
                      padding:
                      const EdgeInsets.symmetric(vertical: 35, horizontal: 45),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.start,
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisSize: MainAxisSize.min,
                        children: <Widget>[
                          titleBar,
                          searchBar,
                          list,
                          // closeButton,
                        ],
                      ),
                    ),
                  ),
                ),
              ));
            },
          ),
        ],
      )

I will need to think of another solution to your request.

@krButani
Copy link
Author

krButani commented Dec 5, 2022

but without user pressing its work?

@lcuis
Copy link
Owner

lcuis commented Dec 5, 2022

I don't think the above example will really help you as it relies on a button that the user needs to press.

The following example, however, is a better starting point.
It lets you assign a closeFn Function from onChanged parameter called pop.

However, I don't know why yet, it seems to only work when the selected value is empty:

Column(
        children: [
          closeFn==null?SizedBox.shrink():ElevatedButton(
            child: Text("Close"),
            onPressed: (){
              closeFn!();
            },
          ),
          SearchChoices.single(
            items: items,
            value: selectedValueSingleMenu,
            hint: "Select one",
            searchHint: null,
            onChanged: (value,Function pop) {
              closeFn=pop;
              setState(() {
                selectedValueSingleMenu = value;
              });
            },
            dialogBox: false,
            isExpanded: true,
            menuConstraints: BoxConstraints.tight(const Size.fromHeight(350)),
            buildDropDownDialog: (
                Widget titleBar,
                Widget searchBar,
                Widget list,
                Widget closeButton,
                BuildContext dropDownContext,
                ) {
              return (AnimatedContainer(
                padding: MediaQuery.of(dropDownContext).viewInsets,
                duration: const Duration(milliseconds: 300),
                child: SizedBox(
                  height: 400,
                  child: Card(
                    margin: const EdgeInsets.symmetric(vertical: 30, horizontal: 40),
                    child: Container(
                      padding:
                      const EdgeInsets.symmetric(vertical: 35, horizontal: 45),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.start,
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisSize: MainAxisSize.min,
                        children: <Widget>[
                          titleBar,
                          searchBar,
                          list,
                          // closeButton,
                        ],
                      ),
                    ),
                  ),
                ),
              ));
            },
          ),
        ],
      )

I will try to get back to this question as soon as possible. It may not be today, I am sorry for the delay in advance.

@lcuis
Copy link
Owner

lcuis commented Dec 5, 2022

Hi @krButani ,

I was not able to make the example above work so I added a new parameter: giveMeThePop

Once released, this version will allow you to run the following example:

      Column(
        children: [
          closeFn==null?SizedBox.shrink():ElevatedButton(
            child: Text("Close"),
            onPressed: (){
              closeFn!();
            },
          ),
          SearchChoices.single(
            giveMeThePop: (Function pop){closeFn=pop;},
            items: items,
            value: selectedValueSingleMenu,
            hint: "Select one",
            searchHint: null,
            onChanged: (value,Function pop) {
              setState(() {
                selectedValueSingleMenu = value;
              });
            },
            dialogBox: false,
            isExpanded: true,
            menuConstraints: BoxConstraints.tight(const Size.fromHeight(350)),
            buildDropDownDialog: (
                Widget titleBar,
                Widget searchBar,
                Widget list,
                Widget closeButton,
                BuildContext dropDownContext,
                ) {
              return (AnimatedContainer(
                padding: MediaQuery.of(dropDownContext).viewInsets,
                duration: const Duration(milliseconds: 300),
                child: SizedBox(
                  height: 400,
                  child: Card(
                    margin: const EdgeInsets.symmetric(vertical: 30, horizontal: 40),
                    child: Container(
                      padding:
                      const EdgeInsets.symmetric(vertical: 35, horizontal: 45),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.start,
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisSize: MainAxisSize.min,
                        children: <Widget>[
                          titleBar,
                          searchBar,
                          list,
                          // closeButton,
                        ],
                      ),
                    ),
                  ),
                ),
              ));
            },
          ),
        ],
      ),

Please note that this will not work until I release version 2.1.8 once I successfully run the automated integration tests. I will let you know here when this is done.

lcuis added a commit that referenced this issue Dec 5, 2022
@lcuis
Copy link
Owner

lcuis commented Dec 5, 2022

The above example should now work as version 2.1.8 is now released.

@krButani
Copy link
Author

krButani commented Dec 6, 2022

Oh Yes it done. @lcuis thank you.

@krButani krButani closed this as completed Dec 6, 2022
@lcuis
Copy link
Owner

lcuis commented Dec 6, 2022

Thanks for the confirmation @krButani !

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

No branches or pull requests

2 participants