LeoNatan / LNPopupController

A framework for presenting view controllers as popups of other view controllers, much like the Apple Music and Podcasts apps.
MIT License
3.03k stars 340 forks source link

How can i remove the botton scroll inset that is added to all my view controllers? #368

Closed myeganeh2876 closed 4 years ago

myeganeh2876 commented 4 years ago

I have managed to move the dockview to the right of tabbar but the bottom inset which is added to the root VC in order to prevent the content from going behind the popupbar is now causing me trouble. please tell me how i can remove this space from my scrolling views. thanks in advance

Current View: Screen Shot 2019-10-24 at 12 54 32 PM

I would like to remove the space between the tabbar and the gray container (which is the last item in my list and the table has no insets)

Desired view: Screen Shot 2019-10-24 at 12 55 33 PM

LeoNatan commented 4 years ago

Hello,

Have you modified the framework to achieve this?

myeganeh2876 commented 4 years ago

Hello,

Have you modified the framework to achieve this?

No i have used it via carthage editted the dock view and moved it to right on ipad and changed tabbar width to achieve this

i may send a pull request if had the time, to add this feature in ipad

LeoNatan commented 4 years ago

Unfortunately, this isn't a supported scenario. You will have to fork the framework and change how the inset logic works.

LeoNatan commented 4 years ago

If you do this, look for the _LNPopupSupportSetPopupInsetsForViewController function calls and set those to UIEdgeInsetsZero instead of the popup bar height.

myeganeh2876 commented 4 years ago

Thanks, if you could provide this inset via a public method it would be useful i guess.

LeoNatan commented 4 years ago

It’s not really possible. The inset is not constant but the height of the bar, which is dynamic according to bar style and custom bar controller size.

myeganeh2876 commented 4 years ago

i guess as a quick workaround i can add a negative inset for each one of my lists since i have zero experience with objective-c

LeoNatan commented 4 years ago

That's not a good approach. Remember that insets can change depending on system layout.

You shouldn't be scared of Objective C.

iDevelopper commented 4 years ago

What about using a custom container view controller subclass and implementing these three properties?

/**
 * Popup presentation containment support in custom container view controller subclasses.
 */
@interface UIViewController (LNPopupCustomContainer)

/**
 * Return a view to dock the popup bar to, or @c nil to use the system-provided view.
 *
 * A default implementation is provided for @c UIViewController, @c UINavigationController and @c UITabBarController.
 * The default implmentation for @c UIViewController returns an invisible @c UIView instance, docked to the bottom. For @c UINavigationController, the toolbar is returned. For @c UITabBarController, the tab bar is returned.
 */
@property (nullable, nonatomic, strong, readonly) __kindof UIView* bottomDockingViewForPopupBar;

/**
 * Return the default frame for the docking view, when the popup is in hidden or closed state. If @c bottomDockingViewForPopupBar returns nil, this method is not called, and the default system-provided frame is used.
 *
 * A default implementation is provided for @c UIViewController, @c UINavigationController and @c UITabBarController.
 */
@property (nonatomic, readonly) CGRect defaultFrameForBottomDockingView;

/**
 * The insets for the bottom docking view from bottom of the container controller's view. By default, this is set to the container controller view's safe area insets in iOS 11 or @c UIEdgeInsetsZero otherwise. Currently, only the bottom inset is respected.
 *
 * The system calculates the position of the popup bar by summing the bottom bar height and the bottom of the insets.
 *
 * @warning This API is experimental and will probably change in the future. Use with care.
 */
@property (nonatomic, readonly) UIEdgeInsets insetsForBottomDockingView;

@end
iDevelopper commented 4 years ago

@mamady83 , this is a tabBar added to your view? Not a tabBarController?

iDevelopper commented 4 years ago

@LeoNatan ,

It’s not really possible. The inset is not constant but the height of the bar, which is dynamic according to bar style and custom bar controller size.

What about creating a new property available (for example wantsAdditionalSafeAreaInsets of type BOOL)? If it is set to NO, you do not call the _LNPopupSupportSetPopupInsetsForViewController function.

LeoNatan commented 4 years ago

I guess that's possible but it sounds like a very limited use-case.

iDevelopper commented 4 years ago

This would allow users of the framework to develop applications that look like Apple Music app on iPad, like @mamady83 trying to do!