Git Product home page Git Product logo

dropdowngridmenu's People

Contributors

ochornenko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

vidhya-sagar-mm

dropdowngridmenu's Issues

Automatic change in the items of Dropdown Grid Menu

I am trying to deselect an item when I already select the other, giving the attribute isSelected = false, but this does not change the view from selected to deselected

menu.presentPopover(self, appear: .fromTop, sender: sender, items: itemsCalendar, itemSize: itemSize, contentSize: contentSize, action: { item in
            if item.isSelected {
                let index = self.getIndex(value: item.text)
                menu.dismissPopover()
                self.dismiss(animated: true, completion: nil)
                self.itemSelected = item.text
                for item2 in self.itemsCalendar {
                    print(self.itemSelected)
                    print(item2.text)
                    print(item2.isSelected)
                    print("##############")
                    
                    if item2.text != self.itemSelected{
                        item2.isSelected = false
                    }else{
                        item2.isSelected = true
                    }
                    
                    print(self.itemSelected)
                    print(item2.text)
                    print(item2.isSelected)
                    print("##############")
                }
                
                self.switchCalendar(index: index)
            } else {
                print("item deselected at index \(self.getIndex(value: item.text))")
            }
        }

In the itemsCalendar variable I have the 2 items that I show, in the itemSelected global variable I store the name of the item that I select, so that I can later make the change. With the prints it apparently makes the change but not visually.
Result of the prints:

Week
Day
false
##############
Week
Week
true
##############

This means, select Week, I'm looping through the Day item and it's not selected. In the following cycle I continue as a Week selection, I am going through the Week item and it is selected.

By default the first thing that is selected is day.
imagen

When making the change to Week it shows me like this.
imagen

Problem closing menu

I think it could be great if you add the possibility of close the menu programmatically and not just using the gestures. I did it by modifying the code a little bit by changing the variable menuController to a class attribute and creating a method called dismissPopover at DropdownGridMenu.
static var menuController = DropdownGridMenuController() ... public static func dismissPopover(){ menuController.dismissPopover() }
Then at the controller I created the method
func dismissPopover(){ self.leaveTheStage { self.dismiss(animated: true, completion: { self.completion?() }) } }
I don´t know if it is the best way to do it but it works.

Thank you for your Dropdown!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.