Git Product home page Git Product logo

easydropdown's Introduction

Dropdowns

❤️ Support my app ❤️

❤️❤️😇😍🤘❤️❤️

Dropdown in Swift

Version License Platform Swift

Usage

Dropdowns provides the quickest way to present a dropdown in your app. It is very lightweight, just provide a list of items and the action closure you want to handle.

Basic

Dropdowns works by showing a child UIViewController as a dropdown from a TitleView. The most common use case is to show from a UINavigationController, in that sense, you can just create a list of items, and provide to TitleView.

let items = ["World", "Sports", "Culture", "Business", "Travel"]
let titleView = TitleView(navigationController: navigationController!, title: "Menu", items: items)
titleView?.action = { [weak self] index in
  print("select \(index)")
}

navigationItem.titleView = titleView

Customization

Dropdowns uses TableController by default, to show list of items in a UITableView. You can customise to show anything you want by using contentController.

let contentController = TableController(items: items, initialIndex: 0)
let dropdown = DropdownController(contentController: contentController, navigationController: navigationController)

Configuration

You can also customise many aspects of Dropdowns via Config

Config.List.DefaultCell.Text.color = UIColor.redColor()

Installation

Dropdowns is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Dropdowns'

Dropdowns is also available through Carthage. To install just write into your Cartfile:

github "onmyway133/Dropdowns"

Dropdowns can also be installed manually. Just download and drop Sources folders in your project.

Author

Credit

Contributing

We would love you to contribute to Dropdowns, check the CONTRIBUTING file for more info.

License

Dropdowns is available under the MIT license. See the LICENSE file for more info.

easydropdown's People

Contributors

onmyway133 avatar tokuriku avatar yonat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easydropdown's Issues

Problem on iOS 10.3 or low

I'm developing an app using Dropdowns the app works fine on my iOS version 11.4, but when i try on a device on version 10.3 the app gets lock i don't know why.

the scenery is this:
I have two options in my dropdown, when i check the second one (Ranking popularidad) the tableview reloads great and shows the information and you can scroll down and scroll up, then I do click on a cell and show the profile of the place, then when i get back clicking on the link Atrás the application get lock, any help

fullsizeoutput_66c
fullsizeoutput_66d
fullsizeoutput_66e

let titleView = TitleView ( navigationController: navigationController!, title: "", items: items, defaultIndex: 0)

`open class TitleView: UIView {

open var dropdown: DropdownController!
open var button: ArrowButton!
open var action: ((Int) -> Void)?

// MARK: - Initialization

public init?(navigationController: UINavigationController, title: String, items: [String], defaultIndex: Int) {
super.init(frame: CGRect.zero)

// Button
button = ArrowButton()
button.label.text = title
button.label.text = items[defaultIndex]
button.addTarget(self, action: #selector(buttonTouched(_:)), for: .touchUpInside)
addSubview(button)
self.layoutSubviews()

// Content
let contentController = TableController(items: items, initialIndex: defaultIndex )

// Dropdown
guard let dropdown = DropdownController(contentController: contentController, navigationController: navigationController)
  else { return nil }

self.dropdown = dropdown

contentController.action = { [weak self, weak dropdown] index in
  self?.button.label.text = items[index]
  self?.action?(index)
  self?.layoutSubviews()
  dropdown?.hide()
}

contentController.dismiss = { [weak dropdown] in
  dropdown?.hide()
}

dropdown.animationBlock = { [weak self] showing in
  self?.button.arrow.transform = showing
    ? CGAffineTransform(rotationAngle: CGFloat.pi) : CGAffineTransform.identity
}

}

public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

open override func layoutSubviews() {
super.layoutSubviews()
button.label.sizeToFit()
button.frame.size.height = 44
button.sizeToFit()
frame.size = button.frame.size
}

// MARK: - Action

@objc func buttonTouched(_ button: ArrowButton) {
dropdown.toggle()
}
}
`

have the problem in dropdown ( thread )

let titleView = TitleView(navigationController: navigationController!, title: "Menu", items: ["World", "Sports", "Culture", "Business", "Travel","jawad"]) here why ?

Fatal error: Unexpectedly found nil while unwrapping an Optional value

Layout issue iOS 11 xCode 9.4

Please change below in DropdownController

let offsetY = UIApplication.shared.statusBarFrame.size.height + navigationController.navigationBar.frame.height

Can't set initial index parameter

I am setting up Dropdowns in my project using cocoapods. But I can't see the initial index parameter to 'TitleView'. I guess it was added recently.
screen shot 2017-12-26 at 2 42 11 pm

background colour

hi, i am trying to change the color of the view that is behind the tableview that is now set to some sort of green (the view that u see when u scroll down). is there a way to do that?

set selected menu

The source you wrote is very useful to me
But, i have a question.
How can i set selected menu in programmatically?

Memory Leak on Background

Hi There,

When I enter in background mode my app crashes due memory leak. I Comment the following code:

let titleView = TitleView(navigationController: nav, title: company.company_name, items: companies)
            titleView?.button.label.textColor = .white
            titleView?.button.arrow.image = titleView?.button.arrow.image?.withRenderingMode(.alwaysTemplate)
            titleView?.button.arrow.tintColor = .white
            titleView?.action = { [weak self] index in
              print("select \(index)")
                let company_name = companies[index]
                let company = user.companies.filter({ $0.company_name == company_name }).first
                self?.selectedCompany = company
                titleView?.button.label.textColor = .white
                titleView?.button.arrow.image = titleView?.button.arrow.image?.withRenderingMode(.alwaysTemplate)
                titleView?.button.arrow.tintColor = .white
                AppSessionManager.shared.retrieveProducts = false
                AppSessionManager.shared.retrieveOrders = false
                NotificationCenter.default.post(name: NSNotification.Name(rawValue: "companyChange"), object: nil)
            }
            navigationItem.titleView = titleView

Now my app does not have memory leaks. What could be happening?

Best regards

app dies on orientation changing

So. I integrated Dropdowns into my project and it worked fine until I started to work on landscape orientations. Every time I try to change orientation of simulator or even real device - app freezes forever and takes 100% cpu. Was hard for me to detect what part of app does actually crash it, but after all I found that without Dropdowns app doesn't show that bug

Detecting when dropdown is showing

Hi, is there a way to detect if the dropdown menu is currently showing? (after the arrow button is pressed and before the selection is made).

Thanks,

Incompatible with Swift 4.1?

When I try to compile it and integrate it with Swift 4.1, I cannot import this module, since it was compiled with Swift 4.0.3.

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.