Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackjacx committed Aug 7, 2019
2 parents 0c2f97a + 0d36a9f commit 69a8b90
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 180 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

## [1.0.1] - 2019-08-07
* Publish DefaultSection initializer - [@Blackjacx](https://github.com/blackjacx).
* Embed Framework, Fix Examples, UIKit dependency - [@Blackjacx](https://github.com/blackjacx).

## [1.0.0] - 2019-08-07
* [#13](https://github.com/Blackjacx/Source/pull/13): Upgrade Project Structure - [@Blackjacx](https://github.com/blackjacx).
* Add AUTHORS file - [@Blackjacx](https://github.com/blackjacx).
Expand Down
174 changes: 84 additions & 90 deletions Example/Source/MultiSectionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,106 +12,100 @@ import Source
class MultiSectionViewController: UIViewController {

let table = UITableView()

var dataSource: Source = Source() {
didSet {
dataSource.dataSourceDidChangedClosure = { [weak self] (dataSource) in
guard let self = self else { return }
self.dataSource.registerCells(for: self.table)
self.table.reloadData()
}
dataSource.registerCells(for: table)
table.reloadData()
}
}
let dataSource = Source()

override func viewDidLoad() {

super.viewDidLoad()

let dataSource: Source = {
let source = Source()
let sections = [
MySection(models: [MyModel(title: "Mom"),
MyModel(title: "Dad"),
MyModel(title: "Brother"),
MyModel(title: "Mom"),
MyModel(title: "Dad"),
MyModel(title: "Brother"),
MyModel(title: "Mom"),
MyModel(title: "Dad"),
MyModel(title: "Brother"),
MyModel(title: "Mom"),
MyModel(title: "Dad"),
MyModel(title: "Brother")],
headerTitle: "Family",
footerTitle: nil),

MySection(models: [MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape"),
MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape"),
MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape"),
MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape")],
headerTitle: "Fruits",
footerTitle: nil),

// No header title -> no section index title
MySection(models: [MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape"),
MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape"),
MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape"),
MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape")],
headerTitle: nil,
footerTitle: nil),

MySection(models: [MyModel(title: "Vampire"),
MyModel(title: "Lycan"),
MyModel(title: "Clown"),
MyModel(title: "God"),
MyModel(title: "Djin"),
MyModel(title: "Vampire"),
MyModel(title: "Lycan"),
MyModel(title: "Clown"),
MyModel(title: "God"),
MyModel(title: "Djin"),
MyModel(title: "Vampire"),
MyModel(title: "Lycan"),
MyModel(title: "Clown"),
MyModel(title: "God"),
MyModel(title: "Djin"),
MyModel(title: "Vampire"),
MyModel(title: "Lycan"),
MyModel(title: "Clown"),
MyModel(title: "God"),
MyModel(title: "Djin")],
headerTitle: "Monsters",
footerTitle: nil)
]

source.collection = ModelCollection(with: sections)
return source
}()
self.dataSource = dataSource

table.dataSource = dataSource
table.delegate = self

table.tableFooterView = UIView()
table.addMaximizedTo(view)

setupDataSource()
}

private func setupDataSource() {

dataSource.dataSourceDidChangedClosure = { [weak self] (source) in
guard let self = self else { return }
source.registerCells(for: self.table)
self.table.reloadData()
}

let sections = [
DefaultSection(models: [MyModel(title: "Mom"),
MyModel(title: "Dad"),
MyModel(title: "Brother"),
MyModel(title: "Mom"),
MyModel(title: "Dad"),
MyModel(title: "Brother"),
MyModel(title: "Mom"),
MyModel(title: "Dad"),
MyModel(title: "Brother"),
MyModel(title: "Mom"),
MyModel(title: "Dad"),
MyModel(title: "Brother")],
headerTitle: "Family",
footerTitle: nil),

DefaultSection(models: [MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape"),
MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape"),
MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape"),
MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape")],
headerTitle: "Fruits",
footerTitle: nil),

// No header title -> no section index title
DefaultSection(models: [MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape"),
MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape"),
MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape"),
MyModel(title: "Apple"),
MyModel(title: "Banana"),
MyModel(title: "Grape")],
headerTitle: nil,
footerTitle: nil),

DefaultSection(models: [MyModel(title: "Vampire"),
MyModel(title: "Lycan"),
MyModel(title: "Clown"),
MyModel(title: "God"),
MyModel(title: "Djin"),
MyModel(title: "Vampire"),
MyModel(title: "Lycan"),
MyModel(title: "Clown"),
MyModel(title: "God"),
MyModel(title: "Djin"),
MyModel(title: "Vampire"),
MyModel(title: "Lycan"),
MyModel(title: "Clown"),
MyModel(title: "God"),
MyModel(title: "Djin"),
MyModel(title: "Vampire"),
MyModel(title: "Lycan"),
MyModel(title: "Clown"),
MyModel(title: "God"),
MyModel(title: "Djin")],
headerTitle: "Monsters",
footerTitle: nil)
]
dataSource.collection = ModelCollection(with: sections)
}

// MARK: - Actions
Expand Down
17 changes: 0 additions & 17 deletions Example/Source/MySection.swift

This file was deleted.

44 changes: 18 additions & 26 deletions Example/Source/SimpleExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,36 @@ import Source
class SimpleExampleViewController: UIViewController {

let table = UITableView()

var dataSource: Source = Source() {
didSet {
dataSource.dataSourceDidChangedClosure = { [weak self] (dataSource) in
guard let self = self else { return }
dataSource.registerCells(for: self.table)
self.table.reloadData()
}
dataSource.registerCells(for: table)
table.reloadData()
}
}
let dataSource = Source()

override func viewDidLoad() {

super.viewDidLoad()

let dataSource: Source = {
let source = Source()
let models = [
MyModel(title: "Einstellungen", didTap: { (sender) in print("Einstellungen") }),
MyModel(title: "Hilfe", didTap: { (sender) in print("Hilfe") }),
MyModel(title: "Logout", didTap: { (sender) in print("Logout") })
]
let section = MySection(models: models, headerTitle: nil, footerTitle: nil)
source.collection = ModelCollection(with: [section])
return source
}()
self.dataSource = dataSource

table.dataSource = dataSource
table.delegate = self

table.tableFooterView = UIView()
table.addMaximizedTo(view)

setupDataSource()
}

private func setupDataSource() {

dataSource.dataSourceDidChangedClosure = { [weak self] (source) in
guard let self = self else { return }
source.registerCells(for: self.table)
self.table.reloadData()
}

self.dataSource = dataSource
let models = [
MyModel(title: "Einstellungen", didTap: { (sender) in print("Einstellungen") }),
MyModel(title: "Hilfe", didTap: { (sender) in print("Hilfe") }),
MyModel(title: "Logout", didTap: { (sender) in print("Logout") })
]
let section = DefaultSection(models: models)
dataSource.collection = ModelCollection(with: [section])
}
}

Expand Down
59 changes: 27 additions & 32 deletions Example/Source/SingleSectionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,43 @@ import Source
class SingleSectionViewController: UIViewController {

let table = UITableView()

var dataSource: Source = Source() {
didSet {
dataSource.dataSourceDidChangedClosure = { [weak self] (dataSource) in
guard let self = self else { return }
self.dataSource.registerCells(for: self.table)
self.table.reloadData()
}
dataSource.registerCells(for: table)
table.reloadData()
}
}
let dataSource = Source()

override func viewDidLoad() {

super.viewDidLoad()

let dataSource: Source = {
let source = Source()
var models = [
MyModel(title: "Einstellungen", didTap: { (sender) in print("Einstellungen") }),
MyModel(title: "Impressung", didTap: { (sender) in print("Impressum") }),
MyModel(title: "Empfehlen", didTap: { (sender) in print("Empfehlen") }),
MyModel(title: "Hilfe", didTap: { (sender) in print("Hilfe") }),
MyModel(title: "Logout", didTap: { (sender) in print("Logout") })
]
// Changing the connected cell class for all models. Alternatively you
// can just create a new model and set another default cell type.
for index in 0..<models.count {
models[index].cellType = MyDisclosureCell.self
}
let section = MySection(models: models, headerTitle: nil, footerTitle: nil)
source.collection = ModelCollection(with: [section])
return source
}()
self.dataSource = dataSource

table.dataSource = dataSource
table.delegate = self

table.tableFooterView = UIView()
table.addMaximizedTo(view)

setupDataSource()
}

private func setupDataSource() {

dataSource.dataSourceDidChangedClosure = { [weak self] (source) in
guard let self = self else { return }
source.registerCells(for: self.table)
self.table.reloadData()
}

var models = [
MyModel(title: "Einstellungen", didTap: { (sender) in print("Einstellungen") }),
MyModel(title: "Impressung", didTap: { (sender) in print("Impressum") }),
MyModel(title: "Empfehlen", didTap: { (sender) in print("Empfehlen") }),
MyModel(title: "Hilfe", didTap: { (sender) in print("Hilfe") }),
MyModel(title: "Logout", didTap: { (sender) in print("Logout") })
]
// Changing the connected cell class for all models. Alternatively you
// can just create a new model and set another default cell type.
for index in 0..<models.count {
models[index].cellType = MyDisclosureCell.self
}
let section = DefaultSection(models: models)
dataSource.collection = ModelCollection(with: [section])
}
}

Expand Down
Loading

0 comments on commit 69a8b90

Please sign in to comment.