Code Monkey home page Code Monkey logo

material-design-search-ui-ios's Introduction

Material Design Search UI iOS

Material design styled search UI consists of search bar and search results view.

Generic badge Generic badge Generic badge Generic badge

overview

You may see the following Medium articles for detailed explanation of developing these UI widgets.

Key Features

  • A Material Design search bar with delegation method for view controller use.
  • A Material Design and enum-driven search results view that clearly defines results view states.
  • Widget classes are made to be open, which gives you flexibility to create your own.
  • A simple location searching application using the above two widgets is included in the project.

Requirements

  • Swift 5.0
  • iOS 11.0+

Usage

Search bar

Declaration

var searchbar: Searchbar!
searchbar = Searchbar(
    onStartSearch: {
        // Your implementation
    },
    onClearInput: { 
        // Your implementation
    },
    delegate: self
)

Delegate methods

extension MainViewController: SearchbarDelegate {

    func searchbarTextDidChange(_ textField: UITextField) {
    
    }
    
    func textFieldDidBeginEditing(_ textField: UITextField) {
    
    }

    func textFieldDidEndEditing(_ textField: UITextField) {
    
    }

    func searchbarTextShouldReturn(_ textField: UITextField) -> Bool {
        return true
    }
}

button

Search results view

Declaration

var searchResultsView: SearchResultsView!
searchResultsView = SearchResultsView(didSelectAction: { 
    // Your implementation
})

button

Load data into results view

searchResultsView.update(newPlacemarks: placemarks, error: error)

Note: I use CLPlacemark here, you can change to whatever data type you'd like to use in your app.

Credits

material-design-search-ui-ios's People

Contributors

twho 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

Watchers

 avatar  avatar  avatar  avatar

material-design-search-ui-ios's Issues

Screen flicking when select a address from search result list

The issue was textFieldDidEndEditing getting called multiple times, cause the function 'viewMovedown' gets called multiple times -> animation multiple times.

Solution,

fire endEditing event only once, what I did was comment out code below in private func didSelectPlacemark()

//self.searchbar.textFieldDidEndEditing(self.searchbar.textInput)
// Dismiss search results view
//self.showSearchResultsView(false) //

then add self.searchbar.endEditing(true) in

// Configure searchResultsView
searchResultsView = SearchResultsView(didSelectAction: { [weak self] (placemark) in
guard let self = self else { return }
self.didSelectPlacemark(placemark)
self.searchbar.endEditing(true)
})

let me know if you want me push the changes.

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.