Skip to content
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

Maintenance: Internal rework related to searchbar #1044

Merged
merged 3 commits into from
May 12, 2024

Conversation

wutschel
Copy link
Collaborator

@wutschel wutschel commented Apr 14, 2024

Description

relates to #1042

Background:

The current implementation is not optimal and shows some unpredictable behaviour. Some of the current seen issues are caused by iOS17 (missing scroll indicator when adding a searchbar as UITableView's tableHeaderView, or too wide searchbars).
But there are general flaws in the implementation like re-creating the searchbar with each switch between list view and collection view, removing and adding searchbar from views multiple times. I prepared a change which reworks this but has a few workarounds which I would like to have 2nd opinion on.

Premises / Constraints:

  • Keep searchbar on top of lists, so pulldown-to-search
  • Keep active searchbar detached from list to be able to scroll the filtered result list
  • Keep searchbar inside the current library view to support iPad (searchbar sitting inside at the top of the stacked views)
  • Keep colored searchbar for album and season views
  • Active and inactive searchbar should look same (wherever possible)
  • UITableView's tableHeaderView must be a UISearchBar to handle insets gently

Changes:

  • Only create self.searchController once in viewDidLoad
  • self.searchController is the UISearchController which is used for an active search and always displayed detached (floating on top of list)
  • To activate a search a dedicated UISearchController + transparent overlayed UIView is created for list view and collection view each. The overlay has a UITapGestureRecognizer which triggers a method to show and activate the central self.searchController. This allows keep the same look of the searchbar.
  • Only create the inactive searchbar + overlay once for list view and once for collection view in viewDidLoad
  • Some refactoring to be able to unify the look of the inactive searchbar (the one with the overlay) and the active self.searchController

Summary for release notes

Maintenance: Internal rework related to searchbar

@wutschel wutschel marked this pull request as ready for review April 21, 2024 09:17
@wutschel wutschel force-pushed the rework_searchbar branch 2 times, most recently from bc5d193 to 639aea7 Compare April 21, 2024 12:08
Copy link
Collaborator

@kambala-decapitator kambala-decapitator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • will check current master no my side now, maybe will figure out what's up with the indicators
  • the PR is probably fine, but that "useless" inactive searchbar is a very strange workaround...
  • please resolve conflicts

XBMC Remote/DetailViewController.m Outdated Show resolved Hide resolved
@wutschel
Copy link
Collaborator Author

  • will check current master no my side now, maybe will figure out what's up with the indicators
  • the PR is probably fine, but that "useless" inactive searchbar is a very strange workaround...
  • please resolve conflicts

Thanks for looking into this. I am lost and have no idea how to resolve this.

@kambala-decapitator
Copy link
Collaborator

what I see is that alpha of scroll indicators is set to 0 and looks like it's not possible to change that from user code - whatever I do, it's always reset to 0.

my suspicion is that view hierarchy is involved, specifically view controller hierarchy. If you open View Debugger, you can see that DetailViewController is not in the view tree - its subviews are directly under MasterViewController, which is abnormal. Although if you print view controller hierarchy in console, then DetailViewController is there. Probably ECSlidingViewController is involved, which is a quite old library as I see.

@wutschel
Copy link
Collaborator Author

wutschel commented May 10, 2024

ECSlidingViewController is not involved on iPad, where the scroll indicator is also missing. For iPad there is another (old) controller involved: StackScrollViewController.

I also now looked into the View Debugger and can see DetailViewController. It is found in InitialSlidingViewController > UIView > CustomNavigationController > UILayoutContainerView > UINavigationTransitionView > UIViewControllerWrapperView. https://ibb.co/wrCdr19

One more detail: When running in iOS 15.5 simulator both horizontal and vertical scroll indicators are present. When running in iOS 17 simulator only the horizontal one is there.
Both there: https://ibb.co/F5bffnM (upper instance = horizontal)
Vertical missing: https://ibb.co/kJBbwKL

@kambala-decapitator
Copy link
Collaborator

oh wow, seems I was looking at the wrong place :) will double-check

@wutschel
Copy link
Collaborator Author

wutschel commented May 11, 2024

oh wow, seems I was looking at the wrong place :) will double-check

For the issue itself it did not matter though. The same issue is also happening for the table which you were looking at (the main menu).

We should better move our discussion on the scroll indicators to #1007.

@kambala-decapitator
Copy link
Collaborator

At least it explains why my hacks Don didn't seem to have any effect

@wutschel
Copy link
Collaborator Author

Even when not directly adding MasterViewController in AppDelegate (not using InitialSildingViewController / ECSlidingViewController at all) the problem persists.

MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil];
masterViewController.mainMenu = mainMenuItems;
self.window.rootViewController = masterViewController;

Is there possibly something very basic wrong or not yet configured right related to window / scene?

@kambala-decapitator
Copy link
Collaborator

don't think it has any relation to window / scene

found a hacky workaround: just add this to viewDidAppear

    dispatch_async(dispatch_get_main_queue(), ^{
        dataList.showsVerticalScrollIndicator = YES;
    });

}
}

- (void)openSearchBar {
showbar = YES;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also rename this ivar to showBar

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, named it showSearchbar.

@wutschel
Copy link
Collaborator Author

don't think it has any relation to window / scene

found a hacky workaround: just add this to viewDidAppear

    dispatch_async(dispatch_get_main_queue(), ^{
        dataList.showsVerticalScrollIndicator = YES;
    });

Cool, works! :)
I will now review for which other places this needs to be done as well. I propose to add a Utilities method for this (parameter = UITableView instance) and always add a "Workaround" comment to each occurance.

@kambala-decapitator
Copy link
Collaborator

I propose to add a Utilities method for this (parameter = UITableView instance) and always add a "Workaround" comment to each occurance.

fully agree, very good idea

@wutschel
Copy link
Collaborator Author

I propose to add a Utilities method for this (parameter = UITableView instance) and always add a "Workaround" comment to each occurance.

fully agree, very good idea

Good. Will create a separate PR in next 30 mins. We can then either close the related issue with this, or keep it open for a real fix. You have any clue what is going wrong?

Only create self.searchController once in viewDidLoad.
self.searchController is the UISearchController which is used for an active search and always displayed detached (floating on top of list). To activate a search a dedicated UISearchController + transparent overlayed UIView is created for list view and collection view each. The overlay has a UITapGestureRecognizer which triggers a method to show and activate the central self.searchController. This allows keep the same look of the searchbar.
Only create the inactive searchbar + overlay once for list view and once for collection view in viewDidLoad.
Some refactoring to be able to unify the look of the inactive searchbar (the one with the overlay) and the active self.searchController
@wutschel
Copy link
Collaborator Author

Squashed, proper commit message and rebased to master.

@kambala-decapitator
Copy link
Collaborator

We can then either close the related issue with this, or keep it open for a real fix. You have any clue what is going wrong?

absolutely no clue and don't really wish to spend any more time on that. Let's close the issue using the found workaround.

@kambala-decapitator kambala-decapitator merged commit 0b67576 into xbmc:master May 12, 2024
@wutschel wutschel deleted the rework_searchbar branch May 12, 2024 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants