Three Level Accordian View for IOS

Overview

ThreeLevelAccordian

CI Status Swift Version License Platform

ThreeLevelAccordian is a three level accordian for IOS. It owes its base code to SwiftyAccordionCells. Most of the design is customisable. It goes till three levels. You can customise the font, color, background color of items, add image to them etc. The innermost items can be multiline too. If an element does not have any child elements, expand icon is not shown against them.

alt tag alt tag

alt tag alt tag

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

ios 8.0+

Installation

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

pod "ThreeLevelAccordian"

##Basic Usage There are three types of cells for three levels of Arcadian: 1) TLAHeaderItem: This is the highest level cell. 2) TLACell: This is the second level cell. 3) TLASubItem: This is the innermost cell.

Setup your tableView whichever way you want before initializing ThreeLevelAccordian. If you wish, you can set the background color 	   and other properties, and they will be retained if you do not override them with options.

Find the basic code below:

import ThreeLevelAccordian

class ViewController: UIViewController, TLADelegate {
	@IBOutlet weak var tableView: UITableView!
		var cells = [TLACell]()
	var delegateController: TLAViewController! //This is very very important

		override func viewDidLoad() {
    		super.viewDidLoad()
		
		//Populating data
		cells.append(TLAHeaderItem(value: "Header1", imageURL: "headerImage1"))
    		cells.append(TLACell(value: "Middle item1", imageURL: "cellImage1"))
    		cells.append(TLASubItem(value: "Lower item1", imageURL: "subItemImage1"))
    		cells.append(TLACell(value: "Middle item2", imageURL: "cellImage2"))
    		cells.append(TLASubItem(value: "Lower item2", imageURL: "subItemImage2"))
   			cells.append(TLACell(value: "Middle item3", imageURL: "cellImage3"))

		cells.append(TLAHeaderItem(value: "Header2", imageURL: "headerImage2"))
		cells.append(TLACell(value: "Middle item21", imageURL: "cellImage2"))
		cells.append(TLASubItem(value: "Lower item21", imageURL: "subItemImage2"))
		cells.append(TLACell(value: "Middle item22"))

		//Customisation properties..This part is optional
		 let options: [TLAOption] = [
		 		.CellBackgroundColor(UIColor.whiteColor()),
                                   	.CellColor(textColor),
                                  	.CellFont(UIFont(name: "HelveticaNeue-Medium", size: 14.0)!),
                                   	.CellHeight(44.0),
                                   	.UseSingleValues(true),
                                   
                                   .UseAccessoryIcons(true),
                                   .ExpandIcon(UIImage(named: "MyExpandIcon.png")!),
                                   .CollapseIcon(UIImage(named: "MyCollapseIcon.png")!),
		 ]
		 
		//Not optional :) 
		//Specify for cell reuse identifier here
		let threeLevelAccordian = ThreeLevelAccordian.init(cells: cells, options: options, reuseIdentifier: 					"checklistAccordianCell") 
		threeLevelAccordian.delegate = self
		
		//The next three lines are extremely important
		delegateController = threeLevelAccordian.controller
		tableView.dataSource = delegateController
		tableView.delegate = delegateController
		
		tableView.reloadData()
	}
	
	//Delegate function
	func didSelectItemAtIndex(index: Int) {
		let alertController = UIAlertController(title: "Clicked", message: "Clicked \(index)", preferredStyle: 					UIAlertControllerStyle.Alert)
		alertController.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Cancel, handler: nil))
		self.presentViewController(alertController, animated: true, completion: nil)
		}
}

Customisations

You can either specify single customisation values for all cell types through the parameters given below:
1) CellBackgroundColor
2) CellColor: Text color
3) CellHeight
4) CellFont
If you want to apply these values, make sure you mark UseSingleValues to true

You can also provide cell type specific customisations. The names are self explanatory.
For TLAHeaderItem
1) HeaderTextFont
2) HeaderTextColor
3) HeaderCellBackgroundColor
4) HeaderCellHeight

For TLACell
1) ItemTextFont
2) ItemTextColor
3) ItemCellBackgroundColor
4) ItemCellHeight

For TLASubItem
1) SubItemTextFont
2) SubItemTextColor
3) SubItemCellBackgroundColor
4) SubItemCellHeighti
5) IsMultiline: Mark this as true if you are expecting your text to be too big for a single line.

Also, if you want default styling that comes with tables, you can pass options as nil.	

There is expand and collapse icons shown on default for appropriate rows (that is, if the row can be expanded or needs to be collapsed). You can turn it off or set your own icons for expand or collapse. Parameters for the same are:
1) UseAccessoryIcons: mark false if you do not want to show expand/collapse icons
2) ExpandIcon
3) CollapseIcon

You can use these options as shown in the Basic Usage section.

Author

Amrata Baghel, [email protected]

License

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

You might also like...
JustLog brings logging on iOS to the next level. It supports console, file and remote Logstash logging via TCP socket with no effort. Support for logz.io available.
JustLog brings logging on iOS to the next level. It supports console, file and remote Logstash logging via TCP socket with no effort. Support for logz.io available.

JustLog JustLog takes logging on iOS to the next level. It supports console, file and remote Logstash logging via TCP socket with no effort. Support f

Aplikasi iOS Advanced Level To Do List dengan Firebase Auth, SwiftUI, MVVM Design Pattern, dan Firebase Firestore

Aplikasi Tasker adalah aplikasi iOS To Do List yang dibuat menggunakan Autentikasi Firebase / Firestore dan MVVM Design Pattern.

A simple iOS app to simulate a laser level using built-in camera and gyroscope.
A simple iOS app to simulate a laser level using built-in camera and gyroscope.

Laser Level A simple iOS app to simulate a laser level using built-in camera and gyroscope. Demo https://youtu.be/aB03EtQ5zsU Usage Download Open .xco

Bond is a Swift binding framework that takes binding concepts to a whole new level.

Bond, Swift Bond Update: Bond 7 has been released! Check out the migration guide to learn more about the update. Bond is a Swift binding framework tha

A type-safe, high-level networking solution for Swift apps
A type-safe, high-level networking solution for Swift apps

What Type-safe network calls made easy Netswift offers an easy way to perform network calls in a structured and type-safe way. Why Networking in Swift

Framework-level dependency graph generator for Xcode projects - with support for custom graphing
Framework-level dependency graph generator for Xcode projects - with support for custom graphing

XCGrapher xcgrapher is, by default, a framework-level dependency graph generator for Xcode projects. It works by reading local clones of the source, s

 Postie - The Next-Level HTTP API Client using Combine
Postie - The Next-Level HTTP API Client using Combine

Postie - The Next-Level HTTP API Client using Combine Postie is a pure Swift library for building URLRequests using property wrappers.

Bolts is a collection of low-level libraries designed to make developing mobile apps easier.

Bolts Bolts is a collection of low-level libraries designed to make developing mobile apps easier. Bolts was designed by Parse and Facebook for our ow

Bolts is a collection of low-level libraries designed to make developing mobile apps easier.

Bolts in Swift Bolts is a collection of low-level libraries designed to make developing mobile apps easier. Bolts was designed by Parse and Facebook f

Robust CloudKit synchronization: offline editing, relationships, shared and public databases, field-level deltas, and more.
Robust CloudKit synchronization: offline editing, relationships, shared and public databases, field-level deltas, and more.

CloudCore CloudCore is a framework that manages syncing between iCloud (CloudKit) and Core Data written on native Swift. Features Leveraging NSPersist

YTKNetwork is a high level request util based on AFNetworking.

YTKNetwork What YTKNetwork is a high level request util based on AFNetworking. It's developed by the iOS Team of YuanTiKu. It provides a High Level AP

DL4S provides a high-level API for many accelerated operations common in neural networks and deep learning.
DL4S provides a high-level API for many accelerated operations common in neural networks and deep learning.

DL4S provides a high-level API for many accelerated operations common in neural networks and deep learning. It furthermore has automatic differentiati

A quick reference cheat sheet for common, high level topics in Swift.

Swift 3+ Cheat Sheet Want to help improve this? File an issue or open a pull request! :) This is not meant to be a beginner's guide or a detailed disc

A quick reference cheat sheet for common, high level topics in Objective-C.

Objective-C Cheat Sheet This is not meant to be a beginner's guide or a detailed discussion about Objective-C; it is meant to be a quick reference to

The world's top-level live sdk...

目录结构说明 本目录包含 iOS 版 移动直播 SDK 的 Demo 源代码,主要演示接口如何调用以及最基本的功能。 ├─ MLVB-API-Example-OC // MLVB API Example,包括直播推流,直播播放,互动直播 | ├─ App

Use any custom view as custom callout view for MKMapView with cool animations. Use any image as annotation view.
Use any custom view as custom callout view for MKMapView with cool animations. Use any image as annotation view.

MapViewPlus About MapViewPlus gives you the missing methods of MapKit which are: imageForAnnotation and calloutViewForAnnotationView delegate methods.

SwiftMessages is a very flexible view and view controller presentation library for iOS.
SwiftMessages is a very flexible view and view controller presentation library for iOS.

SwiftMessages Overview SwiftMessages is a very flexible view and view controller presentation library for iOS. Message views and view controllers can

PBCircularProgressView is a circular progress view for iOS similar to the app store download progress view.
PBCircularProgressView is a circular progress view for iOS similar to the app store download progress view.

Overview PBCircularProgressView is a circular progress view for iOS similar to the app store download progress view. It also ha

Transition from any SwiftUI Text view into an inline navigation bar title when the view is scrolled off-screen, as seen in Apple's TV & TestFlight iOS apps.
Transition from any SwiftUI Text view into an inline navigation bar title when the view is scrolled off-screen, as seen in Apple's TV & TestFlight iOS apps.

SwiftUI Matched Inline Title Transition from any SwiftUI Text view into an inline navigation bar title when the view is scrolled off-screen, as seen i

Owner
Amrata Baghel
Backend engineer, iOS(Swift) and android app developer.
Amrata Baghel
Make your table view expandable just by implementing one method.

ExpyTableView About ExpyTableView is a re-write based on SLExpandableTableView. Takes some ideas, concepts and codes and regenerates them in Swift. Le

Okhan Okbay 359 Dec 27, 2022
Swift library to support collapsible sections in a table view.

CollapsibleTableSectionViewController A Swift library that helps you collapse table view sections. Features Support collapsible sections in a table vi

Su 349 Dec 18, 2022
`SimpleExpandableView` is a SwiftUI view which can collapse and expand the content

SimpleExpandableView 中文说明 ExpandableView structure Example ExpandableView( headerSize: CGSize(width: 250.0, height: 50.0), cardSize: CGSize(wi

Tomortec 5 Oct 6, 2022
✨ Awesome expandable, collapsible tableview cell for iOS written in Swift 4

USE ExpandableCell. New version of this library. YNExpandableCell Updates See CHANGELOG for details Intoduction Easiest usage of expandable & collapsi

Kyle Yi 457 Dec 26, 2022
✨ Awesome expandable, collapsible tableview cell for iOS written in Swift 5

ExpandableCell Intoduction Fully refactored YNExapnadableCell with more concise, bug free. Easiest usage of expandable & collapsible cell for iOS, wri

Kyle Yi 728 Jan 1, 2023
Spin aims to provide a versatile Feedback Loop implementation working with the three main reactive frameworks available in the Swift community (RxSwift, ReactiveSwift and Combine)

With the introduction of Combine and SwiftUI, we will face some transition periods in our code base. Our applications will use both Combine and a thir

Spinners 119 Dec 29, 2022
Whisper is a component that will make the task of display messages and in-app notifications simple. It has three different views inside

Description ?? Break the silence of your UI, whispering, shouting or whistling at it. Whisper is a component that will make the task of displaying mes

HyperRedink 3.7k Dec 25, 2022
JDVideoKit - You can easily transfer your video into Three common video type.

JDVideoKit Introduction You can easily transfer your video into Three common video type. You can use set up camera easily. Installation pod 'JDVideoK

郭介騵 24 Sep 9, 2021
ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation

ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation. Demo Requirements iOS 9.0+ Xcode 8 Insta

Yansong Li 775 Dec 7, 2022
A Swift library to take the power of UIView.animateWithDuration(_:, animations:...) to a whole new level - layers, springs, chain-able animations and mixing view and layer animations together!

ver 2.0 NB! Breaking changes in 2.0 - due to a lot of requests EasyAnimation does NOT automatically install itself when imported. You need to enable i

Marin Todorov 3k Dec 27, 2022