danielsaidi / Sheeeeeeeeet

Sheeeeeeeeet is a Swift library for creating menus, custom action sheets, context menus etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

background shadow on ios 13

akaraul opened this issue · comments

on iOS 13 in the light theme, there is no shadow behind the action sheet. it a bug? is there an easy way to get her back?

Hi @akaraul

I have been fighting this problem, but though I had everything sorted out.

It works in a production app that use the 2.1.0 release, both for bottom sheets on the phone and popovers on the iPad. It also works for me when I run the demo app.

Are you using the final 2.1.0 version? iPhone or iPad? Do you apply any custom appearance?

@danielsaidi
Yes, version 2.1.0. iPhone.
I am using custom appearance for action item subclass

Same issue with 2.1.0 on iPhone--both iOS 13 and 12.2. (Also tried with 2.1.1 commit)

Have tested by removing all custom appearances/icons--has no effect. The "shadow" behind the actionSheet doesn't appear.

Oddly enough, everything works correctly in the demo app.

Ok, that's strange, but I think I know what's going on. The shadow problem that I was fighting was the popover shadow when opening a sheet on the iPad (should be solved now, though), so I'm very happy that it's not that :)

Regarding your problem, do you apply an action sheet appearance when launching your app, or at least before presenting a sheet? I am currently working on the 3.0 release and noticed that I don't mention that you must apply an appearance for the action sheets to get any styling, other than in the release notes.

Basically, I changed the appearance logic when implementing dark mode, so that the built-in views have no standard appearance before you apply one. For instance, the shadow background view is just a clear colored alpha 0 view.

You can easily fix this by calling ActionSheet.applyAppearance(.standard) when launching your app (in the app and scene delegates). However, I don't like that you have to do this manually, so I will try to fix a 2.1.2 that automatically applies the standard appearance if you haven't applied one.

@danielsaidi thanks. ActionSheet.applyAppearance(.standard) help me

I have created a 2.1.2 branch that solves this problem - you no longer have to apply the standard appearance. I have some conflicts in the 3.0.0 branch (big project changes), so I will make sure that I can merge them before I merge to master.

@akaraul Great, thank you so much for bringing this to my attention!

It would be great if you could upgrade to 2.1.2 and remove ActionSheet.applyAppearance(.standard) to confirm that the manual apply is no longer needed.

I will keep the changes in 2.1.2 to a minimum to avoid merge problems with the 3.0 branch, but everything should work better in this version.

Thanks, @danielsaidi. I can confirm it works as expected on the 2.1.2 branch. Thanks so much for the quick fix!

On a related note, do you have an easy way to modify the background/shadow functionality when the actionsheet is active? When in dark mode, the darkened background makes it difficult to see actionsheet edges.

As an alternative, Is there a method to blur the background?

After some more testing here, it looks like there is another issue. It appears that custom appearance settings aren't being reflected until the action sheet is loaded a second time in the app. The first activation uses the standard appearance--then, after the second load it reflects the custom appearance.

Perfect @ericboles - happy to hear that!

Regarding dark mode and sheet edges, I'm not sure what you refer to. The standard appearance uses dark mode adaptive colors, which I think looks pretty good. It also automatically adjust itself when you switch to dark mode. See the attached image.

However, you can set the background color explicitly as well, using the action sheet's various view properties, e.g. backgroundView.

Simulator Screen Shot - iPhone 11 - 2019-09-24 at 15 24 24

@ericboles Do you have an example? I noticed that the colorful demo appearance didn't call its super classes, which made the demo look a bit strange when switching over to that appearance (2.1.3 hehe), but I fixed it and made the demo app use the colorful appearance instead of the demo appearance - that work great for me.

@danielsaidi Here are a few gifs that show the issue. The code is the same--only difference is 2.1.0 vs. 2.1.3. In 2.1.0, the styling loads correctly, but the background shadow does not. In 2.1.3, the background shadow loads, but the styling doesn't load until the action sheet is retrieved the second time--it then loads correctly subsequently.

2.1.3 Below - Styling only loads correctly after second call
2 1 3_shadow_nostyle

2.1.0 (Below) - Styling loads correctly--but no shadow
2 1 0_noshadow

Thank you so much for the gif - it really helps me understanding the problem. Can you also show me how and where you apply the appearance?

I can't reproduce this in the demo app - if I apply the colorful appearance on app launch, it is applied when I present the first action sheet.

Btw...the menu looks amazing!

@danielsaidi I managed to solve the issue by creating a style and calling ActionSheet.applyAppearance. Previously, I was simply doing the styling within my function prior to firing the ActionSheet.

On a related note--it would likely be helpful to be able to have the ActionSheetLinkItem allow for custom icons per item. I wanted the icons to be over on the right side to follow Apple's current convention, but couldn't find a way to do that without modifying the existing type. (Also helpful to provide built-in capability for image tint for the LinkItem).

Thanks so much for the great work and quick responses.

(Glad you like the menu...and happy I ran across Sheeeeeeeeet to make it easier to implement.)

Ah, that those appearance problems could occur when using the old approach with the new appearance engine makes sense - great to hear that you managed to solve it!

Regarding the link icon, to you mean the right arrow? The left icon is individual, and is set with each item's image property. The rightmost linkImage is applies to all link items.

You can always modify every appearance proxy property for each cell instance, but it will be even harder to get access to the specific cells in the upcoming 3.0 release.

Could you create separate issues for the individual image, arrow (or one issue if I misunderstood and that's the same thing) and the tint, so that it's easier to track the work? I'm going to close this issue now, to indicate that the shadow bug is fixed.

Thanks!