-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding preset controller and tools to make custom ones
- Loading branch information
Showing
10 changed files
with
216 additions
and
33 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// ManagerTableViewController.swift | ||
// Presentables_Example | ||
// | ||
// Created by Ondrej Rafaj on 25/04/2018. | ||
// Copyright © 2018 CocoaPods. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Presentables | ||
|
||
|
||
class ManagerTableViewController: PresentableTableViewController { | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
let section = PresentableSection() | ||
|
||
let header = Presentable<TableViewHeader>.create { (header) in | ||
header.titleLabel.text = "It works yet again!" | ||
} | ||
section.header = header | ||
|
||
let presentable = Presentable<TableViewCell2>.create({ (cell) in | ||
cell.textLabel?.text = "Custom cell" | ||
}).cellSelected { | ||
print("First cell has been selected") | ||
} | ||
section.presentables.append(presentable) | ||
|
||
data.append(section) | ||
|
||
presentableManager.selectedCell = { info in | ||
info.tableView.deselectRow(at: info.indexPath, animated: true) | ||
print("Did select cell no. \((info.indexPath.row + 1))") | ||
} | ||
} | ||
|
||
} |
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
30 changes: 30 additions & 0 deletions
30
Presentables/Classes/Table views/PresentableTableViewController.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,30 @@ | ||
// | ||
// PresentableTableViewController.swift | ||
// Presentables | ||
// | ||
// Created by Ondrej Rafaj on 25/04/2018. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
|
||
open class PresentableTableViewController: UITableViewController { | ||
|
||
public let presentableManager = PresentableTableViewDataManager() | ||
|
||
public var data: PresentableSections { | ||
get { return presentableManager.data } | ||
set { presentableManager.data = newValue } | ||
} | ||
|
||
// MARK: View lifecycle | ||
|
||
open override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
var manager: PresentableManager = presentableManager | ||
tableView.bind(withPresentableManager: &manager) | ||
} | ||
|
||
} |
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
25 changes: 25 additions & 0 deletions
25
Presentables/Classes/Table views/PresentableTableViewManageable.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,25 @@ | ||
// | ||
// PresentableTableViewManageable.swift | ||
// Presentables | ||
// | ||
// Created by Ondrej Rafaj on 25/04/2018. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
public protocol PresentableTableViewManageable { | ||
var tableView: UITableView { get } | ||
var presentableManager: PresentableTableViewDataManager { get } | ||
var data: PresentableSections { get set } | ||
} | ||
|
||
|
||
extension PresentableTableViewManageable { | ||
|
||
func bind() { | ||
var manager: PresentableManager = presentableManager | ||
tableView.bind(withPresentableManager: &manager) | ||
} | ||
|
||
} |
Oops, something went wrong.