-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/filter by animal type #90
base: develop
Are you sure you want to change the base?
Conversation
@@ -57,10 +57,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | |||
|
|||
navBar.barStyle = .black | |||
|
|||
UIButton.appearance().tintColor = UIColor.themeTintColor() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to comment this line out because it causes tableviewCell checkmark accessory views and button labels to be white on white (and therefore invisible).
I tried to solve this by setting the tint color of the table view and its cells locally, but that didn't work, so for now I just commented this line out.
Commenting this out, as a temporary solution, didn't seem to have any bad affect on the existing UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say just go ahead and remove the line instead. I'm not sure why we had UIButton appearances set to white. UIBarButtonItem appearances is fine to be white, since the navigation bar is not white.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the UIButton tintColor appearance setting 4b6fb28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good. There are some nitpicky fixes, to be sure. I try not to harp too much on code style, which is why I only mentioned a couple of them. Also, if you can in the future, try not to add other issues into the work you're currently doing, especially if someone else is already working on that issue (talking about the empty state view). In this case, it's fine because it's a minor issue, but I don't want us to trample all over each other's work.
Other than that, thanks for working on this!
History.md
Outdated
@@ -0,0 +1,26 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't necessarily need a History.md file, since we can view the history right in Github, but it does remind me that I should probably do release notes when we're ready to submit v1.1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed History.md. I think I added it somehow by mistake
@@ -0,0 +1,135 @@ | |||
// | |||
// filterViewControlelr.swift |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably a little nitpicky, but the file name is, for one, misspelled (Controlelr
instead of Controller
), and two, convention is to capitalize the names of the files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good eyes :)
fixed with 31da2d4
@@ -175,6 +182,21 @@ class PetListingViewController: UIViewController | |||
self.present(alertController, animated: true, completion: nil) | |||
} | |||
|
|||
func presentFilterViewController() | |||
{ | |||
let filterVC = storyboard?.instantiateViewController(withIdentifier: "filterVC") as? FilterViewController |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unwrapping the optional right up here (either if let
or with a guard
) would prevent needing to force unwrap filterVC
down on line 193.
@@ -466,6 +476,7 @@ | |||
D0950AF71C618D86002E198C /* ViewControllers */ = { | |||
isa = PBXGroup; | |||
children = ( | |||
6F2A704A207EB56D00BF5AA0 /* filter */, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, being nitpicky, but all the other groups are capitalized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 8b4feb5
} | ||
|
||
//////////////////////////////////////////////////////////// | ||
|
||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell | ||
{ | ||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PetCell.reuseIdentifier, for: indexPath) as! PetCell | ||
let pet = petData[indexPath.row] | ||
let pet = filteredPetData[indexPath.row]//petData[indexPath.row] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just remove the commented out code at the end of this line. Unless you left it there for a reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed with d39f3a1
class FilterViewController: UITableViewController { | ||
var delegate: FilterSelectorDelegate? | ||
enum RowIndex:Int { | ||
case All = 0, Dogs, Cats, Birds, SmallFurry, Horses, BarnYard, Reptiles, Rabbits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention for enums in Swift 4 is that cases should begin with lowercase letters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with bd8b2ef
@@ -237,15 +261,16 @@ extension PetListingViewController : UICollectionViewDelegate, UICollectionViewD | |||
{ | |||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int | |||
{ | |||
return self.petData.count | |||
self.noResultsLabel.isHidden = !(self.filteredPetData.count == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So with endless scroll, there is a collection view footer with a UIActivityIndicatorView in it. The purpose of that is to give the users an indication that there is something loading. If the user reaches the very bottom of the collection (2000 results), the activity indicator stops animating.
I noticed a bug whereby if there are no results found, that activity indicator is still animating at the very top. That's that footer with the activity indicator. We will probably need to add something somewhere to stop that animation if there are no results. I'm not sure where exactly to add this, but check out the viewForSupplementaryElementOfKind at indexPath
function to see where we are currently starting and stopping that animation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On another note, I am currently working on the empty view myself, but what I'll do is leave what you have here and then just add my changes afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for taking over the empty state issue. I saw it labeled as 'help needed' and assumed it means its ok to pick it up. I'm very new to the whole collaboration way of doing things so thanks for bearing with me :)
About the activity indicator, I think there is a related problem where if not enough animals of a selected type are loaded to fill the screen, a request to download more animals should be triggered, but isn't. This is because pets are loaded into petData, but displayed out of filteredPetData. Not sure what the best way to solve this would be.
Maybe a solution could be to call loadPets() many times while MAX_SEARCH_RESULTS hasn't bean reached AND OR filteredPetData < minFilteredResultAttempts ?
Any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries about the empty state thing. Typically, if you see someone is assigned to an issue, usually that means they're currently looking into it. At the very least, reach out to that person to find out if they're actively working on an issue. Sometimes someone will assign themselves to an issue and then not have any time to actually work on it (happens to me all the time lol).
Let me think about the activity indicator problem a little bit. For now, I'm ok with leaving this minor bug in there unless we can come up with a solution before we end up pushing the next version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crap, you know what I just thought about? I wonder if it would be better for us to actually modify the API call to only return us a list of pets given the animal type. Going back to the API docs, we can optionally pass a string indicating what type of animals we want returned. The only issue with this I can see is that we may not be able to filter on multiple animal types. Well that and a lot of the work you've already put into this will need to be re-done.
One reason we might want to consider this approach is that because we are rate limited to 2000 results max, we are very likely leaving out a lot of results by default. We could potentially get more results, especially for the less common animals. This will still leave us with the activity indicator problem because, like you mention, the check for stopping that animation is based solely on the max results (2000).
Sorry for only now thinking about this. This is probably one of the reasons I had kept this issue out until v1.2. That and we probably will need to have a discussion about other filtering options we will want to eventually add in.
defaults.synchronize() | ||
} | ||
|
||
func setAnimalTypeCheckmarks() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another bug I've noticed is that you can get into a situation where nothing is checked at all. If I select an animal type and then deselect it, now nothing is checked. It would be nice if in the case that nothing is checked, the "all" option becomes checked. Is that possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with 50a3b0d
@@ -57,10 +57,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | |||
|
|||
navBar.barStyle = .black | |||
|
|||
UIButton.appearance().tintColor = UIColor.themeTintColor() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say just go ahead and remove the line instead. I'm not sure why we had UIButton appearances set to white. UIBarButtonItem appearances is fine to be white, since the navigation bar is not white.
…ed array > 0 or max limit reached
@@ -175,6 +184,21 @@ class PetListingViewController: UIViewController | |||
self.present(alertController, animated: true, completion: nil) | |||
} | |||
|
|||
func presentFilterViewController() | |||
{ | |||
guard let filterVC = storyboard?.instantiateViewController(withIdentifier: "filterVC") as? FilterViewController else {fatalError("Error: could not instantiate filterVC")} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know that I would necessarily want us to fatalError here if the view controller can't be instantiated, since that will just crash the app. I also don't know that I'd want this to silently return either... I guess for now this is fine. At the very least, if this guard does fail, Crashlytics should report the crash and we can investigate further.
@@ -237,15 +261,16 @@ extension PetListingViewController : UICollectionViewDelegate, UICollectionViewD | |||
{ | |||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int | |||
{ | |||
return self.petData.count | |||
self.noResultsLabel.isHidden = !(self.filteredPetData.count == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crap, you know what I just thought about? I wonder if it would be better for us to actually modify the API call to only return us a list of pets given the animal type. Going back to the API docs, we can optionally pass a string indicating what type of animals we want returned. The only issue with this I can see is that we may not be able to filter on multiple animal types. Well that and a lot of the work you've already put into this will need to be re-done.
One reason we might want to consider this approach is that because we are rate limited to 2000 results max, we are very likely leaving out a lot of results by default. We could potentially get more results, especially for the less common animals. This will still leave us with the activity indicator problem because, like you mention, the check for stopping that animation is based solely on the max results (2000).
Sorry for only now thinking about this. This is probably one of the reasons I had kept this issue out until v1.2. That and we probably will need to have a discussion about other filtering options we will want to eventually add in.
Added filter by animal functionality.
Feature #65
EDIT:
I found a little bug introduced with this pull request, where endless scroll doesn't work properly with the filtered results.Fixed :)trying to fix it
Now also fix #78 - Empty state placeholder