extract method for clarity

pull/1/head
Michael Kirk 7 years ago
parent e37a358580
commit ca1119e480

@ -81,12 +81,27 @@ class PhotoCollectionPickerController: OWSTableViewController, PhotoLibraryDeleg
}
}
// MARK: -
private func updateContents() {
photoCollections = library.allPhotoCollections()
let section = OWSTableSection()
for collection in photoCollections {
section.add(OWSTableItem.init(customCellBlock: { () -> UITableViewCell in
let sectionItems = photoCollections.map { collection in
return OWSTableItem(customCellBlock: { self.buildTableCell(collection: collection) },
customRowHeight: UITableViewAutomaticDimension,
actionBlock: { [weak self] in
guard let strongSelf = self else { return }
strongSelf.didSelectCollection(collection: collection)
})
}
let section = OWSTableSection(title: nil, items: sectionItems)
let contents = OWSTableContents()
contents.addSection(section)
self.contents = contents
}
func buildTableCell(collection: PhotoCollection) -> UITableViewCell {
let cell = OWSTableItem.newCell()
cell.backgroundColor = .ows_gray95
@ -126,16 +141,6 @@ class PhotoCollectionPickerController: OWSTableViewController, PhotoLibraryDeleg
stackView.ows_autoPinToSuperviewMargins()
return cell
},
customRowHeight: UITableViewAutomaticDimension,
actionBlock: { [weak self] in
guard let strongSelf = self else { return }
strongSelf.didSelectCollection(collection: collection)
}))
}
let contents = OWSTableContents()
contents.addSection(section)
self.contents = contents
}
@objc

Loading…
Cancel
Save