ochornenko / dropdowngridmenu Goto Github PK
View Code? Open in Web Editor NEWDropdown grid menu for iOS written in Swift.
License: MIT License
Dropdown grid menu for iOS written in Swift.
License: MIT License
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.
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.