-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrey Zonov
committed
Dec 20, 2017
1 parent
0887874
commit fd57ab1
Showing
13 changed files
with
254 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
ExpandableCell/View Controller/BasicDemoViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// | ||
// BasicDemoViewController.swift | ||
// ExpandableCell | ||
// | ||
// Created by Andrey Zonov on 19/12/2017. | ||
// Copyright © 2017 Andrey Zonov. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import AZExpandable | ||
|
||
class BasicDemoViewController: UIViewController { | ||
|
||
// MARK: IBOutlet's | ||
@IBOutlet private weak var tableView: UITableView! | ||
|
||
// MARK: Private Properties | ||
private var expandableTable: ExpandableTable! | ||
private var expandedCell: ExpandedCellInfo? | ||
|
||
// MARK: Lifecycle | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
CellFactory.registerCells(for: tableView) | ||
expandableTable = ExpandableTable(with: tableView, infoProvider: self) | ||
} | ||
|
||
private func toggleItem(at indexPath: IndexPath) { | ||
guard expandedCell?.indexPath != indexPath else { | ||
expandableTable.unexpandCell() | ||
expandedCell = nil | ||
return | ||
} | ||
|
||
// Construct your cell here | ||
let cellType: ExpandedCellInfo.CellType = .custom { [weak self] indexPath -> (UITableViewCell) in | ||
let centeredCell = self?.tableView.dequeueReusableCell(withIdentifier: "CenteredLabelCell", | ||
for: indexPath) as! CenteredLabelCell | ||
centeredCell.configure(with: "Hint Inside your custom cell") | ||
centeredCell.backgroundColor = .lightGray | ||
return centeredCell | ||
} | ||
let cell = ExpandedCellInfo(for: indexPath, cellType: cellType) | ||
expandedCell = cell | ||
expandableTable.expandCell(cell) | ||
} | ||
} | ||
|
||
// MARK: - UITableViewDataSource | ||
extension BasicDemoViewController: UITableViewDataSource { | ||
|
||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return 100 | ||
} | ||
|
||
func tableView(_ tableView: UITableView, | ||
cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
let cell = tableView.dequeueReusableCell(withIdentifier: "CenteredLabelCell", for: indexPath) as! CenteredLabelCell | ||
cell.configure(with: "Tap to reveal hint for \(indexPath.row) row") | ||
return cell | ||
} | ||
} | ||
|
||
// MARK: - UITableViewDelegate | ||
extension BasicDemoViewController: UITableViewDelegate { | ||
|
||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
toggleItem(at: indexPath) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.