Add filter button show/hide unread feeds. Issue #1311

This commit is contained in:
Maurice Parker
2019-11-21 15:55:50 -06:00
parent eed6333368
commit 89e9a7b80e
6 changed files with 81 additions and 20 deletions

View File

@@ -89,6 +89,14 @@ struct AppAssets {
return RSImage(named: "faviconTemplateImage")!
}()
static var filterInactiveImage: UIImage = {
UIImage(systemName: "line.horizontal.3.decrease.circle")!
}()
static var filterActiveImage: UIImage = {
UIImage(systemName: "line.horizontal.3.decrease.circle.fill")!
}()
static var fullScreenBackgroundColor: UIColor = {
return UIColor(named: "fullScreenBackgroundColor")!
}()

View File

@@ -214,9 +214,17 @@
<action selector="settings:" destination="7bK-jq-Zjz" id="Y8a-lz-Im7"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" image="line.horizontal.3.decrease.circle" catalog="system" id="ZJu-oJ-c1R">
<connections>
<action selector="toggleFilter:" destination="7bK-jq-Zjz" id="7lh-Bz-nfD"/>
</connections>
</barButtonItem>
</navigationItem>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="filterButton" destination="ZJu-oJ-c1R" id="jiO-wg-qrG"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Rux-fX-hf1" sceneMemberID="firstResponder"/>
</objects>
@@ -289,6 +297,7 @@
<image name="chevron.up" catalog="system" width="64" height="36"/>
<image name="circle" catalog="system" width="64" height="60"/>
<image name="gear" catalog="system" width="64" height="58"/>
<image name="line.horizontal.3.decrease.circle" catalog="system" width="64" height="60"/>
<image name="multiply.circle.fill" catalog="system" width="64" height="60"/>
<image name="square.and.arrow.up" catalog="system" width="56" height="64"/>
<image name="square.and.arrow.up.fill" catalog="system" width="56" height="64"/>

View File

@@ -14,6 +14,7 @@ import RSTree
class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
@IBOutlet weak var filterButton: UIBarButtonItem!
private var refreshProgressView: RefreshProgressView?
private var addNewItemButton: UIBarButtonItem!
@@ -370,6 +371,16 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
coordinator.showSettings()
}
@IBAction func toggleFilter(_ sender: Any) {
if coordinator.isUnreadFeedsFiltered {
filterButton.image = AppAssets.filterInactiveImage
coordinator.showAllFeeds()
} else {
filterButton.image = AppAssets.filterActiveImage
coordinator.hideUnreadFeeds()
}
}
@IBAction func add(_ sender: UIBarButtonItem) {
coordinator.showAdd(.feed)
}

View File

@@ -112,6 +112,10 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
return panelMode == .three
}
var isUnreadFeedsFiltered: Bool {
return treeControllerDelegate.isUnreadFiltered
}
var rootNode: Node {
return treeController.rootNode
}
@@ -484,6 +488,16 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
}
return 0
}
func showAllFeeds() {
treeControllerDelegate.isUnreadFiltered = false
rebuildBackingStores()
}
func hideUnreadFeeds() {
treeControllerDelegate.isUnreadFiltered = true
rebuildBackingStores()
}
func expand(_ node: Node) {
node.isExpanded = true