Files
GitHawk/Classes/Search/SearchRecentHeaderSectionController.swift
Hesham Salman 1e2e0c1698 Chore/bookmark rewrite (#865)
* Unified store behavior, new bookmark model

- Added a `Store` protocol to the project with default implementations
  that should be sufficient for most models. (#855)
- Switched images in the notification type category to #imageLiterals,
  so we can avoid the optionality of the image.

* Implemented BookMark ViewModel

* Created Bookmark Collection Cell

* Created Bookmark View Controller

Done:
  - Displays empty state
  - Displays bookmarks
  - Allows for adding of new bookmarks
  - Navigating to bookmarks

In flight:
  - Clear All

TODO:
  - Search
  - Cleanup old files & remove SwipeCell hacks

* Unified search and clear all behavior

The search bar and clear all buttons between the search and bookmarks
page had different styles and behavior. This PR:
  - Makes a generic clear-all header
  - Gives one to each VC
  - Makes them behave the same to the user re: visibility etc

* Re-implemented filter

* Deleted old files

* Attributed String Sizing

* Removed bookmark store tests

* Reloading bookmarks & namespacing

Can now reload bookmarks through the listener pattern (#773, #783).
Bookmark store is now correctly namespaced again.
2017-11-06 09:03:29 -05:00

45 lines
1.5 KiB
Swift

//
// SearchRecentHeaderSectionController.swift
// Freetime
//
// Created by Ryan Nystrom on 9/4/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import Foundation
import IGListKit
protocol SearchRecentHeaderSectionControllerDelegate: class {
func didTapClear(sectionController: SearchRecentHeaderSectionController)
}
final class SearchRecentHeaderSectionController: ListSectionController, ClearAllHeaderCellDelegate {
weak var delegate: SearchRecentHeaderSectionControllerDelegate?
init(delegate: SearchRecentHeaderSectionControllerDelegate) {
self.delegate = delegate
super.init()
}
override func sizeForItem(at index: Int) -> CGSize {
guard let width = collectionContext?.containerSize.width else { fatalError("Missing context") }
return CGSize(width: width, height: Styles.Sizes.tableCellHeight)
}
override func cellForItem(at index: Int) -> UICollectionViewCell {
guard let cell = collectionContext?.dequeueReusableCell(of: ClearAllHeaderCell.self, for: self, at: index) as? ClearAllHeaderCell
else { fatalError("Missing context or wrong cell type") }
cell.delegate = self
cell.configure(title: NSLocalizedString("Recent Searches", comment: "").uppercased(with: Locale.current))
return cell
}
// MARK: ClearAllHeaderCellDelegate
func didSelectClear(cell: ClearAllHeaderCell) {
delegate?.didTapClear(sectionController: self)
}
}