-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from Maj0rPaine/master
#162 - Handle favoriting an artist from search results
- Loading branch information
Showing
4 changed files
with
158 additions
and
1,772 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
Apps/Relisten/View Controllers/ArtistsSearchResultsViewController.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,41 @@ | ||
// | ||
// ArtistsSearchResultsViewController.swift | ||
// Relisten | ||
// | ||
// Created by Chris Paine on 3/14/19. | ||
// Copyright © 2019 Alec Gorge. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import RelistenShared | ||
|
||
import AsyncDisplayKit | ||
|
||
class ArtistsSearchResultsViewController: RelistenTableViewController<Any> { | ||
public var favoriteArtists: [UUID]! | ||
public var filteredArtists: [ArtistWithCounts] = [] { | ||
didSet { | ||
DispatchQueue.main.async { | ||
self.tableNode.reloadData() | ||
} | ||
} | ||
} | ||
|
||
// MARK: UITableViewDataSource | ||
|
||
override func numberOfSections(in tableNode: ASTableNode) -> Int { | ||
return filteredArtists.isEmpty ? 0 : 1 | ||
} | ||
|
||
override func tableNode(_ tableNode: ASTableNode, numberOfRowsInSection section: Int) -> Int { | ||
return filteredArtists.count | ||
} | ||
|
||
func tableNode(_ tableNode: ASTableNode, nodeBlockForRowAt indexPath: IndexPath) -> ASCellNodeBlock { | ||
if let artist = filteredArtists.objectAtIndexIfInBounds(indexPath.row) { | ||
return { ArtistCellNode(artist: artist, withFavoritedArtists: self.favoriteArtists) } | ||
} else { | ||
fatalError("Couldn't get an artist at \(indexPath)") | ||
} | ||
} | ||
} |
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
Oops, something went wrong.