Open Janglinator opened 6 years ago
I'd love to have more discussion as to why we (Netfox) even needs to do this. At first glance, it seems like we're having a memory leak. Once the window is shown and dismissed, whether the search controller is active shouldn't matter anymore, it should be deallocated.
There was a bug when the search controller was active and you tried to hide the netfox. Search controller never removed from the screen. In order to workaround on this, we added the notification.
If you want to reproduce the old issue get the master, comment the self.searchController.isActive = false
in the NFXListController_iOS
, shake - open the netfox, perform a search and shake again - search screen is not being removed. If you shake again netfox will appear again above the stacked search screen (as the internal presented state has changed).
In https://github.com/kasketis/netfox/pull/117/commits/5480bf9ceda5060738b1416b7f16f68c59c3aa7c I have removed all the search notifications and now I'm trying to solve the same issue by using the self.definesPresentationContext = YES;
which works well but has some side effects: when you tap on a search result and return back to the list the results move under the search bar.
Let me know if it is clear enough and if you have any idea about the side effect issue 👍 🍺
Here's a suggested fix for issue #36.
Here are some design considerations around the manual showing:
On showing:
if NFX.started
- I check this value in the new method,showManually()
NFX.presented = true
- At this point Netfox will no longer control whether the window has already been presented, that is the job of the new presenter. If Netfox is asked to show usingshow()
, it will (and should) do so.On hiding:
if !NFX.presented
- Same as above, Netfox is no longer in charge if they usedshowManually()
NotificationCenter.default.post
- If the user wishes to deactivate the search window on disappearing, they are free to do so. The notification has been publicly exposed. I'd love to have more discussion as to why we (Netfox) even needs to do this. At first glance, it seems like we're having a memory leak. Once the window is shown and dismissed, whether the search controller is active shouldn't matter anymore, it should be deallocated.NFX.lastVisitDate
- I moved this logic intoNFXListController
'sViewWillDisappear
method. It makes a little more sense to do so, sinceNFXListController
is the only one that cares about it. I left the actual property in NFX, simply because another class might be interested in this value as well (in the future)