Awful / Awful.app

Something Awful Forums browser for iOS
https://forums.somethingawful.com/showthread.php?threadid=3837546&perpage=40&noseen=1
141 stars 44 forks source link

Setting Awful.Toolbar isTranslucent to false causes layout bugs #835

Open realModusOperandi opened 5 years ago

realModusOperandi commented 5 years ago

In starting work on #834 I have run into an issue that someone may be able to help with. When I set isTranslucent to false so that the toolbar can be truly black, the UIView that PostsPageViewController owns decides it's going to be smaller than the available space between the navbar and the toolbar, leaving a glitchy empty space:

screen shot 2018-11-22 at 11 24 09 pm screen shot 2018-11-22 at 11 24 39 pm

Anyone know what could be going on here?

nolanw commented 5 years ago

UIKit will change scroll views’ content insets depending on whether the top and bottom bars (navbar and toolbar in this case) are transparent. Usually what you want to do (without loss of generality) is always have the view confroller’s view go to the bottom, then let the content inset be applied as appropriate. If something isn’t working as expected, check the layout method/constraints, then start twiddling with the many UIViewController properties that mention insets and their adjustment.

Also what works on iOS 12 may not work on iOS 10 may not work on iOS 9 so consider firing up those simulators too.

Welcome to the world of safe areas!

realModusOperandi commented 5 years ago

I don't think this has anything to do with safe areas. It's not a case of a view being there but having no content--the PostsPageViewController's root view just simply does not expand to fill the available space. The topmost view in the hierarchy in that grey part is a UIViewControllerWrapper that seems to belong to the UINavigationController.

What I've noticed is that it has something to do with the translation of the autoresizing mask on the PPVC's view into constraints. Everything appears to be fine until after viewWillAppear, at which point constraints are applied and somehow the UIView-Encapsulated-Layout-Height constraint is set to a wrong value:

screen shot 2018-11-24 at 12 47 15 pm

whereas before the view actually appears, things seem to line up much better:

Translucent toolbar (normal):

begin viewDidLoad: (0.0, 0.0, 414.0, 896.0)
end viewDidLoad: (0.0, 0.0, 414.0, 896.0)
begin viewWillAppear: (0.0, 0.0, 414.0, 808.0)
end viewWillAppear: (0.0, 0.0, 414.0, 808.0)
begin viewDidAppear: (0.0, 0.0, 414.0, 808.0)
end viewDidAppear: (0.0, 0.0, 414.0, 808.0)

Opaque toolbar (bugged):

begin viewDidLoad: (0.0, 0.0, 414.0, 896.0)
end viewDidLoad: (0.0, 0.0, 414.0, 896.0)
begin viewWillAppear: (0.0, 0.0, 414.0, 808.0)
end viewWillAppear: (0.0, 0.0, 414.0, 808.0)
begin viewDidAppear: (0.0, 0.0, 414.0, 642.0)
end viewDidAppear: (0.0, 0.0, 414.0, 642.0)

At this point I would need some sort of debug trace for the laying out of the subviews of the navigation controller when the PPVC is pushed to see where the correct value is turning into the incorrect value. None of the constraints on the toolbar appear to be showing the problem and there are no other constraints I can see in the hierarchy.

nolanw commented 5 years ago

Huh. Maybe we need to set some constraints instead of just setting a frame and autoresizing mask? Anyway, sounds like you’re on it, lmk if I can help (beyond randomly guessing at things, which is always available at no charge).

realModusOperandi commented 5 years ago

Update: I needed to set extendedLayoutIncludesOpaqueBars = true on PostsPageViewController to get rid of the empty space, and edgesForExtendedLayout = .bottom to ensure the top bar can still appear. Sound reasonable?

nolanw commented 5 years ago

Not sure about the opaque bars part. Extending just the bottom makes sense as we do show content behind the (semitransparent iirc) toolbar.

To be honest, I often need fifteen minutes and a whiteboard to figure out what combination of extended layout settings I need and whether I’m seeing what I expect. I have no intuition for it whatsoever.

realModusOperandi commented 5 years ago

The opaque bars part is necessary to get rid of the weird gap when I set the Toolbar to be opaque, which I need to do if we're going to get it to be true black like other apps (I'm looking at Tweetbot most heavily) did for their OLED theme. There are no changes necessary for the current themes. I won't just blindly apply these settings to all themes, I'll figure out how to only apply them when needed.

nolanw commented 5 years ago

Oh I see. You probably explained that to me before and I forgot.

We could add a key to the relevant themes' plists for making the bottom toolbar opaque. Have it default to transparent so existing themes work as-is. Happy to help if that’s not enough to go on.

nolanw commented 5 years ago

When I use the Parent Forum button I get a grey bar just above the bottom nav. — spanky the dolphin

nolanw commented 5 years ago

Loving the SUPER BLACK, but I am getting some weird gray bar thing at the bottom of the screen while in threads.

It appears to be due to the bottom bookmark trying to slide off the screen when entering a thread and the block of space getting “stuck” and floating at the bottom. I can make a video if needed. XS if that’s any help. Seems to be limited to the OLED mode. — Warbird

nolanw commented 5 years ago

Had this happen all of a sudden today (the grey bar).

Stare-Out

nolanw commented 5 years ago

I think I’ve fixed this on master branch?

nolanw commented 5 years ago

This seems to be getting worse, and the app is quitting in background much quicker than it used to. — Jealous Cow