@@ -270,6 +270,27 @@ extension FavoriteListViewController: UITableViewDelegate, UITableViewDataSource
270
270
self . showEmptyViewIfNeeded ( )
271
271
}
272
272
}
273
+
274
+ func scrollViewDidScroll( _ scrollView: UIScrollView ) {
275
+ // This ensures that the search bar is always visible like a sticky while searching
276
+ if isSearching {
277
+ searchBar. endEditing ( true )
278
+ if let searchBarText = searchBar. text,
279
+ searchBarText. isEmpty {
280
+ searchBarCancelButtonClicked ( searchBar)
281
+ }
282
+ return
283
+ }
284
+
285
+ searchBarConstraint? . constant = - min( scrollView. contentOffset. y, searchBarSize) - searchBarSize
286
+ if scrollView. contentOffset. y < - searchBarSize && scrollView. contentInset. top != searchBarSize {
287
+ tableView. contentInset. top = searchBarSize
288
+ }
289
+
290
+ if scrollView. contentOffset. y >= 0 && scrollView. contentInset. top != 0 {
291
+ tableView. contentInset. top = 0
292
+ }
293
+ }
273
294
}
274
295
275
296
extension FavoriteListViewController : FavoriteSectionHeaderDelegate {
@@ -304,29 +325,6 @@ extension FavoriteListViewController: UISearchBarDelegate {
304
325
}
305
326
}
306
327
307
- extension FavoriteListViewController : UIScrollViewDelegate {
308
- func scrollViewDidScroll( _ scrollView: UIScrollView ) {
309
- // This ensures that the search bar is always visible like a sticky while searching
310
- if isSearching {
311
- searchBar. endEditing ( true )
312
- if let searchBarText = searchBar. text,
313
- searchBarText. isEmpty {
314
- searchBarCancelButtonClicked ( searchBar)
315
- }
316
- return
317
- }
318
-
319
- searchBarConstraint? . constant = - min( scrollView. contentOffset. y, searchBarSize) - searchBarSize
320
- if scrollView. contentOffset. y < - searchBarSize && scrollView. contentInset. top != searchBarSize {
321
- tableView. contentInset. top = searchBarSize
322
- }
323
-
324
- if scrollView. contentOffset. y >= 0 && scrollView. contentInset. top != 0 {
325
- tableView. contentInset. top = 0
326
- }
327
- }
328
- }
329
-
330
328
extension FavoriteListViewController {
331
329
private func showCloudFavVC( fav: VLCFavorite ) {
332
330
let favURL = fav. url
0 commit comments