Skip to content

srujanadicharla/SASelectionView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SASelectionView

license ios v1.9.3

A lightweight single selection view that slides up from bottom of the screen.

  • Easy to use
  • Sectioned rows
  • Auto adjusting selection view height
  • Auto displying searchbar based on the number of items. (you can hide/show searbar manually too)
  • Gesture control to drag down to dismiss

A list showing cities (rows) of respective states (sections)

Requirements

SASelectionView works on iOS 9 and higher. It depends on the following Apple frameworks, which should already be included with most Xcode templates:

  • Foundation
  • UIKit

Installation

CocoaPods

You can use CocoaPods to install SASelectionView by adding it to your Podfile:

pod 'SASelectionView'

Manually

  • Download and extraxt zip file.
  • Drag and drop Source folder in your project.
  • Done!

Example

import SwiftUI
import SASelectionView

struct ContentView: View {
    
    @State private var selectedText = ""
    
    var body: some View {
        VStack {
            Button(action: {
                self.showSelectionView()
            }) {
                Text("Show List")
            }
            .padding(EdgeInsets(top: 0, leading: 0, bottom: 12, trailing: 0))
            
            Text(selectedText)
        }
        
    }
    
    func showSelectionView() {
        var sections = [SectionItem]()
        sections.append(SectionItem(title: "Texas", options: ["Dallas", "Houston", "Austin", "San Antonio"]))
        sections.append(SectionItem(title: "California", options: ["Los Angeles", "San Francisco", "Sacramento", "San Diago"]))
        sections.append(SectionItem(title: "New York", options: ["New York City", "Albany", "Buffalo"]))
        sections.append(SectionItem(title: "Florida", options: ["Miami", "Orlando", "Jacksonville", "Key West"], disabledIndices: [3:[1,3]]))

        SASelectionView.show(title: "Locations", sections: sections, showSearchBar: true, emptySearchRowTitle: "Item not found. Add this ...", emptyRowHandler: { (notFoundText) in
            print("Not found result: \(notFoundText)")
            self.selectedText = notFoundText
        }) { (section, row, value) in
            self.selectedText = "\(value), \(sections[section].title ?? "")"
        }
    }
}

#if DEBUG
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
#endif

Contribute

If you have feature requests or bug reports, please feel free to help out by sending pull requests or create issues.

License

This code is distributed under the terms and conditions of the MIT license.

About

A slide-up view from bottom of the screen displaying multiple rows with the ability to select and search row. This library is written in Swift.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published